CodeSampleX

Exemplo

object-assign 4.1.1

Amostra verificada para npm object-assign 4.1.1. O contrato rodou em node 22 · linux alpine/x64 · docker e passou: objectAssign mutates and returns the…

sha256:2c0e13e79340b1146488ba78cf25ed82e0a3c47f07921df12eb346d8fc119183

Esta rede oferece uma coisa: uma amostra que compila. Ela a executou em um sandbox e guardou o recibo assinado. Não classifica nem garante nada — se o mesmo código compila onde você está, ela não mediu. Quantas chaves de assinatura distintas enviaram um recibo de contrato aprovado. Uma é só o autor; mais de uma significa que outra pessoa também o compilou. Uma chave é gerada por conta própria e não tem identidade registrada por trás, então conta chaves, não pessoas. MIT-0

Evidência de execução

O ambiente declarado e as execuções assinadas ficam separados, para você ver exatamente o que esta amostra executou e onde.

Base da evidência
Contrato assinado aprovado
Recibos de verificação
2
Chaves de assinatura que o compilaram
1
Ambiente declarado node 22.23 linux 24 · ubuntu · glibc 2.39 x64 node 22.23 javascript npm 10

Ambientes das execuções de verificação

Ambiente Contrato Etapas Execução
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-26
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

Caso

HOW
Objetivo
verify pkg:npm/object-assign@4.1.1
Pacotes
Ambiente
node 22.23.2
Criado
2026-08-26T08:19:19Z

Contrato

  1. objectAssign mutates and returns the target object
  2. objectAssign merges own enumerable properties from multiple source objects with later sources overriding earlier ones
  3. objectAssign ignores null and undefined sources without throwing
  4. objectAssign throws TypeError when target is null or undefined
  5. objectAssign supports Symbol properties from source objects
  6. objectAssign treats string primitives as objects with indexed enumerable properties while ignoring other primitives

Arquivos

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

Baixar o artefato de código-fonte (tar.gz)

Código-fonte

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/object-assign@4.1.1
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:npm/object-assign@4.1.1
Constraints:
  - executionContext: node
Required runtime conditions:
  - ecosystem: npm
  - language: javascript
  - moduleSystem: cjs
  - packageManager: npm@10.9.8
  - runtime: node@22.23.2

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:b9503373a7bbaf4f6c818b5db18f093bd918d616e9031d49c5293c60c7a36709","constraints":{"executionContext":"node"},"contract":["objectAssign mutates and returns the target object","objectAssign merges own enumerable properties from multiple source objects with later sources overriding earlier ones","objectAssign ignores null and undefined sources without throwing","objectAssign throws TypeError when target is null or undefined","objectAssign supports Symbol properties from source objects","objectAssign treats string primitives as objects with indexed enumerable properties while ignoring other primitives"],"goal":"verify pkg:npm/object-assign@4.1.1","kind":"HOW","packages":["pkg:npm/object-assign@4.1.1"],"schemaVersion":1},"contractCommand":["node","test/contract.js"],"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","verifierAdapter":"node-typescript@1"}
package-lock.json
{
  "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"
      }
    }
  }
}
package.json
{
  "name": "sample-object-assign",
  "version": "1.0.0",
  "private": true,
  "description": "Clean-room verification sample for object-assign",
  "main": "src/index.js",
  "scripts": {
    "test": "node test/contract.js"
  },
  "dependencies": {
    "object-assign": "4.1.1"
  },
  "license": "MIT-0"
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify pkg:npm/object-assign@4.1.1",
  "kind": "HOW",
  "packages": [
    "pkg:npm/object-assign@4.1.1"
  ],
  "constraints": {
    "executionContext": "node"
  },
  "runtimeConditions": {
    "ecosystem": "npm",
    "language": "javascript",
    "moduleSystem": "cjs",
    "packageManager": "npm@10.9.8",
    "runtime": "node@22.23.2"
  }
}
src/index.js
'use strict';

const objectAssign = require('object-assign');

/**
 * Merges source objects into target object using object-assign.
 * @param {object} target
 * @param {...object} sources
 * @returns {object}
 */
function mergeObjects(target, ...sources) {
  return objectAssign(target, ...sources);
}

module.exports = {
  objectAssign,
  mergeObjects
};
test/contract.js
'use strict';

const assert = require('assert');
const objectAssign = require('object-assign');
const { mergeObjects } = require('../src/index.js');

// 1. objectAssign mutates and returns the target object
{
  const target = { a: 1 };
  const result = objectAssign(target, { b: 2 });
  assert.strictEqual(result, target);
  assert.strictEqual(target.a, 1);
  assert.strictEqual(target.b, 2);

  const target2 = { x: 10 };
  const result2 = mergeObjects(target2, { y: 20 });
  assert.strictEqual(result2, target2);
  assert.strictEqual(target2.x, 10);
  assert.strictEqual(target2.y, 20);
}

// 2. objectAssign merges own enumerable properties from multiple source objects with later sources overriding earlier ones
{
  const target = { a: 1, b: 1 };
  const src1 = { b: 2, c: 2 };
  const src2 = { c: 3, d: 4 };
  const result = objectAssign(target, src1, src2);

  assert.deepStrictEqual(result, { a: 1, b: 2, c: 3, d: 4 });
  assert.strictEqual(target.a, 1);
  assert.strictEqual(target.b, 2);
  assert.strictEqual(target.c, 3);
  assert.strictEqual(target.d, 4);
}

// 3. objectAssign ignores null and undefined sources without throwing
{
  const target = { a: 1 };
  const result = objectAssign(target, null, undefined, { b: 2 }, undefined, null);
  assert.strictEqual(result, target);
  assert.deepStrictEqual(result, { a: 1, b: 2 });
}

// 4. objectAssign throws TypeError when target is null or undefined
{
  assert.throws(
    () => {
      objectAssign(null, { a: 1 });
    },
    {
      name: 'TypeError'
    }
  );

  assert.throws(
    () => {
      objectAssign(undefined, { a: 1 });
    },
    {
      name: 'TypeError'
    }
  );
}

// 5. objectAssign supports Symbol properties from source objects
{
  const symA = Symbol('symA');
  const symB = Symbol('symB');
  const target = {};
  const src = { [symA]: 'valueA', [symB]: 'valueB', normal: 'regular' };

  const result = objectAssign(target, src);
  assert.strictEqual(result[symA], 'valueA');
  assert.strictEqual(result[symB], 'valueB');
  assert.strictEqual(result.normal, 'regular');
}

// 6. objectAssign treats string primitives as objects with indexed enumerable properties while ignoring other primitives
{
  const target = {};
  const result = objectAssign(target, 42, true, 'foo', Symbol('test'));
  assert.strictEqual(result['0'], 'f');
  assert.strictEqual(result['1'], 'o');
  assert.strictEqual(result['2'], 'o');
}

console.log('Contract tests passed successfully.');

Seeder de origem

anônimo