CodeSampleX

示例

@babel/runtime 7.29.7

已验证示例 — npm @babel/runtime 7.29.7. contract 在 node 22 · linux alpine/x64 · docker 上运行并通过: assert _typeof correctly identifies primitives, objects, and symbols

sha256:39e1c5c7acbf92e2982a833c1ee7e0cf622d22b63d12e8e165c4e8990ce6d781

本网络只提供一件事:能构建的样本。它在沙箱中运行并保留签名回执。它不评级、不担保——同样的代码能否在你的环境构建,它没有测量过。 提交了通过的契约回执的不同签名密钥数量。为 1 表示只有作者;大于 1 表示还有其他人构建过。密钥是自行生成的,背后没有注册身份,因此计的是密钥而非人。 MIT-0

执行证据

声明的环境与签名的运行分开呈现,你可以看到这个样本究竟运行了什么、在哪里运行。

证据依据
签名契约通过
验证回执
1
构建过它的签名密钥
1
声明的环境 linux 24 · ubuntu · glibc 2.39 x64 npm

验证运行环境

环境 契约 阶段 运行日期
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-28

案例

HOW
目标
verify pkg:npm/@babel/runtime@7.29.7
包
创建时间
2026-08-28T07:47:33Z

契约

  1. assert _typeof correctly identifies primitives, objects, and symbols
  2. assert _objectSpread2 merges object properties and symbol keys
  3. assert _toConsumableArray converts iterables and sets into arrays
  4. assert _slicedToArray extracts elements from iterables and arrays
  5. assert _classCallCheck throws TypeError when constructor is called without new
  6. assert _createClass attaches instance methods to prototype and static methods to constructor
  7. assert _interopRequireDefault handles ES module default export and CommonJS wrappers
  8. assert regeneratorRuntime provides generator helper methods mark and wrap

文件

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

下载源代码构件 (tar.gz)

源代码

NOTES.md
# @babel/runtime Helper Notes

`@babel/runtime` provides modular runtime helpers used by Babel plugins when compiling ES2015+ features:
- `helpers/typeof`: Ensures Symbol and primitive type detection behaves consistently across environments.
- `helpers/objectSpread2`: Implements ES object spread syntax (`...obj`) preserving property descriptors and symbols.
- `helpers/toConsumableArray`: Implements array spread syntax for iterables and sets.
- `helpers/slicedToArray`: Implements array destructuring (`const [a, b] = iterable`).
- `helpers/classCallCheck`: Enforces that constructor functions cannot be invoked without `new`.
- `helpers/createClass`: Configures prototype methods and static properties with proper descriptor flags.
- `helpers/interopRequireDefault`: Normalizes default import semantics across ESM and CommonJS modules.
- `regenerator`: Exposes the regenerator runtime for generator function transformation.
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/@babel/runtime@7.29.7
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:npm/%40babel/runtime@7.29.7

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:78effb58ee4de1dd4adec247c3f51ae04f26c996564d1c07a80d7ecaf232de2b","contract":["assert _typeof correctly identifies primitives, objects, and symbols","assert _objectSpread2 merges object properties and symbol keys","assert _toConsumableArray converts iterables and sets into arrays","assert _slicedToArray extracts elements from iterables and arrays","assert _classCallCheck throws TypeError when constructor is called without new","assert _createClass attaches instance methods to prototype and static methods to constructor","assert _interopRequireDefault handles ES module default export and CommonJS wrappers","assert regeneratorRuntime provides generator helper methods mark and wrap"],"goal":"verify pkg:npm/@babel/runtime@7.29.7","kind":"HOW","packages":["pkg:npm/%40babel/runtime@7.29.7"],"schemaVersion":1},"contractCommand":["node","test/contract.mjs"],"environment":{"arch":"x64","distro":"ubuntu","ecosystem":"npm","libc":"glibc","libcVersion":"2.39","os":"linux","osVersionBucket":"24","packageManager":"npm","schemaVersion":1},"license":"MIT-0","packages":["pkg:npm/%40babel/runtime@7.29.7"],"schemaVersion":1,"subject":"pkg:npm/%40babel/runtime@7.29.7","verifierAdapter":"node-typescript@1"}
package-lock.json
{
  "name": "npm-babel-runtime-contract",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "npm-babel-runtime-contract",
      "version": "1.0.0",
      "license": "MIT-0",
      "dependencies": {
        "@babel/runtime": "7.29.7"
      }
    },
    "node_modules/@babel/runtime": {
      "version": "7.29.7",
      "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.29.7.tgz",
      "integrity": "sha512-Nq8OhGWiZIZGV6hLHoyAKLLcJihP/xFeBMGJoUrxTX2psI8dCifzLhZISFb+VWS3wFMRDmCGw5R+dOySCqPLhw==",
      "license": "MIT",
      "engines": {
        "node": ">=6.9.0"
      }
    }
  }
}
package.json
{
  "name": "npm-babel-runtime-contract",
  "version": "1.0.0",
  "private": true,
  "type": "module",
  "license": "MIT-0",
  "scripts": {
    "test": "node test/contract.mjs"
  },
  "dependencies": {
    "@babel/runtime": "7.29.7"
  }
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify pkg:npm/@babel/runtime@7.29.7",
  "kind": "HOW",
  "packages": [
    "pkg:npm/%40babel/runtime@7.29.7"
  ]
}
test/contract.mjs
import assert from 'node:assert/strict';
import _typeof from '@babel/runtime/helpers/typeof';
import _objectSpread2 from '@babel/runtime/helpers/objectSpread2';
import _toConsumableArray from '@babel/runtime/helpers/toConsumableArray';
import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
import _classCallCheck from '@babel/runtime/helpers/classCallCheck';
import _createClass from '@babel/runtime/helpers/createClass';
import _interopRequireDefault from '@babel/runtime/helpers/interopRequireDefault';
import regeneratorRuntime from '@babel/runtime/regenerator';

