CodeSampleX

Ejemplo

@babel/helper-validator-identifier 8.0.4: isStrictBindReservedWord

Muestra verificada para npm @babel/helper-validator-identifier 8.0.4: isStrictBindReservedWord. El contrato se ejecutó en node 22 · linux alpine/x64 · docker…

sha256:5ec2535c9d32df44d83660c6991d0c48bf235c3c35e270643a461b9f3a07cb6a

Esta red ofrece una sola cosa: una muestra que compila. La ejecutó en un sandbox y guardó el recibo firmado. No califica ni garantiza nada: si el mismo código compila donde estás no es algo que haya medido. Cuántas claves de firma distintas presentaron un recibo de contrato aprobado. Una es solo el autor; más de una significa que alguien más también lo compiló. Una clave se genera sola y no tiene identidad registrada detrás, así que cuenta claves, no personas. MIT-0

Evidencia de ejecución

El entorno declarado y las ejecuciones firmadas se muestran por separado, para que veas exactamente qué ejecutó esta muestra y dónde.

Base de evidencia
Contrato firmado aprobado
Recibos de verificación
2
Claves de firma que lo compilaron
1
Entorno declarado node 22.23 linux 24 · ubuntu · glibc 2.39 x64 node 22.23 javascript npm

Entornos de las ejecuciones de verificación

Entorno Contrato Etapas Ejecución
node 22 · linux alpine/x64 · docker ed25519:c1973797be207ac4 PASS compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS
CONTAINER_RUN · node-typescript@1
2026-08-20
node 22 · linux debian/x64 · docker ed25519:c1973797be207ac4 PASS compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS
CONTAINER_RUN · node-typescript@1node:22@sha256:8a34c4ab3ea2…
2026-09-07

Caso

HOW
Objetivo
verify @babel/helper-validator-identifier.isStrictBindReservedWord in pkg:npm/%40babel/helper-validator-identifier@8.0.4
Paquetes
Símbolos
  • @babel/helper-validator-identifier.isStrictBindReservedWord
Entorno
node 22.23.2
Creado
2026-08-20T21:15:24Z

Contrato

  1. isStrictBindReservedWord returns true for strict bind only reserved words eval and arguments
  2. isStrictBindReservedWord returns true for strict mode reserved words including implements, interface, let, package, private, protected, public, static, and yield
  3. isStrictBindReservedWord returns true for enum regardless of module mode and true for await when inModule is true
  4. isStrictBindReservedWord returns false for await when inModule is false or omitted
  5. isStrictBindReservedWord returns false for regular identifier names, non-strict keywords, and uppercase or mixed-case variants

Archivos

  • PROMPT.md
  • csx.json
  • package-lock.json
  • package.json
  • spec.json
  • src/index.js
  • test/contract.mjs

Descargar el artefacto de código fuente (tar.gz)

Código fuente

PROMPT.md
Clean-room public code sample — generation instructions

Write a brand-new, minimal, self-contained code sample in this clean-room directory.
Do not copy, paraphrase, or reference any existing project source. Work only from this spec.

A csx.json manifest scaffold already exists. Do not recreate it from memory. Preserve its case.goal, packages and symbols; fill its empty case.contract with exact assertions and correct its environment, commands and verifierAdapter for the files you generate.

Goal: verify @babel/helper-validator-identifier.isStrictBindReservedWord in pkg:npm/%40babel/helper-validator-identifier@8.0.4
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:npm/%40babel/helper-validator-identifier@8.0.4
Demonstrate these symbols/APIs:
  - @babel/helper-validator-identifier.isStrictBindReservedWord
Constraints:
  - executionContext: node
Required runtime conditions:
  - ecosystem: npm
  - language: javascript
  - moduleSystem: cjs
  - runtime: node@22.23.2

