Beispiel
utf8-byte-length 1.0.5: utf8ByteLength
Verifiziertes Beispiel für npm utf8-byte-length 1.0.5: utf8ByteLength. Der Vertrag lief auf node 22 · linux alpine/x64 · docker und bestand.
sha256:0188fabe9ee4db4df167a36463d50b25d0d954440911531c68dd8d2ddcf5ee0b
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
- 2
- 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-26 |
| 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 |
Fall
HOW- Ziel
- verify utf8ByteLength in pkg:npm/utf8-byte-length@1.0.5
- Pakete
- Symbole
-
- utf8ByteLength
- Umgebung
- node 22.23.2
- Erstellt
- 2026-08-26T11:22:35Z
Contract
- assert empty string returns zero byte length
- assert ASCII strings return byte length equal to character count
- assert two-byte UTF-8 characters calculate to two bytes per character
- assert three-byte UTF-8 characters such as CJK and currency symbols calculate to three bytes per character
- assert four-byte UTF-8 characters such as emojis calculate to four bytes per character
- assert mixed strings containing ASCII and multi-byte unicode characters return correct total byte length
- assert direct utf8ByteLength symbol invocation returns identical byte length
- assert non-string inputs throw an Error indicating input must be string
Dateien
- PROMPT.md
- csx.json
- index.js
- package-lock.json
- package.json
- spec.json
- test/contract.mjs
Quelltext
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 utf8ByteLength in 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
Demonstrate these symbols/APIs:
- utf8ByteLength
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:73593877e43fb56e32ada3db4ab9ca2dde0035863a55ff66f8619c82e55e294b","contract":["assert empty string returns zero byte length","assert ASCII strings return byte length equal to character count","assert two-byte UTF-8 characters calculate to two bytes per character","assert three-byte UTF-8 characters such as CJK and currency symbols calculate to three bytes per character","assert four-byte UTF-8 characters such as emojis calculate to four bytes per character","assert mixed strings containing ASCII and multi-byte unicode characters return correct total byte length","assert direct utf8ByteLength symbol invocation returns identical byte length","assert non-string inputs throw an Error indicating input must be string"],"goal":"verify utf8ByteLength in pkg:npm/utf8-byte-length@1.0.5","kind":"HOW","packages":["pkg:npm/utf8-byte-length@1.0.5"],"schemaVersion":1,"symbols":["utf8ByteLength"]},"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","symbols":["utf8ByteLength"],"verifierAdapter":"node-typescript@1"}
const utf8ByteLength = require('utf8-byte-length');
function calculateUtf8ByteLength(input) {
return utf8ByteLength(input);
}
module.exports = {
utf8ByteLength,
calculateUtf8ByteLength,
};
{
"name": "sample-utf8-byte-length",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "sample-utf8-byte-length",
"version": "1.0.0",
"license": "MIT-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-utf8-byte-length",
"version": "1.0.0",
"description": "Minimal clean-room sample verifying utf8ByteLength in utf8-byte-length",
"main": "index.js",
"license": "MIT-0",
"dependencies": {
"utf8-byte-length": "1.0.5"
}
}
{
"schemaVersion": 1,
"goal": "verify utf8ByteLength in pkg:npm/utf8-byte-length@1.0.5",
"kind": "HOW",
"packages": [
"pkg:npm/utf8-byte-length@1.0.5"
],
"symbols": [
"utf8ByteLength"
]
}
import assert from 'node:assert';
import utf8ByteLength from 'utf8-byte-length';
import { calculateUtf8ByteLength } from '../index.js';
// 1. Empty string returns 0 bytes
const emptyLen = calculateUtf8ByteLength('');
assert.strictEqual(emptyLen, 0, 'Empty string must return 0 bytes');
// 2. ASCII strings return byte length equal to character count
const asciiStr = 'Hello, World!';
const asciiLen = calculateUtf8ByteLength(asciiStr);
assert.strictEqual(asciiLen, asciiStr.length, 'ASCII string byte length must match character count');
assert.strictEqual(asciiLen, 13, 'ASCII string "Hello, World!" must be 13 bytes');
// 3. Two-byte UTF-8 characters calculate to 2 bytes per character
const twoByteStr = 'café';
const twoByteLen = calculateUtf8ByteLength(twoByteStr);
assert.strictEqual(twoByteLen, 5, 'String "café" must have byte length of 5');
const latinGreekStr = 'αβγ';
assert.strictEqual(calculateUtf8ByteLength(latinGreekStr), 6, 'Three 2-byte Greek characters must be 6 bytes');
// 4. Three-byte UTF-8 characters such as CJK characters and currency symbols calculate to 3 bytes per character
const euroSymbol = '€';
assert.strictEqual(calculateUtf8ByteLength(euroSymbol), 3, 'Euro symbol "€" must be 3 bytes');
const cjkStr = '한국어';
assert.strictEqual(calculateUtf8ByteLength(cjkStr), 9, 'Three CJK characters must be 9 bytes');
// 5. Four-byte UTF-8 characters such as emojis calculate to 4 bytes per character
const emojiStr = '🚀';
assert.strictEqual(calculateUtf8ByteLength(emojiStr), 4, 'Rocket emoji "🚀" must be 4 bytes');
const multipleEmojis = '👍🎉🌟';
assert.strictEqual(calculateUtf8ByteLength(multipleEmojis), 12, 'Three 4-byte emojis must be 12 bytes');
// 6. Mixed strings containing ASCII and multi-byte unicode characters return correct total byte length
const mixedStr = 'CodeSampleX 🚀 한국어 café €100';
const expectedMixedLength = Buffer.byteLength(mixedStr, 'utf8');
assert.strictEqual(
calculateUtf8ByteLength(mixedStr),
expectedMixedLength,
'Mixed unicode string byte length must match Buffer.byteLength'
);
// 7. Direct symbol invocation produces identical results
assert.strictEqual(
utf8ByteLength('Hello 🌍'),
Buffer.byteLength('Hello 🌍', 'utf8'),
'Direct utf8ByteLength invocation must return correct byte length'
);
// 8. Non-string inputs throw an Error indicating input must be string
const invalidInputs = [123, true, false, null, undefined, {}, [], Symbol('test')];
for (const invalid of invalidInputs) {
assert.throws(
() => calculateUtf8ByteLength(invalid),
{
name: 'Error',
message: 'Input must be string',
},
`Expected error for invalid input: ${String(invalid)}`
);
}
console.log('All utf8-byte-length contract assertions passed.');
Ursprungs-Seeder
anonym