CodeSampleX

Beispiel

fflate 0.8.3: zipSync

Verifiziertes Beispiel für npm fflate 0.8.3: zipSync. Der Vertrag lief auf node 22 · linux debian/x64 · docker und bestand: zipSync(data) compresses single…

sha256:dc564d97d463db24b50f62a6ed7b3c4ce33d87c7586d5d4cf9d1c4d9a8224176

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.zipSync in pkg:npm/fflate@0.8.3
Pakete
Symbole
  • fflate.zipSync
Umgebung
node 22.23.2
Erstellt
2026-09-18T00:06:35Z

Contract

  1. zipSync(data) compresses single file Uint8Array into valid ZIP format returning Uint8Array
  2. zipSync(data) supports multiple files and nested directory paths in archive
  3. zipSync(data, opts) respects compression level option including level 0 uncompressed store
  4. zipSync(data) accepts per-file options tuple [data, opts] with custom compression level
  5. zipSync(data) creates empty ZIP archive when provided empty data mapping
  6. zipSync(data) compresses nested object mapping into hierarchical directory structure

Dateien

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

Quellartefakt herunterladen (tar.gz)

Quelltext

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 fflate.zipSync 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.zipSync

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:d6bd5cbd0e992f6be72d2ea47fa48a28cf05734a987c2b124b812453b6d0bea9","contract":["zipSync(data) compresses single file Uint8Array into valid ZIP format returning Uint8Array","zipSync(data) supports multiple files and nested directory paths in archive","zipSync(data, opts) respects compression level option including level 0 uncompressed store","zipSync(data) accepts per-file options tuple [data, opts] with custom compression level","zipSync(data) creates empty ZIP archive when provided empty data mapping","zipSync(data) compresses nested object mapping into hierarchical directory structure"],"goal":"verify fflate.zipSync in pkg:npm/fflate@0.8.3","kind":"HOW","packages":["pkg:npm/fflate@0.8.3"],"schemaVersion":1,"symbols":["fflate.zipSync"]},"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/fflate@0.8.3"],"schemaVersion":1,"subject":"pkg:npm/fflate@0.8.3","symbols":["fflate.zipSync"],"verifierAdapter":"node-typescript@1"}
package-lock.json
{
  "name": "sample-fflate",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "sample-fflate",
      "version": "1.0.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"
    }
  }
}
package.json
{
  "name": "sample-fflate",
  "version": "1.0.0",
  "private": true,
  "description": "Clean-room verification of fflate.zipSync in pkg:npm/fflate@0.8.3",
  "main": "src/index.js",
  "dependencies": {
    "fflate": "0.8.3"
  }
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify fflate.zipSync in pkg:npm/fflate@0.8.3",
  "kind": "HOW",
  "packages": [
    "pkg:npm/fflate@0.8.3"
  ],
  "symbols": [
    "fflate.zipSync"
  ]
}
src/index.js
const {
  zipSync,
  unzipSync,
  strToU8,
  strFromU8
} = require('fflate');

/**
 * Creates a ZIP archive synchronously from a mapping of filenames to file data.
 *
 * @param {Record<string, Uint8Array | [Uint8Array, object] | object>} data - Mapping of filenames/paths to content or nested objects.
 * @param {object} [opts] - Global zip options (e.g. level, mem).
 * @returns {Uint8Array} The compressed ZIP file bytes.
 */
function createZip(data, opts) {
  return zipSync(data, opts);
}

module.exports = {
  createZip,
  zipSync,
  unzipSync,
  strToU8,
  strFromU8
};
test/contract.mjs
import assert from 'node:assert';
import { createRequire } from 'node:module';

const require = createRequire(import.meta.url);
const {
  createZip,
  zipSync,
  unzipSync,
  strToU8,
  strFromU8
} = require('../src/index.js');

// 0. Export verification
assert.strictEqual(typeof createZip, 'function', 'createZip must be a function');
assert.strictEqual(typeof zipSync, 'function', 'zipSync must be a function');
assert.strictEqual(typeof unzipSync, 'function', 'unzipSync must be a function');
assert.strictEqual(typeof strToU8, 'function', 'strToU8 must be a function');
assert.strictEqual(typeof strFromU8, 'function', 'strFromU8 must be a function');

