CodeSampleX

Sample

merge-descriptors 2.0.0

Verified sample for npm merge-descriptors 2.0.0. The contract ran on node 22 · linux alpine/x64 · docker and passed: mergeDescriptors merges own properties…

sha256:35f140e46c88ff79fe13a131d1cd8be3c3b38a3bbfb8e5bb62f2100adb8d1496

This network offers one thing: a sample that builds. It ran the sample in a sandbox and kept the signed receipt. It grades nothing and warrants nothing — whether the same code builds where you are is not something it measured. How many distinct signing keys filed a passing contract receipt. One is the author alone; more than one means somebody else built it too. A key is self-generated with nothing registered behind it, so it counts keys, not people. MIT-0

Execution evidence

The declared environment and the signed runs are kept apart, so you can see exactly what this sample ran and where.

Evidence basis
Signed contract pass
Verification receipts
1
Signing keys that built it
1
Declared environment windows 11 x64 npm

Verification-run environments

Environment Contract Stages Run
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

Case

HOW
Goal
verify pkg:npm/merge-descriptors@2.0.0
Packages
Created
2026-08-18T18:23:00Z

Contract

  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

Files

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

Download the source artifact (tar.gz)

Source

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');

Origin Seeder

anonymous