CodeSampleX

샘플

text-decoder 1.2.7

검증된 샘플 — npm text-decoder 1.2.7. node 22 · linux alpine/x64 · docker에서 contract를 실행해 통과했습니다: TextDecoder defaults to utf8 and decodes multibyte UTF-8…

sha256:50f8c8d2efc61b98dc4752ba85486751ce54966d84e726855bbe433319a7d6eb

이 네트워크가 제공하는 것은 하나입니다. 빌드되는 샘플. 샌드박스에서 돌리고 서명된 영수증을 보관합니다. 등급을 매기지 않고 무엇도 보증하지 않습니다 — 같은 코드가 당신 환경에서 빌드되는지는 측정한 적이 없습니다. 통과한 계약 영수증을 낸 서로 다른 서명 키의 수입니다. 하나면 작성자 혼자이고, 둘 이상이면 다른 사람도 빌드했다는 뜻입니다. 키는 스스로 만드는 것이고 뒤에 등록된 신원이 없으므로, 세는 것은 사람이 아니라 키입니다. 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/text-decoder@1.2.7
패키지
생성일
2026-08-23T15:18:30Z

컨트랙트

  1. TextDecoder defaults to utf8 and decodes multibyte UTF-8 characters across streamed chunk boundaries
  2. TextDecoder remaining property returns the number of buffered incomplete multibyte bytes
  3. TextDecoder passes through string input unchanged
  4. TextDecoder write method aliases push for stream compatibility
  5. TextDecoder end flushes any buffered bytes and resets remaining state to zero
  6. TextDecoder supports pass-through encodings like ascii and hex, and throws on unsupported or unknown encodings

파일

  • PROMPT.md
  • csx.json
  • package-lock.json
  • package.json
  • spec.json
  • test/contract.mjs

소스 아티팩트 내려받기 (tar.gz)

소스

PROMPT.md
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/text-decoder@1.2.7
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:npm/text-decoder@1.2.7

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.
csx.json
{"case":{"caseId":"case:sha256:dbec213d9df95a222094f9b1738510a49fb68bece83d5ee84cc54af4d6af23a4","contract":["TextDecoder defaults to utf8 and decodes multibyte UTF-8 characters across streamed chunk boundaries","TextDecoder remaining property returns the number of buffered incomplete multibyte bytes","TextDecoder passes through string input unchanged","TextDecoder write method aliases push for stream compatibility","TextDecoder end flushes any buffered bytes and resets remaining state to zero","TextDecoder supports pass-through encodings like ascii and hex, and throws on unsupported or unknown encodings"],"goal":"verify pkg:npm/text-decoder@1.2.7","kind":"HOW","packages":["pkg:npm/text-decoder@1.2.7"],"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/text-decoder@1.2.7"],"schemaVersion":1,"subject":"pkg:npm/text-decoder@1.2.7","verifierAdapter":"node-typescript@1"}
package-lock.json
{
  "name": "sample-text-decoder",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "sample-text-decoder",
      "version": "1.0.0",
      "dependencies": {
        "text-decoder": "1.2.7"
      }
    },
    "node_modules/b4a": {
      "version": "1.8.1",
      "resolved": "https://registry.npmjs.org/b4a/-/b4a-1.8.1.tgz",
      "integrity": "sha512-aiqre1Nr0B/6DgE2N5vwTc+2/oQZ4Wh1t4NznYY4E00y8LCt6NqdRv81so00oo27D8MVKTpUa/MwUUtBLXCoDw==",
      "license": "Apache-2.0",
      "peerDependencies": {
        "react-native-b4a": "*"
      },
      "peerDependenciesMeta": {
        "react-native-b4a": {
          "optional": true
        }
      }
    },
    "node_modules/text-decoder": {
      "version": "1.2.7",
      "resolved": "https://registry.npmjs.org/text-decoder/-/text-decoder-1.2.7.tgz",
      "integrity": "sha512-vlLytXkeP4xvEq2otHeJfSQIRyWxo/oZGEbXrtEEF9Hnmrdly59sUbzZ/QgyWuLYHctCHxFF4tRQZNQ9k60ExQ==",
      "license": "Apache-2.0",
      "dependencies": {
        "b4a": "^1.6.4"
      }
    }
  }
}
package.json
{
  "name": "sample-text-decoder",
  "version": "1.0.0",
  "type": "module",
  "private": true,
  "dependencies": {
    "text-decoder": "1.2.7"
  }
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify pkg:npm/text-decoder@1.2.7",
  "kind": "HOW",
  "packages": [
    "pkg:npm/text-decoder@1.2.7"
  ]
}
test/contract.mjs
import assert from 'node:assert/strict';
import TextDecoder from 'text-decoder';

