@oscarpalmer/timer 0.46.0 → 0.47.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/index.d.mts CHANGED
@@ -152,26 +152,30 @@ declare global {
152
152
  //#region src/is.d.ts
153
153
  /**
154
154
  * Is the value a repeating timer?
155
+ *
155
156
  * @param value Value to check
156
- * @returns `true` if the value is a repeating timer
157
+ * @returns `true` if the value is a repeating timer, otherwise `false`
157
158
  */
158
159
  declare function isRepeated(value: unknown): value is Timer;
159
160
  /**
160
161
  * Is the value a timer?
162
+ *
161
163
  * @param value Value to check
162
- * @returns `true` if the value is a timer
164
+ * @returns `true` if the value is a timer, otherwise `false`
163
165
  */
164
166
  declare function isTimer(value: unknown): value is Timer;
165
167
  /**
166
168
  * Is the value a waiting timer?
169
+ *
167
170
  * @param value Value to check
168
- * @returns `true` if the value is a waiting timer
171
+ * @returns `true` if the value is a waiting timer, otherwise `false`
169
172
  */
170
173
  declare function isWaited(value: unknown): value is Timer;
171
174
  /**
172
175
  * Is the value a conditional timer?
176
+ *
173
177
  * @param value Value to check
174
- * @returns `true` if the value is a conditional timer
178
+ * @returns `true` if the value is a conditional timer, otherwise `false`
175
179
  */
176
180
  declare function isWhen(value: unknown): value is When;
177
181
  //#endregion
@@ -181,7 +185,7 @@ declare function isWhen(value: unknown): value is When;
181
185
  *
182
186
  * @param callback Callback to run on each interval
183
187
  * @param options Timer options
184
- * @returns Timer instance
188
+ * @returns Repeating timer
185
189
  */
186
190
  declare function repeat(callback: (index: number) => void, options?: Partial<RepeatOptions>): Timer;
187
191
  //#endregion
@@ -191,6 +195,7 @@ declare function repeat(callback: (index: number) => void, options?: Partial<Rep
191
195
  *
192
196
  * @param callback Callback to run when the timer has finished
193
197
  * @param time How long to wait for _(in milliseconds; defaults to screen refresh rate)_
198
+ * @returns Waiting timer
194
199
  */
195
200
  declare function wait(callback: () => void, time?: number): Timer;
196
201
  //#endregion
package/dist/index.mjs CHANGED
@@ -140,32 +140,36 @@ function is(names, value) {
140
140
  }
141
141
  /**
142
142
  * Is the value a repeating timer?
143
+ *
143
144
  * @param value Value to check
144
- * @returns `true` if the value is a repeating timer
145
+ * @returns `true` if the value is a repeating timer, otherwise `false`
145
146
  */
146
147
  function isRepeated(value) {
147
148
  return is([TYPE_REPEAT], value);
148
149
  }
149
150
  /**
150
151
  * Is the value a timer?
152
+ *
151
153
  * @param value Value to check
152
- * @returns `true` if the value is a timer
154
+ * @returns `true` if the value is a timer, otherwise `false`
153
155
  */
154
156
  function isTimer(value) {
155
157
  return is([TYPE_REPEAT, TYPE_WAIT], value);
156
158
  }
157
159
  /**
158
160
  * Is the value a waiting timer?
161
+ *
159
162
  * @param value Value to check
160
- * @returns `true` if the value is a waiting timer
163
+ * @returns `true` if the value is a waiting timer, otherwise `false`
161
164
  */
162
165
  function isWaited(value) {
163
166
  return is([TYPE_WAIT], value);
164
167
  }
165
168
  /**
166
169
  * Is the value a conditional timer?
170
+ *
167
171
  * @param value Value to check
168
- * @returns `true` if the value is a conditional timer
172
+ * @returns `true` if the value is a conditional timer, otherwise `false`
169
173
  */
170
174
  function isWhen(value) {
171
175
  return is(["when"], value) && typeof value.start === "function";
@@ -235,7 +239,7 @@ function createTimer(name, pick, options, start) {
235
239
  *
236
240
  * @param callback Callback to run on each interval
237
241
  * @param options Timer options
238
- * @returns Timer instance
242
+ * @returns Repeating timer
239
243
  */
240
244
  function repeat(callback, options) {
241
245
  return createTimer(TYPE_REPEAT, {
@@ -256,6 +260,7 @@ function repeat(callback, options) {
256
260
  *
257
261
  * @param callback Callback to run when the timer has finished
258
262
  * @param time How long to wait for _(in milliseconds; defaults to screen refresh rate)_
263
+ * @returns Waiting timer
259
264
  */
260
265
  function wait(callback, time) {
261
266
  return createTimer(TYPE_WAIT, {
package/dist/is.d.mts CHANGED
@@ -2,26 +2,30 @@ import { Timer, When } from "./models.mjs";
2
2
  //#region src/is.d.ts
3
3
  /**
4
4
  * Is the value a repeating timer?
5
+ *
5
6
  * @param value Value to check
6
- * @returns `true` if the value is a repeating timer
7
+ * @returns `true` if the value is a repeating timer, otherwise `false`
7
8
  */
8
9
  declare function isRepeated(value: unknown): value is Timer;
9
10
  /**
10
11
  * Is the value a timer?
12
+ *
11
13
  * @param value Value to check
12
- * @returns `true` if the value is a timer
14
+ * @returns `true` if the value is a timer, otherwise `false`
13
15
  */
14
16
  declare function isTimer(value: unknown): value is Timer;
15
17
  /**
16
18
  * Is the value a waiting timer?
19
+ *
17
20
  * @param value Value to check
18
- * @returns `true` if the value is a waiting timer
21
+ * @returns `true` if the value is a waiting timer, otherwise `false`
19
22
  */
20
23
  declare function isWaited(value: unknown): value is Timer;
21
24
  /**
22
25
  * Is the value a conditional timer?
26
+ *
23
27
  * @param value Value to check
24
- * @returns `true` if the value is a conditional timer
28
+ * @returns `true` if the value is a conditional timer, otherwise `false`
25
29
  */
26
30
  declare function isWhen(value: unknown): value is When;
27
31
  //#endregion
package/dist/is.mjs CHANGED
@@ -5,32 +5,36 @@ function is(names, value) {
5
5
  }
6
6
  /**
7
7
  * Is the value a repeating timer?
8
+ *
8
9
  * @param value Value to check
9
- * @returns `true` if the value is a repeating timer
10
+ * @returns `true` if the value is a repeating timer, otherwise `false`
10
11
  */
11
12
  function isRepeated(value) {
12
13
  return is([TYPE_REPEAT], value);
13
14
  }
14
15
  /**
15
16
  * Is the value a timer?
17
+ *
16
18
  * @param value Value to check
17
- * @returns `true` if the value is a timer
19
+ * @returns `true` if the value is a timer, otherwise `false`
18
20
  */
19
21
  function isTimer(value) {
20
22
  return is([TYPE_REPEAT, TYPE_WAIT], value);
21
23
  }
22
24
  /**
23
25
  * Is the value a waiting timer?
26
+ *
24
27
  * @param value Value to check
25
- * @returns `true` if the value is a waiting timer
28
+ * @returns `true` if the value is a waiting timer, otherwise `false`
26
29
  */
27
30
  function isWaited(value) {
28
31
  return is([TYPE_WAIT], value);
29
32
  }
30
33
  /**
31
34
  * Is the value a conditional timer?
35
+ *
32
36
  * @param value Value to check
33
- * @returns `true` if the value is a conditional timer
37
+ * @returns `true` if the value is a conditional timer, otherwise `false`
34
38
  */
35
39
  function isWhen(value) {
36
40
  return is(["when"], value) && typeof value.start === "function";
package/dist/repeat.d.mts CHANGED
@@ -6,7 +6,7 @@ import "./global.mjs";
6
6
  *
7
7
  * @param callback Callback to run on each interval
8
8
  * @param options Timer options
9
- * @returns Timer instance
9
+ * @returns Repeating timer
10
10
  */
11
11
  declare function repeat(callback: (index: number) => void, options?: Partial<RepeatOptions>): Timer;
12
12
  //#endregion
package/dist/repeat.mjs CHANGED
@@ -9,7 +9,7 @@ import { createTimer } from "./timer.mjs";
9
9
  *
10
10
  * @param callback Callback to run on each interval
11
11
  * @param options Timer options
12
- * @returns Timer instance
12
+ * @returns Repeating timer
13
13
  */
14
14
  function repeat(callback, options) {
15
15
  return createTimer(TYPE_REPEAT, {
package/dist/wait.d.mts CHANGED
@@ -6,6 +6,7 @@ import "./global.mjs";
6
6
  *
7
7
  * @param callback Callback to run when the timer has finished
8
8
  * @param time How long to wait for _(in milliseconds; defaults to screen refresh rate)_
9
+ * @returns Waiting timer
9
10
  */
10
11
  declare function wait(callback: () => void, time?: number): Timer;
11
12
  //#endregion
package/dist/wait.mjs CHANGED
@@ -9,6 +9,7 @@ import { createTimer } from "./timer.mjs";
9
9
  *
10
10
  * @param callback Callback to run when the timer has finished
11
11
  * @param time How long to wait for _(in milliseconds; defaults to screen refresh rate)_
12
+ * @returns Waiting timer
12
13
  */
13
14
  function wait(callback, time) {
14
15
  return createTimer(TYPE_WAIT, {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oscarpalmer/timer",
3
- "version": "0.46.0",
3
+ "version": "0.47.0",
4
4
  "description": "A better solution for timeout- and interval-based timers.",
5
5
  "keywords": [
6
6
  "requestAnimationFrame",
@@ -30,6 +30,10 @@
30
30
  "types": "./dist/index.d.mts",
31
31
  "default": "./dist/index.mjs"
32
32
  },
33
+ "./is": {
34
+ "types": "./dist/is.d.mts",
35
+ "default": "./dist/is.mjs"
36
+ },
33
37
  "./models": {
34
38
  "types": "./dist/models.d.mts",
35
39
  "default": "./dist/models.mjs"
@@ -56,7 +60,7 @@
56
60
  "watch": "npx vite build --watch"
57
61
  },
58
62
  "dependencies": {
59
- "@oscarpalmer/atoms": "^0.193"
63
+ "@oscarpalmer/atoms": "^0.195"
60
64
  },
61
65
  "devDependencies": {
62
66
  "@oxlint/plugins": "^1.80",
package/src/is.ts CHANGED
@@ -8,8 +8,9 @@ function is(names: string[], value: unknown) {
8
8
 
9
9
  /**
10
10
  * Is the value a repeating timer?
11
+ *
11
12
  * @param value Value to check
12
- * @returns `true` if the value is a repeating timer
13
+ * @returns `true` if the value is a repeating timer, otherwise `false`
13
14
  */
14
15
  export function isRepeated(value: unknown): value is Timer {
15
16
  return is([TYPE_REPEAT], value);
@@ -17,8 +18,9 @@ export function isRepeated(value: unknown): value is Timer {
17
18
 
18
19
  /**
19
20
  * Is the value a timer?
21
+ *
20
22
  * @param value Value to check
21
- * @returns `true` if the value is a timer
23
+ * @returns `true` if the value is a timer, otherwise `false`
22
24
  */
23
25
  export function isTimer(value: unknown): value is Timer {
24
26
  return is([TYPE_REPEAT, TYPE_WAIT], value);
@@ -26,8 +28,9 @@ export function isTimer(value: unknown): value is Timer {
26
28
 
27
29
  /**
28
30
  * Is the value a waiting timer?
31
+ *
29
32
  * @param value Value to check
30
- * @returns `true` if the value is a waiting timer
33
+ * @returns `true` if the value is a waiting timer, otherwise `false`
31
34
  */
32
35
  export function isWaited(value: unknown): value is Timer {
33
36
  return is([TYPE_WAIT], value);
@@ -35,8 +38,9 @@ export function isWaited(value: unknown): value is Timer {
35
38
 
36
39
  /**
37
40
  * Is the value a conditional timer?
41
+ *
38
42
  * @param value Value to check
39
- * @returns `true` if the value is a conditional timer
43
+ * @returns `true` if the value is a conditional timer, otherwise `false`
40
44
  */
41
45
  export function isWhen(value: unknown): value is When {
42
46
  return is([TYPE_WHEN], value) && typeof (value as When).start === 'function';
package/src/repeat.ts CHANGED
@@ -9,7 +9,7 @@ import {createTimer} from './timer';
9
9
  *
10
10
  * @param callback Callback to run on each interval
11
11
  * @param options Timer options
12
- * @returns Timer instance
12
+ * @returns Repeating timer
13
13
  */
14
14
  export function repeat(callback: (index: number) => void, options?: Partial<RepeatOptions>): Timer {
15
15
  return createTimer(
package/src/wait.ts CHANGED
@@ -9,6 +9,7 @@ import {createTimer} from './timer';
9
9
  *
10
10
  * @param callback Callback to run when the timer has finished
11
11
  * @param time How long to wait for _(in milliseconds; defaults to screen refresh rate)_
12
+ * @returns Waiting timer
12
13
  */
13
14
  export function wait(callback: () => void, time?: number): Timer {
14
15
  return createTimer(