CodeSampleX

Пример

degenerator 5.0.1

Проверенный пример — npm degenerator 5.0.1. Контракт выполнен на node 22 · linux alpine/x64 · docker и пройден: degenerator converts synchronous function…

sha256:84c726c76ef6a7504433d61bf052f3e32a0ddb61073cca020a7a0f5e3cbd2c51

Эта сеть предлагает одно: образец, который собирается. Она запустила его в песочнице и сохранила подписанную квитанцию. Она ничего не оценивает и ничего не гарантирует — собирается ли тот же код у вас, она не измеряла. Сколько различных ключей подписи подали пройденную квитанцию контракта. Один — только автор; больше одного — значит, кто-то ещё тоже собрал. Ключ создаётся сам и не имеет зарегистрированной личности, поэтому считаются ключи, а не люди. 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-23

Кейс

HOW
Цель
verify pkg:npm/degenerator@5.0.1
Пакеты
Создан
2026-08-23T15:44:45Z

Контракт

  1. degenerator converts synchronous function calling specified function to async function with await expression
  2. degenerator leaves synchronous functions unchanged when no matching functions are called
  3. degenerator matches function names using regular expression patterns
  4. degenerator cascades async conversion to caller functions when a called function becomes async
  5. degenerator tracks variable alias assignments and injects await for calls via aliased names
  6. degenerator supports member expression call targets such as object method invocations
  7. degenerator throws TypeError when names argument is not an array
  8. transformed code executes asynchronously and resolves awaited promise return value

Файлы

  • PROMPT.md
  • csx.json
  • 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/degenerator@5.0.1
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:npm/degenerator@5.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:7dfeae59a38e18916497309c1cf32305de4e84fd87b08e0c64f9c5391c43c589","contract":["degenerator converts synchronous function calling specified function to async function with await expression","degenerator leaves synchronous functions unchanged when no matching functions are called","degenerator matches function names using regular expression patterns","degenerator cascades async conversion to caller functions when a called function becomes async","degenerator tracks variable alias assignments and injects await for calls via aliased names","degenerator supports member expression call targets such as object method invocations","degenerator throws TypeError when names argument is not an array","transformed code executes asynchronously and resolves awaited promise return value"],"goal":"verify pkg:npm/degenerator@5.0.1","kind":"HOW","packages":["pkg:npm/degenerator@5.0.1"],"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/degenerator@5.0.1"],"schemaVersion":1,"subject":"pkg:npm/degenerator@5.0.1","verifierAdapter":"node-typescript@1"}
package-lock.json
{
  "name": "sample-degenerator",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "sample-degenerator",
      "version": "1.0.0",
      "dependencies": {
        "degenerator": "5.0.1"
      }
    },
    "node_modules/ast-types": {
      "version": "0.13.4",
      "resolved": "https://registry.npmjs.org/ast-types/-/ast-types-0.13.4.tgz",
      "integrity": "sha512-x1FCFnFifvYDDzTaLII71vG5uvDwgtmDTEVWAxrgeiR8VjMONcCXJx7E+USjDtHlwFmt9MysbqgF9b9Vjr6w+w==",
      "license": "MIT",
      "dependencies": {
        "tslib": "^2.0.1"
      },
      "engines": {
        "node": ">=4"
      }
    },
    "node_modules/degenerator": {
      "version": "5.0.1",
      "resolved": "https://registry.npmjs.org/degenerator/-/degenerator-5.0.1.tgz",
      "integrity": "sha512-TllpMR/t0M5sqCXfj85i4XaAzxmS5tVA16dqvdkMwGmzI+dXLXnw3J+3Vdv7VKw+ThlTMboK6i9rnZ6Nntj5CQ==",
      "license": "MIT",
      "dependencies": {
        "ast-types": "^0.13.4",
        "escodegen": "^2.1.0",
        "esprima": "^4.0.1"
      },
      "engines": {
        "node": ">= 14"
      }
    },
    "node_modules/escodegen": {
      "version": "2.1.0",
      "resolved": "https://registry.npmjs.org/escodegen/-/escodegen-2.1.0.tgz",
      "integrity": "sha512-2NlIDTwUWJN0mRPQOdtQBzbUHvdGY2P1VXSyU83Q3xKxM7WHX2Ql8dKq782Q9TgQUNOLEzEYu9bzLNj1q88I5w==",
      "license": "BSD-2-Clause",
      "dependencies": {
        "esprima": "^4.0.1",
        "estraverse": "^5.2.0",
        "esutils": "^2.0.2"
      },
      "bin": {
        "escodegen": "bin/escodegen.js",
        "esgenerate": "bin/esgenerate.js"
      },
      "engines": {
        "node": ">=6.0"
      },
      "optionalDependencies": {
        "source-map": "~0.6.1"
      }
    },
    "node_modules/esprima": {
      "version": "4.0.1",
      "resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz",
      "integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==",
      "license": "BSD-2-Clause",
      "bin": {
        "esparse": "bin/esparse.js",
        "esvalidate": "bin/esvalidate.js"
      },
      "engines": {
        "node": ">=4"
      }
    },
    "node_modules/estraverse": {
      "version": "5.3.0",
      "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-5.3.0.tgz",
      "integrity": "sha512-MMdARuVEQziNTeJD8DgMqmhwR11BRQ/cBP+pLtYdSTnf3MIO8fFeiINEbX36ZdNlfU/7A9f3gUw49B3oQsvwBA==",
      "license": "BSD-2-Clause",
      "engines": {
        "node": ">=4.0"
      }
    },
    "node_modules/esutils": {
      "version": "2.0.3",
      "resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.3.tgz",
      "integrity": "sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g==",
      "license": "BSD-2-Clause",
      "engines": {
        "node": ">=0.10.0"
      }
    },
    "node_modules/source-map": {
      "version": "0.6.1",
      "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz",
      "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==",
      "license": "BSD-3-Clause",
      "optional": true,
      "engines": {
        "node": ">=0.10.0"
      }
    },
    "node_modules/tslib": {
      "version": "2.8.1",
      "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.8.1.tgz",
      "integrity": "sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w==",
      "license": "0BSD"
    }
  }
}
package.json
{
  "name": "sample-degenerator",
  "version": "1.0.0",
  "type": "module",
  "private": true,
  "dependencies": {
    "degenerator": "5.0.1"
  }
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify pkg:npm/degenerator@5.0.1",
  "kind": "HOW",
  "packages": [
    "pkg:npm/degenerator@5.0.1"
  ]
}
test/contract.mjs
import assert from 'node:assert/strict';
import { degenerator } from 'degenerator';

