CodeSampleX

示例

unicode-match-property-ecmascript 2.0.0

已验证示例 — npm unicode-match-property-ecmascript 2.0.0. contract 在 node 22 · linux alpine/x64 · docker 上运行并通过: matchProperty returns canonical property name…

sha256:82a606c2c900f44057eb316a97db6a8bcc5c4ca83acd4fe26d5f2c6abe40e98e

本网络只提供一件事:能构建的样本。它在沙箱中运行并保留签名回执。它不评级、不担保——同样的代码能否在你的环境构建,它没有测量过。 提交了通过的契约回执的不同签名密钥数量。为 1 表示只有作者;大于 1 表示还有其他人构建过。密钥是自行生成的,背后没有注册身份,因此计的是密钥而非人。 MIT-0

执行证据

声明的环境与签名的运行分开呈现,你可以看到这个样本究竟运行了什么、在哪里运行。

证据依据
签名契约通过
验证回执
1
构建过它的签名密钥
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-28

案例

HOW
目标
verify pkg:npm/unicode-match-property-ecmascript@2.0.0
包
创建时间
2026-08-28T08:54:24Z

契约

  1. matchProperty returns canonical property name when given a canonical property name directly
  2. matchProperty resolves short property aliases to their canonical ECMAScript property names
  3. matchProperty resolves binary property aliases to their canonical ECMAScript property names
  4. matchProperty throws an Error with Unknown property message when given an unknown property name
  5. matchProperty enforces strict case-sensitivity and throws an Error for incorrect casing

文件

  • PROMPT.md
  • csx.json
  • index.mjs
  • package-lock.json
  • package.json
  • spec.json
  • 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: verify pkg:npm/unicode-match-property-ecmascript@2.0.0
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:npm/unicode-match-property-ecmascript@2.0.0

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:72e7ffd1377f6038c41e26cd6013e7c2d266bee3d30d8882af2ebf2b74a0b9d9","contract":["matchProperty returns canonical property name when given a canonical property name directly","matchProperty resolves short property aliases to their canonical ECMAScript property names","matchProperty resolves binary property aliases to their canonical ECMAScript property names","matchProperty throws an Error with Unknown property message when given an unknown property name","matchProperty enforces strict case-sensitivity and throws an Error for incorrect casing"],"goal":"verify pkg:npm/unicode-match-property-ecmascript@2.0.0","kind":"HOW","packages":["pkg:npm/unicode-match-property-ecmascript@2.0.0"],"schemaVersion":1},"contractCommand":["node","test/contract.mjs"],"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/unicode-match-property-ecmascript@2.0.0"],"schemaVersion":1,"subject":"pkg:npm/unicode-match-property-ecmascript@2.0.0","verifierAdapter":"node-typescript@1"}
index.mjs
import matchProperty from 'unicode-match-property-ecmascript';

/**
 * Match a Unicode property name or alias to its canonical ECMAScript property name.
 *
 * @param {string} property - Unicode property name or alias
 * @returns {string} Canonical ECMAScript property name
 */
export function getCanonicalPropertyName(property) {
  return matchProperty(property);
}

