{"_id":"@deot/helper-scheduler","_rev":"6-456ec879963477af803f7eb8e74933ea","name":"@deot/helper-scheduler","dist-tags":{"latest":"1.1.9"},"versions":{"1.1.4":{"name":"@deot/helper-scheduler","version":"1.1.4","license":"MIT","_id":"@deot/helper-scheduler@1.1.4","maintainers":[{"name":"deot","email":"zrd0921@qq.com"}],"dist":{"shasum":"aefcf8be25093a892e75b5cb90b2c222817529f7","tarball":"https://registry.npmjs.org/@deot/helper-scheduler/-/helper-scheduler-1.1.4.tgz","fileCount":7,"integrity":"sha512-YxKUuOCUkEnXzYyXRZ7dGx0u9jVDvdU/Q9WO4K7USoIbiCTImPzQ4CnFxAuWlyiZ/YtKwby6HTBRX2dt0rkuTQ==","signatures":[{"sig":"MEUCIGkIzbt3hu3iHeZoEdm2LBnHUcRRGAlieihwRq2CgVpEAiEA710SzGVDKutw8ox7V5Gt+aSfNacAiy5cUAxxbzxmSKU=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":6995},"main":"dist/index.js","type":"module","types":"dist/index.d.ts","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js","require":"./dist/index.cjs"}},"gitHead":"5ef6f52422c08a4b1048d3d2e4fa591b8c1cfe56","_npmUser":{"name":"deot","email":"zrd0921@qq.com"},"_npmVersion":"10.2.4","description":"调度器","directories":{},"_nodeVersion":"21.4.0","dependencies":{},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/helper-scheduler_1.1.4_1702893333287_0.6434170276193287","host":"s3://npm-registry-packages"}},"1.1.5":{"name":"@deot/helper-scheduler","version":"1.1.5","license":"MIT","_id":"@deot/helper-scheduler@1.1.5","maintainers":[{"name":"deot","email":"zrd0921@qq.com"}],"dist":{"shasum":"f0ebd9c34df90fcb0fd5b5e38b22c1e41af0e024","tarball":"https://registry.npmjs.org/@deot/helper-scheduler/-/helper-scheduler-1.1.5.tgz","fileCount":7,"integrity":"sha512-+3hzedLl/zZ7q61W4QJ2a+u1XnSb3wx78AgRxhqqX1ap9RVM83wXUovwEyJVJRE3VIv1YnrQsfpddFaYstzy8Q==","signatures":[{"sig":"MEQCIFEVkZWhxLHni8MwCB8wAYeaHhmyE3ShaX7bWoKUUhjQAiBuSvHKaglww12WdwMP2vxSk/bLle1zB3ERhr0UBpFtzg==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":38425},"main":"dist/index.js","type":"module","types":"dist/index.d.ts","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js","require":"./dist/index.cjs"}},"gitHead":"c02bed5f4d21b324e4d2e6f8086e628c71405800","_npmUser":{"name":"deot","email":"zrd0921@qq.com"},"_npmVersion":"10.2.4","description":"调度器 - 进行调度工作的程序","directories":{},"_nodeVersion":"21.5.0","dependencies":{"@deot/helper-fp":"^1.1.3"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/helper-scheduler_1.1.5_1703142453948_0.1910888866549283","host":"s3://npm-registry-packages"}},"1.1.6":{"name":"@deot/helper-scheduler","version":"1.1.6","license":"MIT","_id":"@deot/helper-scheduler@1.1.6","dist":{"shasum":"33fd3aad7620e9d61c406d6853e6e80b9ee6c790","tarball":"https://registry.npmjs.org/@deot/helper-scheduler/-/helper-scheduler-1.1.6.tgz","fileCount":7,"integrity":"sha512-/708ExuN9otMdaKCWZLwC3PFN5+0241/VWD7OQtJgP57omOm/WioEsB1QL9LD6s1e0zmDZ4MsgB6tjYBhnhw7A==","signatures":[{"sig":"MEUCIQCqwZL+gNeWm3FBaKU9ZqwOTOoixnhaPgmqGM8jkZVzhgIgCDOeTFtlIo0rkhbjnv9dOe4AMokNibyXz41aHiIIJIU=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":38441},"main":"dist/index.js","type":"module","types":"dist/index.d.ts","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js","require":"./dist/index.cjs"}},"gitHead":"ff39d165399b4c893f3b6c5c1566abd7d7003354","_npmUser":{"name":"deot","email":"zrd0921@qq.com"},"_npmVersion":"10.8.1","description":"调度器 - 进行调度工作的程序","directories":{},"_nodeVersion":"22.3.0","dependencies":{"@deot/helper-fp":"^1.1.3"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/helper-scheduler_1.1.6_1719456513266_0.9036512227194355","host":"s3://npm-registry-packages"}},"1.1.7":{"name":"@deot/helper-scheduler","version":"1.1.7","license":"MIT","_id":"@deot/helper-scheduler@1.1.7","maintainers":[{"name":"deot","email":"zrd0921@qq.com"}],"dist":{"shasum":"c748df6c4dbd3a399984139569b230f24864c310","tarball":"https://registry.npmjs.org/@deot/helper-scheduler/-/helper-scheduler-1.1.7.tgz","fileCount":7,"integrity":"sha512-gz7LBfUJvRFpuPr7U/51uv0ZS3IggVYGEhWJ3XK+cr0VIOhJdT8dtHHNr6KF533q7aJQUKWlBwqZ4+iBrN3ZMA==","signatures":[{"sig":"MEUCIQDqlFIQPQcgfWwUMMOwT2LAaKWVy+j2qSsGVhInnC56pwIgFaZVX9Tuhp8FO5XpsS6VbEwaXFf96p5vkr3zWWr/VN8=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":38277},"main":"dist/index.js","type":"module","types":"dist/index.d.ts","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js","require":"./dist/index.cjs"}},"gitHead":"d0a40b8b0a00e400db088a0750503fd874ac4455","_npmUser":{"name":"deot","email":"zrd0921@qq.com"},"_npmVersion":"10.9.2","description":"调度器 - 进行调度工作的程序","directories":{},"_nodeVersion":"23.10.0","dependencies":{"@deot/helper-fp":"^1.1.4"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/helper-scheduler_1.1.7_1743152399630_0.5745805732220151","host":"s3://npm-registry-packages-npm-production"}},"1.1.8":{"name":"@deot/helper-scheduler","version":"1.1.8","license":"MIT","_id":"@deot/helper-scheduler@1.1.8","maintainers":[{"name":"deot","email":"zrd0921@qq.com"}],"dist":{"shasum":"d3ae29d3de749d5da4f99cc443b4facb90ae9119","tarball":"https://registry.npmjs.org/@deot/helper-scheduler/-/helper-scheduler-1.1.8.tgz","fileCount":7,"integrity":"sha512-QDA+d0eTTQWyJw+dWceZmLnQfw0uJPNah4/wGdtBhLEOF9S6HTEZ/Z3WDdwJ7KF3dnmWbwvpekSEllz6z/hUKw==","signatures":[{"sig":"MEUCIQDLEr3uNzXbk8simqK0fYnCBKu3pVzBeCsL0G4nSn0cnwIgVckKXVQTI+DkgWm7RMZon1WIzWAlYjDP4y+lfMiIG9M=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":38277},"main":"dist/index.js","type":"module","types":"dist/index.d.ts","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js","require":"./dist/index.cjs"}},"gitHead":"22dd9a425009f4d2689a6fc5f461ef86bb72448e","_npmUser":{"name":"deot","email":"zrd0921@qq.com"},"_npmVersion":"10.9.2","description":"调度器 - 进行调度工作的程序","directories":{},"_nodeVersion":"23.11.0","dependencies":{"@deot/helper-fp":"^1.1.5"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/helper-scheduler_1.1.8_1744108189064_0.86461498204165","host":"s3://npm-registry-packages-npm-production"}},"1.1.9":{"_id":"@deot/helper-scheduler@1.1.9","dist":{"shasum":"5dd25fd3751c933d7df5ce1dca455a7bac2dda0b","tarball":"https://registry.npmjs.org/@deot/helper-scheduler/-/helper-scheduler-1.1.9.tgz","fileCount":7,"integrity":"sha512-OZlmqwqpP73Lm+wRO14E4IMaFs3b0F3c0Kno5bt7qo7HLVWtwNqtl57SNCwOm8s0wujOvnhFtMe616FuhThmwQ==","signatures":[{"sig":"MEUCIBm6yc3vIk9creQcKVXDzKxq67wvqUr2Lx35Zc9qmYjzAiEAtloGEalShyF4BHHucsDwgkp0HZuobs7pGAYYeky7vkw=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"},{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCIF3QRYncXP1o0zCQ5PIbB4PL23mTkkukFL7Ys2Ru9kQZAiA//CzfiQ4PeDCMDz4P8cEpmSE4k6WZKQqovFj8KnZZng=="}],"unpackedSize":43859},"main":"dist/index.js","name":"@deot/helper-scheduler","type":"module","types":"dist/index.d.ts","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js","require":"./dist/index.cjs"}},"gitHead":"75e2a1d6a00104aeaca20f0b4ad93b2baece4209","license":"MIT","version":"1.1.9","_npmUser":{"name":"deot","email":"zrd0921@qq.com"},"_npmVersion":"11.19.0","description":"任务调度入口，提供可等待的 `Interrupter`，并重新导出 `@deot/helper-fp` 中的 `Task`、`Job` 与 `Parallel`。","directories":{},"maintainers":[{"name":"deot","email":"zrd0921@qq.com"}],"_nodeVersion":"24.21.0","dependencies":{"@deot/helper-fp":"^1.1.6"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/helper-scheduler_1.1.9_1790257283330_0.36085479750374727"}}},"time":{"created":"2023-12-18T09:55:33.223Z","modified":"2026-09-24T13:41:23.584Z","1.1.4":"2023-12-18T09:55:33.439Z","1.1.5":"2023-12-21T07:07:34.095Z","1.1.6":"2024-06-27T02:48:33.446Z","1.1.7":"2025-03-28T08:59:59.795Z","1.1.8":"2025-04-08T10:29:49.256Z","1.1.9":"2026-09-24T13:41:23.421Z"},"license":"MIT","description":"任务调度入口，提供可等待的 `Interrupter`，并重新导出 `@deot/helper-fp` 中的 `Task`、`Job` 与 `Parallel`。","maintainers":[{"name":"deot","email":"zrd0921@qq.com"}],"readme":"# @deot/helper-scheduler\n\n任务调度入口，提供可等待的 `Interrupter`，并重新导出 `@deot/helper-fp` 中的 `Task`、`Job` 与 `Parallel`。\n\n## 安装\n\n```bash\npnpm add @deot/helper-scheduler\n```\n\n## 使用\n\n```ts\nimport { Interrupter } from '@deot/helper-scheduler';\n\nconst interrupter = Interrupter.of<number>();\nsetTimeout(() => interrupter.next(1), 100);\n\nconst value = await interrupter;\n```\n\n聚合包可直接导入 `Interrupter`、`Task`、`Job` 和 `Parallel`。\n\n## API\n\n### Interrupter\n\n可重复推进并可永久结束的 Promise-like 中断器。\n\n#### `new Interrupter(options?)` / `Interrupter.of(options?)`\n\n创建 thenable 中断器；timeout 当前仅声明未应用\n\n| 参数 | 参数类型 | 默认值 | 返回值 |\n| --- | --- | --- | --- |\n| `options` | `{ timeout?: number }` | `{}` | `Interrupter<T>` |\n\n#### `Interrupter.next(value?)`\n\n解析当前等待并生成下一轮\n\n| 参数 | 参数类型 | 默认值 | 返回值 |\n| --- | --- | --- | --- |\n| `value` | `T` | `undefined` | `Promise<void>` |\n\n#### `Interrupter.nextWithError(error?)`\n\n拒绝当前等待并生成下一轮\n\n| 参数 | 参数类型 | 默认值 | 返回值 |\n| --- | --- | --- | --- |\n| `error` | `any` | `undefined` | `Promise<void>` |\n\n#### `Interrupter.finish(value?)`\n\n解析并永久结束\n\n| 参数 | 参数类型 | 默认值 | 返回值 |\n| --- | --- | --- | --- |\n| `value` | `T` | `undefined` | `this` |\n\n#### `Interrupter.finishWithError(error?)`\n\n拒绝并永久结束\n\n| 参数 | 参数类型 | 默认值 | 返回值 |\n| --- | --- | --- | --- |\n| `error` | `T` | `undefined` | `this` |\n\n#### `Interrupter.then(resolve, reject?)`\n\nPromise-like then\n\n| 参数 | 参数类型 | 返回值 |\n| --- | --- | --- |\n| `resolve`、`reject` | `(value: T) => void` | `Promise<void>` |\n\n#### `Interrupter.catch(callback?)`\n\nPromise-like catch\n\n| 参数 | 参数类型 | 返回值 |\n| --- | --- | --- |\n| `callback` | `(reason: T) => void` | `Promise<any>` |\n\n#### `Interrupter.finally(callback?)`\n\nPromise-like finally\n\n| 参数 | 参数类型 | 返回值 |\n| --- | --- | --- |\n| `callback` | `() => void` | `Promise<any>` |\n\n#### 公开状态与实现成员\n\n| 成员 | 类型 | 说明 |\n| --- | --- | --- |\n| `options` | `InterrupterOptions` | 构造时传入的配置 |\n| `_finish` | `boolean` | 是否已通过 finish 方法永久结束 |\n| `_task` | `Promise<any>` | 当前一轮等待的 Promise |\n| `_success` / `_fail` | `((value?: any) => void) \\| undefined` | 当前 Promise 的 resolve/reject 包装函数 |\n| `_generateTask()` | `() => void` | 创建下一轮等待 Promise |\n\n下划线成员虽然在当前声明中可见，但属于调度实现状态，不应由业务代码修改或调用。\n\n分别运行成功、错误和永久结束流程，观察 `then`、`catch`、`finally` 与推进方法的调用顺序：\n\n:::playground\n<!--\n<config lang=\"json5\">\n{\n\tviews: ['runtime', 'files']\n}\n</config>\n-->\n```vue\n<script setup>\n/* eslint-disable no-useless-assignment */\nimport { ref } from 'vue';\nimport { Interrupter } from '@deot/helper-scheduler';\n\nconst output = ref([]);\n\nconst runNext = async () => {\n\tconst logs = [];\n\tconst interrupter = Interrupter.of();\n\tconst waiting = interrupter\n\t\t.then(value => logs.push(`then:${value}`))\n\t\t.finally(() => logs.push('finally'));\n\tawait interrupter.next(1);\n\tawait waiting;\n\toutput.value = logs;\n};\n\nconst runError = async () => {\n\tconst logs = [];\n\tconst interrupter = Interrupter.of();\n\tconst waiting = interrupter\n\t\t.catch(reason => logs.push(`catch:${reason}`))\n\t\t.finally(() => logs.push('finally'));\n\tawait interrupter.nextWithError('error');\n\tawait waiting;\n\toutput.value = logs;\n};\n\nconst runFinish = async () => {\n\tconst interrupter = Interrupter.of();\n\tconst waiting = interrupter.then(value => `finish:${value}`);\n\tinterrupter.finish('done');\n\toutput.value = [await waiting, `finished:${interrupter._finish}`];\n};\n\nconst runFinishError = async () => {\n\tconst interrupter = Interrupter.of();\n\tconst waiting = interrupter.catch(reason => `finishWithError:${reason}`);\n\tinterrupter.finishWithError('done');\n\toutput.value = [await waiting, `finished:${interrupter._finish}`];\n};\n</script>\n\n<template>\n\t<div class=\"demo\">\n\t\t<div class=\"actions\">\n\t\t\t<button @click=\"runNext\">next</button>\n\t\t\t<button @click=\"runError\">nextWithError</button>\n\t\t\t<button @click=\"runFinish\">finish</button>\n\t\t\t<button @click=\"runFinishError\">finishWithError</button>\n\t\t</div>\n\t\t<strong>输出</strong>\n\t\t<pre>{{ JSON.stringify(output, null, 2) }}</pre>\n\t</div>\n</template>\n\n<style>\n.demo { display: grid; width: min(100%, 640px); gap: 12px; padding: 12px; box-sizing: border-box; font: 14px/1.5 sans-serif; }\n.actions { display: flex; flex-wrap: wrap; gap: 8px; }\nbutton { width: fit-content; padding: 6px 10px; cursor: pointer; border: 1px solid #cbd5e1; border-radius: 8px; background: #fff; }\npre { margin: 0; padding: 12px; border-radius: 8px; background: #f8fafc; }\n</style>\n```\n:::\n\n#### `InterrupterOptions`\n\n| 字段 | 类型 | 说明 |\n| --- | --- | --- |\n| `timeout` | `number` | 已声明但当前实现尚未应用超时逻辑 |\n\n以下任务类从 `@deot/helper-fp` 重新导出。\n\n### Task\n\n串行函数链，通过 `Task.of(value, parent?)` 或构造函数创建；完整方法、状态和参数见 fp API。\n\n#### `Task.of(value, parent?)` / `new Task(value, parent?)`\n\n创建任务节点\n\n| 参数 | 返回值 |\n| --- | --- |\n| `any` / `Task` | `Task` |\n\n#### `Task.map(fn)` / `Task.flatMap(fn)`\n\n追加映射或展开映射\n\n| 参数 | 返回值 |\n| --- | --- |\n| `Function` | `Task` / `any` |\n\n#### `Task.reduce(collection, done)`\n\n串行归并集合\n\n| 参数 | 返回值 |\n| --- | --- |\n| `any[] \\| Function` / `Function` | `Task` |\n\n#### `Task.start()` / `Task.immediate()`\n\n启动任务链\n\n| 返回值 |\n| --- |\n| `Task` |\n\n#### `Task.pasue()` / `Task.resume()`\n\n暂停或恢复\n\n| 返回值 |\n| --- |\n| `Task` |\n\n#### `Task.cancel()` / `Task.end()`\n\n取消任务链\n\n| 返回值 |\n| --- |\n| `Task` |\n\n#### `Task.restart(value?)`\n\n重建并启动任务链\n\n| 参数 | 返回值 |\n| --- | --- |\n| `any` | `Task` |\n\n#### `Task.toPromise()` / `Task.valueOf()` / `Task.toString()`\n\n等待、取值或格式化\n\n| 返回值 |\n| --- |\n| `Promise<any>` / `any` / `string` |\n\n公开状态包括 `result`、`cancelHooks`、`isCancel`、`isComplete`、`isStart`、`parent`、`child`、`record`、`ready`、`pasuer`；`_ready`、`_pasuer` 是实现回调。\n\n### Job\n\n周期任务，通过 `Job.of(task, interval?)` 或构造函数创建；完整方法、状态和参数见 fp API。\n\n#### `Job.of(task, interval?)` / `new Job(task, interval?)`\n\n创建周期任务\n\n| 参数 | 返回值 |\n| --- | --- |\n| `TaskSource` / `number` | `Job` |\n\n#### `Job.process(leaf?)`\n\n执行并安排下一轮\n\n| 参数 | 返回值 |\n| --- | --- |\n| `TaskSource` | `any` |\n\n#### `Job.start()` / `Job.immediate()`\n\n启动循环\n\n| 返回值 |\n| --- |\n| `void` |\n\n#### `Job.pasue()` / `Job.resume()`\n\n暂停或恢复\n\n| 返回值 |\n| --- |\n| `void` |\n\n#### `Job.cancel()` / `Job.end()`\n\n取消循环\n\n| 返回值 |\n| --- |\n| `void` |\n\n#### `Job.restart()`\n\n清理中断状态并重新执行\n\n| 返回值 |\n| --- |\n| `void` |\n\n公开状态包括 `original`、`task`、`interval`、`isStart` 及继承自 `ATask` 的中断状态。\n\n### Parallel\n\n并发任务，通过 `Parallel.of(task, concurrency?, options?)` 或构造函数创建；完整方法、状态和参数见 fp API。\n\n#### `Parallel.of(task, concurrency?, options?)` / `new Parallel(...)`\n\n创建并发调度器\n\n| 参数 | 返回值 |\n| --- | --- |\n| `ParallelSource` / `number` / `{ skipError?: boolean }` | `Parallel` |\n\n#### `Parallel.setConcurrency(value)`\n\n设置并返回实际并发数\n\n| 参数 | 返回值 |\n| --- | --- |\n| `number` | `number` |\n\n#### `Parallel.process()`\n\n按并发数填充执行队列\n\n| 返回值 |\n| --- |\n| `void` |\n\n#### `Parallel.onFulfilled(value)` / `Parallel.onRejected(error)`\n\n完成或失败后的队列推进回调\n\n| 参数 | 返回值 |\n| --- | --- |\n| `any` | `void` |\n\n#### `Parallel.start()` / `Parallel.immediate()`\n\n启动调度\n\n| 返回值 |\n| --- |\n| `Promise<any>` |\n\n#### `Parallel.pasue()` / `Parallel.resume()`\n\n暂停或恢复\n\n| 返回值 |\n| --- |\n| `Promise<void>` / `void` |\n\n#### `Parallel.cancel()` / `Parallel.end()`\n\n取消调度\n\n| 返回值 |\n| --- |\n| `Promise<void>` |\n\n#### `Parallel.restart()`\n\n重置并重新启动\n\n| 返回值 |\n| --- |\n| `Promise<any>` |\n\n公开状态包括 `original`、`task`、`tasks`、`concurrency`、`options`、`isStart`、`target`、`_target`；后两项属于 Promise 调度实现状态。\n\n## 任务类型说明\n\n```ts\nimport { Task, Job, Parallel } from '@deot/helper-scheduler';\n```\n\n| 类型 | 说明 |\n| --- | --- |\n| `Task` | 串行函数链，支持启动、暂停、恢复、取消和重启 |\n| `Job` | 周期性执行 Task 或 Promise 工厂 |\n| `Parallel` | 按并发数执行 Task 或 Promise 工厂集合 |\n\n这些类型的完整行为见 [`@deot/helper-fp`](../fp/README.md)。为兼容已有 API，暂停方法名为 `pasue()`。\n","readmeFilename":"README.md"}