{"_id":"@aegisjsproject/tempo","_rev":"2-b6d8f4b092b0022894486700bf4d0d23","name":"@aegisjsproject/tempo","dist-tags":{"latest":"1.0.1"},"versions":{"1.0.0":{"name":"@aegisjsproject/tempo","version":"1.0.0","keywords":[],"author":{"name":"Chris Zuber","email":"admin@kernvalley.us"},"license":"MIT","_id":"@aegisjsproject/tempo@1.0.0","maintainers":[{"name":"shgysk8zer0","email":"shgysk8zer0@gmail.com"}],"homepage":"https://github.com/AegisJSProject/tempo#readme","bugs":{"url":"https://github.com/AegisJSProject/tempo/issues"},"dist":{"shasum":"c4dbced9426f0af5682e6af5d40f634b71360de3","tarball":"https://registry.npmjs.org/@aegisjsproject/tempo/-/tempo-1.0.0.tgz","fileCount":8,"integrity":"sha512-cRWsOXI96FpMXnIsU3zmu9BsN8bHxxIcA3t2Sg/fcliCEek6ImiMgvrW8X8XXum7Lu1E4Uf1Zd/JAHMRcZOGAA==","signatures":[{"sig":"MEQCIDnI0wZYV/1dEny4qD1iEl2e84UpaOQ/1LKPc6Ijm/FTAiAil9+UUJwMUp1gtpsFoq3nXMffQTMhqKgmnfovPInDNQ==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@aegisjsproject%2ftempo@1.0.0","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":26561},"main":"./indtempoex.cjs","type":"module","unpkg":"./tempo.min.js","module":"./tempo.js","engines":{"node":">=18.0.0"},"exports":{".":{"import":"./tempo.js","require":"./tempo.cjs"},"./*":{"import":"./*.js","require":"./*.cjs"},"./*.js":{"import":"./*.js","require":"./*.cjs"},"./*.cjs":{"import":"./*.js","require":"./*.cjs"},"./*.mjs":{"import":"./*.js","require":"./*.cjs"}},"funding":[{"url":"https://liberapay.com/shgysk8zer0","type":"librepay"},{"url":"https://github.com/sponsors/shgysk8zer0","type":"github"}],"gitHead":"962783210fdc16f3d8ddb1a6a029a5433553da82","private":false,"scripts":{"test":"npm run lint:js && npm run run:tests","build":"npm run build:js","clean":"rm -f ./*.cjs","fix:js":"eslint . --fix","lint:js":"eslint .","prepare":"npm test && npm run build","build:js":"npm run clean && rollup -c rollup.config.js","run:tests":"node --test","preversion":"npm test && npm run build","create:lock":"npm i --package-lock-only --ignore-scripts --no-audit --no-fund","version:bump":"npm run version:bump:patch","version:bump:major":"npm version --no-git-tag-version major && npm run create:lock","version:bump:minor":"npm version --no-git-tag-version minor && npm run create:lock","version:bump:patch":"npm version --no-git-tag-version patch && npm run create:lock"},"_npmUser":{"name":"shgysk8zer0","email":"shgysk8zer0@gmail.com"},"repository":{"url":"git+https://github.com/AegisJSProject/tempo.git","type":"git"},"_npmVersion":"10.1.0","description":"Tempo provides advanced debouncing and throttling utilities for fine-grained execution control.","directories":{},"_nodeVersion":"20.9.0","_hasShrinkwrap":false,"devDependencies":{"rollup":"^4.36.0","@rollup/plugin-terser":"^0.4.4","@shgysk8zer0/polyfills":"^0.4.10","@shgysk8zer0/eslint-config":"^1.0.3"},"_npmOperationalInternal":{"tmp":"tmp/tempo_1.0.0_1742338378902_0.5172509506828467","host":"s3://npm-registry-packages-npm-production"}},"1.0.1":{"name":"@aegisjsproject/tempo","version":"1.0.1","description":"Tempo provides advanced debouncing and throttling utilities for fine-grained execution control.","keywords":[],"type":"module","main":"./indtempoex.cjs","module":"./tempo.js","unpkg":"./tempo.min.js","exports":{".":{"import":"./tempo.js","require":"./tempo.cjs"},"./*.js":{"import":"./*.js","require":"./*.cjs"},"./*.mjs":{"import":"./*.js","require":"./*.cjs"},"./*.cjs":{"import":"./*.js","require":"./*.cjs"},"./*":{"import":"./*.js","require":"./*.cjs"}},"engines":{"node":">=18.0.0"},"private":false,"scripts":{"test":"npm run lint:js && npm run run:tests","preversion":"npm test && npm run build","prepare":"npm test && npm run build","lint:js":"eslint .","fix:js":"eslint . --fix","build":"npm run build:js","run:tests":"node --test","clean":"rm -f ./*.cjs","build:js":"npm run clean && rollup -c rollup.config.js","create:lock":"npm i --package-lock-only --ignore-scripts --no-audit --no-fund","version:bump":"npm run version:bump:patch","version:bump:patch":"npm version --no-git-tag-version patch && npm run create:lock","version:bump:minor":"npm version --no-git-tag-version minor && npm run create:lock","version:bump:major":"npm version --no-git-tag-version major && npm run create:lock"},"repository":{"type":"git","url":"git+https://github.com/AegisJSProject/tempo.git"},"author":{"name":"Chris Zuber","email":"admin@kernvalley.us"},"license":"MIT","funding":[{"type":"librepay","url":"https://liberapay.com/shgysk8zer0"},{"type":"github","url":"https://github.com/sponsors/shgysk8zer0"}],"bugs":{"url":"https://github.com/AegisJSProject/tempo/issues"},"homepage":"https://github.com/AegisJSProject/tempo#readme","devDependencies":{"@rollup/plugin-terser":"^1.0.0","@shgysk8zer0/eslint-config":"^1.0.7","@shgysk8zer0/polyfills":"^0.6.2","rollup":"^4.59.0"},"gitHead":"27949572a22d8f791fcc9690d1c32a01f0f1eb36","_id":"@aegisjsproject/tempo@1.0.1","_nodeVersion":"25.3.0","_npmVersion":"11.6.2","dist":{"integrity":"sha512-A/NWhi8pNumZBsWEW3uZSCMArOWVCQF9geAaHGPcqt3LynMmDdISrAJydNFUYHMsUloLACA+A+0jLIaYHLvOlw==","shasum":"7e32cfe1c9e09561cd5097e3e81d0095b3d75dea","tarball":"https://registry.npmjs.org/@aegisjsproject/tempo/-/tempo-1.0.1.tgz","fileCount":8,"unpackedSize":26770,"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@aegisjsproject%2ftempo@1.0.1","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIQCzVCJbvfdaJLzaKEfrSzJ7Jsqyzg0MEh0MvTkwczV7mQIgYALDhuFG7DFSyKr7xeCOTjnjL13GWq/YWW/h054kyzM="}]},"_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"oidc:b21810de-46fe-4e0b-a661-092c30034787"}},"directories":{},"maintainers":[{"name":"shgysk8zer0","email":"shgysk8zer0@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/tempo_1.0.1_1773853818422_0.08262636515553234"},"_hasShrinkwrap":false}},"time":{"created":"2025-03-18T22:52:58.811Z","modified":"2026-03-18T17:10:18.845Z","1.0.0":"2025-03-18T22:52:59.059Z","1.0.1":"2026-03-18T17:10:18.568Z"},"bugs":{"url":"https://github.com/AegisJSProject/tempo/issues"},"author":{"name":"Chris Zuber","email":"admin@kernvalley.us"},"license":"MIT","homepage":"https://github.com/AegisJSProject/tempo#readme","keywords":[],"repository":{"type":"git","url":"git+https://github.com/AegisJSProject/tempo.git"},"description":"Tempo provides advanced debouncing and throttling utilities for fine-grained execution control.","maintainers":[{"name":"shgysk8zer0","email":"shgysk8zer0@gmail.com"}],"readme":"# @aegisjsproject/tempo\n\nTempo provides advanced debouncing and throttling utilities for fine-grained execution control.\n\n[![CodeQL](https://github.com/AegisJSProject/tempo/actions/workflows/codeql-analysis.yml/badge.svg)](https://github.com/AegisJSProject/tempo/actions/workflows/codeql-analysis.yml)\n![Node CI](https://github.com/AegisJSProject/tempo/workflows/Node%20CI/badge.svg)\n![Lint Code Base](https://github.com/AegisJSProject/tempo/workflows/Lint%20Code%20Base/badge.svg)\n\n[![GitHub license](https://img.shields.io/github/license/AegisJSProject/tempo.svg)](https://github.com/AegisJSProject/tempo/blob/master/LICENSE)\n[![GitHub last commit](https://img.shields.io/github/last-commit/AegisJSProject/tempo.svg)](https://github.com/AegisJSProject/tempo/commits/master)\n[![GitHub release](https://img.shields.io/github/release/AegisJSProject/tempo?logo=github)](https://github.com/AegisJSProject/tempo/releases)\n[![GitHub Sponsors](https://img.shields.io/github/sponsors/shgysk8zer0?logo=github)](https://github.com/sponsors/shgysk8zer0)\n\n[![npm](https://img.shields.io/npm/v/@aegisjsproject/tempo)](https://www.npmjs.com/package/@aegisjsproject/tempo)\n![node-current](https://img.shields.io/node/v/@aegisjsproject/tempo)\n![npm bundle size gzipped](https://img.shields.io/bundlephobia/minzip/@aegisjsproject/tempo)\n[![npm](https://img.shields.io/npm/dw/@aegisjsproject/tempo?logo=npm)](https://www.npmjs.com/package/@aegisjsproject/tempo)\n\n[![GitHub followers](https://img.shields.io/github/followers/AegisJSProject.svg?style=social)](https://github.com/AegisJSProject)\n![GitHub forks](https://img.shields.io/github/forks/AegisJSProject/tempo.svg?style=social)\n![GitHub stars](https://img.shields.io/github/stars/AegisJSProject/tempo.svg?style=social)\n[![Twitter Follow](https://img.shields.io/twitter/follow/shgysk8zer0.svg?style=social)](https://twitter.com/shgysk8zer0)\n\n[![Donate using Liberapay](https://img.shields.io/liberapay/receives/shgysk8zer0.svg?logo=liberapay)](https://liberapay.com/shgysk8zer0/donate \"Donate using Liberapay\")\n- - -\n\n- [Code of Conduct](./.github/CODE_OF_CONDUCT.md)\n- [Contributing](./.github/CONTRIBUTING.md)\n<!-- - [Security Policy](./.github/SECURITY.md) -->\n\n# @aegisjsproject/tempo\n\nA lightweight JavaScript library for debouncing and throttling functions using modern, native web APIs.\n\n---\n\n## Overview\n\n`@aegisjsproject/tempo` provides robust debouncing and throttling utilities by leveraging the browser's latest scheduling and locking APIs. Using methods like `scheduler.postTask` and `navigator.locks.request`, the library offers precise task scheduling with native priority support, efficient cancellation via AbortSignals, and streamlined resource management.\n\n---\n\n## Features\n\n- **Debounce Function**  \n  Debounces a callback function by scheduling it with `scheduler.postTask`. It supports custom delays, task priorities (`user-blocking`, `user-visible`, `background`), and cancellation through AbortSignals.\n\n- **Throttle Function**  \n  Throttles a callback by combining `scheduler.postTask` with `navigator.locks.request` for controlled, queued execution. It provides options for lock naming, immediate failure or lock stealing, and built-in delay management.\n\n---\n\n## Advantages of Modern Methods\n\n- **Native Integration:**  \n  Leverages browser-native APIs for task scheduling and lock management, reducing dependency overhead and resulting in smaller bundle sizes.\n\n- **Improved Performance:**  \n  Native scheduling with `scheduler.postTask` allows tasks to be queued based on system and user priorities, leading to smoother and more responsive applications.\n\n- **Enhanced Control:**  \n  With built-in support for AbortSignals and fine-grained control over task priorities, developers can efficiently manage resource-intensive operations.\n\n- **Optimized Concurrency:**  \n  The use of `navigator.locks.request` ensures that throttled tasks handle concurrent execution gracefully without resorting to heavy third-party libraries.\n\n---\n\n## Installation\n\nInstall the package via npm:\n\n```bash\nnpm install @aegisjsproject/tempo\n```\n\n---\n\n## Usage\n\nImport the desired functions into your project:\n\n```js\nimport { debounce, throttle } from '@aegisjsproject/tempo';\n```\n\n### Usage with a CDN and `<script type=\"importmap\">`\n\n```html\n<script type=\"importmap\">\n  {\n    \"imports\": {\n      \"@aegisjsproject/tempo\": \"https://unpkg.com/@aegisjsproject[:version]/tempo.js\"\n    }\n  }\n</script>\n```\n### Debounce Example\n\n```js\nconst debouncedAction = debounce(() => {\n  // Your callback code here.\n}, {\n  delay: 300,\n  priority: 'user-visible',\n  signal: myAbortSignal, // Optional: provide an AbortSignal for cancellation.\n});\n```\n\n### Throttle Example\n\n```js\nconst throttledAction = throttle(() => {\n  // Your callback code here.\n}, {\n  lockName: 'uniqueLockName', // Optional: defaults to a random UUID.\n  delay: 200,\n  priority: 'background',\n  ifAvailable: true, // Immediately fail if the lock is unavailable.\n  signal: myAbortSignal, // Optional: provide an AbortSignal for cancellation.\n});\n```\n\n---\n\n## API Documentation\n\n### `debounce(callback, options)`\n\n- **Parameters:**\n  - `callback` *(Function)*: The function to debounce.\n  - `options` *(Object, optional)*:\n    - `delay` *(number)*: The debounce delay in milliseconds.\n    - `priority` *(\"user-blocking\" | \"user-visible\" | \"background\")*: The task priority.\n    - `signal` *(AbortSignal)*: Signal to cancel the debounced call.\n    - `thisArg` *(any, default: null)*: The `this` context for the callback.\n  \n- **Returns:**  \n  A debounced version of the input function.\n\n- **Throws:**  \n  - `TypeError` if the callback is not a function.\n  - `Error` if the provided AbortSignal is already aborted.\n\n### `throttle(callback, options)`\n\n- **Parameters:**\n  - `callback` *(Function)*: The function to throttle.\n  - `options` *(Object, optional)*:\n    - `lockName` *(string, default: crypto.randomUUID())*: Name for the lock.\n    - `delay` *(number)*: Delay in milliseconds after task execution.\n    - `priority` *(\"user-blocking\" | \"user-visible\" | \"background\")*: The task priority.\n    - `ifAvailable` *(boolean, default: true)*: Fail immediately if the lock is not available.\n    - `steal` *(boolean, default: false)*: Allow stealing of the lock.\n    - `mode` *(\"shared\" | \"exclusive\", default: \"exclusive\")*: The lock mode (only 'exclusive' is supported).\n    - `thisArg` *(any, default: null)*: The `this` context for the callback.\n    - `signal` *(AbortSignal)*: Signal to cancel the throttled call.\n  \n- **Returns:**  \n  A throttled version of the input function.\n\n- **Throws:**  \n  - `TypeError` if the callback is not a function or if both `steal` and `ifAvailable` are set to true.\n  - `Error` if the provided AbortSignal is already aborted.\n","readmeFilename":"README.md"}