CodeSampleX

샘플

esutils 2.0.3

검증된 샘플 — npm esutils 2.0.3. node 22 · linux alpine/x64 · docker에서 contract를 실행해 통과했습니다: keyword module identifies JavaScript keywords, reserved words, and…

sha256:478d8047a030f6c5ff1a8907ec3ba1058b22c2be0ee02c52bf4b2cf1e00b9ea0

이 네트워크가 제공하는 것은 하나입니다. 빌드되는 샘플. 샌드박스에서 돌리고 서명된 영수증을 보관합니다. 등급을 매기지 않고 무엇도 보증하지 않습니다 — 같은 코드가 당신 환경에서 빌드되는지는 측정한 적이 없습니다. 통과한 계약 영수증을 낸 서로 다른 서명 키의 수입니다. 하나면 작성자 혼자이고, 둘 이상이면 다른 사람도 빌드했다는 뜻입니다. 키는 스스로 만드는 것이고 뒤에 등록된 신원이 없으므로, 세는 것은 사람이 아니라 키입니다. MIT-0

실행 증거

선언된 환경과 서명된 실행을 분리해 두었습니다. 이 샘플이 무엇을 어디서 실행했는지 그대로 볼 수 있습니다.

증거 기준
서명된 컨트랙트 통과
검증 영수증
2
빌드한 서명 키
1
선언된 환경 linux 24 · ubuntu · glibc 2.39 x64 npm

검증 실행 환경

환경 컨트랙트 단계 실행일
node 22 · linux alpine/x64 · docker ed25519:c1973797be207ac4 PASS compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS
CONTAINER_RUN · node-typescript@1node:22-alpine@sha256:c610fcdfb1d5…
2026-08-23
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

케이스

HOW
목표
verify pkg:npm/esutils@2.0.3
패키지
생성일
2026-08-23T14:12:26Z

컨트랙트

  1. keyword module identifies JavaScript keywords, reserved words, and valid identifier names
  2. code module determines character categories including digits, whitespace, and identifier boundaries
  3. ast module identifies AST node classifications including expressions, statements, and iteration statements

파일

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

소스 아티팩트 내려받기 (tar.gz)

소스

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 pkg:npm/esutils@2.0.3
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:npm/esutils@2.0.3

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:3ce354a7046e3a386367dc5edf9c709f94acd159833dd3124672cfd56b80a363","contract":["keyword module identifies JavaScript keywords, reserved words, and valid identifier names","code module determines character categories including digits, whitespace, and identifier boundaries","ast module identifies AST node classifications including expressions, statements, and iteration statements"],"goal":"verify pkg:npm/esutils@2.0.3","kind":"HOW","packages":["pkg:npm/esutils@2.0.3"],"schemaVersion":1},"contractCommand":["node","test/contract.js"],"environment":{"arch":"x64","distro":"ubuntu","ecosystem":"npm","libc":"glibc","libcVersion":"2.39","os":"linux","osVersionBucket":"24","packageManager":"npm","schemaVersion":1},"license":"MIT-0","packages":["pkg:npm/esutils@2.0.3"],"schemaVersion":1,"subject":"pkg:npm/esutils@2.0.3","verifierAdapter":"node-typescript@1"}
package-lock.json
{
  "name": "sample-esutils",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "sample-esutils",
      "version": "1.0.0",
      "license": "MIT-0",
      "dependencies": {
        "esutils": "2.0.3"
      }
    },
    "node_modules/esutils": {
      "version": "2.0.3",
      "resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.3.tgz",
      "integrity": "sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g==",
      "license": "BSD-2-Clause",
      "engines": {
        "node": ">=0.10.0"
      }
    }
  }
}
package.json
{
  "name": "sample-esutils",
  "version": "1.0.0",
  "private": true,
  "description": "Clean-room verification sample for esutils",
  "main": "src/index.js",
  "scripts": {
    "test": "node test/contract.js"
  },
  "dependencies": {
    "esutils": "2.0.3"
  },
  "license": "MIT-0"
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify pkg:npm/esutils@2.0.3",
  "kind": "HOW",
  "packages": [
    "pkg:npm/esutils@2.0.3"
  ]
}
src/index.js
const esutils = require('esutils');

