CodeSampleX

Beispiel

ini 5.0.0: decode, encode, parse

Verifiziertes Beispiel für npm ini 5.0.0: decode, encode, parse. Der Vertrag lief auf node 22 · linux debian/x64 · docker und bestand.

sha256:ddadc730c2ae6f5a73318a12e3afb539eff7c23cf5bdb03b323d788c21dec3df

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 linux 24 · ubuntu · glibc 2.39 x64 npm

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-10-18

Fall

HOW
Ziel
verify pkg:npm/ini@5.0.0
Pakete
Symbole
  • ini.decode
  • ini.encode
  • ini.parse
  • ini.safe
  • ini.stringify
  • ini.unsafe
Erstellt
2026-10-18T02:10:55Z

Contract

  1. ini.parse and ini.decode parse INI strings into nested null-prototype objects, coercing true/false/null literals, stripping comments (; and #), grouping key[] entries into arrays, and splitting dotted section headers unless escaped with \.
  2. ini.decode with { bracketedArray: false } treats repeated identical keys without [] suffix as an array of values.
  3. ini.stringify and ini.encode serialize objects and nested sections to INI text, supporting options { section, whitespace, sort, align, bracketedArray }.
  4. ini.safe escapes semicolons and hashes or JSON-quotes strings containing =, newlines, leading brackets, or outer whitespace, and ini.unsafe reverses the escaping while stripping unescaped inline comments.

Dateien

  • PROMPT.md
  • csx.json
  • package-lock.json
  • package.json
  • spec.json
  • 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 pkg:npm/ini@5.0.0
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:npm/ini@5.0.0

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:7d4afa424e3d0581ef1ac04ae1e71749d68e368a6347bab66b02b6008a7d8040","contract":["ini.parse and ini.decode parse INI strings into nested null-prototype objects, coercing true/false/null literals, stripping comments (; and #), grouping key[] entries into arrays, and splitting dotted section headers unless escaped with \\.","ini.decode with { bracketedArray: false } treats repeated identical keys without [] suffix as an array of values.","ini.stringify and ini.encode serialize objects and nested sections to INI text, supporting options { section, whitespace, sort, align, bracketedArray }.","ini.safe escapes semicolons and hashes or JSON-quotes strings containing =, newlines, leading brackets, or outer whitespace, and ini.unsafe reverses the escaping while stripping unescaped inline comments."],"goal":"verify pkg:npm/ini@5.0.0","kind":"HOW","packages":["pkg:npm/ini@5.0.0"],"schemaVersion":1,"symbols":["ini.decode","ini.encode","ini.parse","ini.safe","ini.stringify","ini.unsafe"]},"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/ini@5.0.0"],"schemaVersion":1,"subject":"pkg:npm/ini@5.0.0","symbols":["ini.decode","ini.encode","ini.parse","ini.safe","ini.stringify","ini.unsafe"],"verifierAdapter":"node-typescript@1"}
package-lock.json
{
  "name": "verify-ini",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "verify-ini",
      "version": "1.0.0",
      "dependencies": {
        "ini": "5.0.0"
      }
    },
    "node_modules/ini": {
      "version": "5.0.0",
      "resolved": "https://registry.npmjs.org/ini/-/ini-5.0.0.tgz",
      "integrity": "sha512-+N0ngpO3e7cRUWOJAS7qw0IZIVc6XPrW4MlFBdD066F2L4k1L6ker3hLqSq7iXxU5tgS4WGkIUElWn5vogAEnw==",
      "license": "ISC",
      "engines": {
        "node": "^18.17.0 || >=20.5.0"
      }
    }
  }
}
package.json
{
  "name": "verify-ini",
  "version": "1.0.0",
  "private": true,
  "type": "module",
  "scripts": {
    "test": "node test/contract.mjs"
  },
  "dependencies": {
    "ini": "5.0.0"
  }
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify pkg:npm/ini@5.0.0",
  "kind": "HOW",
  "packages": [
    "pkg:npm/ini@5.0.0"
  ]
}
test/contract.mjs
import assert from 'node:assert/strict';
import ini from 'ini';

// 1. Decode / parse basic INI string with sections, arrays, booleans, nulls, and comments
const rawIni = [
  '; top-level comment',
  '# another comment',
  'rootKey = rootValue',
  'enabled = true',
  'disabled = false',
  'emptyVal = null',
  'flagOnly',
  '',
  '[server]',
  'host = localhost',
  'port = 8080',
  'tags[] = alpha',
  'tags[] = beta',
  '',
  '[server.tls]',
  'cert = cert.pem',
  '',
  '[escaped\\.dot]',
  'key = dotVal',
].join('\n');

const parsed = ini.parse(rawIni);
assert.equal(ini.parse, ini.decode);
assert.equal(ini.stringify, ini.encode);

assert.equal(parsed.rootKey, 'rootValue');
assert.equal(parsed.enabled, true);
assert.equal(parsed.disabled, false);
assert.equal(parsed.emptyVal, null);
assert.equal(parsed.flagOnly, true);
assert.equal(parsed.server.host, 'localhost');
assert.equal(parsed.server.port, '8080');
assert.deepEqual(parsed.server.tags, ['alpha', 'beta']);
assert.equal(parsed.server.tls.cert, 'cert.pem');
assert.equal(parsed['escaped.dot'].key, 'dotVal');

// 2. Bracketed array option (bracketedArray: false)
const duplicateKeysIni = 'item = first\nitem = second\n';
const decodedUnbracketed = ini.decode(duplicateKeysIni, { bracketedArray: false });
assert.deepEqual(decodedUnbracketed.item, ['first', 'second']);

// 3. Encode / stringify with options (section, whitespace, sort, align, bracketedArray)
const objToEncode = {
  bKey: 'two',
  aKey: 'one',
  items: ['x', 'y'],
  nested: {
    inner: 'val',
  },
};

const encodedDefault = ini.stringify(objToEncode);
assert.equal(
  encodedDefault,
  'bKey=two\naKey=one\nitems[]=x\nitems[]=y\n\n[nested]\ninner=val\n'
);

const encodedSortedWhitespace = ini.encode(objToEncode, {
  section: 'top',
  whitespace: true,
  sort: true,
  bracketedArray: false,
});
assert.equal(
  encodedSortedWhitespace,
  '[top]\naKey = one\nbKey = two\nitems = x\nitems = y\n\n[top.nested]\ninner = val\n'
);

// 4. Safe and unsafe escaping helpers
assert.equal(ini.safe('plain'), 'plain');
assert.equal(ini.safe('has;semicolon#hash'), 'has\\;semicolon\\#hash');
assert.equal(ini.safe('key=val'), '"key=val"');
assert.equal(ini.safe(' leadingSpace'), '" leadingSpace"');

assert.equal(ini.unsafe('has\\;semicolon\\#hash ; trailing comment'), 'has;semicolon#hash');
assert.equal(ini.unsafe('"key=val"'), 'key=val');

Ursprungs-Seeder

anonym