CodeSampleX

샘플

unicode-match-property-value-ecmascript 2.2.1: match property value aliases to canonical ECMAScript Unicode property values

검증된 샘플 — npm unicode-match-property-value-ecmascript 2.2.1: match property value aliases to canonical ECMAScript Unicode property values. node 22 · linux…

sha256:3f6d0a00862262eed8c539c96f8eabe893395d616f12d8193f99473b92819756

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

실행 증거

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

증거 기준
서명된 컨트랙트 통과
검증 영수증
1
빌드한 서명 키
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@1node:22-alpine@sha256:c610fcdfb1d5…
2026-08-28

케이스

HOW
목표
match property value aliases to canonical ECMAScript Unicode property values
패키지
심벌
  • matchPropertyValue
환경
node 22.23.2
생성일
2026-08-28T08:55:47Z

컨트랙트

  1. matchPropertyValue resolves General_Category aliases and short names to canonical ECMAScript property values
  2. matchPropertyValue resolves Script aliases and short codes to canonical script names
  3. matchPropertyValue resolves Script_Extensions aliases to canonical script extension names
  4. matchPropertyValue throws descriptive Error on unknown property
  5. matchPropertyValue throws descriptive Error on invalid or unknown value for property
  6. resolvePropertyValues resolves multiple aliases to canonical values in sequence
  7. tryResolvePropertyValue safely returns canonical value or null without throwing

파일

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

소스 아티팩트 내려받기 (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: match property value aliases to canonical ECMAScript Unicode property values
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:npm/unicode-match-property-value-ecmascript@2.2.1
Demonstrate these symbols/APIs:
  - matchPropertyValue

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:c09d513aa6ab175c21f8315dec4b5dc0a07aa7e163aafb15e46deb0a4f1a344b","contract":["matchPropertyValue resolves General_Category aliases and short names to canonical ECMAScript property values","matchPropertyValue resolves Script aliases and short codes to canonical script names","matchPropertyValue resolves Script_Extensions aliases to canonical script extension names","matchPropertyValue throws descriptive Error on unknown property","matchPropertyValue throws descriptive Error on invalid or unknown value for property","resolvePropertyValues resolves multiple aliases to canonical values in sequence","tryResolvePropertyValue safely returns canonical value or null without throwing"],"goal":"match property value aliases to canonical ECMAScript Unicode property values","kind":"HOW","packages":["pkg:npm/unicode-match-property-value-ecmascript@2.2.1"],"schemaVersion":1,"symbols":["matchPropertyValue"]},"contractCommand":["node","test/contract.mjs"],"environment":{"arch":"x64","distro":"ubuntu","ecosystem":"npm","executionContext":"node","language":"javascript","libc":"glibc","libcVersion":"2.39","moduleSystem":"esm","os":"linux","osVersionBucket":"24","packageManager":"npm","packageManagerVersion":"10.9.8","runtime":"node","runtimeVersion":"22.23.2","schemaVersion":1},"license":"MIT-0","packages":["pkg:npm/unicode-match-property-value-ecmascript@2.2.1"],"schemaVersion":1,"subject":"pkg:npm/unicode-match-property-value-ecmascript@2.2.1","symbols":["matchPropertyValue"],"verifierAdapter":"node-typescript@1"}
package-lock.json
{
  "name": "sample-unicode-match-property-value-ecmascript",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "sample-unicode-match-property-value-ecmascript",
      "version": "1.0.0",
      "dependencies": {
        "unicode-match-property-value-ecmascript": "2.2.1"
      }
    },
    "node_modules/unicode-match-property-value-ecmascript": {
      "version": "2.2.1",
      "resolved": "https://registry.npmjs.org/unicode-match-property-value-ecmascript/-/unicode-match-property-value-ecmascript-2.2.1.tgz",
      "integrity": "sha512-JQ84qTuMg4nVkx8ga4A16a1epI9H6uTXAknqxkGF/aFfRLw1xC/Bp24HNLaZhHSkWd3+84t8iXnp1J0kYcZHhg==",
      "license": "MIT",
      "engines": {
        "node": ">=4"
      }
    }
  }
}
package.json
{
  "name": "sample-unicode-match-property-value-ecmascript",
  "version": "1.0.0",
  "private": true,
  "description": "Match Unicode property value aliases to canonical values according to ECMAScript RegExp property escapes",
  "type": "module",
  "main": "src/index.js",
  "dependencies": {
    "unicode-match-property-value-ecmascript": "2.2.1"
  }
}
spec.json
{
  "schemaVersion": 1,
  "goal": "match property value aliases to canonical ECMAScript Unicode property values",
  "kind": "HOW",
  "packages": [
    "pkg:npm/unicode-match-property-value-ecmascript@2.2.1"
  ],
  "symbols": [
    "matchPropertyValue"
  ]
}
src/index.js
import { createRequire } from 'node:module';

const require = createRequire(import.meta.url);
const matchPropertyValue = require('unicode-match-property-value-ecmascript');

/**
 * Match a Unicode property value or alias to its canonical ECMAScript property value.
 *
 * @param {string} property - Canonical Unicode property name (e.g. 'General_Category', 'Script', 'Script_Extensions').
 * @param {string} value - Property value or alias (e.g. 'C', 'Lu', 'Grek', 'Aghb').
 * @returns {string} The canonical property value (e.g. 'Other', 'Uppercase_Letter', 'Greek', 'Caucasian_Albanian').
 * @throws {Error} When property is unknown or value is not a valid alias/value for the property.
 */