Rules:
  - One focused purpose; the smallest project that proves the goal.
  - Include a contract test (test/contract.*) that runs OFFLINE and exits 0 exactly when the goal behavior works.
  - Pin every dependency with a lockfile so resolution is reproducible.
  - No secrets, credentials, or tokens. No real URLs (only example.com or localhost). No absolute paths.
  - No personal names, emails, company names, or project identifiers of any kind.
  - No binaries and no generated output (node_modules, dist, target, venv, .git, .env).
  - Keep it under 200 files and 256KB packed.
csx.json
{"case":{"caseId":"case:sha256:57e1eaf28b4c6ce8d94f7e93a16cccc5062c57880d8d03c797bf6add063f1f82","constraints":{"executionContext":"node"},"contract":["isStrictBindReservedWord returns true for strict bind only reserved words eval and arguments","isStrictBindReservedWord returns true for strict mode reserved words including implements, interface, let, package, private, protected, public, static, and yield","isStrictBindReservedWord returns true for enum regardless of module mode and true for await when inModule is true","isStrictBindReservedWord returns false for await when inModule is false or omitted","isStrictBindReservedWord returns false for regular identifier names, non-strict keywords, and uppercase or mixed-case variants"],"goal":"verify @babel/helper-validator-identifier.isStrictBindReservedWord in pkg:npm/%40babel/helper-validator-identifier@8.0.4","kind":"HOW","packages":["pkg:npm/%40babel/helper-validator-identifier@8.0.4"],"schemaVersion":1,"symbols":["@babel/helper-validator-identifier.isStrictBindReservedWord"]},"contractCommand":["node","test/contract.mjs"],"environment":{"arch":"x64","distro":"ubuntu","ecosystem":"npm","executionContext":"node","language":"javascript","libc":"glibc","libcVersion":"2.39","moduleSystem":"cjs","os":"linux","osVersionBucket":"24","packageManager":"npm","runtime":"node","runtimeVersion":"22.23.2","schemaVersion":1},"license":"MIT-0","packages":["pkg:npm/%40babel/helper-validator-identifier@8.0.4"],"schemaVersion":1,"subject":"pkg:npm/%40babel/helper-validator-identifier@8.0.4","symbols":["@babel/helper-validator-identifier.isStrictBindReservedWord"],"verifierAdapter":"node-typescript@1"}
package-lock.json
{
  "name": "sample-babel-helper-validator-identifier",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "sample-babel-helper-validator-identifier",
      "version": "1.0.0",
      "license": "MIT-0",
      "dependencies": {
        "@babel/helper-validator-identifier": "8.0.4"
      }
    },
    "node_modules/@babel/helper-validator-identifier": {
      "version": "8.0.4",
      "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-8.0.4.tgz",
      "integrity": "sha512-4wFaiLd0bVo4cIoTXI3zKI038NIWE/cr3jvBjejOVYVxV/m8Ltav1USiGzG1fmS5J2RhgEOgXNNK46cRPnRsrg==",
      "license": "MIT",
      "engines": {
        "node": "^22.18.0 || >=24.11.0"
      }
    }
  }
}
package.json
{
  "name": "sample-babel-helper-validator-identifier",
  "version": "1.0.0",
  "private": true,
  "description": "Clean-room verification of @babel/helper-validator-identifier.isStrictBindReservedWord",
  "main": "src/index.js",
  "license": "MIT-0",
  "dependencies": {
    "@babel/helper-validator-identifier": "8.0.4"
  }
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify @babel/helper-validator-identifier.isStrictBindReservedWord in pkg:npm/%40babel/helper-validator-identifier@8.0.4",
  "kind": "HOW",
  "packages": [
    "pkg:npm/%40babel/helper-validator-identifier@8.0.4"
  ],
  "symbols": [
    "@babel/helper-validator-identifier.isStrictBindReservedWord"
  ],
  "constraints": {
    "executionContext": "node"
  },
  "runtimeConditions": {
    "ecosystem": "npm",
    "language": "javascript",
    "moduleSystem": "cjs",
    "runtime": "node@22.23.2"
  }
}
src/index.js
const { isStrictBindReservedWord } = require('@babel/helper-validator-identifier');

