CodeSampleX

サンプル

unicode-property-aliases-ecmascript 2.2.0: convert Unicode property aliases to canonical names in ECMAScript RegExp

検証済みサンプル — npm unicode-property-aliases-ecmascript 2.2.0: convert Unicode property aliases to canonical names in ECMAScript RegExp. node 22 · linux…

sha256:bb9762de2c2f10d0f4f250db33917b91709aa9eb1f23932532896ef12ff99c04

このネットワークが提供するのは一つだけです。ビルドされるサンプル。サンドボックスで実行し、署名済みの受領証を保管します。等級はつけず、何も保証しません — 同じコードがあなたの環境でビルドされるかは測定していません。 合格した契約受領証を提出した異なる署名鍵の数です。1 なら作者だけ、2 以上なら他の誰かもビルドしています。鍵は自己生成で背後に登録された身元がないため、数えているのは人ではなく鍵です。 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-27

ケース

HOW
ゴール
convert Unicode property aliases to canonical names in ECMAScript RegExp
パッケージ
シンボル
  • propertyAliases.get
作成日
2026-08-27T12:36:56Z

コントラクト

  1. propertyAliases is an instance of Map exported by unicode-property-aliases-ecmascript
  2. propertyAliases.get maps property alias scx to canonical name Script_Extensions
  3. propertyAliases.get maps property alias gc to canonical name General_Category
  4. propertyAliases.get maps property aliases WSpace and space to canonical name White_Space
  5. propertyAliases.get returns undefined for unmapped or non-existent property aliases
  6. propertyAliases.has accurately reports existence of property aliases
  7. propertyAliases contains exactly 54 property alias entries

ファイル

  • 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: convert Unicode property aliases to canonical names in ECMAScript RegExp
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:npm/unicode-property-aliases-ecmascript@2.2.0
Demonstrate these symbols/APIs:
  - propertyAliases.get

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:5f3068ce6f9340e42d701b576b47b061bc4351a306615a28de1f394ee1c4f7cb","contract":["propertyAliases is an instance of Map exported by unicode-property-aliases-ecmascript","propertyAliases.get maps property alias scx to canonical name Script_Extensions","propertyAliases.get maps property alias gc to canonical name General_Category","propertyAliases.get maps property aliases WSpace and space to canonical name White_Space","propertyAliases.get returns undefined for unmapped or non-existent property aliases","propertyAliases.has accurately reports existence of property aliases","propertyAliases contains exactly 54 property alias entries"],"goal":"convert Unicode property aliases to canonical names in ECMAScript RegExp","kind":"HOW","packages":["pkg:npm/unicode-property-aliases-ecmascript@2.2.0"],"schemaVersion":1,"symbols":["propertyAliases.get"]},"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-property-aliases-ecmascript@2.2.0"],"schemaVersion":1,"subject":"pkg:npm/unicode-property-aliases-ecmascript@2.2.0","symbols":["propertyAliases.get"],"verifierAdapter":"node-typescript@1"}
package-lock.json
{
  "name": "sample-unicode-property-aliases-ecmascript",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "sample-unicode-property-aliases-ecmascript",
      "version": "1.0.0",
      "license": "MIT-0",
      "dependencies": {
        "unicode-property-aliases-ecmascript": "2.2.0"
      }
    },
    "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-property-aliases-ecmascript",
  "version": "1.0.0",
  "private": true,
  "description": "Clean-room code sample for propertyAliases.get in unicode-property-aliases-ecmascript@2.2.0",
  "main": "src/index.js",
  "license": "MIT-0",
  "dependencies": {
    "unicode-property-aliases-ecmascript": "2.2.0"
  }
}
spec.json
{
  "schemaVersion": 1,
  "goal": "convert Unicode property aliases to canonical names in ECMAScript RegExp",
  "kind": "HOW",
  "packages": [
    "pkg:npm/unicode-property-aliases-ecmascript@2.2.0"
  ],
  "symbols": [
    "propertyAliases.get"
  ]
}
src/index.js
const propertyAliases = require('unicode-property-aliases-ecmascript');

/**
 * Look up the canonical Unicode property name for a given alias.
 *
 * @param {string} alias - Short Unicode property alias (e.g. 'scx', 'gc', 'Alpha').
 * @returns {string|undefined} Canonical Unicode property name or undefined if not recognized.
 */
function getCanonicalPropertyName(alias) {
  return propertyAliases.get(alias);
}

