샘플
es-toolkit 1.50.0: delay
검증된 샘플 — npm es-toolkit 1.50.0: delay. node 22 · linux alpine/x64 · docker에서 contract를 실행해 통과했습니다: delay returns a Promise that resolves with undefined after…
sha256:c40cef11f1a785d6172fd7c88e338c3320c224264a00636368979db21fe6d0a6
이 네트워크가 제공하는 것은 하나입니다. 빌드되는 샘플. 샌드박스에서 돌리고 서명된 영수증을 보관합니다. 등급을 매기지 않고 무엇도 보증하지 않습니다 — 같은 코드가 당신 환경에서 빌드되는지는 측정한 적이 없습니다.
통과한 계약 영수증을 낸 서로 다른 서명 키의 수입니다. 하나면 작성자 혼자이고, 둘 이상이면 다른 사람도 빌드했다는 뜻입니다. 키는 스스로 만드는 것이고 뒤에 등록된 신원이 없으므로, 세는 것은 사람이 아니라 키입니다.
MIT-0
실행 증거
선언된 환경과 서명된 실행을 분리해 두었습니다. 이 샘플이 무엇을 어디서 실행했는지 그대로 볼 수 있습니다.
- 증거 기준
- 서명된 컨트랙트 통과
- 검증 영수증
- 1
- 빌드한 서명 키
- 1
선언된 환경
node linux 24 · ubuntu · glibc 2.39 x64 node node 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-27 |
케이스
HOW- 목표
- verify es-toolkit.delay in pkg:npm/es-toolkit@1.50.0
- 심벌
-
- es-toolkit.delay
- 환경
- node
- 생성일
- 2026-08-27T23:53:58Z
컨트랙트
- 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
파일
- NOTES.md
- PROMPT.md
- csx.json
- package-lock.json
- package.json
- spec.json
- test/contract.mjs
소스
# 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',
}
);
}
오리진 시더
익명