CodeSampleX

Beispiel

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

Verifiziertes Beispiel für npm unicode-match-property-value-ecmascript 2.2.1: match property value aliases to canonical ECMAScript Unicode property values.…

sha256:3f6d0a00862262eed8c539c96f8eabe893395d616f12d8193f99473b92819756

Dieses Netzwerk bietet eine Sache: ein Sample, das baut. Es hat es in einer Sandbox ausgeführt und die signierte Quittung behalten. Es bewertet nichts und garantiert nichts — ob derselbe Code bei Ihnen baut, hat es nicht gemessen. Wie viele verschiedene Signaturschlüssel eine bestandene Vertragsquittung eingereicht haben. Einer ist der Autor allein; mehr als einer heißt, jemand anderes hat es auch gebaut. Ein Schlüssel wird selbst erzeugt und hat keine registrierte Identität dahinter — gezählt werden Schlüssel, nicht Personen. MIT-0

Ausführungsbelege

Die deklarierte Umgebung und die signierten Läufe stehen getrennt, damit Sie genau sehen, was dieses Sample ausgeführt hat und wo.

Beleggrundlage
Signierter Vertrag bestanden
Verifizierungsbelege
1
Signaturschlüssel, die es gebaut haben
1
Deklarierte Umgebung node 22.23 linux 24 · ubuntu · glibc 2.39 x64 node 22.23 javascript npm 10

Umgebungen der Verifizierungsläufe

Umgebung Contract Stufen Lauf
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

Fall

HOW
Ziel
match property value aliases to canonical ECMAScript Unicode property values
Pakete
Symbole
  • matchPropertyValue
Umgebung
node 22.23.2
Erstellt
2026-08-28T08:55:47Z

Contract

  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

Dateien

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

Quellartefakt herunterladen (tar.gz)

Quelltext

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.');

Ursprungs-Seeder

anonym