示例
object-assign 4.1.1: object-assign
已验证示例 — npm object-assign 4.1.1: object-assign. contract 在 node 22 · linux alpine/x64 · docker 上运行并通过: objectAssign exports a function that assigns…
sha256:56a8a907126a24e4bfae6d00b7f222dae6685e53cb93b2090e0e2c6ae741b14b
本网络只提供一件事:能构建的样本。它在沙箱中运行并保留签名回执。它不评级、不担保——同样的代码能否在你的环境构建,它没有测量过。
提交了通过的契约回执的不同签名密钥数量。为 1 表示只有作者;大于 1 表示还有其他人构建过。密钥是自行生成的,背后没有注册身份,因此计的是密钥而非人。
MIT-0
执行证据
声明的环境与签名的运行分开呈现,你可以看到这个样本究竟运行了什么、在哪里运行。
- 证据依据
- 签名契约通过
- 验证回执
- 2
- 构建过它的签名密钥
- 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-27 |
| node 22 · linux debian/x64 · docker ed25519:c1973797be207ac4 | PASS | compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS CONTAINER_RUN · node-typescript@1node:22@sha256:8a34c4ab3ea2… |
2026-09-07 |
案例
HOW- 目标
- verify object-assign in pkg:npm/object-assign@4.1.1
- 符号
-
- object-assign
- 环境
- node 22.23.2
- 创建时间
- 2026-08-27T10:00:27Z
契约
- objectAssign exports a function that assigns enumerable own properties to target
- objectAssign mutates and returns the target object
- objectAssign merges multiple source objects with later sources overriding earlier ones
- objectAssign ignores null and undefined source arguments without throwing
- objectAssign throws TypeError when target is null or undefined
- objectAssign copies symbol-keyed enumerable own properties from sources
- objectAssign ignores non-enumerable properties and inherited prototype properties from sources
- applyDefaults creates a new object with merged defaults and custom options
文件
- PROMPT.md
- csx.json
- package-lock.json
- package.json
- spec.json
- src/index.js
- 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 object-assign in pkg:npm/object-assign@4.1.1
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:npm/object-assign@4.1.1
Demonstrate these symbols/APIs:
- object-assign
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:1dffad396ef785f7edc89dbba49211b801cc7dfd83946663e59a40b01e5cd041","contract":["objectAssign exports a function that assigns enumerable own properties to target","objectAssign mutates and returns the target object","objectAssign merges multiple source objects with later sources overriding earlier ones","objectAssign ignores null and undefined source arguments without throwing","objectAssign throws TypeError when target is null or undefined","objectAssign copies symbol-keyed enumerable own properties from sources","objectAssign ignores non-enumerable properties and inherited prototype properties from sources","applyDefaults creates a new object with merged defaults and custom options"],"goal":"verify object-assign in pkg:npm/object-assign@4.1.1","kind":"HOW","packages":["pkg:npm/object-assign@4.1.1"],"schemaVersion":1,"symbols":["object-assign"]},"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/object-assign@4.1.1"],"schemaVersion":1,"subject":"pkg:npm/object-assign@4.1.1","symbols":["object-assign"],"verifierAdapter":"node-typescript@1"}
{
"name": "sample-object-assign",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "sample-object-assign",
"version": "1.0.0",
"license": "MIT-0",
"dependencies": {
"object-assign": "4.1.1"
}
},
"node_modules/object-assign": {
"version": "4.1.1",
"resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz",
"integrity": "sha512-rJgTQnkUnH1sFw8yT6VSU3zD3sWmu6sZhIseY8VX+GRu3P6F7Fu+JNDoXfklElbLJSnc3FUQHVe4cU5hj+BcUg==",
"license": "MIT",
"engines": {
"node": ">=0.10.0"
}
}
}
}
{
"name": "sample-object-assign",
"version": "1.0.0",
"private": true,
"description": "Clean-room code sample for object-assign@4.1.1",
"main": "src/index.js",
"license": "MIT-0",
"dependencies": {
"object-assign": "4.1.1"
}
}
{
"schemaVersion": 1,
"goal": "verify object-assign in pkg:npm/object-assign@4.1.1",
"kind": "HOW",
"packages": [
"pkg:npm/object-assign@4.1.1"
],
"symbols": [
"object-assign"
]
}
const objectAssign = require('object-assign');
/**
* Merges source objects into the target object and returns the mutated target.
*
* @param {Object} target - The target object to copy properties into.
* @param {...Object} sources - One or more source objects.
* @returns {Object} The target object with properties assigned.
*/
function mergeObjects(target, ...sources) {
return objectAssign(target, ...sources);
}
/**
* Creates a shallow clone of an object with default fallbacks and override values.
*
* @param {Object} defaults - Default properties.
* @param {Object} options - Custom options that override defaults.
* @returns {Object} A new object containing merged options.
*/
function applyDefaults(defaults, options) {
return objectAssign({}, defaults, options);
}
module.exports = {
objectAssign,
mergeObjects,
applyDefaults
};
import assert from 'node:assert/strict';
import { createRequire } from 'node:module';
const require = createRequire(import.meta.url);
const {
objectAssign,
mergeObjects,
applyDefaults
} = require('../src/index.js');
async function testAll() {
// 1. objectAssign exports a function that assigns enumerable own properties to target
assert.equal(typeof objectAssign, 'function', 'objectAssign should be a function');
assert.equal(typeof mergeObjects, 'function', 'mergeObjects should be a function');
assert.equal(typeof applyDefaults, 'function', 'applyDefaults should be a function');
// 2. objectAssign mutates and returns the target object
const target = { initial: 'value' };
const source = { added: 123 };
const returnedTarget = objectAssign(target, source);
assert.equal(returnedTarget, target, 'objectAssign must return the identical target reference');
assert.deepEqual(target, { initial: 'value', added: 123 }, 'target object must be mutated');
// 3. objectAssign merges multiple source objects with later sources overriding earlier ones
const base = { a: 1, b: 2 };
const override1 = { b: 20, c: 30 };
const override2 = { c: 300, d: 400 };
const merged = objectAssign({}, base, override1, override2);
assert.deepEqual(merged, { a: 1, b: 20, c: 300, d: 400 }, 'later sources must override previous properties');
// 4. objectAssign ignores null and undefined source arguments without throwing
const targetWithNulls = { preserved: true };
const resultWithNulls = objectAssign(targetWithNulls, null, undefined, { next: 42 }, null);
assert.deepEqual(resultWithNulls, { preserved: true, next: 42 }, 'null and undefined sources must be skipped');
// 5. objectAssign throws TypeError when target is null or undefined
assert.throws(
() => {
objectAssign(null, { key: 'val' });
},
{
name: 'TypeError'
},
'objectAssign(null) must throw TypeError'
);
assert.throws(
() => {
objectAssign(undefined, { key: 'val' });
},
{
name: 'TypeError'
},
'objectAssign(undefined) must throw TypeError'
);
// 6. objectAssign copies symbol-keyed enumerable own properties from sources
const symA = Symbol('symA');
const symB = Symbol('symB');
const symbolSource = { [symA]: 'valueA', regular: 'text' };
Object.defineProperty(symbolSource, symB, {
value: 'hidden',
enumerable: false
});
const symbolTarget = {};
objectAssign(symbolTarget, symbolSource);
assert.equal(symbolTarget[symA], 'valueA', 'enumerable symbol property must be copied');
assert.equal(symbolTarget.regular, 'text', 'string key property must be copied');
assert.equal(symbolTarget[symB], undefined, 'non-enumerable symbol property must not be copied');
// 7. objectAssign ignores non-enumerable properties and inherited prototype properties from sources
const proto = { inheritedProp: 'inherited' };
const sourceWithProto = Object.create(proto);
sourceWithProto.ownProp = 'own';
Object.defineProperty(sourceWithProto, 'nonEnumProp', {
value: 'secret',
enumerable: false
});
const dest = {};
objectAssign(dest, sourceWithProto);
assert.equal(dest.ownProp, 'own', 'own enumerable property must be copied');
assert.equal(dest.inheritedProp, undefined, 'inherited property must not be copied');
assert.equal(dest.nonEnumProp, undefined, 'non-enumerable property must not be copied');
// 8. applyDefaults creates a new object with merged defaults and custom options
const defaultOpts = { timeout: 5000, retries: 3, verbose: false };
const customOpts = { timeout: 10000, verbose: true };
const resolved = applyDefaults(defaultOpts, customOpts);
assert.deepEqual(resolved, { timeout: 10000, retries: 3, verbose: true });
assert.notEqual(resolved, defaultOpts, 'must create a new object without mutating defaults');
assert.equal(defaultOpts.timeout, 5000, 'defaults must remain unmodified');
console.log('All object-assign contract tests passed successfully.');
}
testAll().catch((err) => {
console.error('Contract test failure:', err);
process.exit(1);
});
原始种子者
匿名