Beispiel
fflate 0.8.3: strToU8
Verifiziertes Beispiel für npm fflate 0.8.3: strToU8. Der Vertrag lief auf node 22 · linux debian/x64 · docker und bestand: assert strToU8 encodes ASCII…
sha256:bb57bdc5bfc0e721970e1e9a15f877349687e81b498f78acb1a35e808b762122
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 debian/x64 · docker ed25519:c1973797be207ac4 | PASS | compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS CONTAINER_RUN · node-typescript@1node:22@sha256:8a34c4ab3ea2… |
2026-09-19 |
Fall
HOW- Ziel
- verify fflate.strToU8 in pkg:npm/fflate@0.8.3
- Pakete
- Symbole
-
- fflate.strToU8
- Umgebung
- node 22.23.2
- Erstellt
- 2026-09-17T20:57:47Z
Contract
- assert strToU8 encodes ASCII string to Uint8Array matching UTF-8 byte representation
- assert strToU8 correctly encodes multibyte UTF-8 characters into byte sequences
- assert strToU8 handles empty string returning an empty Uint8Array
- assert strToU8 supports latin1 mode converting characters directly to single-byte values
- assert strToU8 encoded bytes can be decoded back to the original string with strFromU8
Dateien
- PROMPT.md
- csx.json
- index.mjs
- 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 fflate.strToU8 in pkg:npm/fflate@0.8.3
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:npm/fflate@0.8.3
Demonstrate these symbols/APIs:
- fflate.strToU8
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:be5805326bdb69f59a110599b62e6eb71f12e4b49dfb6ad35841303b5aa3f7a4","constraints":{"executionContext":"node"},"contract":["assert strToU8 encodes ASCII string to Uint8Array matching UTF-8 byte representation","assert strToU8 correctly encodes multibyte UTF-8 characters into byte sequences","assert strToU8 handles empty string returning an empty Uint8Array","assert strToU8 supports latin1 mode converting characters directly to single-byte values","assert strToU8 encoded bytes can be decoded back to the original string with strFromU8"],"goal":"verify fflate.strToU8 in pkg:npm/fflate@0.8.3","kind":"HOW","packages":["pkg:npm/fflate@0.8.3"],"schemaVersion":1,"symbols":["fflate.strToU8"]},"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/fflate@0.8.3"],"schemaVersion":1,"subject":"pkg:npm/fflate@0.8.3","symbols":["fflate.strToU8"],"verifierAdapter":"node-typescript@1"}
import { strToU8, strFromU8 } from 'fflate';
/**
* Converts a string into a Uint8Array.
*
* @param {string} str - The string to encode.
* @param {boolean} [latin1] - Whether to interpret as Latin-1.
* @returns {Uint8Array} The encoded byte array.
*/
export function encodeStringToU8(str, latin1) {
return strToU8(str, latin1);
}
/**
* Converts a Uint8Array back into a string.
*
* @param {Uint8Array} bytes - The byte array to decode.
* @param {boolean} [latin1] - Whether to interpret as Latin-1.
* @returns {string} The decoded string.
*/
export function decodeU8ToString(bytes, latin1) {
return strFromU8(bytes, latin1);
}
export { strToU8, strFromU8 };
export default strToU8;
{
"name": "sample-fflate-strtou8",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "sample-fflate-strtou8",
"version": "1.0.0",
"license": "MIT-0",
"dependencies": {
"fflate": "0.8.3"
}
},
"node_modules/fflate": {
"version": "0.8.3",
"resolved": "https://registry.npmjs.org/fflate/-/fflate-0.8.3.tgz",
"integrity": "sha512-tbZNuJrLwGUp3zshBtdy4W+ORxZuIh8a5ilyIEQDC5rY1f3U20JMry0Ll3WBzU58EZKsEuJFXhb5gwv8CsPvgA==",
"license": "MIT"
}
}
}
{
"name": "sample-fflate-strtou8",
"version": "1.0.0",
"private": true,
"type": "module",
"license": "MIT-0",
"dependencies": {
"fflate": "0.8.3"
}
}
{
"schemaVersion": 1,
"goal": "verify fflate.strToU8 in pkg:npm/fflate@0.8.3",
"kind": "HOW",
"packages": [
"pkg:npm/fflate@0.8.3"
],
"symbols": [
"fflate.strToU8"
]
}
import assert from 'node:assert/strict';
import { strToU8, strFromU8, encodeStringToU8, decodeU8ToString } from '../index.mjs';
// 1. assert strToU8 encodes ASCII string to Uint8Array matching UTF-8 byte representation
{
const text = 'Hello CodeSampleX fflate strToU8 test!';
const u8 = encodeStringToU8(text);
assert.ok(u8 instanceof Uint8Array, 'strToU8 must return a Uint8Array');
assert.strictEqual(u8.length, text.length, 'ASCII string byte length must equal string length');
assert.deepStrictEqual(u8, new TextEncoder().encode(text), 'output bytes must match standard UTF-8 encoding');
}
// 2. assert strToU8 correctly encodes multibyte UTF-8 characters into byte sequences
{
const text = 'Hello 🌍 세계 🎉';
const u8 = encodeStringToU8(text);
assert.ok(u8 instanceof Uint8Array, 'strToU8 must return a Uint8Array');
const expected = new TextEncoder().encode(text);
assert.strictEqual(u8.length, expected.length, 'multibyte UTF-8 byte length must match standard encoding');
assert.deepStrictEqual(u8, expected, 'multibyte UTF-8 bytes must match TextEncoder bytes');
}
// 3. assert strToU8 handles empty string returning an empty Uint8Array
{
const u8 = encodeStringToU8('');
assert.ok(u8 instanceof Uint8Array, 'empty string strToU8 must return a Uint8Array');
assert.strictEqual(u8.length, 0, 'empty string strToU8 must produce length 0 Uint8Array');
}
// 4. assert strToU8 supports latin1 mode converting characters directly to single-byte values
{
const latin1String = 'test\x00\xFF\x80\xAB';
const u8 = encodeStringToU8(latin1String, true);
assert.ok(u8 instanceof Uint8Array, 'latin1 strToU8 must return a Uint8Array');
assert.strictEqual(u8.length, latin1String.length, 'latin1 mode must map each character to exactly 1 byte');
for (let i = 0; i < latin1String.length; i++) {
assert.strictEqual(u8[i], latin1String.charCodeAt(i), `byte at ${i} must match character code`);
}
}
// 5. assert strToU8 encoded bytes can be decoded back to the original string with strFromU8
{
const original = 'Roundtrip conversion test: 12345!@#$%^&*()_+ [UTF-8: 한국어, 日本語, Deutsch, Español]';
const encoded = encodeStringToU8(original);
const decoded = decodeU8ToString(encoded);
assert.strictEqual(decoded, original, 'strFromU8(strToU8(s)) must roundtrip to the original string exactly');
}
console.log('All contract assertions passed.');
Ursprungs-Seeder
anonym