// 1. zipSync(data) compresses single file Uint8Array into valid ZIP format returning Uint8Array
{
  const content = strToU8('Hello from CodeSampleX clean-room verification!');
  const archive = zipSync({
    'greeting.txt': content
  });
  assert(archive instanceof Uint8Array, 'archive should be a Uint8Array');
  assert(archive.length > 0, 'archive length should be positive');

  const extracted = unzipSync(archive);
  assert(extracted['greeting.txt'] instanceof Uint8Array, 'extracted greeting.txt should be Uint8Array');
  assert.strictEqual(strFromU8(extracted['greeting.txt']), 'Hello from CodeSampleX clean-room verification!');
}

// 2. zipSync(data) supports multiple files and nested directory paths in archive
{
  const files = {
    'docs/readme.txt': strToU8('Documentation overview'),
    'src/main.js': strToU8('console.log(42);'),
    'LICENSE': strToU8('MIT-0')
  };
  const archive = zipSync(files);
  assert(archive instanceof Uint8Array);

  const extracted = unzipSync(archive);
  assert.strictEqual(Object.keys(extracted).length, 3);
  assert.strictEqual(strFromU8(extracted['docs/readme.txt']), 'Documentation overview');
  assert.strictEqual(strFromU8(extracted['src/main.js']), 'console.log(42);');
  assert.strictEqual(strFromU8(extracted['LICENSE']), 'MIT-0');
}

// 3. zipSync(data, opts) respects compression level option including level 0 uncompressed store
{
  const repetitiveText = 'A'.repeat(5000);
  const data = { 'data.txt': strToU8(repetitiveText) };

  const storeArchive = zipSync(data, { level: 0 });
  const compressedArchive = zipSync(data, { level: 9 });

  assert(storeArchive.length > compressedArchive.length, 'level 0 should be larger than level 9 on repetitive data');

  const uncompressedStore = unzipSync(storeArchive);
  assert.strictEqual(strFromU8(uncompressedStore['data.txt']), repetitiveText);

  const uncompressedCompressed = unzipSync(compressedArchive);
  assert.strictEqual(strFromU8(uncompressedCompressed['data.txt']), repetitiveText);
}

// 4. zipSync(data) accepts per-file options tuple [data, opts] with custom compression level
{
  const payload1 = strToU8('B'.repeat(2000));
  const payload2 = strToU8('C'.repeat(2000));

  const archive = zipSync({
    'stored.txt': [payload1, { level: 0 }],
    'compressed.txt': [payload2, { level: 6 }]
  });

  const extracted = unzipSync(archive);
  assert.strictEqual(strFromU8(extracted['stored.txt']), 'B'.repeat(2000));
  assert.strictEqual(strFromU8(extracted['compressed.txt']), 'C'.repeat(2000));
}

// 5. zipSync(data) creates empty ZIP archive when provided empty data mapping
{
  const emptyArchive = zipSync({});
  assert(emptyArchive instanceof Uint8Array, 'empty archive should be Uint8Array');
  assert(emptyArchive.length >= 22, 'empty ZIP file has at least 22 bytes end of central directory record');

  const extracted = unzipSync(emptyArchive);
  assert.deepStrictEqual(extracted, {}, 'extracted empty archive should have no entries');
}

// 6. zipSync(data) compresses nested object mapping into hierarchical directory structure
{
  const tree = {
    folderA: {
      'inner.txt': strToU8('inner content A'),
      folderB: {
        'deep.txt': strToU8('deep content B')
      }
    }
  };

  const archive = zipSync(tree);
  const extracted = unzipSync(archive);

  assert.strictEqual(strFromU8(extracted['folderA/inner.txt']), 'inner content A');
  assert.strictEqual(strFromU8(extracted['folderA/folderB/deep.txt']), 'deep content B');
}

// Also verify createZip wrapper function works identically
{
  const archive = createZip({ 'wrapped.txt': strToU8('wrapped test') });
  const extracted = unzipSync(archive);
  assert.strictEqual(strFromU8(extracted['wrapped.txt']), 'wrapped test');
}

Ursprungs-Seeder

anonym