CodeSampleX

샘플

merge-descriptors 2.0.0

검증된 샘플 — npm merge-descriptors 2.0.0. node 22 · linux alpine/x64 · docker에서 contract를 실행해 통과했습니다: mergeDescriptors merges own properties from source to…

sha256:35f140e46c88ff79fe13a131d1cd8be3c3b38a3bbfb8e5bb62f2100adb8d1496

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

실행 증거

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

증거 기준
서명된 컨트랙트 통과
검증 영수증
1
빌드한 서명 키
1
선언된 환경 windows 11 x64 npm

검증 실행 환경

환경 컨트랙트 단계 실행일
node 22 · linux alpine/x64 · docker ed25519:2175b912ea1c23b1 PASS compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS
CONTAINER_RUN · node-typescript@1
2026-08-19

케이스

HOW
목표
verify pkg:npm/merge-descriptors@2.0.0
패키지
생성일
2026-08-18T18:23:00Z

컨트랙트

  1. mergeDescriptors merges own properties from source to destination object
  2. mergeDescriptors returns the modified destination object
  3. mergeDescriptors overwrites existing destination properties by default
  4. mergeDescriptors skips existing destination properties when overwrite is false
  5. mergeDescriptors copies getter and setter accessors without invoking them during merge
  6. mergeDescriptors copies non-enumerable properties and preserves property flags
  7. mergeDescriptors throws TypeError when destination or source is missing or falsy
  8. wrapper merge matches direct mergeDescriptors behavior

파일

  • PROMPT.md
  • csx.json
  • index.mjs
  • 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/merge-descriptors@2.0.0
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:npm/merge-descriptors@2.0.0
Constraints:
  - executionContext: node
Required runtime conditions:
  - ecosystem: npm
  - language: javascript
  - moduleSystem: cjs
  - packageManager: npm@11.8.0
  - runtime: node@24.13.1

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:945110b5d6c14dbaa1c532a563020356991ce9f9bcd65473be4670f232ae950b","constraints":{"executionContext":"node"},"contract":["mergeDescriptors merges own properties from source to destination object","mergeDescriptors returns the modified destination object","mergeDescriptors overwrites existing destination properties by default","mergeDescriptors skips existing destination properties when overwrite is false","mergeDescriptors copies getter and setter accessors without invoking them during merge","mergeDescriptors copies non-enumerable properties and preserves property flags","mergeDescriptors throws TypeError when destination or source is missing or falsy","wrapper merge matches direct mergeDescriptors behavior"],"goal":"verify pkg:npm/merge-descriptors@2.0.0","kind":"HOW","packages":["pkg:npm/merge-descriptors@2.0.0"],"schemaVersion":1},"contractCommand":["node","test/contract.mjs"],"environment":{"arch":"x64","ecosystem":"npm","os":"windows","osVersionBucket":"11","packageManager":"npm","schemaVersion":1},"license":"MIT-0","packages":["pkg:npm/merge-descriptors@2.0.0"],"schemaVersion":1,"verifierAdapter":"node-typescript@1"}
index.mjs
import mergeDescriptors from 'merge-descriptors';

/**
 * Merges source properties into destination object.
 * @param {object} destination - Target object to receive properties.
 * @param {object} source - Source object to copy properties from.
 * @param {boolean} [overwrite=true] - Whether to overwrite existing properties.
 * @returns {object} The mutated destination object.
 */
export function merge(destination, source, overwrite = true) {
  return mergeDescriptors(destination, source, overwrite);
}

export default mergeDescriptors;
package-lock.json
{
  "name": "sample",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "sample",
      "version": "1.0.0",
      "dependencies": {
        "merge-descriptors": "2.0.0"
      }
    },
    "node_modules/merge-descriptors": {
      "version": "2.0.0",
      "resolved": "https://registry.npmjs.org/merge-descriptors/-/merge-descriptors-2.0.0.tgz",
      "integrity": "sha512-Snk314V5ayFLhp3fkUREub6WtjBfPdCPY1Ln8/8munuLuiYhsABgBVWsozAG+MWMbVEvcdcpbi9R7ww22l9Q3g==",
      "license": "MIT",
      "engines": {
        "node": ">=18"
      },
      "funding": {
        "url": "https://github.com/sponsors/sindresorhus"
      }
    }
  }
}
package.json
{
  "name": "sample",
  "version": "1.0.0",
  "type": "module",
  "dependencies": {
    "merge-descriptors": "2.0.0"
  }
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify pkg:npm/merge-descriptors@2.0.0",
  "kind": "HOW",
  "packages": [
    "pkg:npm/merge-descriptors@2.0.0"
  ],
  "constraints": {
    "executionContext": "node"
  },
  "runtimeConditions": {
    "ecosystem": "npm",
    "language": "javascript",
    "moduleSystem": "cjs",
    "packageManager": "npm@11.8.0",
    "runtime": "node@24.13.1"
  }
}
test/contract.mjs
import assert from 'node:assert/strict';
import mergeDescriptors from 'merge-descriptors';
import { merge } from '../index.mjs';

