CodeSampleX

Пример

get-proto 1.0.1

Проверенный пример — npm get-proto 1.0.1. Контракт выполнен на node 22 · linux alpine/x64 · docker и пройден: getProto retrieves the prototype of a standard…

sha256:3a0a05a39b9096c509679f97dd50a52abfefae7b1ede496726c2418ad0d7931c

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

Контракт

  1. getProto retrieves the prototype of a standard object literal
  2. getProto returns null for an object created with null prototype
  3. getProto traverses inheritance chain for custom prototype links
  4. getProto resolves class instance and derived class prototype links
  5. getProto retrieves built-in array and function prototypes
  6. wrapper function checkPrototype matches direct getProto behavior

Файлы

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

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

Use EXACTLY these public packages and versions:
  - pkg:npm/get-proto@1.0.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:40d1bef46cdee594dd8eca75a06cd2ad75719dc9142360da03e923054044cfa8","contract":["getProto retrieves the prototype of a standard object literal","getProto returns null for an object created with null prototype","getProto traverses inheritance chain for custom prototype links","getProto resolves class instance and derived class prototype links","getProto retrieves built-in array and function prototypes","wrapper function checkPrototype matches direct getProto behavior"],"goal":"verify pkg:npm/get-proto@1.0.1","kind":"HOW","packages":["pkg:npm/get-proto@1.0.1"],"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/get-proto@1.0.1"],"schemaVersion":1,"verifierAdapter":"node-typescript@1"}
index.mjs
import getProto from 'get-proto';

/**
 * Retrieves the prototype of the provided object.
 * @param {object} obj
 * @returns {object | null}
 */
export function checkPrototype(obj) {
  return getProto(obj);
}

export default getProto;
package-lock.json
{
  "name": "sample",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "sample",
      "version": "1.0.0",
      "dependencies": {
        "get-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/es-object-atoms": {
      "version": "1.1.2",
      "resolved": "https://registry.npmjs.org/es-object-atoms/-/es-object-atoms-1.1.2.tgz",
      "integrity": "sha512-HWcBoN6NileqtSydK2FqHbS/LoDd2pqrnQHLyJzBj4kOp/ky2MWMN694xOfkK8/SnUsW2DH7EfyVlydKCsm1Zw==",
      "license": "MIT",
      "dependencies": {
        "es-errors": "^1.3.0"
      },
      "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/get-proto": {
      "version": "1.0.1",
      "resolved": "https://registry.npmjs.org/get-proto/-/get-proto-1.0.1.tgz",
      "integrity": "sha512-sTSfBjoXBp89JvIKIefqw7U2CCebsc74kiY6awiGogKtoSGbgjYE/G/+l9sF3MWFPNc9IcoOC4ODfKHfxFmp0g==",
      "license": "MIT",
      "dependencies": {
        "dunder-proto": "^1.0.1",
        "es-object-atoms": "^1.0.0"
      },
      "engines": {
        "node": ">= 0.4"
      }
    },
    "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",
  "type": "module",
  "dependencies": {
    "get-proto": "1.0.1"
  }
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify pkg:npm/get-proto@1.0.1",
  "kind": "HOW",
  "packages": [
    "pkg:npm/get-proto@1.0.1"
  ]
}
test/contract.mjs
import assert from 'node:assert/strict';
import getProto from 'get-proto';
import { checkPrototype } from '../index.mjs';

// Case 1: getProto retrieves the prototype of a standard object literal
{
  const obj = { foo: 'bar' };
  const proto = getProto(obj);
  assert.equal(proto, Object.prototype, 'prototype of standard object should be Object.prototype');
}

// Case 2: getProto returns null for an object created with null prototype
{
  const nullProtoObj = Object.create(null);
  const proto = getProto(nullProtoObj);
  assert.equal(proto, null, 'prototype of null-prototype object should be null');
}

// Case 3: getProto traverses inheritance chain for custom prototype links
{
  const parent = { role: 'base' };
  const child = Object.create(parent);
  assert.equal(getProto(child), parent, 'prototype of child should be parent object');
  assert.equal(getProto(parent), Object.prototype, 'prototype of parent should be Object.prototype');
}

// Case 4: getProto resolves class instance and derived class prototype links
{
  class BaseEntity {}
  class UserEntity extends BaseEntity {}

  const user = new UserEntity();
  assert.equal(getProto(user), UserEntity.prototype, 'instance prototype should be UserEntity.prototype');
  assert.equal(getProto(UserEntity.prototype), BaseEntity.prototype, 'UserEntity prototype should be BaseEntity.prototype');
  assert.equal(getProto(BaseEntity.prototype), Object.prototype, 'BaseEntity prototype should be Object.prototype');
  assert.equal(getProto(UserEntity), BaseEntity, 'UserEntity class constructor prototype should be BaseEntity');
}

// Case 5: getProto retrieves built-in array and function prototypes
{
  const list = [10, 20, 30];
  assert.equal(getProto(list), Array.prototype, 'prototype of array should be Array.prototype');

  const fn = function testFunction() {};
  assert.equal(getProto(fn), Function.prototype, 'prototype of function should be Function.prototype');
}

// Case 6: wrapper function checkPrototype matches direct getProto behavior
{
  const sampleObj = { greeting: 'hello' };
  assert.equal(checkPrototype(sampleObj), getProto(sampleObj), 'checkPrototype wrapper should match direct getProto');
}

console.log('PASS: all get-proto contract assertions passed');

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

аноним