CodeSampleX

Пример

dunder-proto 1.0.1: get, set

Проверенный пример — npm dunder-proto 1.0.1: get, set. Контракт выполнен на node 22 · linux alpine/x64 · docker и пройден: dunder-proto/get retrieves…

sha256:5101f9e9fef0b102924b4708e82147a68aa3fdc3737fbb423873373554c8a60a

Эта сеть предлагает одно: образец, который собирается. Она запустила его в песочнице и сохранила подписанную квитанцию. Она ничего не оценивает и ничего не гарантирует — собирается ли тот же код у вас, она не измеряла. Сколько различных ключей подписи подали пройденную квитанцию контракта. Один — только автор; больше одного — значит, кто-то ещё тоже собрал. Ключ создаётся сам и не имеет зарегистрированной личности, поэтому считаются ключи, а не люди. 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/dunder-proto@1.0.1
Пакеты
Символы
  • dunder-proto/get
  • dunder-proto/set
Создан
2026-08-18T18:05:31Z

Контракт

  1. dunder-proto/get retrieves prototype of standard objects and primitives
  2. dunder-proto/set mutates prototype of extensible objects
  3. dunder-proto/set throws TypeError when called on null or undefined

Файлы

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

Скачать артефакт с исходным кодом (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/dunder-proto@1.0.1
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:npm/dunder-proto@1.0.1
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:29a03fead6d816f65cc883f240b0707c5953e758e1986b96dc50239d280da0dc","constraints":{"executionContext":"node"},"contract":["dunder-proto/get retrieves prototype of standard objects and primitives","dunder-proto/set mutates prototype of extensible objects","dunder-proto/set throws TypeError when called on null or undefined"],"goal":"verify pkg:npm/dunder-proto@1.0.1","kind":"HOW","packages":["pkg:npm/dunder-proto@1.0.1"],"schemaVersion":1,"symbols":["dunder-proto/get","dunder-proto/set"]},"contractCommand":["node","test/contract.js"],"environment":{"arch":"x64","ecosystem":"npm","os":"windows","osVersionBucket":"11","packageManager":"npm","schemaVersion":1},"license":"MIT-0","packages":["pkg:npm/dunder-proto@1.0.1"],"schemaVersion":1,"symbols":["dunder-proto/get","dunder-proto/set"],"verifierAdapter":"node-typescript@1"}
index.js
const getDunder = require('dunder-proto/get');
const setDunder = require('dunder-proto/set');

/**
 * Get the [[Prototype]] of a value using dunder-proto.
 * @param {*} value
 * @returns {object | null}
 */
function getPrototype(value) {
  return getDunder(value);
}

/**
 * Set the [[Prototype]] of an object using dunder-proto.
 * @param {object} object
 * @param {object | null} proto
 * @returns {object | null}
 */
function setPrototype(object, proto) {
  return setDunder(object, proto);
}

module.exports = {
  getPrototype,
  setPrototype
};
package-lock.json
{
  "name": "sample",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "sample",
      "version": "1.0.0",
      "dependencies": {
        "dunder-proto": "1.0.1"
      }
    },
    "node_modules/call-bind-apply-helpers": {
      "version": "1.0.2",
      "resolved": "https://registry.npmjs.org/call-bind-apply-helpers/-/call-bind-apply-helpers-1.0.2.tgz",
      "integrity": "sha512-Sp1ablJ0ivDkSzjcaJdxEunN5/XvksFJ2sMBFfq6x0ryhQV/2b/KwFe21cMpmHtPOSij8K99/wSfoEuTObmuMQ==",
      "license": "MIT",
      "dependencies": {
        "es-errors": "^1.3.0",
        "function-bind": "^1.1.2"
      },
      "engines": {
        "node": ">= 0.4"
      }
    },
    "node_modules/dunder-proto": {
      "version": "1.0.1",
      "resolved": "https://registry.npmjs.org/dunder-proto/-/dunder-proto-1.0.1.tgz",
      "integrity": "sha512-KIN/nDJBQRcXw0MLVhZE9iQHmG68qAVIBg9CqmUYjmQIhgij9U5MFvrqkUL5FbtyyzZuOeOt0zdeRe4UY7ct+A==",
      "license": "MIT",
      "dependencies": {
        "call-bind-apply-helpers": "^1.0.1",
        "es-errors": "^1.3.0",
        "gopd": "^1.2.0"
      },
      "engines": {
        "node": ">= 0.4"
      }
    },
    "node_modules/es-errors": {
      "version": "1.3.0",
      "resolved": "https://registry.npmjs.org/es-errors/-/es-errors-1.3.0.tgz",
      "integrity": "sha512-Zf5H2Kxt2xjTvbJvP2ZWLEICxA6j+hAmMzIlypy4xcBg1vKVnx89Wy0GbS+kf5cwCVFFzdCFh2XSCFNULS6csw==",
      "license": "MIT",
      "engines": {
        "node": ">= 0.4"
      }
    },
    "node_modules/function-bind": {
      "version": "1.1.2",
      "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.2.tgz",
      "integrity": "sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA==",
      "license": "MIT",
      "funding": {
        "url": "https://github.com/sponsors/ljharb"
      }
    },
    "node_modules/gopd": {
      "version": "1.2.0",
      "resolved": "https://registry.npmjs.org/gopd/-/gopd-1.2.0.tgz",
      "integrity": "sha512-ZUKRh6/kUFoAiTAtTYPZJ3hw9wNxx+BIBOijnlG9PnrJsCcSjs1wyyD6vJpaYtgnzDrKYRSqf3OO6Rfa93xsRg==",
      "license": "MIT",
      "engines": {
        "node": ">= 0.4"
      },
      "funding": {
        "url": "https://github.com/sponsors/ljharb"
      }
    }
  }
}
package.json
{
  "name": "sample",
  "version": "1.0.0",
  "dependencies": {
    "dunder-proto": "1.0.1"
  }
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify pkg:npm/dunder-proto@1.0.1",
  "kind": "HOW",
  "packages": [
    "pkg:npm/dunder-proto@1.0.1"
  ],
  "constraints": {
    "executionContext": "node"
  },
  "runtimeConditions": {
    "ecosystem": "npm",
    "language": "javascript",
    "moduleSystem": "cjs",
    "packageManager": "npm@11.8.0",
    "runtime": "node@24.13.1"
  }
}
test/contract.js
const assert = require('node:assert/strict');
const getDunder = require('dunder-proto/get');
const setDunder = require('dunder-proto/set');

// Contract 1: dunder-proto/get retrieves prototype of standard objects and primitives
{
  const obj = {};
  assert.equal(getDunder(obj), Object.prototype);

  const nullObj = Object.create(null);
  assert.equal(getDunder(nullObj), null);

  assert.equal(getDunder('hello'), String.prototype);
  assert.equal(getDunder(42), Number.prototype);
}

// Contract 2: dunder-proto/set mutates prototype of extensible objects
{
  const parent = {
    greeting: 'hello world',
    greet() {
      return this.greeting;
    }
  };
  const child = { name: 'child' };

  setDunder(child, parent);
  assert.equal(getDunder(child), parent);
  assert.equal(child.greet(), 'hello world');

  setDunder(child, null);
  assert.equal(getDunder(child), null);
  assert.equal(child.toString, undefined);
}

// Contract 3: dunder-proto/set throws TypeError when called on null or undefined
{
  const proto = { test: true };
  assert.throws(
    () => setDunder(null, proto),
    (err) => err instanceof TypeError
  );
  assert.throws(
    () => setDunder(undefined, proto),
    (err) => err instanceof TypeError
  );
}

console.log('All dunder-proto contract assertions passed successfully.');

Исходный сидер

аноним