// Case 1: mergeDescriptors merges own properties from source to destination object
{
  const dest = { a: 1 };
  const src = { b: 2, c: 'hello' };
  const result = mergeDescriptors(dest, src);
  assert.equal(result, dest, 'result should be the destination object');
  assert.equal(dest.a, 1);
  assert.equal(dest.b, 2);
  assert.equal(dest.c, 'hello');
}

// Case 2: mergeDescriptors returns the modified destination object
{
  const target = {};
  const source = { key: 'value' };
  const returned = mergeDescriptors(target, source);
  assert.strictEqual(returned, target, 'returned reference must strictly equal target');
  assert.equal(returned.key, 'value');
}

// Case 3: mergeDescriptors overwrites existing destination properties by default
{
  const dest = { count: 1, name: 'original' };
  const src = { count: 42, name: 'updated' };
  mergeDescriptors(dest, src);
  assert.equal(dest.count, 42);
  assert.equal(dest.name, 'updated');
}

// Case 4: mergeDescriptors skips existing destination properties when overwrite is false
{
  const dest = { x: 10, y: 20 };
  const src = { x: 99, y: 88, z: 30 };
  mergeDescriptors(dest, src, false);
  assert.equal(dest.x, 10, 'dest.x should not be overwritten');
  assert.equal(dest.y, 20, 'dest.y should not be overwritten');
  assert.equal(dest.z, 30, 'dest.z should be added');
}

// Case 5: mergeDescriptors copies getter and setter accessors without invoking them during merge
{
  let getterCalls = 0;
  let storedValue = 'init';
  const src = {
    get val() {
      getterCalls++;
      return storedValue;
    },
    set val(newVal) {
      storedValue = newVal;
    }
  };

  const dest = {};
  mergeDescriptors(dest, src);
  assert.equal(getterCalls, 0, 'getter should not be called during mergeDescriptors');

  const desc = Object.getOwnPropertyDescriptor(dest, 'val');
  assert.equal(typeof desc.get, 'function');
  assert.equal(typeof desc.set, 'function');

  assert.equal(dest.val, 'init');
  assert.equal(getterCalls, 1);
  dest.val = 'modified';
  assert.equal(dest.val, 'modified');
  assert.equal(getterCalls, 2);
}

// Case 6: mergeDescriptors copies non-enumerable properties and preserves property flags
{
  const src = {};
  Object.defineProperty(src, 'hidden', {
    value: 'secret',
    writable: false,
    enumerable: false,
    configurable: true
  });

  const dest = {};
  mergeDescriptors(dest, src);
  assert.equal(dest.hidden, 'secret');
  const desc = Object.getOwnPropertyDescriptor(dest, 'hidden');
  assert.equal(desc.enumerable, false);
  assert.equal(desc.writable, false);
  assert.equal(desc.configurable, true);
}

// Case 7: mergeDescriptors throws TypeError when destination or source is missing or falsy
{
  assert.throws(
    () => mergeDescriptors(null, { a: 1 }),
    TypeError,
    'null destination should throw TypeError'
  );
  assert.throws(
    () => mergeDescriptors(undefined, { a: 1 }),
    TypeError,
    'undefined destination should throw TypeError'
  );
  assert.throws(
    () => mergeDescriptors({}, null),
    TypeError,
    'null source should throw TypeError'
  );
  assert.throws(
    () => mergeDescriptors({}, undefined),
    TypeError,
    'undefined source should throw TypeError'
  );
}

// Case 8: wrapper merge matches direct mergeDescriptors behavior
{
  const dest = { initial: true };
  const src = { added: 123 };
  const res = merge(dest, src);
  assert.strictEqual(res, dest);
  assert.equal(dest.added, 123);

  const destNoOverwrite = { val: 1 };
  merge(destNoOverwrite, { val: 2, other: 3 }, false);
  assert.equal(destNoOverwrite.val, 1);
  assert.equal(destNoOverwrite.other, 3);
}

console.log('PASS: all merge-descriptors contract assertions passed');

오리진 시더

익명