샘플
js-tokens 9.0.1
검증된 샘플 — npm js-tokens 9.0.1. node 22 · linux alpine/x64 · docker에서 contract를 실행해 통과했습니다: jsTokens yields token objects with type and value for JavaScript…
sha256:284b15822e9206d3e555c82eb5a056c3e3e1587c4813b90b94c472ae01d244cf
이 네트워크가 제공하는 것은 하나입니다. 빌드되는 샘플. 샌드박스에서 돌리고 서명된 영수증을 보관합니다. 등급을 매기지 않고 무엇도 보증하지 않습니다 — 같은 코드가 당신 환경에서 빌드되는지는 측정한 적이 없습니다.
통과한 계약 영수증을 낸 서로 다른 서명 키의 수입니다. 하나면 작성자 혼자이고, 둘 이상이면 다른 사람도 빌드했다는 뜻입니다. 키는 스스로 만드는 것이고 뒤에 등록된 신원이 없으므로, 세는 것은 사람이 아니라 키입니다.
MIT-0
실행 증거
선언된 환경과 서명된 실행을 분리해 두었습니다. 이 샘플이 무엇을 어디서 실행했는지 그대로 볼 수 있습니다.
- 증거 기준
- 서명된 컨트랙트 통과
- 검증 영수증
- 2
- 빌드한 서명 키
- 1
선언된 환경
node 22.23 linux 24 · ubuntu · glibc 2.39 x64 node 22.23 javascript npm 10
검증 실행 환경
| 환경 | 컨트랙트 | 단계 | 실행일 |
|---|---|---|---|
| node 22 · linux alpine/x64 · docker ed25519:c1973797be207ac4 | PASS | compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS CONTAINER_RUN · node-typescript@1 |
2026-08-21 |
| 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/js-tokens@9.0.1
- 패키지
- 환경
- node 22.23.2
- 생성일
- 2026-08-21T03:26:42Z
컨트랙트
- jsTokens yields token objects with type and value for JavaScript code constructs
- tokenize parses identifiers, keywords, punctuators, and numeric literals
- tokenize handles regular expression literals and string literals with closed flag
- tokenize supports JSX syntax when jsx option is enabled
- tokenize handles template literals and template substitutions
- extractSignificantTokens filters whitespace and comments
파일
- PROMPT.md
- csx.json
- package-lock.json
- package.json
- spec.json
- src/index.js
- test/contract.mjs
소스
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/js-tokens@9.0.1
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:npm/js-tokens@9.0.1
Constraints:
- executionContext: node
Required runtime conditions:
- ecosystem: npm
- language: javascript
- moduleSystem: cjs
- packageManager: npm@10.9.8
- 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.
{"case":{"caseId":"case:sha256:f39a58783c94076348c759449624c8ac8f6dd46517146b97e6cba7dd1de2b0b3","constraints":{"executionContext":"node"},"contract":["jsTokens yields token objects with type and value for JavaScript code constructs","tokenize parses identifiers, keywords, punctuators, and numeric literals","tokenize handles regular expression literals and string literals with closed flag","tokenize supports JSX syntax when jsx option is enabled","tokenize handles template literals and template substitutions","extractSignificantTokens filters whitespace and comments"],"goal":"verify pkg:npm/js-tokens@9.0.1","kind":"HOW","packages":["pkg:npm/js-tokens@9.0.1"],"schemaVersion":1},"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","packageManagerVersion":"10.9.8","runtime":"node","runtimeVersion":"22.23.2","schemaVersion":1},"license":"MIT-0","packages":["pkg:npm/js-tokens@9.0.1"],"schemaVersion":1,"subject":"pkg:npm/js-tokens@9.0.1","verifierAdapter":"node-typescript@1"}
{
"name": "sample-js-tokens",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "sample-js-tokens",
"version": "1.0.0",
"dependencies": {
"js-tokens": "9.0.1"
}
},
"node_modules/js-tokens": {
"version": "9.0.1",
"resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-9.0.1.tgz",
"integrity": "sha512-mxa9E9ITFOt0ban3j6L5MpjwegGz6lBQmM1IJkWeBZGcMxto50+eWdjC/52xDbS2vy0k7vIMK0Fe2wfL9OQSpQ==",
"license": "MIT"
}
}
}
{
"name": "sample-js-tokens",
"version": "1.0.0",
"private": true,
"description": "Clean-room verification of js-tokens",
"main": "src/index.js",
"dependencies": {
"js-tokens": "9.0.1"
}
}
{
"schemaVersion": 1,
"goal": "verify pkg:npm/js-tokens@9.0.1",
"kind": "HOW",
"packages": [
"pkg:npm/js-tokens@9.0.1"
],
"constraints": {
"executionContext": "node"
},
"runtimeConditions": {
"ecosystem": "npm",
"language": "javascript",
"moduleSystem": "cjs",
"packageManager": "npm@10.9.8",
"runtime": "node@22.23.2"
}
}
const jsTokens = require('js-tokens');
/**
* Tokenize JavaScript code into an array of token objects.
* @param {string} input - JavaScript code to tokenize.
* @param {object} [options] - Tokenizer options.
* @param {boolean} [options.jsx=false] - Whether to tokenize JSX syntax.
* @returns {Array<{type: string, value: string, closed?: boolean}>}
*/
function tokenize(input, options = {}) {
return Array.from(jsTokens(input, options));
}
/**
* Extract non-whitespace and non-comment token values.
* @param {string} input - JavaScript code.
* @param {object} [options] - Tokenizer options.
* @returns {string[]} Array of significant token string values.
*/
function extractSignificantTokens(input, options = {}) {
const tokens = tokenize(input, options);
return tokens
.filter(
(t) =>
t.type !== 'WhiteSpace' &&
t.type !== 'LineTerminatorSequence' &&
t.type !== 'SingleLineComment' &&
t.type !== 'MultiLineComment' &&
t.type !== 'HashbangComment'
)
.map((t) => t.value);
}
module.exports = {
jsTokens,
tokenize,
extractSignificantTokens
};
import assert from 'node:assert';
import { createRequire } from 'node:module';
const require = createRequire(import.meta.url);
const { jsTokens, tokenize, extractSignificantTokens } = require('../src/index.js');
// 1. Export verification
assert.strictEqual(typeof jsTokens, 'function', 'jsTokens should be exported as a function');
assert.strictEqual(typeof tokenize, 'function', 'tokenize should be exported as a function');
assert.strictEqual(typeof extractSignificantTokens, 'function', 'extractSignificantTokens should be exported as a function');
// 2. Tokenize basic JavaScript declarations and statements
const basicTokens = tokenize('const answer = 42;');
assert.strictEqual(basicTokens.length, 8);
assert.deepStrictEqual(
basicTokens.map((t) => t.type),
[
'IdentifierName',
'WhiteSpace',
'IdentifierName',
'WhiteSpace',
'Punctuator',
'WhiteSpace',
'NumericLiteral',
'Punctuator'
]
);
assert.strictEqual(basicTokens[0].value, 'const');
assert.strictEqual(basicTokens[2].value, 'answer');
assert.strictEqual(basicTokens[4].value, '=');
assert.strictEqual(basicTokens[6].value, '42');
assert.strictEqual(basicTokens[7].value, ';');
// 3. Tokenize regular expression literals and string literals with closed status
const regexTokens = tokenize('/^[a-z]+$/i;');
assert.strictEqual(regexTokens[0].type, 'RegularExpressionLiteral');
assert.strictEqual(regexTokens[0].value, '/^[a-z]+$/i');
assert.strictEqual(regexTokens[0].closed, true);
const closedString = tokenize('"clean room"');
assert.strictEqual(closedString[0].type, 'StringLiteral');
assert.strictEqual(closedString[0].value, '"clean room"');
assert.strictEqual(closedString[0].closed, true);
const unclosedString = tokenize('"unclosed');
assert.strictEqual(unclosedString[0].type, 'StringLiteral');
assert.strictEqual(unclosedString[0].closed, false);
// 4. Tokenize JSX elements when jsx option is true
const jsxCode = '<Button onClick={handleClick}>Click Me</Button>';
const jsxTokens = tokenize(jsxCode, { jsx: true });
const tokenTypes = jsxTokens.map((t) => t.type);
assert.ok(tokenTypes.includes('JSXIdentifier'), 'Should identify JSX tag names');
assert.ok(tokenTypes.includes('JSXPunctuator'), 'Should identify JSX punctuators');
assert.ok(tokenTypes.includes('JSXText'), 'Should identify JSX text content');
const jsxIdentifiers = jsxTokens.filter((t) => t.type === 'JSXIdentifier').map((t) => t.value);
assert.deepStrictEqual(jsxIdentifiers, ['Button', 'onClick', 'Button']);
// 5. Tokenize template literals and substitutions
const templateTokens = tokenize('`User ${name} logged in.`');
assert.strictEqual(templateTokens[0].type, 'TemplateHead');
assert.strictEqual(templateTokens[0].value, '`User ${');
assert.strictEqual(templateTokens[1].type, 'IdentifierName');
assert.strictEqual(templateTokens[1].value, 'name');
assert.strictEqual(templateTokens[2].type, 'TemplateTail');
assert.strictEqual(templateTokens[2].value, '} logged in.`');
assert.strictEqual(templateTokens[2].closed, true);
// 6. Extract significant tokens excluding whitespace and comments
const sourceWithComments = '/* preamble */ let total = 10 + 20; // end of line';
const significant = extractSignificantTokens(sourceWithComments);
assert.deepStrictEqual(significant, ['let', 'total', '=', '10', '+', '20', ';']);
console.log('Contract tests passed successfully.');
오리진 시더
익명