@omnific/utils 0.1.0 → 0.1.1
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/debounce.js +8 -9
- package/dist/hasValue.js +1 -2
- package/dist/main.js +3 -3
- package/package.json +1 -1
package/dist/debounce.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { isUndefined } from "./isUndefined.js";
|
|
2
1
|
import hasValue from "./hasValue.js";
|
|
2
|
+
import { isUndefined } from "./isUndefined.js";
|
|
3
|
+
import { isNil } from "./isNil.js";
|
|
3
4
|
//#region debounce.ts
|
|
4
5
|
/**
|
|
5
6
|
* Creates a debounced function that delays invoking the provided function until after `debounceMs` milliseconds
|
|
@@ -41,10 +42,9 @@ function debounce(func, debounceMs, { signal, edges } = {}) {
|
|
|
41
42
|
const leading = hasValue(edges) && edges.includes("leading");
|
|
42
43
|
const trailing = isUndefined(edges) || edges.includes("trailing");
|
|
43
44
|
const invoke = () => {
|
|
44
|
-
if (
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
}
|
|
45
|
+
if (isNil(pendingInvoke)) return;
|
|
46
|
+
pendingInvoke();
|
|
47
|
+
pendingInvoke = void 0;
|
|
48
48
|
};
|
|
49
49
|
const onTimerEnd = () => {
|
|
50
50
|
if (trailing) invoke();
|
|
@@ -59,10 +59,9 @@ function debounce(func, debounceMs, { signal, edges } = {}) {
|
|
|
59
59
|
}, debounceMs);
|
|
60
60
|
};
|
|
61
61
|
const cancelTimer = () => {
|
|
62
|
-
if (
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
}
|
|
62
|
+
if (isNil(timeoutId)) return;
|
|
63
|
+
clearTimeout(timeoutId);
|
|
64
|
+
timeoutId = void 0;
|
|
66
65
|
};
|
|
67
66
|
const cancel = () => {
|
|
68
67
|
cancelTimer();
|
package/dist/hasValue.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { isNil } from "./isNil.js";
|
|
2
1
|
//#region hasValue.ts
|
|
3
2
|
/**
|
|
4
3
|
* Checks whether a value is neither `null` nor `undefined`.
|
|
@@ -17,7 +16,7 @@ import { isNil } from "./isNil.js";
|
|
|
17
16
|
* }
|
|
18
17
|
*/
|
|
19
18
|
function hasValue(value) {
|
|
20
|
-
return
|
|
19
|
+
return value !== null && value !== void 0;
|
|
21
20
|
}
|
|
22
21
|
//#endregion
|
|
23
22
|
export { hasValue as default, hasValue };
|
package/dist/main.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { isArray } from "./isArray.js";
|
|
2
2
|
import { isBoolean } from "./isBoolean.js";
|
|
3
|
-
import { isUndefined } from "./isUndefined.js";
|
|
4
|
-
import { isNull } from "./isNull.js";
|
|
5
|
-
import { isNil } from "./isNil.js";
|
|
6
3
|
import hasValue from "./hasValue.js";
|
|
7
4
|
import { isBlob } from "./isBlob.js";
|
|
8
5
|
import { isFunction } from "./isFunction.js";
|
|
9
6
|
import { createChainedFunction } from "./createChainedFunction.js";
|
|
7
|
+
import { isUndefined } from "./isUndefined.js";
|
|
8
|
+
import { isNull } from "./isNull.js";
|
|
9
|
+
import { isNil } from "./isNil.js";
|
|
10
10
|
import { debounce } from "./debounce.js";
|
|
11
11
|
import { isFormData } from "./isFormData.js";
|
|
12
12
|
import { isNumber } from "./isNumber.js";
|