export function resolvePropertyValue(property, value) {
  return matchPropertyValue(property, value);
}

/**
 * Match multiple property values against a canonical Unicode property.
 *
 * @param {string} property - Canonical Unicode property name.
 * @param {string[]} values - List of values or aliases to resolve.
 * @returns {string[]} List of resolved canonical property values.
 */
export function resolvePropertyValues(property, values) {
  return values.map((val) => matchPropertyValue(property, val));
}

/**
 * Safely attempt to resolve a property value, returning null if invalid rather than throwing.
 *
 * @param {string} property - Canonical Unicode property name.
 * @param {string} value - Property value or alias.
 * @returns {string|null} Canonical property value or null if unknown.
 */
export function tryResolvePropertyValue(property, value) {
  try {
    return matchPropertyValue(property, value);
  } catch {
    return null;
  }
}

export { matchPropertyValue };
export default matchPropertyValue;
test/contract.mjs
import assert from 'node:assert';
import {
  matchPropertyValue,
  resolvePropertyValue,
  resolvePropertyValues,
  tryResolvePropertyValue,
} from '../src/index.js';

// 1. Symbol and helper function exports verification
assert.strictEqual(typeof matchPropertyValue, 'function', 'matchPropertyValue should be a function');
assert.strictEqual(typeof resolvePropertyValue, 'function', 'resolvePropertyValue should be a function');
assert.strictEqual(typeof resolvePropertyValues, 'function', 'resolvePropertyValues should be a function');
assert.strictEqual(typeof tryResolvePropertyValue, 'function', 'tryResolvePropertyValue should be a function');

// 2. matchPropertyValue resolves General_Category aliases and canonical names
assert.strictEqual(matchPropertyValue('General_Category', 'C'), 'Other');
assert.strictEqual(matchPropertyValue('General_Category', 'Cc'), 'Control');
assert.strictEqual(matchPropertyValue('General_Category', 'cntrl'), 'Control');
assert.strictEqual(matchPropertyValue('General_Category', 'digit'), 'Decimal_Number');
assert.strictEqual(matchPropertyValue('General_Category', 'Nd'), 'Decimal_Number');
assert.strictEqual(matchPropertyValue('General_Category', 'Decimal_Number'), 'Decimal_Number');
assert.strictEqual(matchPropertyValue('General_Category', 'Lu'), 'Uppercase_Letter');
assert.strictEqual(matchPropertyValue('General_Category', 'Uppercase_Letter'), 'Uppercase_Letter');
assert.strictEqual(matchPropertyValue('General_Category', 'punct'), 'Punctuation');

// 3. matchPropertyValue resolves Script aliases and canonical names
assert.strictEqual(matchPropertyValue('Script', 'Grek'), 'Greek');
assert.strictEqual(matchPropertyValue('Script', 'Greek'), 'Greek');
assert.strictEqual(matchPropertyValue('Script', 'Latn'), 'Latin');
assert.strictEqual(matchPropertyValue('Script', 'Latin'), 'Latin');
assert.strictEqual(matchPropertyValue('Script', 'Hani'), 'Han');
assert.strictEqual(matchPropertyValue('Script', 'Han'), 'Han');

// 4. matchPropertyValue resolves Script_Extensions aliases and canonical names
assert.strictEqual(matchPropertyValue('Script_Extensions', 'Aghb'), 'Caucasian_Albanian');
assert.strictEqual(matchPropertyValue('Script_Extensions', 'Caucasian_Albanian'), 'Caucasian_Albanian');
assert.strictEqual(matchPropertyValue('Script_Extensions', 'Arab'), 'Arabic');
assert.strictEqual(matchPropertyValue('Script_Extensions', 'Arabic'), 'Arabic');

// 5. matchPropertyValue throws descriptive Error on unknown property
assert.throws(
  () => matchPropertyValue('UnknownProperty', 'Letter'),
  {
    name: 'Error',
    message: 'Unknown property `UnknownProperty`.'
  }
);

// 6. matchPropertyValue throws descriptive Error on invalid or unknown value for property
assert.throws(
  () => matchPropertyValue('General_Category', 'NonexistentValue'),
  {
    name: 'Error',
    message: 'Unknown value `NonexistentValue` for property `General_Category`.'
  }
);
assert.throws(
  () => matchPropertyValue('Script', 'InvalidScript'),
  {
    name: 'Error',
    message: 'Unknown value `InvalidScript` for property `Script`.'
  }
);

// 7. Helpers resolve collections and safe lookups
assert.deepStrictEqual(
  resolvePropertyValues('General_Category', ['Lu', 'Ll', 'Nd']),
  ['Uppercase_Letter', 'Lowercase_Letter', 'Decimal_Number']
);
assert.strictEqual(tryResolvePropertyValue('General_Category', 'Nd'), 'Decimal_Number');
assert.strictEqual(tryResolvePropertyValue('General_Category', 'invalid'), null);
assert.strictEqual(tryResolvePropertyValue('InvalidProp', 'Nd'), null);

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

오리진 시더

익명