CodeSampleX

Пример

neo-async 2.6.2: waterfall

Проверенный пример — npm neo-async 2.6.2: waterfall. Контракт выполнен на node 22 · linux alpine/x64 · docker и пройден: neo-async.waterfall executes an…

sha256:2088ca1d933ef7c6ba0b3ea0c9555e3b759a653d7114ca5091cfbdd16d28b1bb

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

Свидетельства выполнения

Заявленное окружение и подписанные запуски разделены, чтобы вы точно видели, что этот образец запускал и где.

Основа свидетельства
Подписанный контракт пройден
Квитанции проверки
1
Ключи подписи, собравшие его
1
Заявленная среда node 22.23 linux 24 · ubuntu · glibc 2.39 x64 node 22.23 javascript npm 10

Среды запусков проверки

Окружение Контракт Этапы Запуск
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-27

Кейс

HOW
Цель
verify neo-async.waterfall in pkg:npm/neo-async@2.6.2
Пакеты
Символы
  • neo-async.waterfall
Окружение
node 22.23.2
Создан
2026-08-27T23:09:17Z

Контракт

  1. neo-async.waterfall executes an array of functions in series passing the results of each function to the next
  2. neo-async.waterfall passes multiple arguments between successive tasks in the pipeline
  3. neo-async.waterfall halts execution and invokes final callback immediately when a task returns an error
  4. neo-async.waterfall invokes final callback with undefined result when given an empty task array
  5. neo-async.waterfall passes an error to callback when tasks argument is not an array
  6. neo-async.waterfall supports asynchronous tasks completing on different event loop ticks

Файлы

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

Скачать артефакт с исходным кодом (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 neo-async.waterfall in pkg:npm/neo-async@2.6.2
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:npm/neo-async@2.6.2
Demonstrate these symbols/APIs:
  - neo-async.waterfall

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:cea8ae1471acad79720ec5353b592bccfb8074cc6feab076543994b156e6a44f","contract":["neo-async.waterfall executes an array of functions in series passing the results of each function to the next","neo-async.waterfall passes multiple arguments between successive tasks in the pipeline","neo-async.waterfall halts execution and invokes final callback immediately when a task returns an error","neo-async.waterfall invokes final callback with undefined result when given an empty task array","neo-async.waterfall passes an error to callback when tasks argument is not an array","neo-async.waterfall supports asynchronous tasks completing on different event loop ticks"],"goal":"verify neo-async.waterfall in pkg:npm/neo-async@2.6.2","kind":"HOW","packages":["pkg:npm/neo-async@2.6.2"],"schemaVersion":1,"symbols":["neo-async.waterfall"]},"contractCommand":["node","test/contract.cjs"],"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/neo-async@2.6.2"],"schemaVersion":1,"subject":"pkg:npm/neo-async@2.6.2","symbols":["neo-async.waterfall"],"verifierAdapter":"node-typescript@1"}
index.js
'use strict';

const async = require('neo-async');

function runWaterfall(tasks, callback) {
  return async.waterfall(tasks, callback);
}

module.exports = {
  runWaterfall,
  waterfall: async.waterfall,
  async
};
package-lock.json
{
  "name": "sample-neo-async-waterfall",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "sample-neo-async-waterfall",
      "version": "1.0.0",
      "license": "MIT-0",
      "dependencies": {
        "neo-async": "2.6.2"
      }
    },
    "node_modules/neo-async": {
      "version": "2.6.2",
      "resolved": "https://registry.npmjs.org/neo-async/-/neo-async-2.6.2.tgz",
      "integrity": "sha512-Yd3UES5mWCSqR+qNT93S3UoYUkqAZ9lLg8a7g9rimsWmYGK8cVToA4/sF3RrshdyV3sAGMXVUmpMYOw+dLpOuw==",
      "license": "MIT"
    }
  }
}
package.json
{
  "name": "sample-neo-async-waterfall",
  "version": "1.0.0",
  "private": true,
  "description": "verify neo-async.waterfall in pkg:npm/neo-async@2.6.2",
  "main": "index.js",
  "scripts": {
    "test": "node test/contract.cjs"
  },
  "dependencies": {
    "neo-async": "2.6.2"
  },
  "license": "MIT-0"
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify neo-async.waterfall in pkg:npm/neo-async@2.6.2",
  "kind": "HOW",
  "packages": [
    "pkg:npm/neo-async@2.6.2"
  ],
  "symbols": [
    "neo-async.waterfall"
  ]
}
test/contract.cjs
'use strict';