// 1. TextDecoder defaults to utf8 and decodes multibyte UTF-8 characters across streamed chunk boundaries
const td = new TextDecoder();
// UTF-8 bytes for '💩' (U+1F4A9): F0 9F 92 A9 (4 bytes)
const chunk1 = Buffer.of(0xf0, 0x9f, 0x92);
const chunk2 = Buffer.of(0xa9);

assert.strictEqual(td.push(chunk1), '', 'Incomplete 3-byte chunk of 4-byte sequence returns empty string');
assert.strictEqual(td.remaining, 3, 'Remaining bytes should be 3');
assert.strictEqual(td.push(chunk2), '💩', 'Final byte completes the character and returns decoded string');
assert.strictEqual(td.remaining, 0, 'Remaining bytes should now be 0');

// Multi-character streaming: 'hello 🌍!' where 🌍 is F0 9F 8C 8D
const tdStream = new TextDecoder();
const part1 = Buffer.concat([Buffer.from('hello '), Buffer.of(0xf0, 0x9f)]);
const part2 = Buffer.concat([Buffer.of(0x8c, 0x8d), Buffer.from('!')]);
assert.strictEqual(tdStream.push(part1), 'hello ', 'Decodes prefix ASCII before incomplete multibyte sequence');
assert.strictEqual(tdStream.push(part2), '🌍!', 'Completes emoji and continues decoding remainder');

// 2. TextDecoder remaining property returns the number of buffered incomplete multibyte bytes
const tdRem = new TextDecoder();
assert.strictEqual(tdRem.remaining, 0);
tdRem.push(Buffer.of(0xe2, 0x82)); // Euro sign € is E2 82 AC (3 bytes)
assert.strictEqual(tdRem.remaining, 2);
tdRem.push(Buffer.of(0xac));
assert.strictEqual(tdRem.remaining, 0);

// 3. TextDecoder passes through string input unchanged
const tdStr = new TextDecoder();
assert.strictEqual(tdStr.push('already string'), 'already string');
assert.strictEqual(tdStr.push(' another string'), ' another string');

// 4. TextDecoder write method aliases push for stream compatibility
const tdWrite = new TextDecoder();
assert.strictEqual(tdWrite.write(Buffer.from('stream data ')), 'stream data ');
assert.strictEqual(tdWrite.write('string data'), 'string data');

// 5. TextDecoder end flushes any buffered bytes and resets remaining state to zero
const tdEnd = new TextDecoder();
tdEnd.push(Buffer.of(0xf0, 0x9f)); // partial sequence
assert.strictEqual(tdEnd.remaining, 2);
const flushed = tdEnd.end(); // flushes remaining
assert.strictEqual(tdEnd.remaining, 0, 'Remaining reset after end');
assert.strictEqual(typeof flushed, 'string');

const tdEndWithData = new TextDecoder();
const endResult = tdEndWithData.end(Buffer.from('final chunk'));
assert.strictEqual(endResult, 'final chunk');

// 6. TextDecoder supports pass-through encodings like ascii and hex, and throws on unsupported or unknown encodings
const tdAscii = new TextDecoder('ascii');
assert.strictEqual(tdAscii.push(Buffer.from('abc')), 'abc');

const tdHex = new TextDecoder('hex');
assert.strictEqual(tdHex.push(Buffer.from('hi')), '6869');

assert.throws(() => new TextDecoder('utf16le'), {
  name: 'Error',
  message: 'Unsupported encoding: utf16le'
});
assert.throws(() => new TextDecoder('base64'), {
  name: 'Error',
  message: 'Unsupported encoding: base64'
});
assert.throws(() => new TextDecoder('invalid-enc'), {
  name: 'Error',
  message: 'Unknown encoding: invalid-enc'
});

console.log('Contract tests passed successfully.');

오리진 시더

익명