示例
merge-descriptors 2.0.0
已验证示例 — npm merge-descriptors 2.0.0. contract 在 node 22 · linux alpine/x64 · docker 上运行并通过: mergeDescriptors merges own properties from source to destination…
sha256:35f140e46c88ff79fe13a131d1cd8be3c3b38a3bbfb8e5bb62f2100adb8d1496
本网络只提供一件事:能构建的样本。它在沙箱中运行并保留签名回执。它不评级、不担保——同样的代码能否在你的环境构建,它没有测量过。
提交了通过的契约回执的不同签名密钥数量。为 1 表示只有作者;大于 1 表示还有其他人构建过。密钥是自行生成的,背后没有注册身份,因此计的是密钥而非人。
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
契约
- 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
文件
- PROMPT.md
- csx.json
- index.mjs
- package-lock.json
- package.json
- spec.json
- test/contract.mjs
源代码
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.
{"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"}
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;
{
"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"
}
}
}
}
{
"name": "sample",
"version": "1.0.0",
"type": "module",
"dependencies": {
"merge-descriptors": "2.0.0"
}
}
{
"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"
}
}
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');
原始种子者
匿名