サンプル
iconv-lite 0.4.24: getDecoder
検証済みサンプル — npm iconv-lite 0.4.24: getDecoder. node 22 · linux alpine/x64 · docker で contract を実行し、成功しました: assert iconv.getDecoder returns stateful decoder…
sha256:fe511f784ced4ab597500ffd165b6ed93e83bba4d6c659e7dae04a3400b77fd2
このネットワークが提供するのは一つだけです。ビルドされるサンプル。サンドボックスで実行し、署名済みの受領証を保管します。等級はつけず、何も保証しません — 同じコードがあなたの環境でビルドされるかは測定していません。
合格した契約受領証を提出した異なる署名鍵の数です。1 なら作者だけ、2 以上なら他の誰かもビルドしています。鍵は自己生成で背後に登録された身元がないため、数えているのは人ではなく鍵です。
MIT-0
実行証拠
宣言された環境と署名済みの実行を分けてあります。このサンプルが何をどこで実行したかをそのまま確認できます。
- 証拠の基準
- 署名済みコントラクト合格
- 検証レシート
- 1
- ビルドした署名鍵
- 1
宣言された環境
node 22.23 linux 24 · ubuntu · glibc 2.39 x64 node 22.23 javascript npm
検証実行環境
| 環境 | コントラクト | ステージ | 実行日 |
|---|---|---|---|
| node 22 · linux alpine/x64 · docker ed25519:c1973797be207ac4 | PASS | compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS CONTAINER_RUN · node-typescript@1 |
2026-08-20 |
ケース
HOW- ゴール
- verify iconv-lite.getDecoder in pkg:npm/iconv-lite@0.4.24
- パッケージ
- シンボル
-
- iconv-lite.getDecoder
- 環境
- node 22.23.2
- 作成日
- 2026-08-20T19:15:26Z
コントラクト
- assert iconv.getDecoder returns stateful decoder for chunked utf-8 streams across byte boundaries
- assert iconv.getDecoder decodes multibyte cjk streams in euc-kr and shift_jis across chunk splits
- assert iconv.getDecoder decodes single-byte windows-1251 and windows-1252 byte sequences
- assert iconv.getDecoder respects stripBOM option for byte order mark handling
- assert iconv.getDecoder flushes incomplete trailing multibyte sequences upon calling end
ファイル
- PROMPT.md
- csx.json
- index.js
- package-lock.json
- package.json
- spec.json
- test/contract.js
ソース
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 iconv-lite.getDecoder in pkg:npm/iconv-lite@0.4.24
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:npm/iconv-lite@0.4.24
Demonstrate these symbols/APIs:
- iconv-lite.getDecoder
Constraints:
- executionContext: node
Required runtime conditions:
- ecosystem: npm
- language: javascript
- moduleSystem: cjs
- 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:a7da66d2f92da4739ddbbc944abb2b35f2b69a1891ca0ad1d6d33db3dea4af87","constraints":{"executionContext":"node"},"contract":["assert iconv.getDecoder returns stateful decoder for chunked utf-8 streams across byte boundaries","assert iconv.getDecoder decodes multibyte cjk streams in euc-kr and shift_jis across chunk splits","assert iconv.getDecoder decodes single-byte windows-1251 and windows-1252 byte sequences","assert iconv.getDecoder respects stripBOM option for byte order mark handling","assert iconv.getDecoder flushes incomplete trailing multibyte sequences upon calling end"],"goal":"verify iconv-lite.getDecoder in pkg:npm/iconv-lite@0.4.24","kind":"HOW","packages":["pkg:npm/iconv-lite@0.4.24"],"schemaVersion":1,"symbols":["iconv-lite.getDecoder"]},"contractCommand":["node","test/contract.js"],"environment":{"arch":"x64","distro":"ubuntu","ecosystem":"npm","executionContext":"node","language":"javascript","libc":"glibc","libcVersion":"2.39","moduleSystem":"cjs","os":"linux","osVersionBucket":"24","packageManager":"npm","runtime":"node","runtimeVersion":"22.23.2","schemaVersion":1},"license":"MIT-0","packages":["pkg:npm/iconv-lite@0.4.24"],"schemaVersion":1,"subject":"pkg:npm/iconv-lite@0.4.24","symbols":["iconv-lite.getDecoder"],"verifierAdapter":"node-typescript@1"}
const iconv = require('iconv-lite');
function createDecoder(encoding, options) {
return iconv.getDecoder(encoding, options);
}
function decodeChunks(encoding, chunks, options) {
const decoder = iconv.getDecoder(encoding, options);
let result = '';
for (const chunk of chunks) {
const text = decoder.write(chunk);
if (text) {
result += text;
}
}
const trailing = decoder.end();
if (trailing) {
result += trailing;
}
return result;
}
module.exports = {
createDecoder,
decodeChunks,
};
{
"name": "sample-iconv-lite-get-decoder",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "sample-iconv-lite-get-decoder",
"version": "1.0.0",
"license": "MIT-0",
"dependencies": {
"iconv-lite": "0.4.24"
}
},
"node_modules/iconv-lite": {
"version": "0.4.24",
"resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz",
"integrity": "sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==",
"license": "MIT",
"dependencies": {
"safer-buffer": ">= 2.1.2 < 3"
},
"engines": {
"node": ">=0.10.0"
}
},
"node_modules/safer-buffer": {
"version": "2.1.2",
"resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz",
"integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==",
"license": "MIT"
}
}
}
{
"name": "sample-iconv-lite-get-decoder",
"version": "1.0.0",
"description": "Demonstrate iconv-lite.getDecoder streaming decoder usage",
"main": "index.js",
"scripts": {
"test": "node test/contract.js"
},
"license": "MIT-0",
"dependencies": {
"iconv-lite": "0.4.24"
}
}
{
"schemaVersion": 1,
"goal": "verify iconv-lite.getDecoder in pkg:npm/iconv-lite@0.4.24",
"kind": "HOW",
"packages": [
"pkg:npm/iconv-lite@0.4.24"
],
"symbols": [
"iconv-lite.getDecoder"
],
"constraints": {
"executionContext": "node"
},
"runtimeConditions": {
"ecosystem": "npm",
"language": "javascript",
"moduleSystem": "cjs",
"runtime": "node@22.23.2"
}
}
const assert = require('assert');
const { createDecoder, decodeChunks } = require('../index');
function runTests() {
// 1. Stateful UTF-8 chunk decoding across byte boundaries
const decUtf8 = createDecoder('utf-8');
const chunk1 = decUtf8.write(Buffer.from([0xed, 0x95]));
assert.strictEqual(chunk1, '', 'Incomplete byte sequence should yield empty string');
const chunk2 = decUtf8.write(Buffer.from([0x9c, 0x67, 0x6c]));
assert.strictEqual(chunk2, '한gl', 'Completed byte sequence should yield correct string');
const endUtf8 = decUtf8.end();
assert.strictEqual(endUtf8, '', 'Flushing clean stream should yield empty string');
// 2. Multibyte CJK decoding: EUC-KR and Shift_JIS
const eucChunks = [
Buffer.from([0xc7]),
Buffer.from([0xd1, 0xb1]),
Buffer.from([0xdb])
];
const eucResult = decodeChunks('euc-kr', eucChunks);
assert.strictEqual(eucResult, '한글', 'EUC-KR multibyte chunk stream should decode correctly');
const sjisChunks = [
Buffer.from([0x93]),
Buffer.from([0xfa, 0x96]),
Buffer.from([0x7b, 0x8c, 0xea])
];
const sjisResult = decodeChunks('shift_jis', sjisChunks);
assert.strictEqual(sjisResult, '日本語', 'Shift_JIS multibyte chunk stream should decode correctly');
// 3. Single-byte legacy encodings: windows-1251 and windows-1252
const win1251Chunks = [
Buffer.from([0xcf, 0xf0, 0xe8]),
Buffer.from([0xe2, 0xe5, 0xf2])
];
const win1251Result = decodeChunks('windows-1251', win1251Chunks);
assert.strictEqual(win1251Result, 'Привет', 'Windows-1251 stream should decode correctly');
const win1252Chunks = [
Buffer.from([0x43, 0x61]),
Buffer.from([0x66, 0xe9])
];
const win1252Result = decodeChunks('windows-1252', win1252Chunks);
assert.strictEqual(win1252Result, 'Café', 'Windows-1252 stream should decode correctly');
// 4. Byte Order Mark (BOM) handling options
const bomBuffer = Buffer.from([0xef, 0xbb, 0xbf, 0x68, 0x65, 0x6c, 0x6c, 0x6f]);
const decDefault = createDecoder('utf-8');
const defaultText = decDefault.write(bomBuffer) + (decDefault.end() || '');
assert.strictEqual(defaultText, 'hello', 'Default decoder should strip BOM');
const decKeepBom = createDecoder('utf-8', { stripBOM: false });
const keepBomText = decKeepBom.write(bomBuffer) + (decKeepBom.end() || '');
assert.strictEqual(keepBomText, '\ufeffhello', 'Decoder with stripBOM=false should retain BOM');
// 5. Incomplete multibyte sequence at EOF flushed by end()
const decTrailing = createDecoder('utf-8');
const leadChunk = decTrailing.write(Buffer.from([0xed, 0x95]));
assert.strictEqual(leadChunk, '');
const flushed = decTrailing.end();
assert.strictEqual(flushed, '\ufffd', 'Trailing incomplete bytes should yield replacement character on end');
console.log('Contract tests passed successfully.');
}
runTests();
オリジンシーダー
匿名