// 1. _typeof correctly identifies primitives, objects, and symbols
assert.equal(_typeof('hello'), 'string');
assert.equal(_typeof(42), 'number');
assert.equal(_typeof(Symbol('sym')), 'symbol');
assert.equal(_typeof({ key: 'val' }), 'object');
assert.equal(_typeof(null), 'object');
assert.equal(_typeof(undefined), 'undefined');

// 2. _objectSpread2 merges object properties and symbol keys
const symKey = Symbol('custom');
const sourceObj = { b: 2, [symKey]: 'secret' };
const targetObj = { a: 1 };
const merged = _objectSpread2(targetObj, sourceObj);
assert.equal(merged.a, 1);
assert.equal(merged.b, 2);
assert.equal(merged[symKey], 'secret');

// 3. _toConsumableArray converts iterables and sets into arrays
const set = new Set(['alpha', 'beta', 'gamma']);
const arrayFromSet = _toConsumableArray(set);
assert.deepEqual(arrayFromSet, ['alpha', 'beta', 'gamma']);
assert.ok(Array.isArray(arrayFromSet));

// 4. _slicedToArray extracts elements from iterables and arrays
const iterable = new Set([10, 20, 30]);
const slicedIterable = _slicedToArray(iterable, 2);
assert.deepEqual(slicedIterable, [10, 20]);

const arrayInput = [10, 20, 30];
const slicedArray = _slicedToArray(arrayInput, 2);
assert.equal(slicedArray[0], 10);
assert.equal(slicedArray[1], 20);

// 5. _classCallCheck throws TypeError when constructor is called without new
function DemoClass() {
  _classCallCheck(this, DemoClass);
}
assert.doesNotThrow(() => new DemoClass());
assert.throws(
  () => {
    DemoClass.call({});
  },
  {
    name: 'TypeError',
    message: 'Cannot call a class as a function',
  }
);

// 6. _createClass attaches instance methods to prototype and static methods to constructor
_createClass(
  DemoClass,
  [
    {
      key: 'instanceMethod',
      value: function () {
        return 'instance result';
      },
    },
  ],
  [
    {
      key: 'staticMethod',
      value: function () {
        return 'static result';
      },
    },
  ]
);
const instance = new DemoClass();
assert.equal(instance.instanceMethod(), 'instance result');
assert.equal(DemoClass.staticMethod(), 'static result');

// 7. _interopRequireDefault handles ES module default export and CommonJS wrappers
const esmModule = { __esModule: true, default: { greeting: 'hello' } };
assert.deepEqual(_interopRequireDefault(esmModule), esmModule);

const cjsModule = { greeting: 'hello' };
assert.deepEqual(_interopRequireDefault(cjsModule), { default: cjsModule });

// 8. regeneratorRuntime provides generator helper methods mark and wrap
assert.ok(regeneratorRuntime);
assert.equal(typeof regeneratorRuntime.mark, 'function');
assert.equal(typeof regeneratorRuntime.wrap, 'function');

console.log('babel-runtime.contract.pass');

原始种子者

匿名