const assert = require('assert');
const async = require('neo-async');
const { runWaterfall } = require('../index.js');

async function testSequentialExecution() {
  return new Promise((resolve, reject) => {
    const order = [];
    async.waterfall([
      (cb) => {
        order.push(1);
        cb(null, 'step1');
      },
      (arg1, cb) => {
        order.push(2);
        assert.strictEqual(arg1, 'step1');
        cb(null, 'step2');
      },
      (arg2, cb) => {
        order.push(3);
        assert.strictEqual(arg2, 'step2');
        cb(null, 'finalResult');
      }
    ], (err, result) => {
      if (err) return reject(err);
      try {
        assert.strictEqual(result, 'finalResult');
        assert.deepStrictEqual(order, [1, 2, 3]);
        resolve();
      } catch (e) {
        reject(e);
      }
    });
  });
}

async function testMultipleArgumentsPassing() {
  return new Promise((resolve, reject) => {
    async.waterfall([
      (cb) => {
        cb(null, 'alpha', 'beta', 42);
      },
      (a, b, c, cb) => {
        assert.strictEqual(a, 'alpha');
        assert.strictEqual(b, 'beta');
        assert.strictEqual(c, 42);
        cb(null, `${a}-${b}-${c}`, true);
      },
      (combined, flag, cb) => {
        assert.strictEqual(combined, 'alpha-beta-42');
        assert.strictEqual(flag, true);
        cb(null, { combined, flag });
      }
    ], (err, result) => {
      if (err) return reject(err);
      try {
        assert.deepStrictEqual(result, { combined: 'alpha-beta-42', flag: true });
        resolve();
      } catch (e) {
        reject(e);
      }
    });
  });
}

async function testErrorHaltsExecution() {
  return new Promise((resolve, reject) => {
    let secondTaskRan = false;
    const testError = new Error('waterfall failed in step 1');

    async.waterfall([
      (cb) => {
        cb(testError);
      },
      (cb) => {
        secondTaskRan = true;
        cb(null, 'should not happen');
      }
    ], (err, result) => {
      try {
        assert.strictEqual(err, testError);
        assert.strictEqual(result, undefined);
        assert.strictEqual(secondTaskRan, false);
        resolve();
      } catch (e) {
        reject(e);
      }
    });
  });
}

async function testEmptyTasksArray() {
  return new Promise((resolve, reject) => {
    async.waterfall([], (err, result) => {
      if (err) return reject(err);
      try {
        assert.strictEqual(result, undefined);
        resolve();
      } catch (e) {
        reject(e);
      }
    });
  });
}

async function testNonArrayTasksError() {
  return new Promise((resolve, reject) => {
    async.waterfall(null, (err, result) => {
      try {
        assert(err instanceof Error);
        assert.strictEqual(err.message, 'First argument to waterfall must be an array of functions');
        assert.strictEqual(result, undefined);
        resolve();
      } catch (e) {
        reject(e);
      }
    });
  });
}

async function testAsynchronousTasks() {
  return new Promise((resolve, reject) => {
    const executionOrder = [];
    runWaterfall([
      (cb) => {
        setTimeout(() => {
          executionOrder.push('first');
          cb(null, 10);
        }, 10);
      },
      (val, cb) => {
        setImmediate(() => {
          executionOrder.push('second');
          cb(null, val * 3);
        });
      },
      (val, cb) => {
        process.nextTick(() => {
          executionOrder.push('third');
          cb(null, val + 5);
        });
      }
    ], (err, result) => {
      if (err) return reject(err);
      try {
        assert.strictEqual(result, 35);
        assert.deepStrictEqual(executionOrder, ['first', 'second', 'third']);
        resolve();
      } catch (e) {
        reject(e);
      }
    });
  });
}

async function main() {
  await testSequentialExecution();
  await testMultipleArgumentsPassing();
  await testErrorHaltsExecution();
  await testEmptyTasksArray();
  await testNonArrayTasksError();
  await testAsynchronousTasks();
  console.log('All neo-async.waterfall contract assertions passed successfully.');
}

main().catch((err) => {
  console.error('Contract test failed:', err);
  process.exit(1);
});

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

аноним