// 1. degenerator converts synchronous function calling specified function to async function with await expression
{
  const input = 'function loadData() { const res = fetch("https://example.com"); return res; }';
  const output = degenerator(input, ['fetch']);
  assert.match(output, /async function loadData\(\)/);
  assert.match(output, /await fetch\(['"]https:\/\/example\.com['"]\)/);
}

// 2. degenerator leaves synchronous functions unchanged when no matching functions are called
{
  const input = 'function computeTotal(a, b) { return a + b; }';
  const output = degenerator(input, ['fetch']);
  assert.ok(!output.includes('async'));
  assert.ok(!output.includes('await'));
  assert.match(output, /function computeTotal\(a, b\)/);
}

// 3. degenerator matches function names using regular expression patterns
{
  const input = 'function run() { return getProfile() + fetchFeed(); }';
  const output = degenerator(input, [/^get/, /^fetch/]);
  assert.match(output, /async function run\(\)/);
  assert.match(output, /await getProfile\(\)/);
  assert.match(output, /await fetchFeed\(\)/);
}

// 4. degenerator cascades async conversion to caller functions when a called function becomes async
{
  const input = 'function inner() { return fetch(); }\nfunction outer() { return inner(); }';
  const output = degenerator(input, ['fetch']);
  assert.match(output, /async function inner\(\)/);
  assert.match(output, /async function outer\(\)/);
  assert.match(output, /await inner\(\)/);
}

// 5. degenerator tracks variable alias assignments and injects await for calls via aliased names
{
  const input = 'const request = fetch;\nfunction handler() { return request(); }';
  const output = degenerator(input, ['fetch']);
  assert.match(output, /async function handler\(\)/);
  assert.match(output, /await request\(\)/);
}

// 6. degenerator supports member expression call targets such as object method invocations
{
  const input = 'function resolveHost() { return dns.lookup("localhost"); }';
  const output = degenerator(input, ['dns.lookup']);
  assert.match(output, /async function resolveHost\(\)/);
  assert.match(output, /await dns\.lookup\(['"]localhost['"]\)/);
}

// 7. degenerator throws TypeError when names argument is not an array
{
  assert.throws(
    () => degenerator('function fn() {}', null),
    {
      name: 'TypeError',
      message: 'an array of async function "names" is required'
    }
  );
}

// 8. transformed code executes asynchronously and resolves awaited promise return value
{
  const code = degenerator('function getAnswer() { return queryDatabase(); }', ['queryDatabase']);
  const queryDatabase = () => Promise.resolve(42);
  const fn = new Function('queryDatabase', 'return (' + code + ')()')(queryDatabase);
  const result = await fn;
  assert.equal(result, 42);
}

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

аноним