CodeSampleX

サンプル

@babel/runtime 7.29.15: mark

検証済みサンプル — npm @babel/runtime 7.29.15: mark. node 22 · linux debian/x64 · docker で contract を実行し、成功しました: require('@babel/runtime') throws…

sha256:9839300e0c51a63ce177b0ea6f859e25af90e31b6a6c5bf0a8aa194b13d1ca80

このネットワークが提供するのは一つだけです。ビルドされるサンプル。サンドボックスで実行し、署名済みの受領証を保管します。等級はつけず、何も保証しません — 同じコードがあなたの環境でビルドされるかは測定していません。 合格した契約受領証を提出した異なる署名鍵の数です。1 なら作者だけ、2 以上なら他の誰かもビルドしています。鍵は自己生成で背後に登録された身元がないため、数えているのは人ではなく鍵です。 MIT-0

実行証拠

宣言された環境と署名済みの実行を分けてあります。このサンプルが何をどこで実行したかをそのまま確認できます。

証拠の基準
署名済みコントラクト合格
検証レシート
1
ビルドした署名鍵
1
宣言された環境 node 22.23 linux 24 · ubuntu · glibc 2.39 x64 node 22.23 javascript npm 10

検証実行環境

環境 コントラクト ステージ 実行日
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-11-21

ケース

HOW
ゴール
verify @babel/runtime.mark in pkg:npm/%40babel/runtime@7.29.15
パッケージ
シンボル
  • @babel/runtime.mark
環境
node 22.23.2
作成日
2026-11-21T23:06:56Z

コントラクト

  1. require('@babel/runtime') throws ERR_PACKAGE_PATH_NOT_EXPORTED; mark is exposed via @babel/runtime/regenerator and @babel/runtime/helpers/regeneratorRuntime
  2. regeneratorRuntime.mark is identical to require('@babel/runtime/helpers/regeneratorRuntime')().mark
  3. regeneratorRuntime.mark(fn) returns fn in place, makes regeneratorRuntime.isGeneratorFunction(fn) true, sets Object.prototype.toString.call(fn) to '[object GeneratorFunction]', and installs Generator prototype methods on fn.prototype
  4. calling a marked generator returns an iterable Generator instance (instanceof marked, Symbol.iterator returns self, toString is '[object Generator]')
  5. generator instances support next() with sent values, Array.from/for..of iteration, early return(value), and throw(err) termination
  6. regeneratorRuntime.mark(null) throws TypeError

ファイル

  • 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 @babel/runtime.mark in pkg:npm/%40babel/runtime@7.29.15
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:npm/%40babel/runtime@7.29.15
Demonstrate these symbols/APIs:
  - @babel/runtime.mark
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:d60f763eceadb963a9ccd27a7b4e1c4d7b5f2cf91fbd435467f9fda17cd522d2","constraints":{"executionContext":"node"},"contract":["require('@babel/runtime') throws ERR_PACKAGE_PATH_NOT_EXPORTED; mark is exposed via @babel/runtime/regenerator and @babel/runtime/helpers/regeneratorRuntime","regeneratorRuntime.mark is identical to require('@babel/runtime/helpers/regeneratorRuntime')().mark","regeneratorRuntime.mark(fn) returns fn in place, makes regeneratorRuntime.isGeneratorFunction(fn) true, sets Object.prototype.toString.call(fn) to '[object GeneratorFunction]', and installs Generator prototype methods on fn.prototype","calling a marked generator returns an iterable Generator instance (instanceof marked, Symbol.iterator returns self, toString is '[object Generator]')","generator instances support next() with sent values, Array.from/for..of iteration, early return(value), and throw(err) termination","regeneratorRuntime.mark(null) throws TypeError"],"goal":"verify @babel/runtime.mark in pkg:npm/%40babel/runtime@7.29.15","kind":"HOW","packages":["pkg:npm/%40babel/runtime@7.29.15"],"schemaVersion":1,"symbols":["@babel/runtime.mark"]},"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/%40babel/runtime@7.29.15"],"schemaVersion":1,"subject":"pkg:npm/%40babel/runtime@7.29.15","symbols":["@babel/runtime.mark"],"verifierAdapter":"node-typescript@1"}
index.js
"use strict";

const regeneratorRuntime = require("@babel/runtime/regenerator");
const getRegeneratorRuntime = require("@babel/runtime/helpers/regeneratorRuntime");

function createCounterGeneratorFactory() {
  const marked = regeneratorRuntime.mark(function counter(start, end) {
    let current;
    let step;
    return regeneratorRuntime.wrap(function counter$(ctx) {
      while (true) {
        switch ((ctx.prev = ctx.next)) {
          case 0:
            current = start;
          case 1:
            if (!(current <= end)) {
              ctx.next = 7;
              break;
            }
            ctx.next = 4;
            return current;
          case 4:
            step = ctx.sent;
            current += typeof step === "number" ? step : 1;
            ctx.next = 1;
            break;
          case 7:
            return ctx.abrupt("return", current);
          case 8:
          case "end":
            return ctx.stop();
        }
      }
    }, marked);
  });

  return marked;
}

