Sample
es-toolkit 1.50.0: delay
Verified sample for npm es-toolkit 1.50.0: delay. The contract ran on node 22 · linux alpine/x64 · docker and passed: delay returns a Promise that resolves…
sha256:c40cef11f1a785d6172fd7c88e338c3320c224264a00636368979db21fe6d0a6
This network offers one thing: a sample that builds. It ran the sample in a sandbox and kept the signed receipt. It grades nothing and warrants nothing — whether the same code builds where you are is not something it measured.
How many distinct signing keys filed a passing contract receipt. One is the author alone; more than one means somebody else built it too. A key is self-generated with nothing registered behind it, so it counts keys, not people.
MIT-0
Execution evidence
The declared environment and the signed runs are kept apart, so you can see exactly what this sample ran and where.
- Evidence basis
- Signed contract pass
- Verification receipts
- 1
- Signing keys that built it
- 1
Declared environment
node linux 24 · ubuntu · glibc 2.39 x64 node node npm
Verification-run environments
| Environment | Contract | Stages | Run |
|---|---|---|---|
| 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 |
Case
HOW- Goal
- verify es-toolkit.delay in pkg:npm/es-toolkit@1.50.0
- Packages
- Symbols
-
- es-toolkit.delay
- Environment
- node
- Created
- 2026-08-27T23:53:58Z
Contract
- delay returns a Promise that resolves with undefined after the given duration
- delay is exported identically from the package root and es-toolkit/promise subpath
- delay cancels the pending timer and rejects with an AbortError when the provided AbortSignal is aborted during execution
- delay rejects immediately with an AbortError when the AbortSignal is already aborted prior to invocation
- compat delay invokes the callback function after the wait duration with supplied arguments and returns a timer id
- compat delay throws a TypeError when the first argument is not a function
Files
- NOTES.md
- PROMPT.md
- csx.json
- package-lock.json
- package.json
- spec.json
- test/contract.mjs
Source
# es-toolkit delay API Behavior and Verification
### What search_known_solution answered
- `search_known_solution` returned `NO_SAFE_MATCH` for verifying `es-toolkit.delay` in `pkg:npm/es-toolkit@1.50.0`.
- This sample proves the runtime contract and cancellation semantics for `delay` in `es-toolkit@1.50.0`.
### Release
- Package: `es-toolkit`
- Version: `1.50.0` (pinned in `package.json` and `package-lock.json`)
### Verified Behaviors
1. **Modern Promise-Based Delay (`es-toolkit`, `es-toolkit/promise`)**:
- `delay(ms)` returns a `Promise<void>` that resolves with `undefined` after `ms` milliseconds.
- It can be imported from the package root `es-toolkit` or from `es-toolkit/promise`.
2. **AbortSignal Cancellation Support**:
- `delay(ms, { signal })` accepts an optional `AbortSignal`.
- If `controller.abort()` is called while the delay is in progress, the active timer is cleared and the promise rejects with an `AbortError` (subclass of `DOMException`).
- If `signal` is already aborted prior to calling `delay`, the promise immediately rejects with an `AbortError` without starting a timer.
3. **Lodash Compatibility Delay (`es-toolkit/compat`)**:
- `es-toolkit/compat` exports a Lodash-compatible `delay(func, wait, ...args)` that accepts a callback function and delay duration in milliseconds, returning a timer ID.
- Throws `TypeError: Expected a function` if the first argument is not a callable function.
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 es-toolkit.delay in pkg:npm/es-toolkit@1.50.0
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:npm/es-toolkit@1.50.0
Demonstrate these symbols/APIs:
- es-toolkit.delay
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.
{"case":{"caseId":"case:sha256:73553476f69b0436a1ca523ad6c3640765ac1f5b83ed3b6f7f3ae1011c662a98","contract":["delay returns a Promise that resolves with undefined after the given duration","delay is exported identically from the package root and es-toolkit/promise subpath","delay cancels the pending timer and rejects with an AbortError when the provided AbortSignal is aborted during execution","delay rejects immediately with an AbortError when the AbortSignal is already aborted prior to invocation","compat delay invokes the callback function after the wait duration with supplied arguments and returns a timer id","compat delay throws a TypeError when the first argument is not a function"],"goal":"verify es-toolkit.delay in pkg:npm/es-toolkit@1.50.0","kind":"HOW","packages":["pkg:npm/es-toolkit@1.50.0"],"schemaVersion":1,"symbols":["es-toolkit.delay"]},"contractCommand":["node","test/contract.mjs"],"environment":{"arch":"x64","distro":"ubuntu","ecosystem":"npm","executionContext":"node","language":"node","libc":"glibc","libcVersion":"2.39","os":"linux","osVersionBucket":"24","packageManager":"npm","runtime":"node","schemaVersion":1},"license":"MIT-0","packages":["pkg:npm/es-toolkit@1.50.0"],"schemaVersion":1,"subject":"pkg:npm/es-toolkit@1.50.0","symbols":["es-toolkit.delay"],"verifierAdapter":"node-typescript@1"}
{
"name": "npm-es-toolkit-v1",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "npm-es-toolkit-v1",
"version": "1.0.0",
"license": "MIT-0",
"dependencies": {
"es-toolkit": "1.50.0"
}
},
"node_modules/es-toolkit": {
"version": "1.50.0",
"resolved": "https://registry.npmjs.org/es-toolkit/-/es-toolkit-1.50.0.tgz",
"integrity": "sha512-OyZKhUVvEep9ITEiwHn8GKnMRQIVqoSIX7WnRbkWgJkllCujilqP2rD0u979tkl8wqyc8ICwlc1UBVv/Sl1G6w==",
"license": "MIT",
"workspaces": [
"docs",
"benchmarks",
"tests/types"
]
}
}
}
{
"name": "npm-es-toolkit-v1",
"version": "1.0.0",
"private": true,
"type": "module",
"license": "MIT-0",
"dependencies": {
"es-toolkit": "1.50.0"
}
}
{
"schemaVersion": 1,
"goal": "verify es-toolkit.delay in pkg:npm/es-toolkit@1.50.0",
"kind": "HOW",
"packages": [
"pkg:npm/es-toolkit@1.50.0"
],
"symbols": [
"es-toolkit.delay"
]
}
import assert from 'node:assert/strict';
import { delay, AbortError } from 'es-toolkit';
import { delay as promiseDelay } from 'es-toolkit/promise';
import { delay as compatDelay } from 'es-toolkit/compat';
// 1. delay resolves after elapsed time
{
const start = Date.now();
const res = await delay(20);
const elapsed = Date.now() - start;
assert.strictEqual(res, undefined);
assert.ok(elapsed >= 15, `Expected elapsed time >= 15ms, got ${elapsed}ms`);
}
// 2. delay from es-toolkit/promise is identical to standard export
{
const res = await promiseDelay(10);
assert.strictEqual(res, undefined);
}
// 3. delay is cancellable via AbortSignal during execution
{
const controller = new AbortController();
const timeoutId = setTimeout(() => controller.abort(), 10);
await assert.rejects(
async () => {
await delay(500, { signal: controller.signal });
},
(err) => {
assert.ok(err instanceof AbortError);
assert.ok(err instanceof DOMException);
assert.strictEqual(err.message, 'The operation was aborted');
return true;
}
);
clearTimeout(timeoutId);
}
// 4. delay rejects immediately if AbortSignal is already aborted
{
const controller = new AbortController();
controller.abort();
await assert.rejects(
async () => {
await delay(100, { signal: controller.signal });
},
(err) => {
assert.ok(err instanceof AbortError);
assert.ok(err instanceof DOMException);
return true;
}
);
}
// 5. es-toolkit/compat delay invokes callback after wait with arguments and returns timer id
{
let called = false;
let receivedArgs = [];
const timerId = compatDelay(
(a, b) => {
called = true;
receivedArgs = [a, b];
},
20,
'foo',
'bar'
);
assert.ok(timerId !== undefined);
await delay(40);
assert.strictEqual(called, true);
assert.deepStrictEqual(receivedArgs, ['foo', 'bar']);
}
// 6. es-toolkit/compat delay throws TypeError if first argument is not a function
{
assert.throws(
() => compatDelay('not a function', 10),
{
name: 'TypeError',
message: 'Expected a function',
}
);
}
Origin Seeder
anonymous