Beispiel
js-yaml 4.1.0: load
Verifiziertes Beispiel für npm js-yaml 4.1.0: load. Der Vertrag lief auf node 22 · linux alpine/x64 · docker und bestand: yaml.load parses YAML mapping…
sha256:65ea4d5b1a46193b007805523740c2971c59c60588f1ecd89996ef4c2a9e3367
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 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-28 |
Fall
HOW- Ziel
- verify js-yaml.load in pkg:npm/js-yaml@4.1.0
- Pakete
- Symbole
-
- js-yaml.load
- Umgebung
- node 22.23.2
- Erstellt
- 2026-08-28T03:39:00Z
Contract
- yaml.load parses YAML mapping, sequence, and scalar types into JavaScript values
- yaml.load returns undefined for empty input string
- yaml.load returns null for comment-only input or explicit null/tilde scalar
- yaml.load throws YAMLException when stream contains multiple documents
- yaml.load throws YAMLException on duplicate mapping keys by default
- yaml.load allows duplicate mapping keys when json option is enabled
- yaml.load respects schema option such as FAILSAFE_SCHEMA preserving scalar strings
- yaml.load invokes custom listener callback during parsing
- yaml.load throws YAMLException on invalid YAML syntax
Dateien
- PROMPT.md
- csx.json
- index.js
- 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 js-yaml.load in pkg:npm/js-yaml@4.1.0
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:npm/js-yaml@4.1.0
Demonstrate these symbols/APIs:
- js-yaml.load
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:95f61d883dbd9f993184f411e4f9648d4137f1ef7732e987ece8d9024d7c3749","contract":["yaml.load parses YAML mapping, sequence, and scalar types into JavaScript values","yaml.load returns undefined for empty input string","yaml.load returns null for comment-only input or explicit null/tilde scalar","yaml.load throws YAMLException when stream contains multiple documents","yaml.load throws YAMLException on duplicate mapping keys by default","yaml.load allows duplicate mapping keys when json option is enabled","yaml.load respects schema option such as FAILSAFE_SCHEMA preserving scalar strings","yaml.load invokes custom listener callback during parsing","yaml.load throws YAMLException on invalid YAML syntax"],"goal":"verify js-yaml.load in pkg:npm/js-yaml@4.1.0","kind":"HOW","packages":["pkg:npm/js-yaml@4.1.0"],"schemaVersion":1,"symbols":["js-yaml.load"]},"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/js-yaml@4.1.0"],"schemaVersion":1,"subject":"pkg:npm/js-yaml@4.1.0","symbols":["js-yaml.load"],"verifierAdapter":"node-typescript@1"}
const yaml = require('js-yaml');
/**
* Parses a YAML string into a JavaScript value.
*
* @param {string} input - YAML string to parse.
* @param {object} [options] - Parsing options.
* @returns {*} Parsed value.
*/
function parseYaml(input, options) {
return yaml.load(input, options);
}
module.exports = {
parseYaml,
yaml,
};
{
"name": "sample-js-yaml-load",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "sample-js-yaml-load",
"version": "1.0.0",
"license": "MIT-0",
"dependencies": {
"js-yaml": "4.1.0"
}
},
"node_modules/argparse": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz",
"integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==",
"license": "Python-2.0"
},
"node_modules/js-yaml": {
"version": "4.1.0",
"resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.0.tgz",
"integrity": "sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA==",
"license": "MIT",
"dependencies": {
"argparse": "^2.0.1"
},
"bin": {
"js-yaml": "bin/js-yaml.js"
}
}
}
}
{
"name": "sample-js-yaml-load",
"version": "1.0.0",
"description": "Clean-room sample verifying js-yaml.load functionality",
"main": "index.js",
"license": "MIT-0",
"dependencies": {
"js-yaml": "4.1.0"
}
}
{
"schemaVersion": 1,
"goal": "verify js-yaml.load in pkg:npm/js-yaml@4.1.0",
"kind": "HOW",
"packages": [
"pkg:npm/js-yaml@4.1.0"
],
"symbols": [
"js-yaml.load"
]
}
import assert from 'node:assert';
import yaml from 'js-yaml';
import { parseYaml } from '../index.js';
// 1. Basic parsing of YAML mapping, sequence, and scalar types
const yamlSource = `
name: CodeSampleX
version: 4
active: true
pi: 3.14
items:
- first
- second
nested:
key: value
`;
const doc1 = parseYaml(yamlSource);
assert.deepStrictEqual(doc1, {
name: 'CodeSampleX',
version: 4,
active: true,
pi: 3.14,
items: ['first', 'second'],
nested: {
key: 'value',
},
});
const directDoc = yaml.load(yamlSource);
assert.deepStrictEqual(directDoc, doc1);
// 2. Empty string returns undefined
assert.strictEqual(parseYaml(''), undefined);
assert.strictEqual(yaml.load(''), undefined);
// 3. Comment-only or explicit null returns null
assert.strictEqual(parseYaml('# comment only\n'), null);
assert.strictEqual(parseYaml('null'), null);
assert.strictEqual(parseYaml('~'), null);
// 4. Multiple documents in a stream throw YAMLException in load()
assert.throws(
() => {
parseYaml('---\ndoc: 1\n---\ndoc: 2\n');
},
{
name: 'YAMLException',
}
);
// 5. Duplicate keys throw YAMLException by default
assert.throws(
() => {
parseYaml('key: first\nkey: second');
},
{
name: 'YAMLException',
}
);
// 6. Duplicate keys are permitted when json: true option is enabled
const jsonModeDoc = parseYaml('key: first\nkey: second', { json: true });
assert.deepStrictEqual(jsonModeDoc, { key: 'second' });
// 7. Schema option: FAILSAFE_SCHEMA preserves scalar types as strings
const failsafeDoc = parseYaml('num: 123\nflag: true', { schema: yaml.FAILSAFE_SCHEMA });
assert.deepStrictEqual(failsafeDoc, { num: '123', flag: 'true' });
// 8. Custom listener option receives parse events
const events = [];
parseYaml('item: value', {
listener: (op, state) => {
events.push({ op, hasResult: state.result !== undefined });
},
});
assert.strictEqual(events.length > 0, true);
// 9. Invalid YAML syntax throws YAMLException
assert.throws(
() => {
parseYaml('foo: : bar');
},
{
name: 'YAMLException',
}
);
console.log('All contract assertions passed.');
Ursprungs-Seeder
anonym