@alwatr/delay 6.0.22 → 7.0.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/dist/main.js ADDED
@@ -0,0 +1,5 @@
1
+ /* 📦 @alwatr/delay v7.0.0 */
2
+ import{parseDuration as O}from"@alwatr/parse-duration";import{getGlobalThis as M}from"@alwatr/global-this";var H=M(),K=H.requestAnimationFrame?.bind(H)??((z)=>setTimeout(()=>z(performance.now()),16.666666666666668)),L=H.requestIdleCallback?.bind(H)??((z,B)=>{let E=Date.now();return setTimeout(()=>{z({didTimeout:!!B?.timeout,timeRemaining:()=>Math.max(0,50-(Date.now()-E))})},B?.timeout??20)});var U={by:(z)=>new Promise((B)=>setTimeout(B,O(z))),animationFrame:()=>new Promise((z)=>K(z)),idleCallback:(z)=>new Promise((B)=>L(B,z)),domEvent:(z,B,E={passive:!0})=>new Promise((J)=>z.addEventListener(B,J,{...E,once:!0})),event:(z,B,E={passive:!0})=>new Promise((J)=>z.addEventListener(B,J,{...E,once:!0})),nextMacrotask:()=>new Promise((z)=>setTimeout(z,0)),nextMicrotask:()=>Promise.resolve().then(()=>{})};export{L as requestIdleCallback,K as requestAnimationFrame,U as delay};
3
+
4
+ //# debugId=1D85DC7FC1CE00E964756E2164756E21
5
+ //# sourceMappingURL=main.js.map
@@ -0,0 +1,11 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/main.ts", "../src/polyfill.ts"],
4
+ "sourcesContent": [
5
+ "import {parseDuration, type Duration} from '@alwatr/parse-duration';\n\nimport {requestAnimationFrame, requestIdleCallback} from './polyfill.js';\n\nexport {requestAnimationFrame, requestIdleCallback};\n\n/**\n * A utility module to help manage asynchronous operations and waiting for events or timeouts.\n */\nexport const delay = {\n /**\n * Pauses execution for a specified duration.\n *\n * @param duration The duration to wait. Can be a number in milliseconds or a string like '2s', '100ms'.\n * @returns A Promise that resolves after the specified duration.\n *\n * @example\n * ```typescript\n * await delay.by('1m'); // Wait for 1 minute\n * await delay.by('2s'); // Wait for 2 seconds\n * ```\n */\n by: (duration: Duration): Promise<void> => new Promise((resolve) => setTimeout(resolve, parseDuration(duration))),\n\n /**\n * Pauses execution until the next animation frame.\n *\n * @returns A Promise that resolves with the high-resolution timestamp of the next animation frame.\n *\n * @example\n * ```typescript\n * const timestamp = await delay.animationFrame();\n * console.log(`Next frame at ${timestamp}`);\n * ```\n */\n animationFrame: (): Promise<DOMHighResTimeStamp> => new Promise((resolve) => requestAnimationFrame(resolve)),\n\n /**\n * Pauses execution until the browser is idle.\n *\n * @param timeout An optional maximum duration to wait.\n * @returns A Promise that resolves with an `IdleDeadline` object.\n *\n * @example\n * ```typescript\n * const deadline = await delay.idleCallback({ timeout: 2000 });\n * if (deadline.didTimeout) {\n * console.log('Idle callback timed out.');\n * }\n * ```\n */\n idleCallback: (options?: IdleRequestOptions): Promise<IdleDeadline> => new Promise((resolve) => requestIdleCallback(resolve, options)),\n\n /**\n * Pauses execution until a specific DOM event is dispatched on an element.\n *\n * @param element The HTMLElement to listen on.\n * @param eventName The name of the event to wait for.\n * @param options Optional event listener options.\n * @template T The event map type for the element.\n * @returns A Promise that resolves with the triggered event object.\n *\n * @example\n * ```typescript\n * const button = document.getElementById('my-button');\n * if (button) {\n * const clickEvent = await delay.domEvent(button, 'click');\n * console.log('Button clicked!', clickEvent);\n * }\n * ```\n */\n domEvent: <T extends keyof HTMLElementEventMap>(\n element: HTMLElement,\n eventName: T,\n options: AddEventListenerOptions = {passive: true},\n ): Promise<HTMLElementEventMap[T]> =>\n new Promise((resolve) =>\n element.addEventListener(eventName, resolve, {\n ...options,\n once: true,\n }),\n ),\n\n /**\n * Pauses execution until a specific event is dispatched on any event target.\n *\n * @param target The event target (e.g., window, document, or a custom event emitter).\n * @param eventName The name of the event to wait for.\n * @param options Optional event listener options.\n * @returns A Promise that resolves with the triggered event object.\n *\n * @example\n * ```typescript\n * const resizeEvent = await delay.event(window, 'resize');\n * console.log('Window resized:', resizeEvent);\n * ```\n */\n event: (target: EventTarget, eventName: string, options: AddEventListenerOptions = {passive: true}): Promise<Event> =>\n new Promise((resolve) =>\n target.addEventListener(eventName, resolve, {\n ...options,\n once: true,\n }),\n ),\n\n /**\n * Schedules a macrotask to run after the current event loop task completes.\n * Uses `setTimeout(..., 0)`.\n *\n * @returns A Promise that resolves when the macrotask is executed.\n *\n * @example\n * ```typescript\n * console.log('Start');\n * await delay.nextMacrotask();\n * console.log('End - after current task');\n * ```\n */\n nextMacrotask: (): Promise<void> => new Promise((resolve) => setTimeout(resolve, 0)),\n\n /**\n * Queues a microtask to run after the current task completes but before the next macrotask.\n *\n * @returns A Promise that resolves when the microtask is executed.\n *\n * @example\n * ```typescript\n * console.log('Start');\n * await delay.nextMicrotask();\n * console.log('End - immediately after current task');\n * ```\n */\n // eslint-disable-next-line @typescript-eslint/no-empty-function\n nextMicrotask: (): Promise<void> => Promise.resolve().then(() => {}),\n} as const;\n",
6
+ "import {getGlobalThis} from '@alwatr/global-this';\n\nimport type {} from '@alwatr/type-helper';\n\nconst globalThis = getGlobalThis<DictionaryOpt<unknown>>();\n\n/**\n * Ensures compatibility for `requestAnimationFrame` by using the native API\n * available in `globalThis`. If it's not available, it falls back to a `setTimeout`\n * call that aims for a 60 frames per second refresh rate.\n *\n * @param callback The function to call when it's time to update your animation for the next repaint.\n * @returns A long integer value, the request ID, that uniquely identifies the entry in the callback list.\n */\nexport const requestAnimationFrame: (callback: FrameRequestCallback) => number =\n globalThis.requestAnimationFrame?.bind(globalThis) ??\n ((callback: FrameRequestCallback) => setTimeout(() => callback(performance.now()), 1000 / 60));\n\n/**\n * Ensures compatibility for `requestIdleCallback` by using the native API.\n * If unavailable, it falls back to a `setTimeout` that executes the callback\n * after a short delay, providing a mock `IdleDeadline` object.\n *\n * The mock `IdleDeadline` gives the task a 50ms budget to run.\n *\n * @param callback A reference to a function that should be called in the near future, when the event loop is idle.\n * @param options An optional object with configuration parameters.\n * @returns An ID which can be used to cancel the callback by calling `cancelIdleCallback()`.\n */\nexport const requestIdleCallback: (callback: (deadline: IdleDeadline) => void, options?: IdleRequestOptions) => number =\n globalThis.requestIdleCallback?.bind(globalThis) ??\n ((\n callback: (deadline: IdleDeadline) => void,\n // options is not used in the fallback but kept for API consistency\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n options?: IdleRequestOptions,\n ) => {\n const startTime = Date.now();\n return setTimeout(() => {\n callback({\n didTimeout: !!options?.timeout,\n timeRemaining: () => Math.max(0, 50 - (Date.now() - startTime)),\n });\n }, options?.timeout ?? 20);\n });\n"
7
+ ],
8
+ "mappings": ";AAAA,wBAAQ,+BCAR,wBAAQ,4BAIR,IAAM,EAAa,EAAsC,EAU5C,EACX,EAAW,uBAAuB,KAAK,CAAU,IAChD,CAAC,IAAmC,WAAW,IAAM,EAAS,YAAY,IAAI,CAAC,EAAG,kBAAS,GAajF,EACX,EAAW,qBAAqB,KAAK,CAAU,IAC9C,CACC,EAGA,IACG,CACH,IAAM,EAAY,KAAK,IAAI,EAC3B,OAAO,WAAW,IAAM,CACtB,EAAS,CACP,WAAY,CAAC,CAAC,GAAS,QACvB,cAAe,IAAM,KAAK,IAAI,EAAG,IAAM,KAAK,IAAI,EAAI,EAAU,CAChE,CAAC,GACA,GAAS,SAAW,EAAE,IDlCtB,IAAM,EAAQ,CAanB,GAAI,CAAC,IAAsC,IAAI,QAAQ,CAAC,IAAY,WAAW,EAAS,EAAc,CAAQ,CAAC,CAAC,EAahH,eAAgB,IAAoC,IAAI,QAAQ,CAAC,IAAY,EAAsB,CAAO,CAAC,EAgB3G,aAAc,CAAC,IAAwD,IAAI,QAAQ,CAAC,IAAY,EAAoB,EAAS,CAAO,CAAC,EAoBrI,SAAU,CACR,EACA,EACA,EAAmC,CAAC,QAAS,EAAI,IAEjD,IAAI,QAAQ,CAAC,IACX,EAAQ,iBAAiB,EAAW,EAAS,IACxC,EACH,KAAM,EACR,CAAC,CACH,EAgBF,MAAO,CAAC,EAAqB,EAAmB,EAAmC,CAAC,QAAS,EAAI,IAC/F,IAAI,QAAQ,CAAC,IACX,EAAO,iBAAiB,EAAW,EAAS,IACvC,EACH,KAAM,EACR,CAAC,CACH,EAeF,cAAe,IAAqB,IAAI,QAAQ,CAAC,IAAY,WAAW,EAAS,CAAC,CAAC,EAenF,cAAe,IAAqB,QAAQ,QAAQ,EAAE,KAAK,IAAM,EAAE,CACrE",
9
+ "debugId": "1D85DC7FC1CE00E964756E2164756E21",
10
+ "names": []
11
+ }
package/package.json CHANGED
@@ -1,30 +1,30 @@
1
1
  {
2
2
  "name": "@alwatr/delay",
3
3
  "description": "Comprehensive toolkit for managing asynchronous operations.",
4
- "version": "6.0.22",
4
+ "version": "7.0.0",
5
5
  "author": "S. Ali Mihandoost <ali.mihandoost@gmail.com>",
6
6
  "bugs": "https://github.com/Alwatr/nanolib/issues",
7
7
  "dependencies": {
8
- "@alwatr/global-this": "5.6.10",
9
- "@alwatr/parse-duration": "5.5.31"
8
+ "@alwatr/global-this": "6.0.0",
9
+ "@alwatr/parse-duration": "6.0.0"
10
10
  },
11
11
  "devDependencies": {
12
- "@alwatr/nano-build": "6.4.2",
13
- "@alwatr/prettier-config": "6.0.2",
14
- "@alwatr/tsconfig-base": "6.0.4",
15
- "@alwatr/type-helper": "7.0.2",
12
+ "@alwatr/nano-build": "7.0.0",
13
+ "@alwatr/prettier-config": "7.0.0",
14
+ "@alwatr/tsconfig-base": "7.0.0",
15
+ "@alwatr/type-helper": "8.0.0",
16
16
  "@types/node": "^24.12.0",
17
17
  "typescript": "^5.9.3"
18
18
  },
19
19
  "exports": {
20
20
  ".": {
21
21
  "types": "./dist/main.d.ts",
22
- "import": "./dist/main.mjs",
23
- "require": "./dist/main.cjs"
22
+ "default": "./dist/main.js"
24
23
  }
25
24
  },
26
25
  "files": [
27
- "**/*.{js,mjs,cjs,map,d.ts,html,md,LEGAL.txt}",
26
+ "**/*.{js,mjs,cjs,ts,map,d.ts,html,LEGAL.txt}",
27
+ "README.md",
28
28
  "LICENSE",
29
29
  "!demo/**/*",
30
30
  "!**/*.test.js"
@@ -50,8 +50,6 @@
50
50
  "wait"
51
51
  ],
52
52
  "license": "MPL-2.0",
53
- "main": "./dist/main.cjs",
54
- "module": "./dist/main.mjs",
55
53
  "prettier": "@alwatr/prettier-config",
56
54
  "publishConfig": {
57
55
  "access": "public"
@@ -64,12 +62,12 @@
64
62
  "scripts": {
65
63
  "b": "bun run build",
66
64
  "build": "bun run build:ts && bun run build:es",
67
- "build:es": "nano-build --preset=module",
65
+ "build:es": "nano-build --preset=module src/main.ts",
68
66
  "build:ts": "tsc --build",
69
67
  "c": "bun run clean",
70
68
  "cb": "bun run clean && bun run build",
71
69
  "clean": "rm -rfv dist *.tsbuildinfo",
72
- "d": "bun run build:es && bun --enable-source-maps --trace-warnings",
70
+ "d": "bun run build:es && bun",
73
71
  "w": "bun run watch",
74
72
  "watch": "bun run watch:ts & bun run watch:es",
75
73
  "watch:es": "bun run build:es --watch",
@@ -78,5 +76,5 @@
78
76
  "sideEffects": false,
79
77
  "type": "module",
80
78
  "types": "./dist/main.d.ts",
81
- "gitHead": "def1decf8f496f4b0d3d3ab952c346c689c30160"
79
+ "gitHead": "056102a1c8a563bbae8a290b6830450f467322a3"
82
80
  }
package/src/main.ts ADDED
@@ -0,0 +1,135 @@
1
+ import {parseDuration, type Duration} from '@alwatr/parse-duration';
2
+
3
+ import {requestAnimationFrame, requestIdleCallback} from './polyfill.js';
4
+
5
+ export {requestAnimationFrame, requestIdleCallback};
6
+
7
+ /**
8
+ * A utility module to help manage asynchronous operations and waiting for events or timeouts.
9
+ */
10
+ export const delay = {
11
+ /**
12
+ * Pauses execution for a specified duration.
13
+ *
14
+ * @param duration The duration to wait. Can be a number in milliseconds or a string like '2s', '100ms'.
15
+ * @returns A Promise that resolves after the specified duration.
16
+ *
17
+ * @example
18
+ * ```typescript
19
+ * await delay.by('1m'); // Wait for 1 minute
20
+ * await delay.by('2s'); // Wait for 2 seconds
21
+ * ```
22
+ */
23
+ by: (duration: Duration): Promise<void> => new Promise((resolve) => setTimeout(resolve, parseDuration(duration))),
24
+
25
+ /**
26
+ * Pauses execution until the next animation frame.
27
+ *
28
+ * @returns A Promise that resolves with the high-resolution timestamp of the next animation frame.
29
+ *
30
+ * @example
31
+ * ```typescript
32
+ * const timestamp = await delay.animationFrame();
33
+ * console.log(`Next frame at ${timestamp}`);
34
+ * ```
35
+ */
36
+ animationFrame: (): Promise<DOMHighResTimeStamp> => new Promise((resolve) => requestAnimationFrame(resolve)),
37
+
38
+ /**
39
+ * Pauses execution until the browser is idle.
40
+ *
41
+ * @param timeout An optional maximum duration to wait.
42
+ * @returns A Promise that resolves with an `IdleDeadline` object.
43
+ *
44
+ * @example
45
+ * ```typescript
46
+ * const deadline = await delay.idleCallback({ timeout: 2000 });
47
+ * if (deadline.didTimeout) {
48
+ * console.log('Idle callback timed out.');
49
+ * }
50
+ * ```
51
+ */
52
+ idleCallback: (options?: IdleRequestOptions): Promise<IdleDeadline> => new Promise((resolve) => requestIdleCallback(resolve, options)),
53
+
54
+ /**
55
+ * Pauses execution until a specific DOM event is dispatched on an element.
56
+ *
57
+ * @param element The HTMLElement to listen on.
58
+ * @param eventName The name of the event to wait for.
59
+ * @param options Optional event listener options.
60
+ * @template T The event map type for the element.
61
+ * @returns A Promise that resolves with the triggered event object.
62
+ *
63
+ * @example
64
+ * ```typescript
65
+ * const button = document.getElementById('my-button');
66
+ * if (button) {
67
+ * const clickEvent = await delay.domEvent(button, 'click');
68
+ * console.log('Button clicked!', clickEvent);
69
+ * }
70
+ * ```
71
+ */
72
+ domEvent: <T extends keyof HTMLElementEventMap>(
73
+ element: HTMLElement,
74
+ eventName: T,
75
+ options: AddEventListenerOptions = {passive: true},
76
+ ): Promise<HTMLElementEventMap[T]> =>
77
+ new Promise((resolve) =>
78
+ element.addEventListener(eventName, resolve, {
79
+ ...options,
80
+ once: true,
81
+ }),
82
+ ),
83
+
84
+ /**
85
+ * Pauses execution until a specific event is dispatched on any event target.
86
+ *
87
+ * @param target The event target (e.g., window, document, or a custom event emitter).
88
+ * @param eventName The name of the event to wait for.
89
+ * @param options Optional event listener options.
90
+ * @returns A Promise that resolves with the triggered event object.
91
+ *
92
+ * @example
93
+ * ```typescript
94
+ * const resizeEvent = await delay.event(window, 'resize');
95
+ * console.log('Window resized:', resizeEvent);
96
+ * ```
97
+ */
98
+ event: (target: EventTarget, eventName: string, options: AddEventListenerOptions = {passive: true}): Promise<Event> =>
99
+ new Promise((resolve) =>
100
+ target.addEventListener(eventName, resolve, {
101
+ ...options,
102
+ once: true,
103
+ }),
104
+ ),
105
+
106
+ /**
107
+ * Schedules a macrotask to run after the current event loop task completes.
108
+ * Uses `setTimeout(..., 0)`.
109
+ *
110
+ * @returns A Promise that resolves when the macrotask is executed.
111
+ *
112
+ * @example
113
+ * ```typescript
114
+ * console.log('Start');
115
+ * await delay.nextMacrotask();
116
+ * console.log('End - after current task');
117
+ * ```
118
+ */
119
+ nextMacrotask: (): Promise<void> => new Promise((resolve) => setTimeout(resolve, 0)),
120
+
121
+ /**
122
+ * Queues a microtask to run after the current task completes but before the next macrotask.
123
+ *
124
+ * @returns A Promise that resolves when the microtask is executed.
125
+ *
126
+ * @example
127
+ * ```typescript
128
+ * console.log('Start');
129
+ * await delay.nextMicrotask();
130
+ * console.log('End - immediately after current task');
131
+ * ```
132
+ */
133
+ // eslint-disable-next-line @typescript-eslint/no-empty-function
134
+ nextMicrotask: (): Promise<void> => Promise.resolve().then(() => {}),
135
+ } as const;
@@ -0,0 +1,45 @@
1
+ import {getGlobalThis} from '@alwatr/global-this';
2
+
3
+ import type {} from '@alwatr/type-helper';
4
+
5
+ const globalThis = getGlobalThis<DictionaryOpt<unknown>>();
6
+
7
+ /**
8
+ * Ensures compatibility for `requestAnimationFrame` by using the native API
9
+ * available in `globalThis`. If it's not available, it falls back to a `setTimeout`
10
+ * call that aims for a 60 frames per second refresh rate.
11
+ *
12
+ * @param callback The function to call when it's time to update your animation for the next repaint.
13
+ * @returns A long integer value, the request ID, that uniquely identifies the entry in the callback list.
14
+ */
15
+ export const requestAnimationFrame: (callback: FrameRequestCallback) => number =
16
+ globalThis.requestAnimationFrame?.bind(globalThis) ??
17
+ ((callback: FrameRequestCallback) => setTimeout(() => callback(performance.now()), 1000 / 60));
18
+
19
+ /**
20
+ * Ensures compatibility for `requestIdleCallback` by using the native API.
21
+ * If unavailable, it falls back to a `setTimeout` that executes the callback
22
+ * after a short delay, providing a mock `IdleDeadline` object.
23
+ *
24
+ * The mock `IdleDeadline` gives the task a 50ms budget to run.
25
+ *
26
+ * @param callback A reference to a function that should be called in the near future, when the event loop is idle.
27
+ * @param options An optional object with configuration parameters.
28
+ * @returns An ID which can be used to cancel the callback by calling `cancelIdleCallback()`.
29
+ */
30
+ export const requestIdleCallback: (callback: (deadline: IdleDeadline) => void, options?: IdleRequestOptions) => number =
31
+ globalThis.requestIdleCallback?.bind(globalThis) ??
32
+ ((
33
+ callback: (deadline: IdleDeadline) => void,
34
+ // options is not used in the fallback but kept for API consistency
35
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
36
+ options?: IdleRequestOptions,
37
+ ) => {
38
+ const startTime = Date.now();
39
+ return setTimeout(() => {
40
+ callback({
41
+ didTimeout: !!options?.timeout,
42
+ timeRemaining: () => Math.max(0, 50 - (Date.now() - startTime)),
43
+ });
44
+ }, options?.timeout ?? 20);
45
+ });
package/CHANGELOG.md DELETED
@@ -1,492 +0,0 @@
1
- # Change Log
2
-
3
- All notable changes to this project will be documented in this file.
4
- See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
-
6
- ## [6.0.22](https://github.com/Alwatr/nanolib/compare/@alwatr/delay@6.0.21...@alwatr/delay@6.0.22) (2026-03-18)
7
-
8
- **Note:** Version bump only for package @alwatr/delay
9
-
10
- ## [6.0.21](https://github.com/Alwatr/nanolib/compare/@alwatr/delay@6.0.20...@alwatr/delay@6.0.21) (2026-03-16)
11
-
12
- ### 🔨 Code Refactoring
13
-
14
- * migrate build scripts from yarn to bun across multiple packages ([d90e962](https://github.com/Alwatr/nanolib/commit/d90e962f15e5c951e191d5f02341279b6472abc3))
15
-
16
- ### 🔗 Dependencies update
17
-
18
- * bump the npm-dependencies group with 10 updates ([c48d9ba](https://github.com/Alwatr/nanolib/commit/c48d9baa1cd7c2dc144b3e01e0fda60bf87c074c))
19
-
20
- ## [6.0.20](https://github.com/Alwatr/nanolib/compare/@alwatr/delay@6.0.19...@alwatr/delay@6.0.20) (2026-02-18)
21
-
22
- ### 🔗 Dependencies update
23
-
24
- * update @types/node to version 24.10.13 across multiple packages ([4c6d2a3](https://github.com/Alwatr/nanolib/commit/4c6d2a37ab26b1c86812b2aa38b2eca4ee097cb6))
25
-
26
- ## [6.0.19](https://github.com/Alwatr/nanolib/compare/@alwatr/delay@6.0.18...@alwatr/delay@6.0.19) (2025-12-23)
27
-
28
- ### 🔗 Dependencies update
29
-
30
- * upgrade @types/node to version 24.10.4 and update related dependencies ([acf04df](https://github.com/Alwatr/nanolib/commit/acf04df71647f5a401ef5e6bbfffcc478e4326d2))
31
-
32
- ## [6.0.18](https://github.com/Alwatr/nanolib/compare/@alwatr/delay@6.0.17...@alwatr/delay@6.0.18) (2025-12-13)
33
-
34
- ### 🔗 Dependencies update
35
-
36
- * update `@types/node` and `[@lerna-lite](https://github.com/lerna-lite)` dependencies. ([8daa8fd](https://github.com/Alwatr/nanolib/commit/8daa8fd023d5414c9f95feb4319353c6ea34be31))
37
-
38
- ## [6.0.17](https://github.com/Alwatr/nanolib/compare/@alwatr/delay@6.0.16...@alwatr/delay@6.0.17) (2025-12-10)
39
-
40
- ### 🔗 Dependencies update
41
-
42
- * Upgrade lerna-lite, prettier, types/node, and yarn dependencies. ([42a7fca](https://github.com/Alwatr/nanolib/commit/42a7fca15430aca2ac1eaa19496c2a2ebfc8c470))
43
-
44
- ## [6.0.16](https://github.com/Alwatr/nanolib/compare/@alwatr/delay@6.0.15...@alwatr/delay@6.0.16) (2025-11-18)
45
-
46
- ### 🐛 Bug Fixes
47
-
48
- * add type imports from @alwatr/nano-build and @alwatr/type-helper across multiple packages ([5ab7f15](https://github.com/Alwatr/nanolib/commit/5ab7f159ba57788bf8df40fa96a3027f589d5a77))
49
-
50
- ### 🔨 Code Refactoring
51
-
52
- * remove unnecessary type declarations from tsconfig.json files ([89bcc7d](https://github.com/Alwatr/nanolib/commit/89bcc7db839807110b80f8ba34414ea9734d9c75))
53
-
54
- ## [6.0.15](https://github.com/Alwatr/nanolib/compare/@alwatr/delay@6.0.14...@alwatr/delay@6.0.15) (2025-11-15)
55
-
56
- ### 🔗 Dependencies update
57
-
58
- * bump the npm-dependencies group with 2 updates ([a80b84d](https://github.com/Alwatr/nanolib/commit/a80b84dada6c09b5e5621e7487c8ec13fff3c23a))
59
-
60
- ## [6.0.14](https://github.com/Alwatr/nanolib/compare/@alwatr/delay@6.0.13...@alwatr/delay@6.0.14) (2025-11-15)
61
-
62
- **Note:** Version bump only for package @alwatr/delay
63
-
64
- ## [6.0.13](https://github.com/Alwatr/nanolib/compare/@alwatr/delay@6.0.12...@alwatr/delay@6.0.13) (2025-11-04)
65
-
66
- ### 🔗 Dependencies update
67
-
68
- * bump the npm-dependencies group across 1 directory with 9 updates ([fdf29d5](https://github.com/Alwatr/nanolib/commit/fdf29d5aa89983cb06f79d42650a364521f5c4b9))
69
- * update @types/node from ^22.18.12 to ^24.10.0 across multiple packages ([1169a86](https://github.com/Alwatr/nanolib/commit/1169a86001da2abfbe99a7da33c8e92183f553f6))
70
-
71
- ## [6.0.12](https://github.com/Alwatr/nanolib/compare/@alwatr/delay@6.0.11...@alwatr/delay@6.0.12) (2025-10-06)
72
-
73
- ### 🔗 Dependencies update
74
-
75
- * bump the npm-dependencies group with 4 updates ([9825815](https://github.com/Alwatr/nanolib/commit/982581552bbb4b97dca52af5e93a80937f0c3109))
76
-
77
- ## [6.0.11](https://github.com/Alwatr/nanolib/compare/@alwatr/delay@6.0.10...@alwatr/delay@6.0.11) (2025-09-27)
78
-
79
- ### 🧹 Miscellaneous Chores
80
-
81
- * exclude test files from package distribution ([86f4f2f](https://github.com/Alwatr/nanolib/commit/86f4f2f5985845c5cf3a3a9398de7b2f98ce53e7))
82
-
83
- ## [6.0.10](https://github.com/Alwatr/nanolib/compare/@alwatr/delay@6.0.9...@alwatr/delay@6.0.10) (2025-09-22)
84
-
85
- **Note:** Version bump only for package @alwatr/delay
86
-
87
- ## [6.0.9](https://github.com/Alwatr/nanolib/compare/@alwatr/delay@6.0.8...@alwatr/delay@6.0.9) (2025-09-22)
88
-
89
- **Note:** Version bump only for package @alwatr/delay
90
-
91
- ## [6.0.8](https://github.com/Alwatr/nanolib/compare/@alwatr/delay@6.0.7...@alwatr/delay@6.0.8) (2025-09-21)
92
-
93
- **Note:** Version bump only for package @alwatr/delay
94
-
95
- ## [6.0.7](https://github.com/Alwatr/nanolib/compare/@alwatr/delay@6.0.6...@alwatr/delay@6.0.7) (2025-09-20)
96
-
97
- ### 🐛 Bug Fixes
98
-
99
- * add sideEffects property to package.json files for better tree-shaking ([c7b9e74](https://github.com/Alwatr/nanolib/commit/c7b9e74e1920c8e35b438742de61883ca62da58c))
100
- * add sideEffects property to package.json files for better tree-shaking ([e8402c4](https://github.com/Alwatr/nanolib/commit/e8402c481a14a1f807a37aaa862a936713d26176))
101
- * remove unnecessary pure annotations ([adeb916](https://github.com/Alwatr/nanolib/commit/adeb9166f8e911f59269032b76c36cb1888332cf))
102
-
103
- ### 🧹 Miscellaneous Chores
104
-
105
- * remove duplicate sideEffects property from multiple package.json files ([b123f86](https://github.com/Alwatr/nanolib/commit/b123f86be81481de2314aae9bb2eeb629743d24c))
106
-
107
- ## [6.0.6](https://github.com/Alwatr/nanolib/compare/@alwatr/delay@6.0.5...@alwatr/delay@6.0.6) (2025-09-19)
108
-
109
- **Note:** Version bump only for package @alwatr/delay
110
-
111
- ## [6.0.5](https://github.com/Alwatr/nanolib/compare/@alwatr/delay@6.0.4...@alwatr/delay@6.0.5) (2025-09-15)
112
-
113
- **Note:** Version bump only for package @alwatr/delay
114
-
115
- ## [6.0.4](https://github.com/Alwatr/nanolib/compare/@alwatr/delay@6.0.3...@alwatr/delay@6.0.4) (2025-09-14)
116
-
117
- **Note:** Version bump only for package @alwatr/delay
118
-
119
- ## [6.0.3](https://github.com/Alwatr/nanolib/compare/@alwatr/delay@6.0.2...@alwatr/delay@6.0.3) (2025-09-13)
120
-
121
- ### 🔗 Dependencies update
122
-
123
- * update @types/node version to ^22.18.3 in multiple package.json files ([13db6fc](https://github.com/Alwatr/nanolib/commit/13db6fc176bc6cdcefedc50d77ac550bd5052c9a))
124
-
125
- ## [6.0.2](https://github.com/Alwatr/nanolib/compare/@alwatr/delay@6.0.1...@alwatr/delay@6.0.2) (2025-09-13)
126
-
127
- ### 🧹 Miscellaneous Chores
128
-
129
- * remove package-tracer dependency and related code from fetch package ([96fe4e9](https://github.com/Alwatr/nanolib/commit/96fe4e9552a205f218ceed187c55e4e904a07089))
130
-
131
- ## [6.0.1](https://github.com/Alwatr/nanolib/compare/@alwatr/delay@6.0.0...@alwatr/delay@6.0.1) (2025-09-09)
132
-
133
- **Note:** Version bump only for package @alwatr/delay
134
-
135
- ## [6.0.0](https://github.com/Alwatr/nanolib/compare/@alwatr/delay@5.5.11...@alwatr/delay@6.0.0) (2025-09-08)
136
-
137
- ### ⚠ BREAKING CHANGES
138
-
139
- * **delay:** The API has been completely redesigned. All previous standalone functions are removed and replaced by methods on the `delay` object.
140
-
141
- - **REMOVED:**
142
- - `untilNextAnimationFrame`
143
- - `untilIdle`
144
- - `untilDomEvent`
145
- - `untilEvent`
146
- - `immediate`
147
- - `nextMicrotask`
148
-
149
- - **ADDED:**
150
- - `delay.animationFrame` (replaces `waitForAnimationFrame`)
151
- - `delay.idleCallback` (replaces `waitForIdle`)
152
- - `delay.domEvent` (replaces `waitForDomEvent`)
153
- - `delay.event` (replaces `waitForEvent`)
154
- - `delay.nextMacrotask` (replaces `waitForImmediate`)
155
- - `delay.nextMicrotask` (replaces `waitForMicrotask`)
156
-
157
- Users must update their code to import the `delay` object and use the new method names. For example, `delay.immediate()` should be changed to `delay.nextMacrotask()`.
158
-
159
- ### ✨ Features
160
-
161
- * **delay:** Overhaul delay module with improved API and corrected implementations ([7c12483](https://github.com/Alwatr/nanolib/commit/7c1248354f2535a65cb7981c42ad4e319badb4aa))
162
-
163
- ### 🔨 Code Refactoring
164
-
165
- * **polyfill:** rename global_ to globalThis for clarity and consistency ([7d1484f](https://github.com/Alwatr/nanolib/commit/7d1484fb91a66d46b62011d0fb7825f3089183f8))
166
- * **polyfill:** streamline requestAnimationFrame and requestIdleCallback implementations ([d18443d](https://github.com/Alwatr/nanolib/commit/d18443d4dedddff8f54227aa7aff2bca5aaacdfa))
167
-
168
- ### 🧹 Miscellaneous Chores
169
-
170
- * **main:** export requestAnimationFrame and requestIdleCallback from main module ([ef80797](https://github.com/Alwatr/nanolib/commit/ef80797319e3bded5c36e98352b6317427d08a59))
171
-
172
- ## [5.5.11](https://github.com/Alwatr/nanolib/compare/@alwatr/delay@5.5.10...@alwatr/delay@5.5.11) (2025-09-06)
173
-
174
- **Note:** Version bump only for package @alwatr/delay
175
-
176
- ## [5.5.10](https://github.com/Alwatr/nanolib/compare/@alwatr/delay@5.5.9...@alwatr/delay@5.5.10) (2025-09-05)
177
-
178
- ### 🔗 Dependencies update
179
-
180
- * update jest to version 30.1.3 and @types/node to version 22.18.1 ([754212b](https://github.com/Alwatr/nanolib/commit/754212b1523cfc4cfe26c9e9f6d634aa8311e0b7))
181
-
182
- ## [5.5.9](https://github.com/Alwatr/nanolib/compare/@alwatr/delay@5.5.8...@alwatr/delay@5.5.9) (2025-09-01)
183
-
184
- ### 🔗 Dependencies update
185
-
186
- * update lerna-lite dependencies to version 4.7.3 and jest to 30.1.2 ([95d7870](https://github.com/Alwatr/nanolib/commit/95d7870ec7ad1e6ed2688bafddcabf46857f6981))
187
-
188
- ## [5.5.8](https://github.com/Alwatr/nanolib/compare/@alwatr/delay@5.5.7...@alwatr/delay@5.5.8) (2025-08-23)
189
-
190
- **Note:** Version bump only for package @alwatr/delay
191
-
192
- ## [5.5.7](https://github.com/Alwatr/nanolib/compare/@alwatr/delay@5.5.4...@alwatr/delay@5.5.7) (2025-08-23)
193
-
194
- ### 🐛 Bug Fixes
195
-
196
- * update license from AGPL-3.0-only to MPL-2.0 ([d20968e](https://github.com/Alwatr/nanolib/commit/d20968e60cc89b1dcdf9b96507178da6ed562f55))
197
- * update package versions in multiple package.json files ([7638b1c](https://github.com/Alwatr/nanolib/commit/7638b1cafee2b4e0f97db7a89ac9fba6384b9b10))
198
-
199
- ### 🔨 Code Refactoring
200
-
201
- * Updated all package.json files in the project to change dependency version specifiers from "workspace:^" to "workspace:*" for consistency and to allow for more flexible version resolution. ([db6a4f7](https://github.com/Alwatr/nanolib/commit/db6a4f76deec2d1d8039978144e4bc51b6f1a0e3))
202
-
203
- ### 🧹 Miscellaneous Chores
204
-
205
- * fix packages/delay/package.json dir ([9777696](https://github.com/Alwatr/nanolib/commit/9777696f070eef855058a791057dde948f6b564b))
206
- * fix packages/delay/package.json homepage ([eb054b9](https://github.com/Alwatr/nanolib/commit/eb054b95e56840e2835e5a300647c3e6ddf0e21a))
207
- * reformat all package.json files ([ceda45d](https://github.com/Alwatr/nanolib/commit/ceda45de186667790474f729cb4b161a5148ce19))
208
- * remove license and contributing sections from README.md ([ba91e2d](https://github.com/Alwatr/nanolib/commit/ba91e2d7faa883f4f2f74e762ee361b48839ce7c))
209
-
210
- ### 🔗 Dependencies update
211
-
212
- * revert @types/node version to ^22.17.2 (LTS) ([49f8101](https://github.com/Alwatr/nanolib/commit/49f8101eac5c41aa7684112f4308254dbfab9787))
213
- * update TypeScript and Jest versions across all packages to improve compatibility and performance ([31baf36](https://github.com/Alwatr/nanolib/commit/31baf366101e92e27db66a21c849fb101f19be47))
214
-
215
- ## [5.5.5](https://github.com/Alwatr/nanolib/compare/@alwatr/delay@5.5.4...@alwatr/delay@5.5.5) (2025-08-23)
216
-
217
- ### Code Refactoring
218
-
219
- * Updated all package.json files in the project to change dependency version specifiers from "workspace:^" to "workspace:*" for consistency and to allow for more flexible version resolution. ([db6a4f7](https://github.com/Alwatr/nanolib/commit/db6a4f76deec2d1d8039978144e4bc51b6f1a0e3)) by @alimd
220
-
221
- ## [5.5.4](https://github.com/Alwatr/nanolib/compare/@alwatr/delay@5.5.3...@alwatr/delay@5.5.4) (2025-04-20)
222
-
223
- **Note:** Version bump only for package @alwatr/delay
224
-
225
- ## <small>5.5.3 (2025-04-15)</small>
226
-
227
- **Note:** Version bump only for package @alwatr/delay
228
-
229
- ## [5.5.2](https://github.com/Alwatr/nanolib/compare/@alwatr/delay@5.5.1...@alwatr/delay@5.5.2) (2025-04-01)
230
-
231
- ### Dependencies update
232
-
233
- * bump the development-dependencies group across 1 directory with 2 updates ([c1320b4](https://github.com/Alwatr/nanolib/commit/c1320b447a492c5e720e25ad71e9df81eeea3670)) by @dependabot[bot]
234
-
235
- ## [5.5.1](https://github.com/Alwatr/nanolib/compare/@alwatr/delay@5.5.0...@alwatr/delay@5.5.1) (2025-03-18)
236
-
237
- ### Bug Fixes
238
-
239
- * **delay:** specify type for getGlobalThis in polyfill.ts ([57fa717](https://github.com/Alwatr/nanolib/commit/57fa7173f6b040f7d4e536ecb18cf41fbaf218ea)) by @alimd
240
-
241
- ### Dependencies update
242
-
243
- * bump the development-dependencies group with 9 updates ([7290aa3](https://github.com/Alwatr/nanolib/commit/7290aa3b52ce66ca237d2a12d28a7687b113f83d)) by @dependabot[bot]
244
-
245
- ## [5.5.0](https://github.com/Alwatr/nanolib/compare/@alwatr/delay@5.4.0...@alwatr/delay@5.5.0) (2025-03-06)
246
-
247
- ### Miscellaneous Chores
248
-
249
- * update username casing in changelog entries ([9722ac9](https://github.com/Alwatr/nanolib/commit/9722ac9a078438a4e8ebfa5826ea70e0e3a52ca6)) by @
250
-
251
- ### Dependencies update
252
-
253
- * bump the development-dependencies group across 1 directory with 11 updates ([720c395](https://github.com/Alwatr/nanolib/commit/720c3954da55c929fe8fb16957121f4c51fb7f0c)) by @dependabot[bot]
254
-
255
- ## [5.4.0](https://github.com/Alwatr/nanolib/compare/@alwatr/delay@1.0.8...@alwatr/delay@5.4.0) (2025-02-18)
256
-
257
- ### Dependencies update
258
-
259
- * bump @types/node from ^22.13.0 to ^22.13.4 and prettier from 3.4.2 to 3.5.1; update eslint-import-resolver-typescript to 3.8.2 ([b9a8399](https://github.com/Alwatr/nanolib/commit/b9a8399add39509e90bfdc589fb5e2321718029d)) by @
260
-
261
- ## 5.3.0 (2025-02-03)
262
-
263
- ### Miscellaneous Chores
264
-
265
- * edit README ([3860b3d](https://github.com/Alwatr/nanolib/commit/3860b3df48ab82dc479d5236c2e8579df614aabf)) by @
266
-
267
- ### Dependencies update
268
-
269
- * bump the development-dependencies group across 1 directory with 11 updates ([cb79d07](https://github.com/Alwatr/nanolib/commit/cb79d072a57c79e1c01abff1a293d6757bb65350)) by @
270
- * update typescript and @types/node to version 5.7.3 and 22.13.0 respectively across multiple packages ([ddab05b](https://github.com/Alwatr/nanolib/commit/ddab05b5d767c30191f36a065e4bc88744e8e3fe)) by @
271
-
272
- ## 5.0.0 (2024-11-02)
273
-
274
- ### ⚠ BREAKING CHANGES
275
-
276
- * To simplify version management and ensure consistency, all nanolib packages now use the same version as @alwatr/nanolib. This may require updates to your project's dependencies.
277
-
278
- ### Code Refactoring
279
-
280
- * use the same version as @alwatr/nanolib ([60eb860](https://github.com/Alwatr/nanolib/commit/60eb860a0e33dfffe2d1d95e63ce54c60876be06)) by @
281
-
282
- ## [5.3.0](https://github.com/Alwatr/nanolib/compare/v5.2.1...v5.3.0) (2025-02-03)
283
-
284
- ### Miscellaneous Chores
285
-
286
- * edit README ([3860b3d](https://github.com/Alwatr/nanolib/commit/3860b3df48ab82dc479d5236c2e8579df614aabf)) by @ArmanAsadian
287
-
288
- ### Dependencies update
289
-
290
- * bump the development-dependencies group across 1 directory with 11 updates ([cb79d07](https://github.com/Alwatr/nanolib/commit/cb79d072a57c79e1c01abff1a293d6757bb65350)) by @dependabot[bot]
291
- * update typescript and @types/node to version 5.7.3 and 22.13.0 respectively across multiple packages ([ddab05b](https://github.com/Alwatr/nanolib/commit/ddab05b5d767c30191f36a065e4bc88744e8e3fe)) by @alimd
292
-
293
- ## 5.0.0 (2024-11-02)
294
-
295
- ### ⚠ BREAKING CHANGES
296
-
297
- * To simplify version management and ensure consistency, all nanolib packages now use the same version as @alwatr/nanolib. This may require updates to your project's dependencies.
298
-
299
- ### Features
300
-
301
- * use `package-tracer` ([cc3c5f9](https://github.com/Alwatr/nanolib/commit/cc3c5f9c1a3d03f0d81b46835665f16a0426fd0d)) by @
302
-
303
- ### Bug Fixes
304
-
305
- * use new `global-this` package & remove global type & prevent sidee-ffects ([092d448](https://github.com/Alwatr/nanolib/commit/092d44885738ed58215698917ae97c13958f7c7d)) by @
306
-
307
- ### Code Refactoring
308
-
309
- * **delay:** prevent side-effects ([f92eeed](https://github.com/Alwatr/nanolib/commit/f92eeed7d917f6eb3ca9a407fab0b1ea77adc1d4)) by @
310
- * **delay:** update delay package to use @alwatr/parse-duration for duration delays ([cca1be2](https://github.com/Alwatr/nanolib/commit/cca1be2dcfeec6dce388562ef867b81af1823b62)) by @
311
- * **delay:** update untilIdle function to accept Duration instead of DurationString ([b3a5c32](https://github.com/Alwatr/nanolib/commit/b3a5c322a1b59833693149da644c7d2eddd6a374)) by @
312
- * prevent side-effects ([01e00e1](https://github.com/Alwatr/nanolib/commit/01e00e191385cc92b28677df0c01a085916ae677)) by @
313
- * update Dictionary type definitions ([c94cbc4](https://github.com/Alwatr/nanolib/commit/c94cbc4523864e2cc47828ccf5508b68945ac2b8)) by @
314
- * use new `global-this` package ([42510b9](https://github.com/Alwatr/nanolib/commit/42510b9ae0e385206a902db093d188949f1cb84e)) by @
315
- * use new type-helper global types and remove all import types ([08b5d08](https://github.com/Alwatr/nanolib/commit/08b5d08c03c7c315382337239de0426462f384b8)) by @
316
- * use the same version as @alwatr/nanolib ([60eb860](https://github.com/Alwatr/nanolib/commit/60eb860a0e33dfffe2d1d95e63ce54c60876be06)) by @
317
- * **wait:** rename package to delay ([cf8c45c](https://github.com/Alwatr/nanolib/commit/cf8c45cf3f5b61fdd4b1b1c7f744c4eb3e230016)) by @
318
-
319
- ### Miscellaneous Chores
320
-
321
- * fix versions ([497a6d8](https://github.com/Alwatr/nanolib/commit/497a6d81ae5989e566e96d498fc5f1b6c80193ae)) by @
322
- * include LICENSE and LEGAL files to publish ([09f366f](https://github.com/Alwatr/nanolib/commit/09f366f680bfa9fb26acb2cd1ccbc68c5a9e9ad8)) by @
323
-
324
- ### Dependencies update
325
-
326
- * bump the development-dependencies group across 1 directory with 2 updates ([2dfda9e](https://github.com/Alwatr/nanolib/commit/2dfda9ec38a595f1fd961490d1a2fbf060f20a66)) by @
327
- * bump the development-dependencies group with 10 updates ([fa4aaf0](https://github.com/Alwatr/nanolib/commit/fa4aaf04c907ecae06aa14000ce35216170c15ad)) by @
328
- * bump the development-dependencies group with 8 updates ([16847ac](https://github.com/Alwatr/nanolib/commit/16847acba91da027c422e3910d0f2dcc1f084e93)) by @
329
- * update ([4434ba6](https://github.com/Alwatr/nanolib/commit/4434ba67c3f576bb1a0c307fbdb263c43cd9733a)) by @
330
-
331
- ## [1.0.8](https://github.com/Alwatr/nanolib/compare/@alwatr/delay@1.0.7...@alwatr/delay@1.0.8) (2024-11-02)
332
-
333
- ### Dependencies update
334
-
335
- * update ([4434ba6](https://github.com/Alwatr/nanolib/commit/4434ba67c3f576bb1a0c307fbdb263c43cd9733a)) by @alimd
336
-
337
- ## [1.0.7](https://github.com/Alwatr/nanolib/compare/@alwatr/delay@1.0.6...@alwatr/delay@1.0.7) (2024-10-25)
338
-
339
- ### Dependencies update
340
-
341
- * bump the development-dependencies group across 1 directory with 2 updates ([2dfda9e](https://github.com/Alwatr/nanolib/commit/2dfda9ec38a595f1fd961490d1a2fbf060f20a66)) by @dependabot[bot]
342
- * bump the development-dependencies group with 8 updates ([16847ac](https://github.com/Alwatr/nanolib/commit/16847acba91da027c422e3910d0f2dcc1f084e93)) by @dependabot[bot]
343
-
344
- ## [1.0.6](https://github.com/Alwatr/nanolib/compare/@alwatr/delay@1.0.5...@alwatr/delay@1.0.6) (2024-10-12)
345
-
346
- **Note:** Version bump only for package @alwatr/delay
347
-
348
- ## [1.0.5](https://github.com/Alwatr/nanolib/compare/@alwatr/delay@1.0.4...@alwatr/delay@1.0.5) (2024-10-11)
349
-
350
- ### Bug Fixes
351
-
352
- - use new `global-this` package & remove global type & prevent sidee-ffects ([092d448](https://github.com/Alwatr/nanolib/commit/092d44885738ed58215698917ae97c13958f7c7d)) by @mohammadhonarvar
353
-
354
- ### Code Refactoring
355
-
356
- - **delay:** prevent side-effects ([f92eeed](https://github.com/Alwatr/nanolib/commit/f92eeed7d917f6eb3ca9a407fab0b1ea77adc1d4)) by @mohammadhonarvar
357
- - prevent side-effects ([01e00e1](https://github.com/Alwatr/nanolib/commit/01e00e191385cc92b28677df0c01a085916ae677)) by @mohammadhonarvar
358
- - use new `global-this` package ([42510b9](https://github.com/Alwatr/nanolib/commit/42510b9ae0e385206a902db093d188949f1cb84e)) by @mohammadhonarvar
359
-
360
- ## [1.0.4](https://github.com/Alwatr/nanolib/compare/@alwatr/delay@1.0.3...@alwatr/delay@1.0.4) (2024-10-11)
361
-
362
- ### Miscellaneous Chores
363
-
364
- - include LICENSE and LEGAL files to publish ([09f366f](https://github.com/Alwatr/nanolib/commit/09f366f680bfa9fb26acb2cd1ccbc68c5a9e9ad8)) by @alimd
365
-
366
- ## [1.0.3](https://github.com/Alwatr/nanolib/compare/@alwatr/delay@1.0.2...@alwatr/delay@1.0.3) (2024-10-11)
367
-
368
- **Note:** Version bump only for package @alwatr/delay
369
-
370
- ## [1.0.2](https://github.com/Alwatr/nanolib/compare/@alwatr/delay@1.0.1...@alwatr/delay@1.0.2) (2024-10-10)
371
-
372
- ### Dependencies update
373
-
374
- - bump the development-dependencies group with 10 updates ([fa4aaf0](https://github.com/Alwatr/nanolib/commit/fa4aaf04c907ecae06aa14000ce35216170c15ad)) by @dependabot[bot]
375
-
376
- ## [1.0.1](https://github.com/Alwatr/nanolib/compare/@alwatr/delay@1.0.0...@alwatr/delay@1.0.1) (2024-10-08)
377
-
378
- **Note:** Version bump only for package @alwatr/delay
379
-
380
- ## 1.0.0 (2024-09-29)
381
-
382
- ### Features
383
-
384
- - use `package-tracer` ([cc3c5f9](https://github.com/Alwatr/nanolib/commit/cc3c5f9c1a3d03f0d81b46835665f16a0426fd0d)) by @mohammadhonarvar
385
-
386
- ### Code Refactoring
387
-
388
- - **delay:** update delay package to use @alwatr/parse-duration for duration delays ([cca1be2](https://github.com/Alwatr/nanolib/commit/cca1be2dcfeec6dce388562ef867b81af1823b62)) by @alimd
389
- - **delay:** update untilIdle function to accept Duration instead of DurationString ([b3a5c32](https://github.com/Alwatr/nanolib/commit/b3a5c322a1b59833693149da644c7d2eddd6a374)) by @alimd
390
- - update Dictionary type definitions ([c94cbc4](https://github.com/Alwatr/nanolib/commit/c94cbc4523864e2cc47828ccf5508b68945ac2b8)) by @alimd
391
- - use new type-helper global types and remove all import types ([08b5d08](https://github.com/Alwatr/nanolib/commit/08b5d08c03c7c315382337239de0426462f384b8)) by @alimd
392
- - **wait:** rename package to delay ([cf8c45c](https://github.com/Alwatr/nanolib/commit/cf8c45cf3f5b61fdd4b1b1c7f744c4eb3e230016)) by @alimd
393
-
394
- ### Miscellaneous Chores
395
-
396
- - fix versions ([497a6d8](https://github.com/Alwatr/nanolib/commit/497a6d81ae5989e566e96d498fc5f1b6c80193ae)) by @alimd
397
-
398
- ## [1.1.16](https://github.com/Alwatr/nanolib/compare/@alwatr/delay@1.1.15...@alwatr/delay@1.1.16) (2024-09-21)
399
-
400
- **Note:** Version bump only for package @alwatr/delay
401
-
402
- ## [1.1.15](https://github.com/Alwatr/nanolib/compare/@alwatr/delay@1.1.14...@alwatr/delay@1.1.15) (2024-09-15)
403
-
404
- ### Dependencies update
405
-
406
- - bump the development-dependencies group across 1 directory with 10 updates ([9ed98ff](https://github.com/Alwatr/nanolib/commit/9ed98ffd0668d5a36e255c82edab3af53bffda8f)) by @dependabot[bot]
407
- - update ([c36ed50](https://github.com/Alwatr/nanolib/commit/c36ed50f68da2f5608ccd96119963a16cfacb4ce)) by @alimd
408
-
409
- ## [1.1.14](https://github.com/Alwatr/nanolib/compare/@alwatr/delay@1.1.13...@alwatr/delay@1.1.14) (2024-08-31)
410
-
411
- ### Miscellaneous Chores
412
-
413
- - Update package.json exports for [@alwatr](https://github.com/alwatr) packages ([dacb362](https://github.com/Alwatr/nanolib/commit/dacb362b145e3c51b4aba00ff643687a3fac11d2)) by @
414
-
415
- ## [1.1.13](https://github.com/Alwatr/nanolib/compare/@alwatr/delay@1.1.12...@alwatr/delay@1.1.13) (2024-08-31)
416
-
417
- ### Dependencies update
418
-
419
- - update all dependencies ([1e0c30e](https://github.com/Alwatr/nanolib/commit/1e0c30e6a3a8e19deb5185814e24ab6c08dca573)) by @alimd
420
-
421
- ## [1.1.12](https://github.com/Alwatr/nanolib/compare/@alwatr/delay@1.1.11...@alwatr/delay@1.1.12) (2024-07-04)
422
-
423
- ### Dependencies update
424
-
425
- - update all dependencies ([0e908b4](https://github.com/Alwatr/nanolib/commit/0e908b476a6b976ec2447f864c8cafcbb8a0f099)) by @
426
-
427
- ## [1.1.11](https://github.com/Alwatr/nanolib/compare/@alwatr/delay@1.1.10...@alwatr/delay@1.1.11) (2024-05-12)
428
-
429
- ### Dependencies update
430
-
431
- - upgrade ([6dbd300](https://github.com/Alwatr/nanolib/commit/6dbd300642c9bcc9e7d0b281e244bf1b06eb1c38)) by @alimd
432
-
433
- ## [1.1.10](https://github.com/Alwatr/nanolib/compare/@alwatr/delay@1.1.9...@alwatr/delay@1.1.10) (2024-04-25)
434
-
435
- **Note:** Version bump only for package @alwatr/delay
436
-
437
- ## [1.1.9](https://github.com/Alwatr/nanolib/compare/@alwatr/delay@1.1.8...@alwatr/delay@1.1.9) (2024-03-28)
438
-
439
- **Note:** Version bump only for package @alwatr/delay
440
-
441
- ## [1.1.8](https://github.com/Alwatr/nanolib/compare/@alwatr/delay@1.1.7...@alwatr/delay@1.1.8) (2024-01-31)
442
-
443
- ### Bug Fixes
444
-
445
- - exported types by add .js extensions to all imports ([fc3d83e](https://github.com/Alwatr/nanolib/commit/fc3d83e8f375da97ba276314b2e6966aa82c9b3f)) by @alimd
446
-
447
- ### Miscellaneous Chores
448
-
449
- - **deps:** update ([1a45030](https://github.com/Alwatr/nanolib/commit/1a450305440b710a300787d4ca24b1ed8c6a39d7)) by @alimd
450
-
451
- ## [1.1.7](https://github.com/Alwatr/nanolib/compare/@alwatr/delay@1.1.6...@alwatr/delay@1.1.7) (2024-01-24)
452
-
453
- **Note:** Version bump only for package @alwatr/delay
454
-
455
- ## [1.1.6](https://github.com/Alwatr/nanolib/compare/@alwatr/delay@1.1.5...@alwatr/delay@1.1.6) (2024-01-20)
456
-
457
- **Note:** Version bump only for package @alwatr/delay
458
-
459
- ## [1.1.5](https://github.com/Alwatr/nanolib/compare/@alwatr/delay@1.1.4...@alwatr/delay@1.1.5) (2024-01-16)
460
-
461
- **Note:** Version bump only for package @alwatr/delay
462
-
463
- ## [1.1.4](https://github.com/Alwatr/nanolib/compare/@alwatr/delay@1.1.3...@alwatr/delay@1.1.4) (2024-01-08)
464
-
465
- **Note:** Version bump only for package @alwatr/delay
466
-
467
- ## [1.1.3](https://github.com/Alwatr/nanolib/compare/@alwatr/delay@1.1.2...@alwatr/delay@1.1.3) (2024-01-03)
468
-
469
- **Note:** Version bump only for package @alwatr/delay
470
-
471
- ## [1.1.2](https://github.com/Alwatr/nanolib/compare/@alwatr/delay@1.1.1...@alwatr/delay@1.1.2) (2024-01-03)
472
-
473
- ### Bug Fixes
474
-
475
- - **wait:** requestIdleCallback polyfill ([d41180d](https://github.com/Alwatr/nanolib/commit/d41180dc2f0c313eb86f05f60050e57e891897c3)) by @alimd
476
-
477
- ## [1.1.1](https://github.com/Alwatr/nanolib/compare/@alwatr/delay@1.1.0...@alwatr/delay@1.1.1) (2023-12-27)
478
-
479
- **Note:** Version bump only for package @alwatr/delay
480
-
481
- # 1.1.0 (2023-12-27)
482
-
483
- ### Bug Fixes
484
-
485
- - deps ([34cd4fe](https://github.com/Alwatr/nanolib/commit/34cd4fead81b309765144a24add67e3f63bca127)) by @njfamirm
486
- - **wait:** polyfill ([6a0f5fb](https://github.com/Alwatr/nanolib/commit/6a0f5fb5f0ae369d832760c026c26428689d258d)) by @alimd
487
- - **wait:** polyfill check ([cd9befa](https://github.com/Alwatr/nanolib/commit/cd9befa0ae01090016eb16befc08d1ce17ba881d)) by @njfamirm
488
-
489
- ### Features
490
-
491
- - **wait:** base package ([8f29498](https://github.com/Alwatr/nanolib/commit/8f294983f9250e1ec8fb60dce72347f9586c561b)) by @njfamirm
492
- - **wait:** polyfill and docs ([9725dc2](https://github.com/Alwatr/nanolib/commit/9725dc2cfa4d70fb5dac8a2816f986ad00c4f43f)) by @njfamirm
package/dist/main.cjs DELETED
@@ -1,3 +0,0 @@
1
- /** 📦 @alwatr/delay v6.0.22 */
2
- "use strict";var __defProp=Object.defineProperty;var __getOwnPropDesc=Object.getOwnPropertyDescriptor;var __getOwnPropNames=Object.getOwnPropertyNames;var __hasOwnProp=Object.prototype.hasOwnProperty;var __export=(target,all)=>{for(var name in all)__defProp(target,name,{get:all[name],enumerable:true})};var __copyProps=(to,from,except,desc)=>{if(from&&typeof from==="object"||typeof from==="function"){for(let key of __getOwnPropNames(from))if(!__hasOwnProp.call(to,key)&&key!==except)__defProp(to,key,{get:()=>from[key],enumerable:!(desc=__getOwnPropDesc(from,key))||desc.enumerable})}return to};var __toCommonJS=mod=>__copyProps(__defProp({},"__esModule",{value:true}),mod);var main_exports={};__export(main_exports,{delay:()=>delay,requestAnimationFrame:()=>requestAnimationFrame,requestIdleCallback:()=>requestIdleCallback});module.exports=__toCommonJS(main_exports);var import_parse_duration=require("@alwatr/parse-duration");var import_global_this=require("@alwatr/global-this");var globalThis=(0,import_global_this.getGlobalThis)();var requestAnimationFrame=globalThis.requestAnimationFrame?.bind(globalThis)??(callback=>setTimeout(()=>callback(performance.now()),1e3/60));var requestIdleCallback=globalThis.requestIdleCallback?.bind(globalThis)??((callback,options)=>{const startTime=Date.now();return setTimeout(()=>{callback({didTimeout:!!options?.timeout,timeRemaining:()=>Math.max(0,50-(Date.now()-startTime))})},options?.timeout??20)});var delay={by:duration=>new Promise(resolve=>setTimeout(resolve,(0,import_parse_duration.parseDuration)(duration))),animationFrame:()=>new Promise(resolve=>requestAnimationFrame(resolve)),idleCallback:options=>new Promise(resolve=>requestIdleCallback(resolve,options)),domEvent:(element,eventName,options={passive:true})=>new Promise(resolve=>element.addEventListener(eventName,resolve,{...options,once:true})),event:(target,eventName,options={passive:true})=>new Promise(resolve=>target.addEventListener(eventName,resolve,{...options,once:true})),nextMacrotask:()=>new Promise(resolve=>setTimeout(resolve,0)),nextMicrotask:()=>Promise.resolve().then(()=>{})};0&&(module.exports={delay,requestAnimationFrame,requestIdleCallback});
3
- //# sourceMappingURL=main.cjs.map
package/dist/main.cjs.map DELETED
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../src/main.ts", "../src/polyfill.ts"],
4
- "sourcesContent": ["import {parseDuration, type Duration} from '@alwatr/parse-duration';\n\nimport {requestAnimationFrame, requestIdleCallback} from './polyfill.js';\n\nexport {requestAnimationFrame, requestIdleCallback};\n\n/**\n * A utility module to help manage asynchronous operations and waiting for events or timeouts.\n */\nexport const delay = {\n /**\n * Pauses execution for a specified duration.\n *\n * @param duration The duration to wait. Can be a number in milliseconds or a string like '2s', '100ms'.\n * @returns A Promise that resolves after the specified duration.\n *\n * @example\n * ```typescript\n * await delay.by('1m'); // Wait for 1 minute\n * await delay.by('2s'); // Wait for 2 seconds\n * ```\n */\n by: (duration: Duration): Promise<void> => new Promise((resolve) => setTimeout(resolve, parseDuration(duration))),\n\n /**\n * Pauses execution until the next animation frame.\n *\n * @returns A Promise that resolves with the high-resolution timestamp of the next animation frame.\n *\n * @example\n * ```typescript\n * const timestamp = await delay.animationFrame();\n * console.log(`Next frame at ${timestamp}`);\n * ```\n */\n animationFrame: (): Promise<DOMHighResTimeStamp> => new Promise((resolve) => requestAnimationFrame(resolve)),\n\n /**\n * Pauses execution until the browser is idle.\n *\n * @param timeout An optional maximum duration to wait.\n * @returns A Promise that resolves with an `IdleDeadline` object.\n *\n * @example\n * ```typescript\n * const deadline = await delay.idleCallback({ timeout: 2000 });\n * if (deadline.didTimeout) {\n * console.log('Idle callback timed out.');\n * }\n * ```\n */\n idleCallback: (options?: IdleRequestOptions): Promise<IdleDeadline> => new Promise((resolve) => requestIdleCallback(resolve, options)),\n\n /**\n * Pauses execution until a specific DOM event is dispatched on an element.\n *\n * @param element The HTMLElement to listen on.\n * @param eventName The name of the event to wait for.\n * @param options Optional event listener options.\n * @template T The event map type for the element.\n * @returns A Promise that resolves with the triggered event object.\n *\n * @example\n * ```typescript\n * const button = document.getElementById('my-button');\n * if (button) {\n * const clickEvent = await delay.domEvent(button, 'click');\n * console.log('Button clicked!', clickEvent);\n * }\n * ```\n */\n domEvent: <T extends keyof HTMLElementEventMap>(\n element: HTMLElement,\n eventName: T,\n options: AddEventListenerOptions = {passive: true},\n ): Promise<HTMLElementEventMap[T]> =>\n new Promise((resolve) =>\n element.addEventListener(eventName, resolve, {\n ...options,\n once: true,\n }),\n ),\n\n /**\n * Pauses execution until a specific event is dispatched on any event target.\n *\n * @param target The event target (e.g., window, document, or a custom event emitter).\n * @param eventName The name of the event to wait for.\n * @param options Optional event listener options.\n * @returns A Promise that resolves with the triggered event object.\n *\n * @example\n * ```typescript\n * const resizeEvent = await delay.event(window, 'resize');\n * console.log('Window resized:', resizeEvent);\n * ```\n */\n event: (target: EventTarget, eventName: string, options: AddEventListenerOptions = {passive: true}): Promise<Event> =>\n new Promise((resolve) =>\n target.addEventListener(eventName, resolve, {\n ...options,\n once: true,\n }),\n ),\n\n /**\n * Schedules a macrotask to run after the current event loop task completes.\n * Uses `setTimeout(..., 0)`.\n *\n * @returns A Promise that resolves when the macrotask is executed.\n *\n * @example\n * ```typescript\n * console.log('Start');\n * await delay.nextMacrotask();\n * console.log('End - after current task');\n * ```\n */\n nextMacrotask: (): Promise<void> => new Promise((resolve) => setTimeout(resolve, 0)),\n\n /**\n * Queues a microtask to run after the current task completes but before the next macrotask.\n *\n * @returns A Promise that resolves when the microtask is executed.\n *\n * @example\n * ```typescript\n * console.log('Start');\n * await delay.nextMicrotask();\n * console.log('End - immediately after current task');\n * ```\n */\n // eslint-disable-next-line @typescript-eslint/no-empty-function\n nextMicrotask: (): Promise<void> => Promise.resolve().then(() => {}),\n} as const;\n", "import {getGlobalThis} from '@alwatr/global-this';\n\nimport type {} from '@alwatr/type-helper';\n\nconst globalThis = getGlobalThis<DictionaryOpt<unknown>>();\n\n/**\n * Ensures compatibility for `requestAnimationFrame` by using the native API\n * available in `globalThis`. If it's not available, it falls back to a `setTimeout`\n * call that aims for a 60 frames per second refresh rate.\n *\n * @param callback The function to call when it's time to update your animation for the next repaint.\n * @returns A long integer value, the request ID, that uniquely identifies the entry in the callback list.\n */\nexport const requestAnimationFrame: (callback: FrameRequestCallback) => number =\n globalThis.requestAnimationFrame?.bind(globalThis) ??\n ((callback: FrameRequestCallback) => setTimeout(() => callback(performance.now()), 1000 / 60));\n\n/**\n * Ensures compatibility for `requestIdleCallback` by using the native API.\n * If unavailable, it falls back to a `setTimeout` that executes the callback\n * after a short delay, providing a mock `IdleDeadline` object.\n *\n * The mock `IdleDeadline` gives the task a 50ms budget to run.\n *\n * @param callback A reference to a function that should be called in the near future, when the event loop is idle.\n * @param options An optional object with configuration parameters.\n * @returns An ID which can be used to cancel the callback by calling `cancelIdleCallback()`.\n */\nexport const requestIdleCallback: (callback: (deadline: IdleDeadline) => void, options?: IdleRequestOptions) => number =\n globalThis.requestIdleCallback?.bind(globalThis) ??\n ((\n callback: (deadline: IdleDeadline) => void,\n // options is not used in the fallback but kept for API consistency\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n options?: IdleRequestOptions,\n ) => {\n const startTime = Date.now();\n return setTimeout(() => {\n callback({\n didTimeout: !!options?.timeout,\n timeRemaining: () => Math.max(0, 50 - (Date.now() - startTime)),\n });\n }, options?.timeout ?? 20);\n });\n"],
5
- "mappings": ";qqBAAA,6NAA2C,kCCA3C,uBAA4B,+BAI5B,IAAM,cAAa,kCAAsC,EAUlD,IAAM,sBACX,WAAW,uBAAuB,KAAK,UAAU,IAC/C,UAAmC,WAAW,IAAM,SAAS,YAAY,IAAI,CAAC,EAAG,IAAO,EAAE,GAavF,IAAM,oBACX,WAAW,qBAAqB,KAAK,UAAU,IAC9C,CACC,SAGA,UACG,CACH,MAAM,UAAY,KAAK,IAAI,EAC3B,OAAO,WAAW,IAAM,CACtB,SAAS,CACP,WAAY,CAAC,CAAC,SAAS,QACvB,cAAe,IAAM,KAAK,IAAI,EAAG,IAAM,KAAK,IAAI,EAAI,UAAU,CAChE,CAAC,CACH,EAAG,SAAS,SAAW,EAAE,CAC3B,GDnCK,IAAM,MAAQ,CAanB,GAAK,UAAsC,IAAI,QAAS,SAAY,WAAW,WAAS,qCAAc,QAAQ,CAAC,CAAC,EAahH,eAAgB,IAAoC,IAAI,QAAS,SAAY,sBAAsB,OAAO,CAAC,EAgB3G,aAAe,SAAwD,IAAI,QAAS,SAAY,oBAAoB,QAAS,OAAO,CAAC,EAoBrI,SAAU,CACR,QACA,UACA,QAAmC,CAAC,QAAS,IAAI,IAEjD,IAAI,QAAS,SACX,QAAQ,iBAAiB,UAAW,QAAS,CAC3C,GAAG,QACH,KAAM,IACR,CAAC,CACH,EAgBF,MAAO,CAAC,OAAqB,UAAmB,QAAmC,CAAC,QAAS,IAAI,IAC/F,IAAI,QAAS,SACX,OAAO,iBAAiB,UAAW,QAAS,CAC1C,GAAG,QACH,KAAM,IACR,CAAC,CACH,EAeF,cAAe,IAAqB,IAAI,QAAS,SAAY,WAAW,QAAS,CAAC,CAAC,EAenF,cAAe,IAAqB,QAAQ,QAAQ,EAAE,KAAK,IAAM,CAAC,CAAC,CACrE",
6
- "names": []
7
- }
package/dist/main.mjs DELETED
@@ -1,3 +0,0 @@
1
- /** 📦 @alwatr/delay v6.0.22 */
2
- import{parseDuration}from"@alwatr/parse-duration";import{getGlobalThis}from"@alwatr/global-this";var globalThis=getGlobalThis();var requestAnimationFrame=globalThis.requestAnimationFrame?.bind(globalThis)??(callback=>setTimeout(()=>callback(performance.now()),1e3/60));var requestIdleCallback=globalThis.requestIdleCallback?.bind(globalThis)??((callback,options)=>{const startTime=Date.now();return setTimeout(()=>{callback({didTimeout:!!options?.timeout,timeRemaining:()=>Math.max(0,50-(Date.now()-startTime))})},options?.timeout??20)});var delay={by:duration=>new Promise(resolve=>setTimeout(resolve,parseDuration(duration))),animationFrame:()=>new Promise(resolve=>requestAnimationFrame(resolve)),idleCallback:options=>new Promise(resolve=>requestIdleCallback(resolve,options)),domEvent:(element,eventName,options={passive:true})=>new Promise(resolve=>element.addEventListener(eventName,resolve,{...options,once:true})),event:(target,eventName,options={passive:true})=>new Promise(resolve=>target.addEventListener(eventName,resolve,{...options,once:true})),nextMacrotask:()=>new Promise(resolve=>setTimeout(resolve,0)),nextMicrotask:()=>Promise.resolve().then(()=>{})};export{delay,requestAnimationFrame,requestIdleCallback};
3
- //# sourceMappingURL=main.mjs.map
package/dist/main.mjs.map DELETED
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../src/main.ts", "../src/polyfill.ts"],
4
- "sourcesContent": ["import {parseDuration, type Duration} from '@alwatr/parse-duration';\n\nimport {requestAnimationFrame, requestIdleCallback} from './polyfill.js';\n\nexport {requestAnimationFrame, requestIdleCallback};\n\n/**\n * A utility module to help manage asynchronous operations and waiting for events or timeouts.\n */\nexport const delay = {\n /**\n * Pauses execution for a specified duration.\n *\n * @param duration The duration to wait. Can be a number in milliseconds or a string like '2s', '100ms'.\n * @returns A Promise that resolves after the specified duration.\n *\n * @example\n * ```typescript\n * await delay.by('1m'); // Wait for 1 minute\n * await delay.by('2s'); // Wait for 2 seconds\n * ```\n */\n by: (duration: Duration): Promise<void> => new Promise((resolve) => setTimeout(resolve, parseDuration(duration))),\n\n /**\n * Pauses execution until the next animation frame.\n *\n * @returns A Promise that resolves with the high-resolution timestamp of the next animation frame.\n *\n * @example\n * ```typescript\n * const timestamp = await delay.animationFrame();\n * console.log(`Next frame at ${timestamp}`);\n * ```\n */\n animationFrame: (): Promise<DOMHighResTimeStamp> => new Promise((resolve) => requestAnimationFrame(resolve)),\n\n /**\n * Pauses execution until the browser is idle.\n *\n * @param timeout An optional maximum duration to wait.\n * @returns A Promise that resolves with an `IdleDeadline` object.\n *\n * @example\n * ```typescript\n * const deadline = await delay.idleCallback({ timeout: 2000 });\n * if (deadline.didTimeout) {\n * console.log('Idle callback timed out.');\n * }\n * ```\n */\n idleCallback: (options?: IdleRequestOptions): Promise<IdleDeadline> => new Promise((resolve) => requestIdleCallback(resolve, options)),\n\n /**\n * Pauses execution until a specific DOM event is dispatched on an element.\n *\n * @param element The HTMLElement to listen on.\n * @param eventName The name of the event to wait for.\n * @param options Optional event listener options.\n * @template T The event map type for the element.\n * @returns A Promise that resolves with the triggered event object.\n *\n * @example\n * ```typescript\n * const button = document.getElementById('my-button');\n * if (button) {\n * const clickEvent = await delay.domEvent(button, 'click');\n * console.log('Button clicked!', clickEvent);\n * }\n * ```\n */\n domEvent: <T extends keyof HTMLElementEventMap>(\n element: HTMLElement,\n eventName: T,\n options: AddEventListenerOptions = {passive: true},\n ): Promise<HTMLElementEventMap[T]> =>\n new Promise((resolve) =>\n element.addEventListener(eventName, resolve, {\n ...options,\n once: true,\n }),\n ),\n\n /**\n * Pauses execution until a specific event is dispatched on any event target.\n *\n * @param target The event target (e.g., window, document, or a custom event emitter).\n * @param eventName The name of the event to wait for.\n * @param options Optional event listener options.\n * @returns A Promise that resolves with the triggered event object.\n *\n * @example\n * ```typescript\n * const resizeEvent = await delay.event(window, 'resize');\n * console.log('Window resized:', resizeEvent);\n * ```\n */\n event: (target: EventTarget, eventName: string, options: AddEventListenerOptions = {passive: true}): Promise<Event> =>\n new Promise((resolve) =>\n target.addEventListener(eventName, resolve, {\n ...options,\n once: true,\n }),\n ),\n\n /**\n * Schedules a macrotask to run after the current event loop task completes.\n * Uses `setTimeout(..., 0)`.\n *\n * @returns A Promise that resolves when the macrotask is executed.\n *\n * @example\n * ```typescript\n * console.log('Start');\n * await delay.nextMacrotask();\n * console.log('End - after current task');\n * ```\n */\n nextMacrotask: (): Promise<void> => new Promise((resolve) => setTimeout(resolve, 0)),\n\n /**\n * Queues a microtask to run after the current task completes but before the next macrotask.\n *\n * @returns A Promise that resolves when the microtask is executed.\n *\n * @example\n * ```typescript\n * console.log('Start');\n * await delay.nextMicrotask();\n * console.log('End - immediately after current task');\n * ```\n */\n // eslint-disable-next-line @typescript-eslint/no-empty-function\n nextMicrotask: (): Promise<void> => Promise.resolve().then(() => {}),\n} as const;\n", "import {getGlobalThis} from '@alwatr/global-this';\n\nimport type {} from '@alwatr/type-helper';\n\nconst globalThis = getGlobalThis<DictionaryOpt<unknown>>();\n\n/**\n * Ensures compatibility for `requestAnimationFrame` by using the native API\n * available in `globalThis`. If it's not available, it falls back to a `setTimeout`\n * call that aims for a 60 frames per second refresh rate.\n *\n * @param callback The function to call when it's time to update your animation for the next repaint.\n * @returns A long integer value, the request ID, that uniquely identifies the entry in the callback list.\n */\nexport const requestAnimationFrame: (callback: FrameRequestCallback) => number =\n globalThis.requestAnimationFrame?.bind(globalThis) ??\n ((callback: FrameRequestCallback) => setTimeout(() => callback(performance.now()), 1000 / 60));\n\n/**\n * Ensures compatibility for `requestIdleCallback` by using the native API.\n * If unavailable, it falls back to a `setTimeout` that executes the callback\n * after a short delay, providing a mock `IdleDeadline` object.\n *\n * The mock `IdleDeadline` gives the task a 50ms budget to run.\n *\n * @param callback A reference to a function that should be called in the near future, when the event loop is idle.\n * @param options An optional object with configuration parameters.\n * @returns An ID which can be used to cancel the callback by calling `cancelIdleCallback()`.\n */\nexport const requestIdleCallback: (callback: (deadline: IdleDeadline) => void, options?: IdleRequestOptions) => number =\n globalThis.requestIdleCallback?.bind(globalThis) ??\n ((\n callback: (deadline: IdleDeadline) => void,\n // options is not used in the fallback but kept for API consistency\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n options?: IdleRequestOptions,\n ) => {\n const startTime = Date.now();\n return setTimeout(() => {\n callback({\n didTimeout: !!options?.timeout,\n timeRemaining: () => Math.max(0, 50 - (Date.now() - startTime)),\n });\n }, options?.timeout ?? 20);\n });\n"],
5
- "mappings": ";AAAA,OAAQ,kBAAmC,yBCA3C,OAAQ,kBAAoB,sBAI5B,IAAM,WAAa,cAAsC,EAUlD,IAAM,sBACX,WAAW,uBAAuB,KAAK,UAAU,IAC/C,UAAmC,WAAW,IAAM,SAAS,YAAY,IAAI,CAAC,EAAG,IAAO,EAAE,GAavF,IAAM,oBACX,WAAW,qBAAqB,KAAK,UAAU,IAC9C,CACC,SAGA,UACG,CACH,MAAM,UAAY,KAAK,IAAI,EAC3B,OAAO,WAAW,IAAM,CACtB,SAAS,CACP,WAAY,CAAC,CAAC,SAAS,QACvB,cAAe,IAAM,KAAK,IAAI,EAAG,IAAM,KAAK,IAAI,EAAI,UAAU,CAChE,CAAC,CACH,EAAG,SAAS,SAAW,EAAE,CAC3B,GDnCK,IAAM,MAAQ,CAanB,GAAK,UAAsC,IAAI,QAAS,SAAY,WAAW,QAAS,cAAc,QAAQ,CAAC,CAAC,EAahH,eAAgB,IAAoC,IAAI,QAAS,SAAY,sBAAsB,OAAO,CAAC,EAgB3G,aAAe,SAAwD,IAAI,QAAS,SAAY,oBAAoB,QAAS,OAAO,CAAC,EAoBrI,SAAU,CACR,QACA,UACA,QAAmC,CAAC,QAAS,IAAI,IAEjD,IAAI,QAAS,SACX,QAAQ,iBAAiB,UAAW,QAAS,CAC3C,GAAG,QACH,KAAM,IACR,CAAC,CACH,EAgBF,MAAO,CAAC,OAAqB,UAAmB,QAAmC,CAAC,QAAS,IAAI,IAC/F,IAAI,QAAS,SACX,OAAO,iBAAiB,UAAW,QAAS,CAC1C,GAAG,QACH,KAAM,IACR,CAAC,CACH,EAeF,cAAe,IAAqB,IAAI,QAAS,SAAY,WAAW,QAAS,CAAC,CAAC,EAenF,cAAe,IAAqB,QAAQ,QAAQ,EAAE,KAAK,IAAM,CAAC,CAAC,CACrE",
6
- "names": []
7
- }