샘플
utf8-byte-length 1.0.5
검증된 샘플 — npm utf8-byte-length 1.0.5. node 22 · linux alpine/x64 · docker에서 contract를 실행해 통과했습니다: utf8ByteLength returns 0 bytes for an empty string
sha256:ddd82985346606f111b4e743db8ac139292693152fdebe6746ac171376cf1cbc
이 네트워크가 제공하는 것은 하나입니다. 빌드되는 샘플. 샌드박스에서 돌리고 서명된 영수증을 보관합니다. 등급을 매기지 않고 무엇도 보증하지 않습니다 — 같은 코드가 당신 환경에서 빌드되는지는 측정한 적이 없습니다.
통과한 계약 영수증을 낸 서로 다른 서명 키의 수입니다. 하나면 작성자 혼자이고, 둘 이상이면 다른 사람도 빌드했다는 뜻입니다. 키는 스스로 만드는 것이고 뒤에 등록된 신원이 없으므로, 세는 것은 사람이 아니라 키입니다.
MIT-0
실행 증거
선언된 환경과 서명된 실행을 분리해 두었습니다. 이 샘플이 무엇을 어디서 실행했는지 그대로 볼 수 있습니다.
- 증거 기준
- 서명된 컨트랙트 통과
- 검증 영수증
- 2
- 빌드한 서명 키
- 1
선언된 환경
node 22.23 linux 24 · ubuntu · glibc 2.39 x64 node 22.23 javascript npm 10
검증 실행 환경
| 환경 | 컨트랙트 | 단계 | 실행일 |
|---|---|---|---|
| node 22 · linux alpine/x64 · docker ed25519:c1973797be207ac4 | PASS | compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS CONTAINER_RUN · node-typescript@1 |
2026-08-21 |
| 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-07 |
케이스
HOW- 목표
- verify pkg:npm/utf8-byte-length@1.0.5
- 환경
- node 22.23.2
- 생성일
- 2026-08-21T05:22:35Z
컨트랙트
- utf8ByteLength returns 0 bytes for an empty string
- utf8ByteLength calculates 1 byte per ASCII character
- utf8ByteLength calculates 2 bytes per 2-byte UTF-8 character
- utf8ByteLength calculates 3 bytes per 3-byte UTF-8 character
- utf8ByteLength calculates 4 bytes per 4-byte UTF-8 character such as emojis
- utf8ByteLength calculates the exact total byte length for mixed multi-byte strings
- utf8ByteLength throws an Error when passed non-string inputs
파일
- PROMPT.md
- csx.json
- index.js
- package-lock.json
- package.json
- spec.json
- 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/utf8-byte-length@1.0.5
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:npm/utf8-byte-length@1.0.5
Constraints:
- executionContext: node
Required runtime conditions:
- ecosystem: npm
- language: javascript
- moduleSystem: cjs
- packageManager: npm@10.9.8
- runtime: node@22.23.2
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:ca5410aa997c02bb32ae7fa6bddb355d94443017d1362653f0ddb506cb7832e6","constraints":{"executionContext":"node"},"contract":["utf8ByteLength returns 0 bytes for an empty string","utf8ByteLength calculates 1 byte per ASCII character","utf8ByteLength calculates 2 bytes per 2-byte UTF-8 character","utf8ByteLength calculates 3 bytes per 3-byte UTF-8 character","utf8ByteLength calculates 4 bytes per 4-byte UTF-8 character such as emojis","utf8ByteLength calculates the exact total byte length for mixed multi-byte strings","utf8ByteLength throws an Error when passed non-string inputs"],"goal":"verify pkg:npm/utf8-byte-length@1.0.5","kind":"HOW","packages":["pkg:npm/utf8-byte-length@1.0.5"],"schemaVersion":1},"contractCommand":["node","test/contract.mjs"],"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/utf8-byte-length@1.0.5"],"schemaVersion":1,"subject":"pkg:npm/utf8-byte-length@1.0.5","verifierAdapter":"node-typescript@1"}
'use strict';
const utf8ByteLength = require('utf8-byte-length');
function calculatePayloadSize(text) {
return utf8ByteLength(text);
}
module.exports = {
calculatePayloadSize,
};
{
"name": "sample",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "sample",
"version": "1.0.0",
"dependencies": {
"utf8-byte-length": "1.0.5"
}
},
"node_modules/utf8-byte-length": {
"version": "1.0.5",
"resolved": "https://registry.npmjs.org/utf8-byte-length/-/utf8-byte-length-1.0.5.tgz",
"integrity": "sha512-Xn0w3MtiQ6zoz2vFyUVruaCL53O/DwUvkEeOvj+uulMm0BkUGYWmBYVyElqZaSLhY6ZD0ulfU3aBra2aVT4xfA==",
"license": "(WTFPL OR MIT)"
}
}
}
{
"name": "sample",
"version": "1.0.0",
"private": true,
"description": "Clean-room verification of utf8-byte-length",
"main": "index.js",
"scripts": {
"test": "node test/contract.mjs"
},
"dependencies": {
"utf8-byte-length": "1.0.5"
}
}
{
"schemaVersion": 1,
"goal": "verify pkg:npm/utf8-byte-length@1.0.5",
"kind": "HOW",
"packages": [
"pkg:npm/utf8-byte-length@1.0.5"
],
"constraints": {
"executionContext": "node"
},
"runtimeConditions": {
"ecosystem": "npm",
"language": "javascript",
"moduleSystem": "cjs",
"packageManager": "npm@10.9.8",
"runtime": "node@22.23.2"
}
}
import assert from 'node:assert/strict';
import utf8ByteLength from 'utf8-byte-length';
import { calculatePayloadSize } from '../index.js';
// 1. utf8ByteLength returns 0 bytes for an empty string
assert.equal(utf8ByteLength(''), 0);
assert.equal(calculatePayloadSize(''), 0);
// 2. utf8ByteLength calculates 1 byte per ASCII character
assert.equal(utf8ByteLength('a'), 1);
assert.equal(utf8ByteLength('hello world'), 11);
assert.equal(calculatePayloadSize('12345'), 5);
// 3. utf8ByteLength calculates 2 bytes per 2-byte UTF-8 character
assert.equal(utf8ByteLength('é'), 2);
assert.equal(utf8ByteLength('ñ'), 2);
assert.equal(utf8ByteLength('α'), 2);
assert.equal(utf8ByteLength('д'), 2);
// 4. utf8ByteLength calculates 3 bytes per 3-byte UTF-8 character
assert.equal(utf8ByteLength('한'), 3);
assert.equal(utf8ByteLength('글'), 3);
assert.equal(utf8ByteLength('日'), 3);
assert.equal(utf8ByteLength('本'), 3);
assert.equal(utf8ByteLength('語'), 3);
assert.equal(utf8ByteLength('€'), 3);
// 5. utf8ByteLength calculates 4 bytes per 4-byte UTF-8 character such as emojis
assert.equal(utf8ByteLength('🚀'), 4);
assert.equal(utf8ByteLength('🎉'), 4);
assert.equal(utf8ByteLength('👍'), 4);
// 6. utf8ByteLength calculates the exact total byte length for mixed multi-byte strings
assert.equal(utf8ByteLength('Hello, 世界! 🚀'), 19);
assert.equal(calculatePayloadSize('Hello, 世界! 🚀'), 19);
// 7. utf8ByteLength throws an Error when passed non-string inputs
assert.throws(() => utf8ByteLength(null), {
name: 'Error',
message: 'Input must be string',
});
assert.throws(() => utf8ByteLength(undefined), {
name: 'Error',
message: 'Input must be string',
});
assert.throws(() => utf8ByteLength(12345), {
name: 'Error',
message: 'Input must be string',
});
assert.throws(() => utf8ByteLength({}), {
name: 'Error',
message: 'Input must be string',
});
assert.throws(() => utf8ByteLength(true), {
name: 'Error',
message: 'Input must be string',
});
console.log('All contract assertions passed.');
오리진 시더
익명