module.exports = {
  regeneratorRuntime,
  getRegeneratorRuntime,
  createCounterGeneratorFactory,
};
package-lock.json
{
  "name": "babel-runtime-mark-sample",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "babel-runtime-mark-sample",
      "version": "1.0.0",
      "dependencies": {
        "@babel/runtime": "7.29.15"
      }
    },
    "node_modules/@babel/runtime": {
      "version": "7.29.15",
      "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.29.15.tgz",
      "integrity": "sha512-304gsbbGVmQc+cNGHzwHBlqepYdWLKj3VXCQBGt/EGcV7PUPfKI7kAUNW1FZEOCwlQiLvQjg1JEaAlRQ616h+Q==",
      "license": "MIT",
      "engines": {
        "node": ">=6.9.0"
      }
    }
  }
}
package.json
{
  "name": "babel-runtime-mark-sample",
  "version": "1.0.0",
  "private": true,
  "description": "Minimal verification of @babel/runtime.mark via @babel/runtime/regenerator",
  "main": "index.js",
  "scripts": {
    "test": "node test/contract.js"
  },
  "dependencies": {
    "@babel/runtime": "7.29.15"
  }
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify @babel/runtime.mark in pkg:npm/%40babel/runtime@7.29.15",
  "kind": "HOW",
  "packages": [
    "pkg:npm/%40babel/runtime@7.29.15"
  ],
  "symbols": [
    "@babel/runtime.mark"
  ],
  "constraints": {
    "executionContext": "node"
  },
  "runtimeConditions": {
    "ecosystem": "npm",
    "language": "javascript",
    "moduleSystem": "cjs",
    "packageManager": "npm@10.9.8",
    "runtime": "node@22.23.2"
  }
}
test/contract.js
"use strict";

const assert = require("node:assert/strict");
const {
  regeneratorRuntime,
  getRegeneratorRuntime,
  createCounterGeneratorFactory,
} = require("../index.js");

// 1. Root import is not exported; mark must be accessed via subpath exports.
assert.throws(
  () => require("@babel/runtime"),
  (err) => err && err.code === "ERR_PACKAGE_PATH_NOT_EXPORTED"
);

// 2. Subpath exports expose the same mark function.
const helperRuntime = getRegeneratorRuntime();
assert.equal(typeof regeneratorRuntime.mark, "function");
assert.equal(regeneratorRuntime.mark, helperRuntime.mark);

// 3. mark() mutates and returns the target function with GeneratorFunction prototype and Generator.prototype.
function plainFn() {}
assert.equal(regeneratorRuntime.isGeneratorFunction(plainFn), false);

function rawFn() {
  return regeneratorRuntime.wrap(function rawFn$(ctx) {
    switch ((ctx.prev = ctx.next)) {
      case 0:
        return ctx.stop();
    }
  }, rawFn);
}
const markedRaw = regeneratorRuntime.mark(rawFn);
assert.equal(markedRaw, rawFn);
assert.equal(regeneratorRuntime.isGeneratorFunction(markedRaw), true);
assert.equal(
  Object.prototype.toString.call(markedRaw),
  "[object GeneratorFunction]"
);
assert.equal(typeof markedRaw.prototype.next, "function");
assert.equal(typeof markedRaw.prototype.throw, "function");
assert.equal(typeof markedRaw.prototype.return, "function");

// 4. Calling a marked generator produces a Generator instance inheriting from marked.prototype.
const counterGen = createCounterGeneratorFactory();
assert.equal(regeneratorRuntime.isGeneratorFunction(counterGen), true);

const iter = counterGen(1, 5);
assert.equal(iter instanceof counterGen, true);
assert.equal(Object.getPrototypeOf(iter), counterGen.prototype);
assert.equal(Object.prototype.toString.call(iter), "[object Generator]");
assert.equal(iter[Symbol.iterator](), iter);

// 5. Stepping with next() yields values, receives sent values, and completes with the return value.
assert.deepEqual(iter.next(), { value: 1, done: false });
assert.deepEqual(iter.next(2), { value: 3, done: false });
assert.deepEqual(iter.next(2), { value: 5, done: false });
assert.deepEqual(iter.next(1), { value: 6, done: true });
assert.deepEqual(iter.next(), { value: undefined, done: true });

// 6. Standard for..of iteration works over the marked generator.
assert.deepEqual(Array.from(counterGen(2, 4)), [2, 3, 4]);

// 7. Early return() terminates the generator and returns the provided completion value.
const earlyReturnIter = counterGen(10, 20);
assert.deepEqual(earlyReturnIter.next(), { value: 10, done: false });
assert.deepEqual(earlyReturnIter.return("stopped"), {
  value: "stopped",
  done: true,
});
assert.deepEqual(earlyReturnIter.next(), { value: undefined, done: true });

// 8. throw() propagates the error and closes the generator.
const throwingIter = counterGen(1, 3);
assert.deepEqual(throwingIter.next(), { value: 1, done: false });
assert.throws(
  () => throwingIter.throw(new Error("injected failure")),
  /injected failure/
);
assert.deepEqual(throwingIter.next(), { value: undefined, done: true });

// 9. Passing a non-object (such as null) to mark() throws a TypeError.
assert.throws(() => regeneratorRuntime.mark(null), TypeError);

オリジンシーダー

匿名