export { matchProperty };
export default matchProperty;
package-lock.json
{
  "name": "sample-unicode-match-property-ecmascript",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "sample-unicode-match-property-ecmascript",
      "version": "1.0.0",
      "license": "MIT-0",
      "dependencies": {
        "unicode-match-property-ecmascript": "2.0.0"
      }
    },
    "node_modules/unicode-canonical-property-names-ecmascript": {
      "version": "2.0.1",
      "resolved": "https://registry.npmjs.org/unicode-canonical-property-names-ecmascript/-/unicode-canonical-property-names-ecmascript-2.0.1.tgz",
      "integrity": "sha512-dA8WbNeb2a6oQzAQ55YlT5vQAWGV9WXOsi3SskE3bcCdM0P4SDd+24zS/OCacdRq5BkdsRj9q3Pg6YyQoxIGqg==",
      "license": "MIT",
      "engines": {
        "node": ">=4"
      }
    },
    "node_modules/unicode-match-property-ecmascript": {
      "version": "2.0.0",
      "resolved": "https://registry.npmjs.org/unicode-match-property-ecmascript/-/unicode-match-property-ecmascript-2.0.0.tgz",
      "integrity": "sha512-5kaZCrbp5mmbz5ulBkDkbY0SsPOjKqVS35VpL9ulMPfSl0J0Xsm+9Evphv9CoIZFwre7aJoa94AY6seMKGVN5Q==",
      "license": "MIT",
      "dependencies": {
        "unicode-canonical-property-names-ecmascript": "^2.0.0",
        "unicode-property-aliases-ecmascript": "^2.0.0"
      },
      "engines": {
        "node": ">=4"
      }
    },
    "node_modules/unicode-property-aliases-ecmascript": {
      "version": "2.2.0",
      "resolved": "https://registry.npmjs.org/unicode-property-aliases-ecmascript/-/unicode-property-aliases-ecmascript-2.2.0.tgz",
      "integrity": "sha512-hpbDzxUY9BFwX+UeBnxv3Sh1q7HFxj48DTmXchNgRa46lO8uj3/1iEn3MiNUYTg1g9ctIqXCCERn8gYZhHC5lQ==",
      "license": "MIT",
      "engines": {
        "node": ">=4"
      }
    }
  }
}
package.json
{
  "name": "sample-unicode-match-property-ecmascript",
  "version": "1.0.0",
  "type": "module",
  "private": true,
  "description": "verify pkg:npm/unicode-match-property-ecmascript@2.0.0",
  "main": "index.mjs",
  "scripts": {
    "test": "node test/contract.mjs"
  },
  "dependencies": {
    "unicode-match-property-ecmascript": "2.0.0"
  },
  "license": "MIT-0"
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify pkg:npm/unicode-match-property-ecmascript@2.0.0",
  "kind": "HOW",
  "packages": [
    "pkg:npm/unicode-match-property-ecmascript@2.0.0"
  ]
}
test/contract.mjs
import assert from 'node:assert/strict';
import matchProperty from 'unicode-match-property-ecmascript';
import { getCanonicalPropertyName } from '../index.mjs';

// 1. matchProperty returns canonical property name when given a canonical property name directly
{
  assert.equal(matchProperty('Script'), 'Script');
  assert.equal(matchProperty('General_Category'), 'General_Category');
  assert.equal(matchProperty('Script_Extensions'), 'Script_Extensions');
  assert.equal(matchProperty('ASCII_Hex_Digit'), 'ASCII_Hex_Digit');
  assert.equal(getCanonicalPropertyName('Script'), 'Script');
  assert.equal(getCanonicalPropertyName('General_Category'), 'General_Category');
}

// 2. matchProperty resolves short property aliases to their canonical ECMAScript property names
{
  assert.equal(matchProperty('sc'), 'Script');
  assert.equal(matchProperty('gc'), 'General_Category');
  assert.equal(matchProperty('scx'), 'Script_Extensions');
  assert.equal(getCanonicalPropertyName('sc'), 'Script');
  assert.equal(getCanonicalPropertyName('gc'), 'General_Category');
  assert.equal(getCanonicalPropertyName('scx'), 'Script_Extensions');
}

// 3. matchProperty resolves binary property aliases to their canonical ECMAScript property names
{
  assert.equal(matchProperty('AHex'), 'ASCII_Hex_Digit');
  assert.equal(matchProperty('ASCII'), 'ASCII');
  assert.equal(matchProperty('Any'), 'Any');
  assert.equal(matchProperty('Assigned'), 'Assigned');
  assert.equal(matchProperty('IDS'), 'ID_Start');
  assert.equal(getCanonicalPropertyName('AHex'), 'ASCII_Hex_Digit');
  assert.equal(getCanonicalPropertyName('IDS'), 'ID_Start');
}

// 4. matchProperty throws an Error with Unknown property message when given an unknown property name
{
  assert.throws(
    () => matchProperty('unknown_property'),
    {
      name: 'Error',
      message: 'Unknown property: unknown_property'
    }
  );
  assert.throws(
    () => getCanonicalPropertyName('invalid_alias'),
    {
      name: 'Error',
      message: 'Unknown property: invalid_alias'
    }
  );
}

// 5. matchProperty enforces strict case-sensitivity and throws an Error for incorrect casing
{
  assert.throws(
    () => matchProperty('script'),
    {
      name: 'Error',
      message: 'Unknown property: script'
    }
  );
  assert.throws(
    () => matchProperty('general_category'),
    {
      name: 'Error',
      message: 'Unknown property: general_category'
    }
  );
  assert.throws(
    () => getCanonicalPropertyName('SC'),
    {
      name: 'Error',
      message: 'Unknown property: SC'
    }
  );
}

console.log('All contract tests passed.');

原始种子者

匿名