/**
 * Checks if a string is a valid JavaScript identifier name in ES6.
 * @param {string} name
 * @returns {boolean}
 */
function isValidIdentifier(name) {
  return esutils.keyword.isIdentifierES6(name);
}

/**
 * Checks if a string is a reserved keyword in ES6.
 * @param {string} word
 * @param {boolean} [strict=true]
 * @returns {boolean}
 */
function isKeyword(word, strict = true) {
  return esutils.keyword.isKeywordES6(word, strict);
}

/**
 * Checks if a character code represents a whitespace character.
 * @param {number} code
 * @returns {boolean}
 */
function isWhitespaceChar(code) {
  return esutils.code.isWhiteSpace(code);
}

/**
 * Checks if an AST node is a statement.
 * @param {object} node
 * @returns {boolean}
 */
function isStatementNode(node) {
  return esutils.ast.isStatement(node);
}

module.exports = {
  esutils,
  isValidIdentifier,
  isKeyword,
  isWhitespaceChar,
  isStatementNode,
};
test/contract.js
const assert = require('node:assert');
const esutils = require('esutils');
const {
  isValidIdentifier,
  isKeyword,
  isWhitespaceChar,
  isStatementNode,
} = require('../src/index.js');

// 1. keyword module identifies JavaScript keywords, reserved words, and valid identifier names
{
  // Keywords in ES6
  assert.strictEqual(esutils.keyword.isKeywordES6('class', true), true, 'class is ES6 keyword');
  assert.strictEqual(esutils.keyword.isKeywordES6('const', true), true, 'const is ES6 keyword');
  assert.strictEqual(esutils.keyword.isKeywordES6('let', true), true, 'let is ES6 keyword');
  assert.strictEqual(esutils.keyword.isKeywordES6('import', true), true, 'import is ES6 keyword');
  assert.strictEqual(esutils.keyword.isKeywordES6('export', true), true, 'export is ES6 keyword');
  assert.strictEqual(esutils.keyword.isKeywordES6('myVariable', true), false, 'myVariable is not a keyword');
  assert.strictEqual(isKeyword('function'), true, 'helper isKeyword confirms function');
  assert.strictEqual(isKeyword('nonKeyword'), false, 'helper isKeyword rejects nonKeyword');

  // Reserved words & restricted words
  assert.strictEqual(esutils.keyword.isRestrictedWord('eval'), true, 'eval is restricted word');
  assert.strictEqual(esutils.keyword.isRestrictedWord('arguments'), true, 'arguments is restricted word');
  assert.strictEqual(esutils.keyword.isRestrictedWord('regularName'), false, 'regularName is not restricted');

  // Valid / invalid identifiers
  assert.strictEqual(esutils.keyword.isIdentifierES6('validIdent'), true, 'validIdent is valid identifier');
  assert.strictEqual(esutils.keyword.isIdentifierES6('$dollar'), true, '$dollar is valid identifier');
  assert.strictEqual(esutils.keyword.isIdentifierES6('_underscore'), true, '_underscore is valid identifier');
  assert.strictEqual(esutils.keyword.isIdentifierES6('123number'), false, '123number is invalid identifier');
  assert.strictEqual(esutils.keyword.isIdentifierES6('class'), false, 'keyword is not valid identifier');
  assert.strictEqual(esutils.keyword.isIdentifierNameES6('class'), true, 'class is valid identifier name');
  assert.strictEqual(isValidIdentifier('myVar'), true, 'helper isValidIdentifier confirms valid name');
  assert.strictEqual(isValidIdentifier('for'), false, 'helper isValidIdentifier rejects keyword');
}