/**
 * Check whether a given property alias exists in the ECMAScript Unicode property aliases map.
 *
 * @param {string} alias - Short Unicode property alias.
 * @returns {boolean} True if the alias exists in the mapping.
 */
function hasPropertyAlias(alias) {
  return propertyAliases.has(alias);
}

/**
 * Resolve a property name or alias to its canonical name.
 * If the input is already in the aliases map, its canonical name is returned;
 * otherwise undefined is returned.
 *
 * @param {string} alias - Property alias to resolve.
 * @returns {string|undefined} Canonical name or undefined.
 */
function resolvePropertyAlias(alias) {
  return propertyAliases.get(alias);
}

/**
 * Returns the total count of supported property aliases.
 *
 * @returns {number} The size of the property aliases Map.
 */
function getSupportedAliasCount() {
  return propertyAliases.size;
}

module.exports = {
  propertyAliases,
  getCanonicalPropertyName,
  hasPropertyAlias,
  resolvePropertyAlias,
  getSupportedAliasCount
};
test/contract.mjs
import assert from 'node:assert/strict';
import { createRequire } from 'node:module';

const require = createRequire(import.meta.url);
const {
  propertyAliases,
  getCanonicalPropertyName,
  hasPropertyAlias,
  resolvePropertyAlias,
  getSupportedAliasCount
} = require('../src/index.js');

async function runTests() {
  // 1. propertyAliases is an instance of Map exported by unicode-property-aliases-ecmascript
  assert.ok(propertyAliases instanceof Map, 'propertyAliases must be an instance of Map');
  assert.equal(typeof propertyAliases.get, 'function', 'propertyAliases.get must be a function');
  assert.equal(typeof propertyAliases.has, 'function', 'propertyAliases.has must be a function');

  // 2. propertyAliases.get maps property alias scx to canonical name Script_Extensions
  assert.equal(propertyAliases.get('scx'), 'Script_Extensions', 'scx should map to Script_Extensions');
  assert.equal(getCanonicalPropertyName('scx'), 'Script_Extensions', 'helper getCanonicalPropertyName(scx) should map to Script_Extensions');

  // 3. propertyAliases.get maps property alias gc to canonical name General_Category
  assert.equal(propertyAliases.get('sc'), 'Script', 'sc should map to Script');
  assert.equal(propertyAliases.get('gc'), 'General_Category', 'gc should map to General_Category');
  assert.equal(getCanonicalPropertyName('gc'), 'General_Category', 'helper getCanonicalPropertyName(gc) should map to General_Category');

  // 4. propertyAliases.get maps property aliases WSpace and space to canonical name White_Space
  assert.equal(propertyAliases.get('WSpace'), 'White_Space', 'WSpace should map to White_Space');
  assert.equal(propertyAliases.get('space'), 'White_Space', 'space should map to White_Space');
  assert.equal(propertyAliases.get('Alpha'), 'Alphabetic', 'Alpha should map to Alphabetic');
  assert.equal(propertyAliases.get('ExtPict'), 'Extended_Pictographic', 'ExtPict should map to Extended_Pictographic');

  // 5. propertyAliases.get returns undefined for unmapped or non-existent property aliases
  assert.equal(propertyAliases.get('unknown_alias'), undefined, 'unknown alias should return undefined');
  assert.equal(propertyAliases.get(''), undefined, 'empty string should return undefined');
  assert.equal(getCanonicalPropertyName('invalid'), undefined, 'helper with invalid alias should return undefined');

  // 6. propertyAliases.has accurately reports existence of property aliases
  assert.equal(propertyAliases.has('scx'), true, 'scx must exist in propertyAliases');
  assert.equal(propertyAliases.has('gc'), true, 'gc must exist in propertyAliases');
  assert.equal(propertyAliases.has('unknown_alias'), false, 'unknown_alias must not exist in propertyAliases');
  assert.equal(hasPropertyAlias('WSpace'), true, 'helper hasPropertyAlias(WSpace) must be true');
  assert.equal(hasPropertyAlias('nonexistent'), false, 'helper hasPropertyAlias(nonexistent) must be false');

  // 7. propertyAliases contains exactly 54 property alias entries
  assert.equal(propertyAliases.size, 54, 'propertyAliases size must be 54');
  assert.equal(getSupportedAliasCount(), 54, 'helper getSupportedAliasCount must return 54');

  console.log('All contract assertions for unicode-property-aliases-ecmascript passed successfully.');
}

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

オリジンシーダー

匿名