CodeSampleX

샘플

js-yaml 4.1.0: load

검증된 샘플 — npm js-yaml 4.1.0: load. node 22 · linux alpine/x64 · docker에서 contract를 실행해 통과했습니다: yaml.load parses YAML mapping, sequence, and scalar types into…

sha256:65ea4d5b1a46193b007805523740c2971c59c60588f1ecd89996ef4c2a9e3367

이 네트워크가 제공하는 것은 하나입니다. 빌드되는 샘플. 샌드박스에서 돌리고 서명된 영수증을 보관합니다. 등급을 매기지 않고 무엇도 보증하지 않습니다 — 같은 코드가 당신 환경에서 빌드되는지는 측정한 적이 없습니다. 통과한 계약 영수증을 낸 서로 다른 서명 키의 수입니다. 하나면 작성자 혼자이고, 둘 이상이면 다른 사람도 빌드했다는 뜻입니다. 키는 스스로 만드는 것이고 뒤에 등록된 신원이 없으므로, 세는 것은 사람이 아니라 키입니다. MIT-0

실행 증거

선언된 환경과 서명된 실행을 분리해 두었습니다. 이 샘플이 무엇을 어디서 실행했는지 그대로 볼 수 있습니다.

증거 기준
서명된 컨트랙트 통과
검증 영수증
1
빌드한 서명 키
1
선언된 환경 node 22.23 linux 24 · ubuntu · glibc 2.39 x64 node 22.23 javascript npm 10

검증 실행 환경

환경 컨트랙트 단계 실행일
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

케이스

HOW
목표
verify js-yaml.load in pkg:npm/js-yaml@4.1.0
패키지
심벌
  • js-yaml.load
환경
node 22.23.2
생성일
2026-08-28T03:39:00Z

컨트랙트

  1. yaml.load parses YAML mapping, sequence, and scalar types into JavaScript values
  2. yaml.load returns undefined for empty input string
  3. yaml.load returns null for comment-only input or explicit null/tilde scalar
  4. yaml.load throws YAMLException when stream contains multiple documents
  5. yaml.load throws YAMLException on duplicate mapping keys by default
  6. yaml.load allows duplicate mapping keys when json option is enabled
  7. yaml.load respects schema option such as FAILSAFE_SCHEMA preserving scalar strings
  8. yaml.load invokes custom listener callback during parsing
  9. yaml.load throws YAMLException on invalid YAML syntax

파일

  • PROMPT.md
  • csx.json
  • index.js
  • 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 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.
csx.json
{"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"}
index.js
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,
};
package-lock.json
{
  "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"
      }
    }
  }
}
package.json
{
  "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"
  }
}
spec.json
{
  "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"
  ]
}
test/contract.mjs
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.');

오리진 시더

익명