// 2. code module determines character categories including digits, whitespace, and identifier boundaries
{
  // Digits
  assert.strictEqual(esutils.code.isDecimalDigit('0'.charCodeAt(0)), true, '0 is decimal digit');
  assert.strictEqual(esutils.code.isDecimalDigit('9'.charCodeAt(0)), true, '9 is decimal digit');
  assert.strictEqual(esutils.code.isDecimalDigit('a'.charCodeAt(0)), false, 'a is not decimal digit');

  assert.strictEqual(esutils.code.isHexDigit('a'.charCodeAt(0)), true, 'a is hex digit');
  assert.strictEqual(esutils.code.isHexDigit('F'.charCodeAt(0)), true, 'F is hex digit');
  assert.strictEqual(esutils.code.isHexDigit('g'.charCodeAt(0)), false, 'g is not hex digit');

  assert.strictEqual(esutils.code.isOctalDigit('7'.charCodeAt(0)), true, '7 is octal digit');
  assert.strictEqual(esutils.code.isOctalDigit('8'.charCodeAt(0)), false, '8 is not octal digit');

  // Whitespace and Line Terminators
  assert.strictEqual(esutils.code.isWhiteSpace(' '.charCodeAt(0)), true, 'space is whitespace');
  assert.strictEqual(esutils.code.isWhiteSpace('\t'.charCodeAt(0)), true, 'tab is whitespace');
  assert.strictEqual(isWhitespaceChar(' '.charCodeAt(0)), true, 'helper isWhitespaceChar confirms space');
  assert.strictEqual(esutils.code.isLineTerminator('\n'.charCodeAt(0)), true, 'newline is line terminator');
  assert.strictEqual(esutils.code.isLineTerminator('\r'.charCodeAt(0)), true, 'carriage return is line terminator');

  // Identifier start and part
  assert.strictEqual(esutils.code.isIdentifierStartES6('a'.charCodeAt(0)), true, 'a can start identifier');
  assert.strictEqual(esutils.code.isIdentifierStartES6('$'.charCodeAt(0)), true, '$ can start identifier');
  assert.strictEqual(esutils.code.isIdentifierStartES6('_'.charCodeAt(0)), true, '_ can start identifier');
  assert.strictEqual(esutils.code.isIdentifierStartES6('1'.charCodeAt(0)), false, '1 cannot start identifier');
  assert.strictEqual(esutils.code.isIdentifierPartES6('1'.charCodeAt(0)), true, '1 can be identifier part');
}

// 3. ast module identifies AST node classifications including expressions, statements, and iteration statements
{
  // Expressions
  assert.strictEqual(esutils.ast.isExpression({ type: 'Identifier' }), true, 'Identifier is expression');
  assert.strictEqual(esutils.ast.isExpression({ type: 'BinaryExpression' }), true, 'BinaryExpression is expression');
  assert.strictEqual(esutils.ast.isExpression({ type: 'FunctionDeclaration' }), false, 'FunctionDeclaration is not expression');

  // Statements
  assert.strictEqual(esutils.ast.isStatement({ type: 'IfStatement' }), true, 'IfStatement is statement');
  assert.strictEqual(esutils.ast.isStatement({ type: 'BlockStatement' }), true, 'BlockStatement is statement');
  assert.strictEqual(isStatementNode({ type: 'WhileStatement' }), true, 'helper isStatementNode confirms WhileStatement');
  assert.strictEqual(isStatementNode({ type: 'Literal' }), false, 'helper isStatementNode rejects Literal');

  // Iteration statements
  assert.strictEqual(esutils.ast.isIterationStatement({ type: 'ForStatement' }), true, 'ForStatement is iteration');
  assert.strictEqual(esutils.ast.isIterationStatement({ type: 'WhileStatement' }), true, 'WhileStatement is iteration');
  assert.strictEqual(esutils.ast.isIterationStatement({ type: 'DoWhileStatement' }), true, 'DoWhileStatement is iteration');
  assert.strictEqual(esutils.ast.isIterationStatement({ type: 'IfStatement' }), false, 'IfStatement is not iteration');

  // Source element
  assert.strictEqual(esutils.ast.isSourceElement({ type: 'FunctionDeclaration' }), true, 'FunctionDeclaration is source element');
  assert.strictEqual(esutils.ast.isSourceElement({ type: 'VariableDeclaration' }), true, 'VariableDeclaration is source element');
}

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

오리진 시더

익명