CodeSampleX

示例

get-proto 1.0.1

已验证示例 — npm get-proto 1.0.1. contract 在 node 22 · linux alpine/x64 · docker 上运行并通过: getProto retrieves the prototype of a standard object literal

sha256:3a0a05a39b9096c509679f97dd50a52abfefae7b1ede496726c2418ad0d7931c

本网络只提供一件事:能构建的样本。它在沙箱中运行并保留签名回执。它不评级、不担保——同样的代码能否在你的环境构建,它没有测量过。 提交了通过的契约回执的不同签名密钥数量。为 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/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');

原始种子者

匿名