示例
is-fullwidth-code-point 3.0.0
已验证示例 — npm is-fullwidth-code-point 3.0.0. contract 在 node 22 · linux alpine/x64 · docker 上运行并通过: isFullwidthCodePoint returns true for CJK unified…
sha256:aa6fdf87bad9070deaf4e9e1f1ca023eb2bbee9ffff73b305fe5900cba19f6fd
本网络只提供一件事:能构建的样本。它在沙箱中运行并保留签名回执。它不评级、不担保——同样的代码能否在你的环境构建,它没有测量过。
提交了通过的契约回执的不同签名密钥数量。为 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-23 |
案例
HOW- 目标
- verify pkg:npm/is-fullwidth-code-point@3.0.0
- 创建时间
- 2026-08-23T07:53:13Z
契约
- isFullwidthCodePoint returns true for CJK unified ideographs and Hangul syllables
- isFullwidthCodePoint returns true for fullwidth ASCII variants and CJK punctuation
- isFullwidthCodePoint returns true for supplementary plane ideographs
- isFullwidthCodePoint returns false for standard ASCII characters and whitespace
- isFullwidthCodePoint returns false for NaN or invalid code points
- checkCodePoint and isCharFullwidth helper functions correctly determine fullwidth status from code points and strings
- calculateStringWidth calculates display width by counting 2 columns for fullwidth characters and 1 column for standard characters
文件
- PROMPT.md
- csx.json
- package-lock.json
- package.json
- spec.json
- src/index.mjs
- test/contract.mjs
源代码
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/is-fullwidth-code-point@3.0.0
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:npm/is-fullwidth-code-point@3.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.
{"case":{"caseId":"case:sha256:f76c6f46a804808daea252b1eeaaf6bce3c430b62d2f7c58075ba5c221591039","contract":["isFullwidthCodePoint returns true for CJK unified ideographs and Hangul syllables","isFullwidthCodePoint returns true for fullwidth ASCII variants and CJK punctuation","isFullwidthCodePoint returns true for supplementary plane ideographs","isFullwidthCodePoint returns false for standard ASCII characters and whitespace","isFullwidthCodePoint returns false for NaN or invalid code points","checkCodePoint and isCharFullwidth helper functions correctly determine fullwidth status from code points and strings","calculateStringWidth calculates display width by counting 2 columns for fullwidth characters and 1 column for standard characters"],"goal":"verify pkg:npm/is-fullwidth-code-point@3.0.0","kind":"HOW","packages":["pkg:npm/is-fullwidth-code-point@3.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/is-fullwidth-code-point@3.0.0"],"schemaVersion":1,"subject":"pkg:npm/is-fullwidth-code-point@3.0.0","verifierAdapter":"node-typescript@1"}
{
"name": "sample-is-fullwidth-code-point",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "sample-is-fullwidth-code-point",
"version": "1.0.0",
"license": "MIT-0",
"dependencies": {
"is-fullwidth-code-point": "3.0.0"
}
},
"node_modules/is-fullwidth-code-point": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz",
"integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==",
"license": "MIT",
"engines": {
"node": ">=8"
}
}
}
}
{
"name": "sample-is-fullwidth-code-point",
"version": "1.0.0",
"private": true,
"description": "Clean-room verification of pkg:npm/is-fullwidth-code-point@3.0.0",
"main": "src/index.mjs",
"type": "module",
"license": "MIT-0",
"dependencies": {
"is-fullwidth-code-point": "3.0.0"
}
}
{
"schemaVersion": 1,
"goal": "verify pkg:npm/is-fullwidth-code-point@3.0.0",
"kind": "HOW",
"packages": [
"pkg:npm/is-fullwidth-code-point@3.0.0"
]
}
import isFullwidthCodePoint from "is-fullwidth-code-point";
/**
* Checks whether a given Unicode code point is fullwidth.
*
* @param {number} codePoint - The Unicode code point to test.
* @returns {boolean} True if the code point is fullwidth, false otherwise.
*/
export function checkCodePoint(codePoint) {
return isFullwidthCodePoint(codePoint);
}
/**
* Checks whether a character at the specified index in a string is fullwidth.
*
* @param {string} str - The input string.
* @param {number} [index=0] - Character index.
* @returns {boolean} True if character at index is fullwidth.
*/
export function isCharFullwidth(str, index = 0) {
const codePoint = str.codePointAt(index);
if (codePoint === undefined) {
return false;
}
return isFullwidthCodePoint(codePoint);
}
/**
* Calculates the display width of a string considering fullwidth characters (width 2) vs standard characters (width 1).
*
* @param {string} str - The string to measure.
* @returns {number} The calculated column width.
*/
export function calculateStringWidth(str) {
let width = 0;
for (const char of str) {
const cp = char.codePointAt(0);
width += isFullwidthCodePoint(cp) ? 2 : 1;
}
return width;
}
export { isFullwidthCodePoint };
export default isFullwidthCodePoint;
import assert from "node:assert/strict";
import isFullwidthCodePoint, {
checkCodePoint,
isCharFullwidth,
calculateStringWidth,
} from "../src/index.mjs";
function testCJKAndHangul() {
// Hangul Jamo (0x1100 - 0x115F)
assert.strictEqual(isFullwidthCodePoint(0x1100), true, "Hangul Jamo should be fullwidth");
assert.strictEqual(isFullwidthCodePoint(0x115f), true, "Hangul Jamo end should be fullwidth");
// Hangul Syllables (0xAC00 - 0xD7A3)
assert.strictEqual(isFullwidthCodePoint(0xac00), true, "Hangul syllable '가' should be fullwidth");
assert.strictEqual(isFullwidthCodePoint(0xd7a3), true, "Hangul syllable '힣' should be fullwidth");
// CJK Unified Ideographs (0x4E00 - 0xA4C6)
assert.strictEqual(isFullwidthCodePoint(0x4e00), true, "CJK ideograph '一' should be fullwidth");
assert.strictEqual(isFullwidthCodePoint(0x9fa5), true, "CJK ideograph should be fullwidth");
}
function testFullwidthVariantsAndSymbols() {
// Fullwidth Forms (0xFF01 - 0xFF60, 0xFFE0 - 0xFFE6)
assert.strictEqual(isFullwidthCodePoint(0xff01), true, "Fullwidth exclamation mark should be fullwidth");
assert.strictEqual(isFullwidthCodePoint(0xff21), true, "Fullwidth Latin capital A should be fullwidth");
assert.strictEqual(isFullwidthCodePoint(0xffe0), true, "Fullwidth cent sign should be fullwidth");
// Angle brackets
assert.strictEqual(isFullwidthCodePoint(0x2329), true, "Left-pointing angle bracket should be fullwidth");
assert.strictEqual(isFullwidthCodePoint(0x232a), true, "Right-pointing angle bracket should be fullwidth");
}
function testSupplementaryPlanes() {
// Supplementary Ideographic Plane (0x20000 - 0x3FFFD)
assert.strictEqual(isFullwidthCodePoint(0x20000), true, "Extension B ideograph should be fullwidth");
assert.strictEqual(isFullwidthCodePoint(0x2a6d6), true, "Supplementary ideograph should be fullwidth");
}
function testStandardAsciiAndNarrow() {
// ASCII Latin letters and numbers
assert.strictEqual(isFullwidthCodePoint(0x41), false, "ASCII 'A' is not fullwidth");
assert.strictEqual(isFullwidthCodePoint(0x61), false, "ASCII 'a' is not fullwidth");
assert.strictEqual(isFullwidthCodePoint(0x30), false, "ASCII '0' is not fullwidth");
assert.strictEqual(isFullwidthCodePoint(0x20), false, "ASCII space is not fullwidth");
// Halfwidth Katakana (0xFF61 - 0xFFDC) are not fullwidth
assert.strictEqual(isFullwidthCodePoint(0xff61), false, "Halfwidth ideographic full stop is not fullwidth");
assert.strictEqual(isFullwidthCodePoint(0xff71), false, "Halfwidth Katakana letter A is not fullwidth");
}
function testInvalidAndNaN() {
assert.strictEqual(isFullwidthCodePoint(NaN), false, "NaN should return false");
assert.strictEqual(isFullwidthCodePoint(Number.NaN), false, "Number.NaN should return false");
}
function testHelperFunctions() {
assert.strictEqual(checkCodePoint(0xac00), true);
assert.strictEqual(checkCodePoint(0x41), false);
assert.strictEqual(isCharFullwidth("가나다", 0), true);
assert.strictEqual(isCharFullwidth("abc", 0), false);
assert.strictEqual(isCharFullwidth("", 0), false);
// String width calculation: 'Hello 세계!' -> 5 (Hello) + 1 (space) + 2*2 (세계) + 1 (!) = 11
const text = "Hello 세계!";
assert.strictEqual(calculateStringWidth(text), 11, "Width of 'Hello 세계!' should be 11");
assert.strictEqual(calculateStringWidth(""), 0);
assert.strictEqual(calculateStringWidth("全角"), 4);
}
function main() {
testCJKAndHangul();
testFullwidthVariantsAndSymbols();
testSupplementaryPlanes();
testStandardAsciiAndNarrow();
testInvalidAndNaN();
testHelperFunctions();
console.log("All pkg:npm/is-fullwidth-code-point@3.0.0 contracts passed successfully.");
}
main();
原始种子者
匿名