CodeSampleX

示例

ip-address 10.4.0: v6.helpers

已验证示例 — npm ip-address 10.4.0: v6.helpers. contract 在 node 22 · linux debian/x64 · docker 上运行并通过: helpers is accessible via v6.helpers export on the…

sha256:e8d86b60d6eec6376abd20b4acef04a1bae79eb946bccd7642d9288dd762527d

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

执行证据

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

证据依据
签名契约通过
验证回执
1
构建过它的签名密钥
1
声明的环境 node 22.23 linux 24 · ubuntu · glibc 2.39 x64 node 22.23 javascript npm 10

验证运行环境

环境 契约 阶段 运行日期
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-01

案例

HOW
目标
verify ip-address.v6.helpers in pkg:npm/ip-address@10.4.0
包
符号
  • ip-address.v6.helpers
环境
node 22.23.2
创建时间
2026-09-01T22:48:10Z

契约

  1. helpers is accessible via v6.helpers export on the ip-address package
  2. helpers.escapeHtml escapes special characters (&, <, >, ", ') to HTML entities
  3. helpers.spanAllZeroes wraps all occurrences of one or more consecutive zeroes in span elements with class zero and escapes HTML
  4. helpers.spanAll wraps each character in a digit span with its value, position class including optional offset, and inner zero spans
  5. helpers.spanLeadingZeroes wraps leading zeroes of each colon-separated group in a span element with class zero
  6. helpers.simpleGroup splits an address by colons and wraps each non-v4 group in a hover-group span with indexed group class and offset

文件

  • PROMPT.md
  • csx.json
  • package-lock.json
  • package.json
  • spec.json
  • test/contract.cjs

下载源代码构件 (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 ip-address.v6.helpers in pkg:npm/ip-address@10.4.0
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:npm/ip-address@10.4.0
Demonstrate these symbols/APIs:
  - ip-address.v6.helpers

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:4419d9d3236b9880f84deb07f27fcc1ca048c0dabf2af6852d86aa2080987980","contract":["helpers is accessible via v6.helpers export on the ip-address package","helpers.escapeHtml escapes special characters (\u0026, \u003c, \u003e, \", ') to HTML entities","helpers.spanAllZeroes wraps all occurrences of one or more consecutive zeroes in span elements with class zero and escapes HTML","helpers.spanAll wraps each character in a digit span with its value, position class including optional offset, and inner zero spans","helpers.spanLeadingZeroes wraps leading zeroes of each colon-separated group in a span element with class zero","helpers.simpleGroup splits an address by colons and wraps each non-v4 group in a hover-group span with indexed group class and offset"],"goal":"verify ip-address.v6.helpers in pkg:npm/ip-address@10.4.0","kind":"HOW","packages":["pkg:npm/ip-address@10.4.0"],"schemaVersion":1,"symbols":["ip-address.v6.helpers"]},"contractCommand":["node","test/contract.cjs"],"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/ip-address@10.4.0"],"schemaVersion":1,"subject":"pkg:npm/ip-address@10.4.0","symbols":["ip-address.v6.helpers"],"verifierAdapter":"node-typescript@1"}
package-lock.json
{
  "name": "ip-address-sample",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "ip-address-sample",
      "version": "1.0.0",
      "dependencies": {
        "ip-address": "10.4.0"
      }
    },
    "node_modules/ip-address": {
      "version": "10.4.0",
      "resolved": "https://registry.npmjs.org/ip-address/-/ip-address-10.4.0.tgz",
      "integrity": "sha512-oSK96Grm3aP6OrS263xVxbNDGVL7rzBtYdpGqlDG8iQdoenDoTs/nkki+DflYbAEE8Xl6o5YxhxlrKvI3nqKXQ==",
      "license": "MIT",
      "engines": {
        "node": ">= 12"
      }
    }
  }
}
package.json
{
  "name": "ip-address-sample",
  "version": "1.0.0",
  "private": true,
  "description": "Verification sample for ip-address 10.4.0",
  "dependencies": {
    "ip-address": "10.4.0"
  }
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify ip-address.v6.helpers in pkg:npm/ip-address@10.4.0",
  "kind": "HOW",
  "packages": [
    "pkg:npm/ip-address@10.4.0"
  ],
  "symbols": [
    "ip-address.v6.helpers"
  ]
}
test/contract.cjs
const assert = require("node:assert/strict");
const { v6 } = require("ip-address");