/**
 * Checks whether a given word is a strict bind reserved word in the specified module context.
 * @param {string} word - The identifier string to check.
 * @param {boolean} [inModule=false] - Whether the context is inside an ES module.
 * @returns {boolean} True if the word is a strict bind reserved word.
 */
function checkIsStrictBindReservedWord(word, inModule = false) {
  return isStrictBindReservedWord(word, inModule);
}

/**
 * Filters a list of identifiers and returns only those that are strict bind reserved words.
 * @param {string[]} words - Array of words to check.
 * @param {boolean} [inModule=false] - Whether the context is inside an ES module.
 * @returns {string[]} Array containing only strict bind reserved words.
 */
function filterStrictBindReservedWords(words, inModule = false) {
  if (!Array.isArray(words)) {
    return [];
  }
  return words.filter((word) => typeof word === 'string' && isStrictBindReservedWord(word, inModule));
}

module.exports = {
  checkIsStrictBindReservedWord,
  filterStrictBindReservedWords,
};
test/contract.mjs
import assert from 'node:assert';
import { createRequire } from 'node:module';

const require = createRequire(import.meta.url);
const { checkIsStrictBindReservedWord, filterStrictBindReservedWords } = require('../src/index.js');
const { isStrictBindReservedWord } = require('@babel/helper-validator-identifier');

