skillfit 0.9.0 → 0.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +41 -15
- package/README.zh-CN.md +41 -15
- package/benches/README.md +23 -0
- package/benches/contrib/README.md +1 -0
- package/benches/contrib/oss-skill-independent/README.md +60 -0
- package/benches/contrib/oss-skill-independent/bench.json +79 -0
- package/benches/contrib/oss-skill-independent/fixtures/commander-async-listener-order/LICENSE +22 -0
- package/benches/contrib/oss-skill-independent/fixtures/commander-async-listener-order/Readme.md +1015 -0
- package/benches/contrib/oss-skill-independent/fixtures/commander-async-listener-order/esm.mjs +15 -0
- package/benches/contrib/oss-skill-independent/fixtures/commander-async-listener-order/index.js +27 -0
- package/benches/contrib/oss-skill-independent/fixtures/commander-async-listener-order/lib/argument.js +147 -0
- package/benches/contrib/oss-skill-independent/fixtures/commander-async-listener-order/lib/command.js +1944 -0
- package/benches/contrib/oss-skill-independent/fixtures/commander-async-listener-order/lib/error.js +45 -0
- package/benches/contrib/oss-skill-independent/fixtures/commander-async-listener-order/lib/help.js +396 -0
- package/benches/contrib/oss-skill-independent/fixtures/commander-async-listener-order/lib/option.js +208 -0
- package/benches/contrib/oss-skill-independent/fixtures/commander-async-listener-order/lib/suggestSimilar.js +100 -0
- package/benches/contrib/oss-skill-independent/fixtures/commander-async-listener-order/package-support.json +16 -0
- package/benches/contrib/oss-skill-independent/fixtures/commander-async-listener-order/package.json +63 -0
- package/benches/contrib/oss-skill-independent/fixtures/commander-async-listener-order/test-clock.mjs +65 -0
- package/benches/contrib/oss-skill-independent/fixtures/commander-async-listener-order/test.mjs +4 -0
- package/benches/contrib/oss-skill-independent/fixtures/commander-async-listener-order/typings/index.d.ts +774 -0
- package/benches/contrib/oss-skill-independent/fixtures/commander-async-listener-order/typings/index.test-d.ts +416 -0
- package/benches/contrib/oss-skill-independent/fixtures/commander-async-listener-order/upstream-package.json +69 -0
- package/benches/contrib/oss-skill-independent/fixtures/commander-output-isolation/LICENSE +22 -0
- package/benches/contrib/oss-skill-independent/fixtures/commander-output-isolation/Readme.md +1149 -0
- package/benches/contrib/oss-skill-independent/fixtures/commander-output-isolation/esm.mjs +16 -0
- package/benches/contrib/oss-skill-independent/fixtures/commander-output-isolation/index.js +24 -0
- package/benches/contrib/oss-skill-independent/fixtures/commander-output-isolation/lib/argument.js +149 -0
- package/benches/contrib/oss-skill-independent/fixtures/commander-output-isolation/lib/command.js +2662 -0
- package/benches/contrib/oss-skill-independent/fixtures/commander-output-isolation/lib/error.js +39 -0
- package/benches/contrib/oss-skill-independent/fixtures/commander-output-isolation/lib/help.js +713 -0
- package/benches/contrib/oss-skill-independent/fixtures/commander-output-isolation/lib/option.js +367 -0
- package/benches/contrib/oss-skill-independent/fixtures/commander-output-isolation/lib/suggestSimilar.js +101 -0
- package/benches/contrib/oss-skill-independent/fixtures/commander-output-isolation/package-support.json +16 -0
- package/benches/contrib/oss-skill-independent/fixtures/commander-output-isolation/package.json +71 -0
- package/benches/contrib/oss-skill-independent/fixtures/commander-output-isolation/test-clock.mjs +65 -0
- package/benches/contrib/oss-skill-independent/fixtures/commander-output-isolation/test.mjs +4 -0
- package/benches/contrib/oss-skill-independent/fixtures/commander-output-isolation/typings/esm.d.mts +3 -0
- package/benches/contrib/oss-skill-independent/fixtures/commander-output-isolation/typings/index.d.ts +1045 -0
- package/benches/contrib/oss-skill-independent/fixtures/commander-output-isolation/typings/index.test-d.ts +737 -0
- package/benches/contrib/oss-skill-independent/fixtures/commander-output-isolation/upstream-package.json +82 -0
- package/benches/contrib/oss-skill-independent/fixtures/limit-async-context/index.d.ts +40 -0
- package/benches/contrib/oss-skill-independent/fixtures/limit-async-context/index.js +68 -0
- package/benches/contrib/oss-skill-independent/fixtures/limit-async-context/license +9 -0
- package/benches/contrib/oss-skill-independent/fixtures/limit-async-context/package.json +54 -0
- package/benches/contrib/oss-skill-independent/fixtures/limit-async-context/readme.md +99 -0
- package/benches/contrib/oss-skill-independent/fixtures/limit-async-context/test-clock.mjs +65 -0
- package/benches/contrib/oss-skill-independent/fixtures/limit-async-context/test.mjs +4 -0
- package/benches/contrib/oss-skill-independent/fixtures/limit-async-context/upstream-package.json +54 -0
- package/benches/contrib/oss-skill-independent/fixtures/limit-async-context/vendor/yocto-queue/index.js +67 -0
- package/benches/contrib/oss-skill-independent/fixtures/limit-async-context/vendor/yocto-queue/license +9 -0
- package/benches/contrib/oss-skill-independent/fixtures/limit-async-context/vendor/yocto-queue/package.json +46 -0
- package/benches/contrib/oss-skill-independent/fixtures/limit-map-iteration-rejection/index.d.ts +136 -0
- package/benches/contrib/oss-skill-independent/fixtures/limit-map-iteration-rejection/index.js +132 -0
- package/benches/contrib/oss-skill-independent/fixtures/limit-map-iteration-rejection/license +9 -0
- package/benches/contrib/oss-skill-independent/fixtures/limit-map-iteration-rejection/package.json +57 -0
- package/benches/contrib/oss-skill-independent/fixtures/limit-map-iteration-rejection/readme.md +181 -0
- package/benches/contrib/oss-skill-independent/fixtures/limit-map-iteration-rejection/test-clock.mjs +65 -0
- package/benches/contrib/oss-skill-independent/fixtures/limit-map-iteration-rejection/test.mjs +4 -0
- package/benches/contrib/oss-skill-independent/fixtures/limit-map-iteration-rejection/upstream-package.json +58 -0
- package/benches/contrib/oss-skill-independent/fixtures/limit-map-iteration-rejection/vendor/yocto-queue/index.js +84 -0
- package/benches/contrib/oss-skill-independent/fixtures/limit-map-iteration-rejection/vendor/yocto-queue/license +9 -0
- package/benches/contrib/oss-skill-independent/fixtures/limit-map-iteration-rejection/vendor/yocto-queue/package.json +48 -0
- package/benches/contrib/oss-skill-independent/fixtures/throttle-sync-throw/index.d.ts +136 -0
- package/benches/contrib/oss-skill-independent/fixtures/throttle-sync-throw/index.js +116 -0
- package/benches/contrib/oss-skill-independent/fixtures/throttle-sync-throw/license +9 -0
- package/benches/contrib/oss-skill-independent/fixtures/throttle-sync-throw/package.json +60 -0
- package/benches/contrib/oss-skill-independent/fixtures/throttle-sync-throw/readme.md +170 -0
- package/benches/contrib/oss-skill-independent/fixtures/throttle-sync-throw/test-clock.mjs +65 -0
- package/benches/contrib/oss-skill-independent/fixtures/throttle-sync-throw/test.mjs +4 -0
- package/benches/contrib/oss-skill-independent/fixtures/throttle-sync-throw/upstream-package.json +60 -0
- package/benches/contrib/oss-skill-independent/fixtures/timeout-custom-timers/index.d.ts +149 -0
- package/benches/contrib/oss-skill-independent/fixtures/timeout-custom-timers/index.js +93 -0
- package/benches/contrib/oss-skill-independent/fixtures/timeout-custom-timers/license +9 -0
- package/benches/contrib/oss-skill-independent/fixtures/timeout-custom-timers/package.json +52 -0
- package/benches/contrib/oss-skill-independent/fixtures/timeout-custom-timers/readme.md +192 -0
- package/benches/contrib/oss-skill-independent/fixtures/timeout-custom-timers/test-clock.mjs +65 -0
- package/benches/contrib/oss-skill-independent/fixtures/timeout-custom-timers/test.mjs +4 -0
- package/benches/contrib/oss-skill-independent/fixtures/timeout-custom-timers/upstream-package.json +52 -0
- package/benches/contrib/oss-skill-independent/fixtures/timeout-infinity-abort/index.d.ts +151 -0
- package/benches/contrib/oss-skill-independent/fixtures/timeout-infinity-abort/index.js +114 -0
- package/benches/contrib/oss-skill-independent/fixtures/timeout-infinity-abort/license +9 -0
- package/benches/contrib/oss-skill-independent/fixtures/timeout-infinity-abort/package.json +48 -0
- package/benches/contrib/oss-skill-independent/fixtures/timeout-infinity-abort/readme.md +158 -0
- package/benches/contrib/oss-skill-independent/fixtures/timeout-infinity-abort/test-clock.mjs +65 -0
- package/benches/contrib/oss-skill-independent/fixtures/timeout-infinity-abort/test.mjs +4 -0
- package/benches/contrib/oss-skill-independent/fixtures/timeout-infinity-abort/upstream-package.json +48 -0
- package/benches/contrib/oss-skill-independent/fixtures/timeout-rejection-listener/index.d.ts +151 -0
- package/benches/contrib/oss-skill-independent/fixtures/timeout-rejection-listener/index.js +122 -0
- package/benches/contrib/oss-skill-independent/fixtures/timeout-rejection-listener/license +9 -0
- package/benches/contrib/oss-skill-independent/fixtures/timeout-rejection-listener/package.json +50 -0
- package/benches/contrib/oss-skill-independent/fixtures/timeout-rejection-listener/readme.md +190 -0
- package/benches/contrib/oss-skill-independent/fixtures/timeout-rejection-listener/test-clock.mjs +65 -0
- package/benches/contrib/oss-skill-independent/fixtures/timeout-rejection-listener/test.mjs +4 -0
- package/benches/contrib/oss-skill-independent/fixtures/timeout-rejection-listener/upstream-package.json +50 -0
- package/benches/contrib/oss-skill-independent/ground-truth/commander-async-listener-order/LICENSE +22 -0
- package/benches/contrib/oss-skill-independent/ground-truth/commander-async-listener-order/Readme.md +1015 -0
- package/benches/contrib/oss-skill-independent/ground-truth/commander-async-listener-order/esm.mjs +15 -0
- package/benches/contrib/oss-skill-independent/ground-truth/commander-async-listener-order/index.js +27 -0
- package/benches/contrib/oss-skill-independent/ground-truth/commander-async-listener-order/lib/argument.js +147 -0
- package/benches/contrib/oss-skill-independent/ground-truth/commander-async-listener-order/lib/command.js +1948 -0
- package/benches/contrib/oss-skill-independent/ground-truth/commander-async-listener-order/lib/error.js +45 -0
- package/benches/contrib/oss-skill-independent/ground-truth/commander-async-listener-order/lib/help.js +396 -0
- package/benches/contrib/oss-skill-independent/ground-truth/commander-async-listener-order/lib/option.js +208 -0
- package/benches/contrib/oss-skill-independent/ground-truth/commander-async-listener-order/lib/suggestSimilar.js +100 -0
- package/benches/contrib/oss-skill-independent/ground-truth/commander-async-listener-order/package-support.json +16 -0
- package/benches/contrib/oss-skill-independent/ground-truth/commander-async-listener-order/package.json +63 -0
- package/benches/contrib/oss-skill-independent/ground-truth/commander-async-listener-order/regression.test.mjs +5 -0
- package/benches/contrib/oss-skill-independent/ground-truth/commander-async-listener-order/test-clock.mjs +65 -0
- package/benches/contrib/oss-skill-independent/ground-truth/commander-async-listener-order/test.mjs +4 -0
- package/benches/contrib/oss-skill-independent/ground-truth/commander-async-listener-order/typings/index.d.ts +774 -0
- package/benches/contrib/oss-skill-independent/ground-truth/commander-async-listener-order/typings/index.test-d.ts +416 -0
- package/benches/contrib/oss-skill-independent/ground-truth/commander-async-listener-order/upstream-package.json +69 -0
- package/benches/contrib/oss-skill-independent/ground-truth/commander-output-isolation/LICENSE +22 -0
- package/benches/contrib/oss-skill-independent/ground-truth/commander-output-isolation/Readme.md +1149 -0
- package/benches/contrib/oss-skill-independent/ground-truth/commander-output-isolation/esm.mjs +16 -0
- package/benches/contrib/oss-skill-independent/ground-truth/commander-output-isolation/index.js +24 -0
- package/benches/contrib/oss-skill-independent/ground-truth/commander-output-isolation/lib/argument.js +149 -0
- package/benches/contrib/oss-skill-independent/ground-truth/commander-output-isolation/lib/command.js +2666 -0
- package/benches/contrib/oss-skill-independent/ground-truth/commander-output-isolation/lib/error.js +39 -0
- package/benches/contrib/oss-skill-independent/ground-truth/commander-output-isolation/lib/help.js +713 -0
- package/benches/contrib/oss-skill-independent/ground-truth/commander-output-isolation/lib/option.js +367 -0
- package/benches/contrib/oss-skill-independent/ground-truth/commander-output-isolation/lib/suggestSimilar.js +101 -0
- package/benches/contrib/oss-skill-independent/ground-truth/commander-output-isolation/package-support.json +16 -0
- package/benches/contrib/oss-skill-independent/ground-truth/commander-output-isolation/package.json +71 -0
- package/benches/contrib/oss-skill-independent/ground-truth/commander-output-isolation/regression.test.mjs +5 -0
- package/benches/contrib/oss-skill-independent/ground-truth/commander-output-isolation/test-clock.mjs +65 -0
- package/benches/contrib/oss-skill-independent/ground-truth/commander-output-isolation/test.mjs +4 -0
- package/benches/contrib/oss-skill-independent/ground-truth/commander-output-isolation/typings/esm.d.mts +3 -0
- package/benches/contrib/oss-skill-independent/ground-truth/commander-output-isolation/typings/index.d.ts +1045 -0
- package/benches/contrib/oss-skill-independent/ground-truth/commander-output-isolation/typings/index.test-d.ts +737 -0
- package/benches/contrib/oss-skill-independent/ground-truth/commander-output-isolation/upstream-package.json +82 -0
- package/benches/contrib/oss-skill-independent/ground-truth/limit-async-context/async-hooks-stub.js +15 -0
- package/benches/contrib/oss-skill-independent/ground-truth/limit-async-context/index.d.ts +40 -0
- package/benches/contrib/oss-skill-independent/ground-truth/limit-async-context/index.js +71 -0
- package/benches/contrib/oss-skill-independent/ground-truth/limit-async-context/license +9 -0
- package/benches/contrib/oss-skill-independent/ground-truth/limit-async-context/package.json +61 -0
- package/benches/contrib/oss-skill-independent/ground-truth/limit-async-context/readme.md +99 -0
- package/benches/contrib/oss-skill-independent/ground-truth/limit-async-context/regression.test.mjs +6 -0
- package/benches/contrib/oss-skill-independent/ground-truth/limit-async-context/test-clock.mjs +65 -0
- package/benches/contrib/oss-skill-independent/ground-truth/limit-async-context/test.mjs +4 -0
- package/benches/contrib/oss-skill-independent/ground-truth/limit-async-context/upstream-package.json +54 -0
- package/benches/contrib/oss-skill-independent/ground-truth/limit-async-context/vendor/yocto-queue/index.js +67 -0
- package/benches/contrib/oss-skill-independent/ground-truth/limit-async-context/vendor/yocto-queue/license +9 -0
- package/benches/contrib/oss-skill-independent/ground-truth/limit-async-context/vendor/yocto-queue/package.json +46 -0
- package/benches/contrib/oss-skill-independent/ground-truth/limit-map-iteration-rejection/index.d.ts +136 -0
- package/benches/contrib/oss-skill-independent/ground-truth/limit-map-iteration-rejection/index.js +148 -0
- package/benches/contrib/oss-skill-independent/ground-truth/limit-map-iteration-rejection/license +9 -0
- package/benches/contrib/oss-skill-independent/ground-truth/limit-map-iteration-rejection/package.json +57 -0
- package/benches/contrib/oss-skill-independent/ground-truth/limit-map-iteration-rejection/readme.md +181 -0
- package/benches/contrib/oss-skill-independent/ground-truth/limit-map-iteration-rejection/regression.test.mjs +5 -0
- package/benches/contrib/oss-skill-independent/ground-truth/limit-map-iteration-rejection/test-clock.mjs +65 -0
- package/benches/contrib/oss-skill-independent/ground-truth/limit-map-iteration-rejection/test.mjs +4 -0
- package/benches/contrib/oss-skill-independent/ground-truth/limit-map-iteration-rejection/upstream-package.json +58 -0
- package/benches/contrib/oss-skill-independent/ground-truth/limit-map-iteration-rejection/vendor/yocto-queue/index.js +84 -0
- package/benches/contrib/oss-skill-independent/ground-truth/limit-map-iteration-rejection/vendor/yocto-queue/license +9 -0
- package/benches/contrib/oss-skill-independent/ground-truth/limit-map-iteration-rejection/vendor/yocto-queue/package.json +48 -0
- package/benches/contrib/oss-skill-independent/ground-truth/oracle-commander-async-listener-order.mjs +1 -0
- package/benches/contrib/oss-skill-independent/ground-truth/oracle-commander-output-isolation.mjs +1 -0
- package/benches/contrib/oss-skill-independent/ground-truth/oracle-limit-async-context.mjs +1 -0
- package/benches/contrib/oss-skill-independent/ground-truth/oracle-limit-map-iteration-rejection.mjs +1 -0
- package/benches/contrib/oss-skill-independent/ground-truth/oracle-throttle-sync-throw.mjs +1 -0
- package/benches/contrib/oss-skill-independent/ground-truth/oracle-timeout-custom-timers.mjs +1 -0
- package/benches/contrib/oss-skill-independent/ground-truth/oracle-timeout-infinity-abort.mjs +1 -0
- package/benches/contrib/oss-skill-independent/ground-truth/oracle-timeout-rejection-listener.mjs +1 -0
- package/benches/contrib/oss-skill-independent/ground-truth/throttle-sync-throw/index.d.ts +136 -0
- package/benches/contrib/oss-skill-independent/ground-truth/throttle-sync-throw/index.js +121 -0
- package/benches/contrib/oss-skill-independent/ground-truth/throttle-sync-throw/license +9 -0
- package/benches/contrib/oss-skill-independent/ground-truth/throttle-sync-throw/package.json +60 -0
- package/benches/contrib/oss-skill-independent/ground-truth/throttle-sync-throw/readme.md +170 -0
- package/benches/contrib/oss-skill-independent/ground-truth/throttle-sync-throw/regression.test.mjs +6 -0
- package/benches/contrib/oss-skill-independent/ground-truth/throttle-sync-throw/test-clock.mjs +65 -0
- package/benches/contrib/oss-skill-independent/ground-truth/throttle-sync-throw/test.mjs +4 -0
- package/benches/contrib/oss-skill-independent/ground-truth/throttle-sync-throw/upstream-package.json +60 -0
- package/benches/contrib/oss-skill-independent/ground-truth/timeout-custom-timers/index.d.ts +149 -0
- package/benches/contrib/oss-skill-independent/ground-truth/timeout-custom-timers/index.js +95 -0
- package/benches/contrib/oss-skill-independent/ground-truth/timeout-custom-timers/license +9 -0
- package/benches/contrib/oss-skill-independent/ground-truth/timeout-custom-timers/package.json +52 -0
- package/benches/contrib/oss-skill-independent/ground-truth/timeout-custom-timers/readme.md +192 -0
- package/benches/contrib/oss-skill-independent/ground-truth/timeout-custom-timers/regression.test.mjs +5 -0
- package/benches/contrib/oss-skill-independent/ground-truth/timeout-custom-timers/test-clock.mjs +65 -0
- package/benches/contrib/oss-skill-independent/ground-truth/timeout-custom-timers/test.mjs +4 -0
- package/benches/contrib/oss-skill-independent/ground-truth/timeout-custom-timers/upstream-package.json +52 -0
- package/benches/contrib/oss-skill-independent/ground-truth/timeout-infinity-abort/index.d.ts +151 -0
- package/benches/contrib/oss-skill-independent/ground-truth/timeout-infinity-abort/index.js +114 -0
- package/benches/contrib/oss-skill-independent/ground-truth/timeout-infinity-abort/license +9 -0
- package/benches/contrib/oss-skill-independent/ground-truth/timeout-infinity-abort/package.json +48 -0
- package/benches/contrib/oss-skill-independent/ground-truth/timeout-infinity-abort/readme.md +158 -0
- package/benches/contrib/oss-skill-independent/ground-truth/timeout-infinity-abort/regression.test.mjs +5 -0
- package/benches/contrib/oss-skill-independent/ground-truth/timeout-infinity-abort/test-clock.mjs +65 -0
- package/benches/contrib/oss-skill-independent/ground-truth/timeout-infinity-abort/test.mjs +4 -0
- package/benches/contrib/oss-skill-independent/ground-truth/timeout-infinity-abort/upstream-package.json +48 -0
- package/benches/contrib/oss-skill-independent/ground-truth/timeout-rejection-listener/index.d.ts +151 -0
- package/benches/contrib/oss-skill-independent/ground-truth/timeout-rejection-listener/index.js +122 -0
- package/benches/contrib/oss-skill-independent/ground-truth/timeout-rejection-listener/license +9 -0
- package/benches/contrib/oss-skill-independent/ground-truth/timeout-rejection-listener/package.json +50 -0
- package/benches/contrib/oss-skill-independent/ground-truth/timeout-rejection-listener/readme.md +190 -0
- package/benches/contrib/oss-skill-independent/ground-truth/timeout-rejection-listener/regression.test.mjs +5 -0
- package/benches/contrib/oss-skill-independent/ground-truth/timeout-rejection-listener/test-clock.mjs +65 -0
- package/benches/contrib/oss-skill-independent/ground-truth/timeout-rejection-listener/test.mjs +4 -0
- package/benches/contrib/oss-skill-independent/ground-truth/timeout-rejection-listener/upstream-package.json +50 -0
- package/benches/contrib/oss-skill-independent/prompts/commander-async-listener-order.md +3 -0
- package/benches/contrib/oss-skill-independent/prompts/commander-output-isolation.md +3 -0
- package/benches/contrib/oss-skill-independent/prompts/limit-async-context.md +3 -0
- package/benches/contrib/oss-skill-independent/prompts/limit-map-iteration-rejection.md +3 -0
- package/benches/contrib/oss-skill-independent/prompts/throttle-sync-throw.md +3 -0
- package/benches/contrib/oss-skill-independent/prompts/timeout-custom-timers.md +3 -0
- package/benches/contrib/oss-skill-independent/prompts/timeout-infinity-abort.md +3 -0
- package/benches/contrib/oss-skill-independent/prompts/timeout-rejection-listener.md +3 -0
- package/benches/contrib/oss-skill-independent/provenance.json +1903 -0
- package/benches/contrib/oss-skill-independent/task-specs.json +63 -0
- package/benches/contrib/oss-skill-independent/test-clock.mjs +65 -0
- package/benches/contrib/oss-skill-independent/verifiers/cases.mjs +197 -0
- package/benches/contrib/oss-skill-independent/verifiers/commander-async-listener-order.mjs +1 -0
- package/benches/contrib/oss-skill-independent/verifiers/commander-output-isolation.mjs +1 -0
- package/benches/contrib/oss-skill-independent/verifiers/grade.mjs +48 -0
- package/benches/contrib/oss-skill-independent/verifiers/limit-async-context.mjs +1 -0
- package/benches/contrib/oss-skill-independent/verifiers/limit-map-iteration-rejection.mjs +1 -0
- package/benches/contrib/oss-skill-independent/verifiers/probe.mjs +16 -0
- package/benches/contrib/oss-skill-independent/verifiers/regression-evidence.mjs +105 -0
- package/benches/contrib/oss-skill-independent/verifiers/test-reporter.mjs +29 -0
- package/benches/contrib/oss-skill-independent/verifiers/throttle-sync-throw.mjs +1 -0
- package/benches/contrib/oss-skill-independent/verifiers/timeout-custom-timers.mjs +1 -0
- package/benches/contrib/oss-skill-independent/verifiers/timeout-infinity-abort.mjs +1 -0
- package/benches/contrib/oss-skill-independent/verifiers/timeout-rejection-listener.mjs +1 -0
- package/dist/cli.js +166 -53
- package/dist/commands/bench-check-json.test.js +221 -0
- package/dist/commands/bench-check-report.js +48 -0
- package/dist/commands/bench-command-template.js +129 -0
- package/dist/commands/bench-manage.js +91 -0
- package/dist/commands/bench-manage.test.js +87 -0
- package/dist/commands/bench.js +68 -38
- package/dist/commands/bench.test.js +101 -0
- package/dist/commands/eval-component.js +17 -0
- package/dist/commands/eval-export.js +152 -0
- package/dist/commands/eval-export.test.js +122 -0
- package/dist/commands/eval.js +14 -3
- package/dist/commands/eval.test.js +58 -1
- package/dist/harness/bench.js +21 -2
- package/dist/harness/eval-audit.js +42 -4
- package/dist/harness/eval-budget.js +51 -0
- package/dist/harness/eval-budget.test.js +210 -0
- package/dist/harness/eval-component.test.js +36 -0
- package/dist/harness/eval-contract.js +5 -1
- package/dist/harness/replay-package.js +85 -0
- package/dist/harness/runner.js +22 -1
- package/docs/bench-authoring.md +40 -0
- package/docs/bench-check-json.md +115 -0
- package/docs/case-management.md +65 -0
- package/docs/eval-component.md +60 -49
- package/docs/examples/check-receiver-mechanism-proposal.mjs +124 -0
- package/docs/examples/prepare-native-diff-probe.mjs +75 -0
- package/docs/examples/reproduce-independent-comparison-budget.mjs +73 -0
- package/docs/first-real-eval.md +6 -0
- package/docs/growth-roadmap-2026-10.md +57 -93
- package/docs/metrics.md +21 -0
- package/docs/plans/2026-10-14-evidence-and-release-sequence.md +30 -13
- package/docs/plans/2026-10-15-independent-comparison-budget.json +1769 -0
- package/docs/plans/2026-10-15-independent-comparison-inputs.json +373 -0
- package/docs/plans/2026-10-15-independent-comparison-proposal.md +177 -0
- package/docs/plans/2026-10-15-native-diff-mechanism.md +105 -0
- package/docs/plans/2026-10-15-receiver-mechanism-proposal.json +342 -0
- package/docs/plans/2026-10-15-receiver-mechanism-proposal.md +146 -0
- package/docs/plans/2026-10-15-receiver-mechanism-verification.json +105 -0
- package/docs/plans/2026-10-16-case-workflow-and-release.md +30 -0
- package/docs/releases/0.10.0.md +45 -0
- package/docs/releases/0.9.0-verification.json +38 -0
- package/docs/releases/0.9.0.md +20 -3
- package/docs/releases/0.9.1-first-publication.json +249 -0
- package/docs/releases/0.9.1-verification.json +122 -0
- package/docs/releases/0.9.1.md +65 -0
- package/docs/releases/trusted-publishing.md +114 -0
- package/docs/replay-packages.md +88 -0
- package/docs/schemas/bench-check.schema.json +109 -0
- package/docs/schemas/eval-request.schema.json +12 -0
- package/docs/sharing-results.md +6 -0
- package/docs/skill-evaluation-evidence.md +52 -0
- package/evidence/2026-10-15-diagnosing-receiver-correction.md +140 -0
- package/evidence/2026-10-15-independent-comparison-regression-stop.md +162 -0
- package/evidence/2026-10-15-independent-offline-readiness.md +144 -0
- package/evidence/2026-10-15-native-diff-mechanism.md +196 -0
- package/evidence/2026-10-15-receiver-mechanism-stop.md +154 -0
- package/evidence/artifacts/2026-10-15-diagnosing-receiver-correction/README.md +35 -0
- package/evidence/artifacts/2026-10-15-diagnosing-receiver-correction/expected.json +577 -0
- package/evidence/artifacts/2026-10-15-diagnosing-receiver-correction/receiver-contract.test.mjs +138 -0
- package/evidence/artifacts/2026-10-15-diagnosing-receiver-correction/replay.mjs +127 -0
- package/evidence/artifacts/2026-10-15-diagnosing-receiver-correction/verification.json +105 -0
- package/evidence/artifacts/2026-10-15-independent-comparison-regression-stop/README.md +32 -0
- package/evidence/artifacts/2026-10-15-independent-comparison-regression-stop/checks.json +32 -0
- package/evidence/artifacts/2026-10-15-independent-comparison-regression-stop/package.tar.gz +0 -0
- package/evidence/artifacts/2026-10-15-independent-comparison-regression-stop/verification.json +25 -0
- package/evidence/artifacts/2026-10-15-independent-offline-readiness/README.md +17 -0
- package/evidence/artifacts/2026-10-15-independent-offline-readiness/verification.json +1548 -0
- package/evidence/artifacts/2026-10-15-native-diff-mechanism/README.md +48 -0
- package/evidence/artifacts/2026-10-15-native-diff-mechanism/package.tar.gz +0 -0
- package/evidence/artifacts/2026-10-15-receiver-mechanism-stop/README.md +38 -0
- package/evidence/artifacts/2026-10-15-receiver-mechanism-stop/checks.json +118 -0
- package/evidence/artifacts/2026-10-15-receiver-mechanism-stop/package.tar.gz +0 -0
- package/evidence/artifacts/2026-10-15-receiver-mechanism-stop/verification.json +36 -0
- package/evidence/inputs/diagnosing-bugs-compact-v4.1-receiver/LICENSE +21 -0
- package/evidence/inputs/diagnosing-bugs-compact-v4.1-receiver/SKILL.md +51 -0
- package/evidence/inputs/diagnosing-bugs-compact-v4.1-receiver/agents/openai.yaml +3 -0
- package/evidence/inputs/diagnosing-bugs-compact-v4.1-receiver/scripts/hitl-loop.template.sh +44 -0
- package/package.json +3 -3
- package/skills/skillfit/SKILL.md +17 -5
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
/*
|
|
2
|
+
How it works:
|
|
3
|
+
`this.#head` is an instance of `Node` which keeps track of its current value and nests another instance of `Node` that keeps the value that comes after it. When a value is provided to `.enqueue()`, the code needs to iterate through `this.#head`, going deeper and deeper to find the last value. However, iterating through every single item is slow. This problem is solved by saving a reference to the last value as `this.#tail` so that it can reference it to add a new value.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
class Node {
|
|
7
|
+
value;
|
|
8
|
+
next;
|
|
9
|
+
|
|
10
|
+
constructor(value) {
|
|
11
|
+
this.value = value;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export default class Queue {
|
|
16
|
+
#head;
|
|
17
|
+
#tail;
|
|
18
|
+
#size;
|
|
19
|
+
|
|
20
|
+
constructor() {
|
|
21
|
+
this.clear();
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
enqueue(value) {
|
|
25
|
+
const node = new Node(value);
|
|
26
|
+
|
|
27
|
+
if (this.#head) {
|
|
28
|
+
this.#tail.next = node;
|
|
29
|
+
this.#tail = node;
|
|
30
|
+
} else {
|
|
31
|
+
this.#head = node;
|
|
32
|
+
this.#tail = node;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
this.#size++;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
dequeue() {
|
|
39
|
+
const current = this.#head;
|
|
40
|
+
if (!current) {
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
this.#head = this.#head.next;
|
|
45
|
+
this.#size--;
|
|
46
|
+
return current.value;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
peek() {
|
|
50
|
+
if (!this.#head) {
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
return this.#head.value;
|
|
55
|
+
|
|
56
|
+
// TODO: Node.js 18.
|
|
57
|
+
// return this.#head?.value;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
clear() {
|
|
61
|
+
this.#head = undefined;
|
|
62
|
+
this.#tail = undefined;
|
|
63
|
+
this.#size = 0;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
get size() {
|
|
67
|
+
return this.#size;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
* [Symbol.iterator]() {
|
|
71
|
+
let current = this.#head;
|
|
72
|
+
|
|
73
|
+
while (current) {
|
|
74
|
+
yield current.value;
|
|
75
|
+
current = current.next;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
* drain() {
|
|
80
|
+
while (this.#head) {
|
|
81
|
+
yield this.dequeue();
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.com)
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
6
|
+
|
|
7
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
8
|
+
|
|
9
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "yocto-queue",
|
|
3
|
+
"version": "1.2.1",
|
|
4
|
+
"description": "Tiny queue data structure",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"repository": "sindresorhus/yocto-queue",
|
|
7
|
+
"funding": "https://github.com/sponsors/sindresorhus",
|
|
8
|
+
"author": {
|
|
9
|
+
"name": "Sindre Sorhus",
|
|
10
|
+
"email": "sindresorhus@gmail.com",
|
|
11
|
+
"url": "https://sindresorhus.com"
|
|
12
|
+
},
|
|
13
|
+
"type": "module",
|
|
14
|
+
"exports": "./index.js",
|
|
15
|
+
"types": "./index.d.ts",
|
|
16
|
+
"sideEffects": false,
|
|
17
|
+
"engines": {
|
|
18
|
+
"node": ">=12.20"
|
|
19
|
+
},
|
|
20
|
+
"scripts": {
|
|
21
|
+
"//test": "xo && ava && tsd",
|
|
22
|
+
"test": "ava && tsd"
|
|
23
|
+
},
|
|
24
|
+
"files": [
|
|
25
|
+
"index.js",
|
|
26
|
+
"index.d.ts"
|
|
27
|
+
],
|
|
28
|
+
"keywords": [
|
|
29
|
+
"queue",
|
|
30
|
+
"data",
|
|
31
|
+
"structure",
|
|
32
|
+
"algorithm",
|
|
33
|
+
"queues",
|
|
34
|
+
"queuing",
|
|
35
|
+
"list",
|
|
36
|
+
"array",
|
|
37
|
+
"linkedlist",
|
|
38
|
+
"fifo",
|
|
39
|
+
"enqueue",
|
|
40
|
+
"dequeue",
|
|
41
|
+
"data-structure"
|
|
42
|
+
],
|
|
43
|
+
"devDependencies": {
|
|
44
|
+
"ava": "^3.15.0",
|
|
45
|
+
"tsd": "^0.17.0",
|
|
46
|
+
"xo": "^0.44.0"
|
|
47
|
+
}
|
|
48
|
+
}
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
type AnyFunction = (...arguments_: readonly any[]) => unknown;
|
|
2
|
+
|
|
3
|
+
export type ThrottledFunction<F extends AnyFunction> = F & {
|
|
4
|
+
/**
|
|
5
|
+
Whether future function calls should be throttled or count towards throttling thresholds.
|
|
6
|
+
|
|
7
|
+
@default true
|
|
8
|
+
*/
|
|
9
|
+
isEnabled: boolean;
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
The number of queued items waiting to be executed.
|
|
13
|
+
*/
|
|
14
|
+
readonly queueSize: number;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export type Options = {
|
|
18
|
+
/**
|
|
19
|
+
The maximum number of calls within an `interval`.
|
|
20
|
+
*/
|
|
21
|
+
readonly limit: number;
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
The timespan for `limit` in milliseconds.
|
|
25
|
+
*/
|
|
26
|
+
readonly interval: number;
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
Use a strict, more resource intensive, throttling algorithm. The default algorithm uses a windowed approach that will work correctly in most cases, limiting the total number of calls at the specified limit per interval window. The strict algorithm throttles each call individually, ensuring the limit is not exceeded for any interval.
|
|
30
|
+
|
|
31
|
+
@default false
|
|
32
|
+
*/
|
|
33
|
+
readonly strict?: boolean;
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
Abort pending executions. When aborted, all unresolved promises are rejected with `signal.reason`.
|
|
37
|
+
|
|
38
|
+
@example
|
|
39
|
+
```
|
|
40
|
+
import pThrottle from 'p-throttle';
|
|
41
|
+
|
|
42
|
+
const controller = new AbortController();
|
|
43
|
+
|
|
44
|
+
const throttle = pThrottle({
|
|
45
|
+
limit: 2,
|
|
46
|
+
interval: 1000,
|
|
47
|
+
signal: controller.signal
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
const throttled = throttle(() => {
|
|
51
|
+
console.log('Executing...');
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
await throttled();
|
|
55
|
+
await throttled();
|
|
56
|
+
controller.abort('aborted')
|
|
57
|
+
await throttled();
|
|
58
|
+
//=> Executing...
|
|
59
|
+
//=> Executing...
|
|
60
|
+
//=> Promise rejected with reason `aborted`
|
|
61
|
+
```
|
|
62
|
+
*/
|
|
63
|
+
signal?: AbortSignal;
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
Get notified when function calls are delayed due to exceeding the `limit` of allowed calls within the given `interval`.
|
|
67
|
+
|
|
68
|
+
Can be useful for monitoring the throttling efficiency.
|
|
69
|
+
|
|
70
|
+
@example
|
|
71
|
+
```
|
|
72
|
+
import pThrottle from 'p-throttle';
|
|
73
|
+
|
|
74
|
+
const throttle = pThrottle({
|
|
75
|
+
limit: 2,
|
|
76
|
+
interval: 1000,
|
|
77
|
+
onDelay: (a, b) => {
|
|
78
|
+
console.log(`Reached interval limit, call is delayed for ${a} ${b}`);
|
|
79
|
+
},
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
const throttled = throttle(() => {
|
|
83
|
+
console.log('Executing...');
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
await throttled(1, 2);
|
|
87
|
+
await throttled(3, 4);
|
|
88
|
+
await throttled(5, 6);
|
|
89
|
+
//=> Executing with 1 2...
|
|
90
|
+
//=> Executing with 3 4...
|
|
91
|
+
//=> Reached interval limit, call is delayed for 5 6
|
|
92
|
+
//=> Executing with 5 6...
|
|
93
|
+
```
|
|
94
|
+
*/
|
|
95
|
+
readonly onDelay?: (...arguments_: readonly any[]) => void;
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
Throttle promise-returning/async/normal functions.
|
|
100
|
+
|
|
101
|
+
It rate-limits function calls without discarding them, making it ideal for external API interactions where avoiding call loss is crucial.
|
|
102
|
+
|
|
103
|
+
@returns A throttle function.
|
|
104
|
+
|
|
105
|
+
Both the `limit` and `interval` options must be specified.
|
|
106
|
+
|
|
107
|
+
@example
|
|
108
|
+
```
|
|
109
|
+
import pThrottle from 'p-throttle';
|
|
110
|
+
|
|
111
|
+
const now = Date.now();
|
|
112
|
+
|
|
113
|
+
const throttle = pThrottle({
|
|
114
|
+
limit: 2,
|
|
115
|
+
interval: 1000
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
const throttled = throttle(async index => {
|
|
119
|
+
const secDiff = ((Date.now() - now) / 1000).toFixed();
|
|
120
|
+
return `${index}: ${secDiff}s`;
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
for (let index = 1; index <= 6; index++) {
|
|
124
|
+
(async () => {
|
|
125
|
+
console.log(await throttled(index));
|
|
126
|
+
})();
|
|
127
|
+
}
|
|
128
|
+
//=> 1: 0s
|
|
129
|
+
//=> 2: 0s
|
|
130
|
+
//=> 3: 1s
|
|
131
|
+
//=> 4: 1s
|
|
132
|
+
//=> 5: 2s
|
|
133
|
+
//=> 6: 2s
|
|
134
|
+
```
|
|
135
|
+
*/
|
|
136
|
+
export default function pThrottle(options: Options): <F extends AnyFunction>(function_: F) => ThrottledFunction<F>;
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
const registry = new FinalizationRegistry(({signal, aborted}) => {
|
|
2
|
+
signal?.removeEventListener('abort', aborted);
|
|
3
|
+
});
|
|
4
|
+
|
|
5
|
+
export default function pThrottle({limit, interval, strict, signal, onDelay}) {
|
|
6
|
+
if (!Number.isFinite(limit)) {
|
|
7
|
+
throw new TypeError('Expected `limit` to be a finite number');
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
if (!Number.isFinite(interval)) {
|
|
11
|
+
throw new TypeError('Expected `interval` to be a finite number');
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
const queue = new Map();
|
|
15
|
+
|
|
16
|
+
let currentTick = 0;
|
|
17
|
+
let activeCount = 0;
|
|
18
|
+
|
|
19
|
+
function windowedDelay() {
|
|
20
|
+
const now = Date.now();
|
|
21
|
+
|
|
22
|
+
if ((now - currentTick) > interval) {
|
|
23
|
+
activeCount = 1;
|
|
24
|
+
currentTick = now;
|
|
25
|
+
return 0;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
if (activeCount < limit) {
|
|
29
|
+
activeCount++;
|
|
30
|
+
} else {
|
|
31
|
+
currentTick += interval;
|
|
32
|
+
activeCount = 1;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
return currentTick - now;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const strictTicks = [];
|
|
39
|
+
|
|
40
|
+
function strictDelay() {
|
|
41
|
+
const now = Date.now();
|
|
42
|
+
|
|
43
|
+
// Clear the queue if there's a significant delay since the last execution
|
|
44
|
+
if (strictTicks.length > 0 && now - strictTicks.at(-1) > interval) {
|
|
45
|
+
strictTicks.length = 0;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// If the queue is not full, add the current time and execute immediately
|
|
49
|
+
if (strictTicks.length < limit) {
|
|
50
|
+
strictTicks.push(now);
|
|
51
|
+
return 0;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
// Calculate the next execution time based on the first item in the queue
|
|
55
|
+
const nextExecutionTime = strictTicks[0] + interval;
|
|
56
|
+
|
|
57
|
+
// Shift the queue and add the new execution time
|
|
58
|
+
strictTicks.shift();
|
|
59
|
+
strictTicks.push(nextExecutionTime);
|
|
60
|
+
|
|
61
|
+
// Calculate the delay for the current execution
|
|
62
|
+
return Math.max(0, nextExecutionTime - now);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
const getDelay = strict ? strictDelay : windowedDelay;
|
|
66
|
+
|
|
67
|
+
return function_ => {
|
|
68
|
+
const throttled = function (...arguments_) {
|
|
69
|
+
if (!throttled.isEnabled) {
|
|
70
|
+
return (async () => function_.apply(this, arguments_))();
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
let timeoutId;
|
|
74
|
+
return new Promise((resolve, reject) => {
|
|
75
|
+
const execute = () => {
|
|
76
|
+
resolve(function_.apply(this, arguments_));
|
|
77
|
+
queue.delete(timeoutId);
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
const delay = getDelay();
|
|
81
|
+
if (delay > 0) {
|
|
82
|
+
timeoutId = setTimeout(execute, delay);
|
|
83
|
+
queue.set(timeoutId, reject);
|
|
84
|
+
onDelay?.(...arguments_);
|
|
85
|
+
} else {
|
|
86
|
+
execute();
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
const aborted = () => {
|
|
92
|
+
for (const timeout of queue.keys()) {
|
|
93
|
+
clearTimeout(timeout);
|
|
94
|
+
queue.get(timeout)(signal.reason);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
queue.clear();
|
|
98
|
+
strictTicks.splice(0, strictTicks.length);
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
registry.register(throttled, {signal, aborted});
|
|
102
|
+
|
|
103
|
+
signal?.throwIfAborted();
|
|
104
|
+
signal?.addEventListener('abort', aborted, {once: true});
|
|
105
|
+
|
|
106
|
+
throttled.isEnabled = true;
|
|
107
|
+
|
|
108
|
+
Object.defineProperty(throttled, 'queueSize', {
|
|
109
|
+
get() {
|
|
110
|
+
return queue.size;
|
|
111
|
+
},
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
return throttled;
|
|
115
|
+
};
|
|
116
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.com)
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
6
|
+
|
|
7
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
8
|
+
|
|
9
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "p-throttle",
|
|
3
|
+
"version": "7.0.0",
|
|
4
|
+
"description": "Throttle promise-returning & async functions",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"repository": "sindresorhus/p-throttle",
|
|
7
|
+
"funding": "https://github.com/sponsors/sindresorhus",
|
|
8
|
+
"author": {
|
|
9
|
+
"name": "Sindre Sorhus",
|
|
10
|
+
"email": "sindresorhus@gmail.com",
|
|
11
|
+
"url": "https://sindresorhus.com"
|
|
12
|
+
},
|
|
13
|
+
"type": "module",
|
|
14
|
+
"exports": {
|
|
15
|
+
"types": "./index.d.ts",
|
|
16
|
+
"default": "./index.js"
|
|
17
|
+
},
|
|
18
|
+
"sideEffects": false,
|
|
19
|
+
"engines": {
|
|
20
|
+
"node": ">=18"
|
|
21
|
+
},
|
|
22
|
+
"scripts": {
|
|
23
|
+
"test": "node --test test.mjs"
|
|
24
|
+
},
|
|
25
|
+
"files": [
|
|
26
|
+
"index.js",
|
|
27
|
+
"index.d.ts"
|
|
28
|
+
],
|
|
29
|
+
"keywords": [
|
|
30
|
+
"promise",
|
|
31
|
+
"throttle",
|
|
32
|
+
"throat",
|
|
33
|
+
"limit",
|
|
34
|
+
"limited",
|
|
35
|
+
"interval",
|
|
36
|
+
"rate",
|
|
37
|
+
"batch",
|
|
38
|
+
"ratelimit",
|
|
39
|
+
"queue",
|
|
40
|
+
"discard",
|
|
41
|
+
"async",
|
|
42
|
+
"await",
|
|
43
|
+
"promises",
|
|
44
|
+
"time",
|
|
45
|
+
"out",
|
|
46
|
+
"cancel",
|
|
47
|
+
"bluebird"
|
|
48
|
+
],
|
|
49
|
+
"devDependencies": {
|
|
50
|
+
"ava": "^6.2.0",
|
|
51
|
+
"delay": "^6.0.0",
|
|
52
|
+
"in-range": "^3.0.0",
|
|
53
|
+
"time-span": "^5.1.0",
|
|
54
|
+
"tsd": "^0.31.2",
|
|
55
|
+
"xo": "^0.59.3"
|
|
56
|
+
},
|
|
57
|
+
"ava": {
|
|
58
|
+
"serial": true
|
|
59
|
+
}
|
|
60
|
+
}
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
# p-throttle
|
|
2
|
+
|
|
3
|
+
> Throttle promise-returning & async functions
|
|
4
|
+
|
|
5
|
+
It also works with normal functions.
|
|
6
|
+
|
|
7
|
+
It rate-limits function calls without discarding them, making it ideal for external API interactions where avoiding call loss is crucial.
|
|
8
|
+
|
|
9
|
+
## Install
|
|
10
|
+
|
|
11
|
+
```sh
|
|
12
|
+
npm install p-throttle
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Usage
|
|
16
|
+
|
|
17
|
+
Here, the throttled function is only called twice a second:
|
|
18
|
+
|
|
19
|
+
```js
|
|
20
|
+
import pThrottle from 'p-throttle';
|
|
21
|
+
|
|
22
|
+
const now = Date.now();
|
|
23
|
+
|
|
24
|
+
const throttle = pThrottle({
|
|
25
|
+
limit: 2,
|
|
26
|
+
interval: 1000
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
const throttled = throttle(async index => {
|
|
30
|
+
const secDiff = ((Date.now() - now) / 1000).toFixed();
|
|
31
|
+
return `${index}: ${secDiff}s`;
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
for (let index = 1; index <= 6; index++) {
|
|
35
|
+
(async () => {
|
|
36
|
+
console.log(await throttled(index));
|
|
37
|
+
})();
|
|
38
|
+
}
|
|
39
|
+
//=> 1: 0s
|
|
40
|
+
//=> 2: 0s
|
|
41
|
+
//=> 3: 1s
|
|
42
|
+
//=> 4: 1s
|
|
43
|
+
//=> 5: 2s
|
|
44
|
+
//=> 6: 2s
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
## API
|
|
48
|
+
|
|
49
|
+
### pThrottle(options)
|
|
50
|
+
|
|
51
|
+
Returns a throttle function.
|
|
52
|
+
|
|
53
|
+
#### options
|
|
54
|
+
|
|
55
|
+
Type: `object`
|
|
56
|
+
|
|
57
|
+
Both the `limit` and `interval` options must be specified.
|
|
58
|
+
|
|
59
|
+
##### limit
|
|
60
|
+
|
|
61
|
+
Type: `number`
|
|
62
|
+
|
|
63
|
+
The maximum number of calls within an `interval`.
|
|
64
|
+
|
|
65
|
+
##### interval
|
|
66
|
+
|
|
67
|
+
Type: `number`
|
|
68
|
+
|
|
69
|
+
The timespan for `limit` in milliseconds.
|
|
70
|
+
|
|
71
|
+
##### strict
|
|
72
|
+
|
|
73
|
+
Type: `boolean`\
|
|
74
|
+
Default: `false`
|
|
75
|
+
|
|
76
|
+
Use a strict, more resource intensive, throttling algorithm. The default algorithm uses a windowed approach that will work correctly in most cases, limiting the total number of calls at the specified limit per interval window. The strict algorithm throttles each call individually, ensuring the limit is not exceeded for any interval.
|
|
77
|
+
|
|
78
|
+
#### signal
|
|
79
|
+
|
|
80
|
+
Type: [`AbortSignal`](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal)
|
|
81
|
+
|
|
82
|
+
Abort pending executions. When aborted, all unresolved promises are rejected with `signal.reason`.
|
|
83
|
+
|
|
84
|
+
```js
|
|
85
|
+
import pThrottle from 'p-throttle';
|
|
86
|
+
|
|
87
|
+
const controller = new AbortController();
|
|
88
|
+
|
|
89
|
+
const throttle = pThrottle({
|
|
90
|
+
limit: 2,
|
|
91
|
+
interval: 1000,
|
|
92
|
+
signal: controller.signal
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
const throttled = throttle(() => {
|
|
96
|
+
console.log('Executing...');
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
await throttled();
|
|
100
|
+
await throttled();
|
|
101
|
+
controller.abort('aborted')
|
|
102
|
+
await throttled();
|
|
103
|
+
//=> Executing...
|
|
104
|
+
//=> Executing...
|
|
105
|
+
//=> Promise rejected with reason `aborted`
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
##### onDelay
|
|
109
|
+
|
|
110
|
+
Type: `Function`
|
|
111
|
+
|
|
112
|
+
Get notified when function calls are delayed due to exceeding the `limit` of allowed calls within the given `interval`. The delayed call arguments are passed to the `onDelay` callback.
|
|
113
|
+
|
|
114
|
+
Can be useful for monitoring the throttling efficiency.
|
|
115
|
+
|
|
116
|
+
In the following example, the third call gets delayed and triggers the `onDelay` callback:
|
|
117
|
+
|
|
118
|
+
```js
|
|
119
|
+
import pThrottle from 'p-throttle';
|
|
120
|
+
|
|
121
|
+
const throttle = pThrottle({
|
|
122
|
+
limit: 2,
|
|
123
|
+
interval: 1000,
|
|
124
|
+
onDelay: (a, b) => {
|
|
125
|
+
console.log(`Reached interval limit, call is delayed for ${a} ${b}`);
|
|
126
|
+
},
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
const throttled = throttle((a, b) => {
|
|
130
|
+
console.log(`Executing with ${a} ${b}...`);
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
await throttled(1, 2);
|
|
134
|
+
await throttled(3, 4);
|
|
135
|
+
await throttled(5, 6);
|
|
136
|
+
//=> Executing with 1 2...
|
|
137
|
+
//=> Executing with 3 4...
|
|
138
|
+
//=> Reached interval limit, call is delayed for 5 6
|
|
139
|
+
//=> Executing with 5 6...
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
### throttle(function_)
|
|
143
|
+
|
|
144
|
+
Returns a throttled version of `function_`.
|
|
145
|
+
|
|
146
|
+
#### function_
|
|
147
|
+
|
|
148
|
+
Type: `Function`
|
|
149
|
+
|
|
150
|
+
A promise-returning/async function or a normal function.
|
|
151
|
+
|
|
152
|
+
### throttledFn.isEnabled
|
|
153
|
+
|
|
154
|
+
Type: `boolean`\
|
|
155
|
+
Default: `true`
|
|
156
|
+
|
|
157
|
+
Whether future function calls should be throttled and count towards throttling thresholds.
|
|
158
|
+
|
|
159
|
+
### throttledFn.queueSize
|
|
160
|
+
|
|
161
|
+
Type: `number`
|
|
162
|
+
|
|
163
|
+
The number of queued items waiting to be executed.
|
|
164
|
+
|
|
165
|
+
## Related
|
|
166
|
+
|
|
167
|
+
- [p-debounce](https://github.com/sindresorhus/p-debounce) - Debounce promise-returning & async functions
|
|
168
|
+
- [p-limit](https://github.com/sindresorhus/p-limit) - Run multiple promise-returning & async functions with limited concurrency
|
|
169
|
+
- [p-memoize](https://github.com/sindresorhus/p-memoize) - Memoize promise-returning & async functions
|
|
170
|
+
- [More…](https://github.com/sindresorhus/promise-fun)
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import assert from 'node:assert/strict';
|
|
2
|
+
|
|
3
|
+
export async function flush() {
|
|
4
|
+
for (let i = 0; i < 24; i++) await Promise.resolve();
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export function observe(promise) {
|
|
8
|
+
const state = {status: 'pending'};
|
|
9
|
+
Promise.resolve(promise).then(
|
|
10
|
+
value => Object.assign(state, {status: 'fulfilled', value}),
|
|
11
|
+
reason => Object.assign(state, {status: 'rejected', reason}),
|
|
12
|
+
);
|
|
13
|
+
return state;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export function gate() {
|
|
17
|
+
let release;
|
|
18
|
+
const promise = new Promise(resolve => { release = resolve; });
|
|
19
|
+
return {promise, release};
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
// Only test processes replace their clock; fixtures and the eval runner stay unchanged.
|
|
23
|
+
export async function withClock(run) {
|
|
24
|
+
const original = {setTimeout: globalThis.setTimeout, clearTimeout: globalThis.clearTimeout, now: Date.now};
|
|
25
|
+
let now = 1000, serial = 0;
|
|
26
|
+
const timers = new Map(), errors = [];
|
|
27
|
+
globalThis.setTimeout = (fn, delay = 0, ...args) => {
|
|
28
|
+
const id = ++serial;
|
|
29
|
+
timers.set(id, {at: now + Math.max(0, Number(delay)), fn, args});
|
|
30
|
+
return id;
|
|
31
|
+
};
|
|
32
|
+
globalThis.clearTimeout = id => timers.delete(id);
|
|
33
|
+
Date.now = () => now;
|
|
34
|
+
const clock = {
|
|
35
|
+
get now() { return now; },
|
|
36
|
+
get pending() { return timers.size; },
|
|
37
|
+
async advance(amount) {
|
|
38
|
+
const end = now + amount;
|
|
39
|
+
for (let steps = 0; ; steps++) {
|
|
40
|
+
assert.ok(steps < 1000, 'timer queue must make bounded progress');
|
|
41
|
+
const next = [...timers.entries()].filter(([, t]) => t.at <= end)
|
|
42
|
+
.sort((a, b) => a[1].at - b[1].at || a[0] - b[0])[0];
|
|
43
|
+
if (!next) break;
|
|
44
|
+
const [id, timer] = next;
|
|
45
|
+
timers.delete(id); now = timer.at;
|
|
46
|
+
try {
|
|
47
|
+
const result = timer.fn(...timer.args);
|
|
48
|
+
if (result?.then) Promise.resolve(result).catch(error => errors.push(error));
|
|
49
|
+
} catch (error) { errors.push(error); }
|
|
50
|
+
await flush();
|
|
51
|
+
}
|
|
52
|
+
now = end;
|
|
53
|
+
await flush();
|
|
54
|
+
},
|
|
55
|
+
};
|
|
56
|
+
try {
|
|
57
|
+
await run(clock);
|
|
58
|
+
await flush();
|
|
59
|
+
assert.deepEqual(errors, [], 'scheduled callbacks must not throw outside their public promises');
|
|
60
|
+
} finally {
|
|
61
|
+
globalThis.setTimeout = original.setTimeout;
|
|
62
|
+
globalThis.clearTimeout = original.clearTimeout;
|
|
63
|
+
Date.now = original.now;
|
|
64
|
+
}
|
|
65
|
+
}
|