const { helpers } = v6;

// 1. helpers is accessible via v6.helpers export on the ip-address package
assert.equal(typeof helpers, "object");
assert.equal(typeof helpers.escapeHtml, "function");
assert.equal(typeof helpers.spanAllZeroes, "function");
assert.equal(typeof helpers.spanAll, "function");
assert.equal(typeof helpers.spanLeadingZeroes, "function");
assert.equal(typeof helpers.simpleGroup, "function");

// 2. helpers.escapeHtml escapes special characters (&, <, >, ", ') to HTML entities
assert.equal(helpers.escapeHtml("plain-text"), "plain-text");
assert.equal(helpers.escapeHtml('<div class="box" data-id=\'1\'>&</div>'), "&lt;div class=&quot;box&quot; data-id=&#39;1&#39;&gt;&amp;&lt;/div&gt;");
assert.equal(helpers.escapeHtml("a & b < c > d \"e\" 'f'"), "a &amp; b &lt; c &gt; d &quot;e&quot; &#39;f&#39;");

// 3. helpers.spanAllZeroes wraps all occurrences of one or more consecutive zeroes in span elements with class zero and escapes HTML
assert.equal(helpers.spanAllZeroes("2001:00ab:0:1200"), "2<span class=\"zero\">00</span>1:<span class=\"zero\">00</span>ab:<span class=\"zero\">0</span>:12<span class=\"zero\">00</span>");
assert.equal(helpers.spanAllZeroes("ffff:1234"), "ffff:1234");
assert.equal(helpers.spanAllZeroes("<0>"), "&lt;<span class=\"zero\">0</span>&gt;");
assert.equal(helpers.spanAllZeroes("0000"), "<span class=\"zero\">0000</span>");

// 4. helpers.spanAll wraps each character in a digit span with its value, position class including optional offset, and inner zero spans
assert.equal(
  helpers.spanAll("2001", 0),
  '<span class="digit value-2 position-0">2</span>' +
  '<span class="digit value-0 position-1"><span class="zero">0</span></span>' +
  '<span class="digit value-0 position-2"><span class="zero">0</span></span>' +
  '<span class="digit value-1 position-3">1</span>'
);
assert.equal(
  helpers.spanAll("0a", 4),
  '<span class="digit value-0 position-4"><span class="zero">0</span></span>' +
  '<span class="digit value-a position-5">a</span>'
);
assert.equal(helpers.spanAll(""), "");

// 5. helpers.spanLeadingZeroes wraps leading zeroes of each colon-separated group in a span element with class zero
assert.equal(
  helpers.spanLeadingZeroes("2001:00ab:0000:0100:0:1"),
  '2001:<span class="zero">00</span>ab:<span class="zero">0000</span>:<span class="zero">0</span>100:<span class="zero">0</span>:1'
);
assert.equal(helpers.spanLeadingZeroes("0042"), '<span class="zero">00</span>42');
assert.equal(helpers.spanLeadingZeroes("abcd:1234"), "abcd:1234");

// 6. helpers.simpleGroup splits an address by colons and wraps each non-v4 group in a hover-group span with indexed group class and offset
assert.deepEqual(
  helpers.simpleGroup("2001:00ab:0000:0100", 0),
  [
    '<span class="hover-group group-0">2001</span>',
    '<span class="hover-group group-1"><span class="zero">00</span>ab</span>',
    '<span class="hover-group group-2"><span class="zero">0000</span></span>',
    '<span class="hover-group group-3"><span class="zero">0</span>100</span>'
  ]
);
assert.deepEqual(
  helpers.simpleGroup("fe80:0", 4),
  [
    '<span class="hover-group group-4">fe80</span>',
    '<span class="hover-group group-5"><span class="zero">0</span></span>'
  ]
);
assert.deepEqual(
  helpers.simpleGroup("fe80:group-v4-part", 0),
  [
    '<span class="hover-group group-0">fe80</span>',
    'group-v4-part'
  ]
);

console.log("Contract verified successfully.");

原始种子者

匿名