async function runContract() {
  // 1. isStrictBindReservedWord returns true for strict bind only reserved words eval and arguments
  const strictBindWords = ['eval', 'arguments'];
  for (const word of strictBindWords) {
    assert.strictEqual(isStrictBindReservedWord(word, true), true, `expected isStrictBindReservedWord("${word}", true) to be true`);
    assert.strictEqual(isStrictBindReservedWord(word, false), true, `expected isStrictBindReservedWord("${word}", false) to be true`);
    assert.strictEqual(isStrictBindReservedWord(word), true, `expected isStrictBindReservedWord("${word}") to be true`);
    assert.strictEqual(checkIsStrictBindReservedWord(word, true), true, `expected wrapper checkIsStrictBindReservedWord("${word}", true) to be true`);
    assert.strictEqual(checkIsStrictBindReservedWord(word, false), true, `expected wrapper checkIsStrictBindReservedWord("${word}", false) to be true`);
    assert.strictEqual(checkIsStrictBindReservedWord(word), true, `expected wrapper checkIsStrictBindReservedWord("${word}") to be true`);
  }

  // 2. isStrictBindReservedWord returns true for strict mode reserved words including implements, interface, let, package, private, protected, public, static, and yield
  const strictWords = [
    'implements',
    'interface',
    'let',
    'package',
    'private',
    'protected',
    'public',
    'static',
    'yield',
  ];
  for (const word of strictWords) {
    assert.strictEqual(isStrictBindReservedWord(word, true), true, `expected isStrictBindReservedWord("${word}", true) to be true`);
    assert.strictEqual(isStrictBindReservedWord(word, false), true, `expected isStrictBindReservedWord("${word}", false) to be true`);
    assert.strictEqual(isStrictBindReservedWord(word), true, `expected isStrictBindReservedWord("${word}") to be true`);
    assert.strictEqual(checkIsStrictBindReservedWord(word, true), true, `expected wrapper checkIsStrictBindReservedWord("${word}", true) to be true`);
    assert.strictEqual(checkIsStrictBindReservedWord(word, false), true, `expected wrapper checkIsStrictBindReservedWord("${word}", false) to be true`);
    assert.strictEqual(checkIsStrictBindReservedWord(word), true, `expected wrapper checkIsStrictBindReservedWord("${word}") to be true`);
  }

  // 3. isStrictBindReservedWord returns true for enum regardless of module mode and true for await when inModule is true
  assert.strictEqual(isStrictBindReservedWord('enum', true), true, 'expected isStrictBindReservedWord("enum", true) to be true');
  assert.strictEqual(isStrictBindReservedWord('enum', false), true, 'expected isStrictBindReservedWord("enum", false) to be true');
  assert.strictEqual(isStrictBindReservedWord('enum'), true, 'expected isStrictBindReservedWord("enum") to be true');
  assert.strictEqual(checkIsStrictBindReservedWord('enum', true), true, 'expected wrapper checkIsStrictBindReservedWord("enum", true) to be true');
  assert.strictEqual(checkIsStrictBindReservedWord('enum', false), true, 'expected wrapper checkIsStrictBindReservedWord("enum", false) to be true');
  assert.strictEqual(checkIsStrictBindReservedWord('enum'), true, 'expected wrapper checkIsStrictBindReservedWord("enum") to be true');

  assert.strictEqual(isStrictBindReservedWord('await', true), true, 'expected isStrictBindReservedWord("await", true) to be true');
  assert.strictEqual(checkIsStrictBindReservedWord('await', true), true, 'expected wrapper checkIsStrictBindReservedWord("await", true) to be true');

  // 4. isStrictBindReservedWord returns false for await when inModule is false or omitted
  assert.strictEqual(Boolean(isStrictBindReservedWord('await', false)), false, 'expected isStrictBindReservedWord("await", false) to be false');
  assert.strictEqual(Boolean(isStrictBindReservedWord('await')), false, 'expected isStrictBindReservedWord("await") to be false');
  assert.strictEqual(Boolean(checkIsStrictBindReservedWord('await', false)), false, 'expected wrapper checkIsStrictBindReservedWord("await", false) to be false');
  assert.strictEqual(Boolean(checkIsStrictBindReservedWord('await')), false, 'expected wrapper checkIsStrictBindReservedWord("await") to be false');

  // 5. isStrictBindReservedWord returns false for regular identifier names, non-strict keywords, and uppercase or mixed-case variants
  const nonStrictBindWords = [
    'foo',
    'bar',
    'identifierName',
    'myVar',
    'var',
    'const',
    'function',
    'class',
    'return',
    'if',
    'while',
    'null',
    'true',
    'false',
    'undefined',
    'EVAL',
    'Eval',
    'ARGUMENTS',
    'Arguments',
    'LET',
    'Let',
    'YIELD',
    'Yield',
    'ENUM',
    'Enum',
    'AWAIT',
    'Await',
  ];

  for (const word of nonStrictBindWords) {
    assert.strictEqual(Boolean(isStrictBindReservedWord(word, true)), false, `expected isStrictBindReservedWord("${word}", true) to be false`);
    assert.strictEqual(Boolean(isStrictBindReservedWord(word, false)), false, `expected isStrictBindReservedWord("${word}", false) to be false`);
    assert.strictEqual(Boolean(checkIsStrictBindReservedWord(word, true)), false, `expected wrapper checkIsStrictBindReservedWord("${word}", true) to be false`);
    assert.strictEqual(Boolean(checkIsStrictBindReservedWord(word, false)), false, `expected wrapper checkIsStrictBindReservedWord("${word}", false) to be false`);
  }

  // Wrapper utility tests
  const candidates = ['eval', 'foo', 'let', 'bar', 'await', 'arguments', 'var'];
  const inModuleResult = filterStrictBindReservedWords(candidates, true);
  assert.deepStrictEqual(inModuleResult, ['eval', 'let', 'await', 'arguments']);

  const scriptResult = filterStrictBindReservedWords(candidates, false);
  assert.deepStrictEqual(scriptResult, ['eval', 'let', 'arguments']);

  assert.deepStrictEqual(filterStrictBindReservedWords([]), []);
  assert.deepStrictEqual(filterStrictBindReservedWords(null), []);

  console.log('Contract tests passed successfully.');
}

runContract().catch((err) => {
  console.error('Contract test failed:', err);
  process.exit(1);
});

Seeder de origen

anónimo