@koine/utils 2.0.0-beta.1 → 2.0.0-beta.10
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/Defer.js +23 -18
- package/Defer.mjs +6 -5
- package/Emitter.js +31 -20
- package/Emitter.mjs +13 -16
- package/README.md +6 -1
- package/accentSets.js +129 -37
- package/accentSets.mjs +113 -29
- package/addOrReplaceAtIdx.js +27 -10
- package/addOrReplaceAtIdx.mjs +9 -6
- package/areEqual.js +35 -41
- package/areEqual.mjs +16 -22
- package/arrayOfAll.js +20 -11
- package/arrayOfAll.mjs +1 -6
- package/arraySum.js +20 -9
- package/arraySum.mjs +1 -4
- package/arrayToLookup.js +21 -9
- package/arrayToLookup.mjs +2 -4
- package/buildUrlQueryString.js +32 -29
- package/buildUrlQueryString.mjs +11 -14
- package/capitalize.js +21 -9
- package/capitalize.mjs +3 -5
- package/changeUrlPath.js +23 -17
- package/changeUrlPath.mjs +2 -3
- package/chunkByChunks.js +35 -24
- package/chunkByChunks.mjs +17 -20
- package/chunkBySize.js +21 -8
- package/chunkBySize.mjs +3 -4
- package/clamp.js +19 -6
- package/clamp.mjs +1 -2
- package/clsx.d.ts +4 -1
- package/clsx.js +30 -23
- package/clsx.mjs +12 -14
- package/convertRange.js +20 -7
- package/convertRange.mjs +2 -3
- package/cookie.js +13 -5
- package/cookie.mjs +3 -2
- package/createPalette.js +32 -19
- package/createPalette.mjs +14 -6
- package/debounce.js +27 -21
- package/debounce.mjs +9 -17
- package/debouncePromise.d.ts +14 -4
- package/debouncePromise.js +86 -11
- package/debouncePromise.mjs +69 -3
- package/debounceRaf.js +23 -14
- package/debounceRaf.mjs +5 -10
- package/decode.js +20 -7
- package/decode.mjs +2 -3
- package/encode.js +20 -7
- package/encode.mjs +2 -3
- package/ensureInt.js +20 -9
- package/ensureInt.mjs +1 -4
- package/env.js +1 -1
- package/env.mjs +0 -1
- package/errorToString.js +21 -14
- package/errorToString.mjs +1 -4
- package/findDuplicatedIndexes.js +22 -9
- package/findDuplicatedIndexes.mjs +4 -5
- package/forin.js +20 -7
- package/forin.mjs +2 -3
- package/gbToBytes.js +20 -7
- package/gbToBytes.mjs +1 -2
- package/getEmptyArray.js +25 -16
- package/getEmptyArray.mjs +4 -3
- package/getKeys.js +20 -6
- package/getKeys.mjs +1 -2
- package/getMediaQueryWidthResolvers.js +62 -53
- package/getMediaQueryWidthResolvers.mjs +44 -49
- package/getMediaQueryWidthTailwindScreens.js +36 -18
- package/getMediaQueryWidthTailwindScreens.mjs +18 -14
- package/getNonce.js +20 -10
- package/getNonce.mjs +1 -2
- package/getParamAmong.js +22 -19
- package/getParamAmong.mjs +2 -4
- package/getParamAsInt.js +22 -19
- package/getParamAsInt.mjs +2 -4
- package/getParamAsString.js +21 -16
- package/getParamAsString.mjs +1 -2
- package/getType.js +19 -12
- package/getType.mjs +2 -4
- package/getUrlHashParams.js +20 -13
- package/getUrlHashParams.mjs +2 -4
- package/getUrlHashPathname.js +20 -8
- package/getUrlHashPathname.mjs +1 -3
- package/getUrlPathnameParts.js +23 -23
- package/getUrlPathnameParts.mjs +2 -7
- package/getUrlQueryParams.js +26 -33
- package/getUrlQueryParams.mjs +7 -18
- package/imgEmptyPixel.js +20 -6
- package/imgEmptyPixel.mjs +1 -2
- package/index.d.ts +1 -1
- package/index.js +531 -266
- package/index.mjs +2 -2
- package/invariant.js +24 -12
- package/invariant.mjs +6 -8
- package/isAnyObject.js +21 -12
- package/isAnyObject.mjs +1 -2
- package/isArray.js +21 -12
- package/isArray.mjs +1 -2
- package/isBlob.js +21 -12
- package/isBlob.mjs +1 -2
- package/isBoolean.js +21 -12
- package/isBoolean.mjs +1 -2
- package/isBrowser.js +20 -6
- package/isBrowser.mjs +1 -2
- package/isBrowserNow.js +21 -11
- package/isBrowserNow.mjs +1 -2
- package/isDate.js +21 -12
- package/isDate.mjs +1 -2
- package/isEmptyArray.js +21 -12
- package/isEmptyArray.mjs +1 -2
- package/isEmptyObject.js +21 -12
- package/isEmptyObject.mjs +1 -2
- package/isEmptyString.js +19 -6
- package/isEmptyString.mjs +1 -2
- package/isError.js +21 -12
- package/isError.mjs +1 -2
- package/isExternalUrl.js +24 -18
- package/isExternalUrl.mjs +4 -6
- package/isFile.js +21 -12
- package/isFile.mjs +1 -2
- package/isFloat.js +21 -12
- package/isFloat.mjs +1 -2
- package/isFormData.js +21 -12
- package/isFormData.mjs +1 -2
- package/isFullArray.js +21 -12
- package/isFullArray.mjs +1 -2
- package/isFullObject.js +21 -12
- package/isFullObject.mjs +1 -2
- package/isFullString.js +21 -12
- package/isFullString.mjs +1 -2
- package/isFunction.js +18 -9
- package/isFunction.mjs +1 -2
- package/isInt.js +21 -12
- package/isInt.mjs +1 -2
- package/isMap.js +21 -12
- package/isMap.mjs +1 -2
- package/isNaNValue.js +21 -12
- package/isNaNValue.mjs +1 -2
- package/isNegativeNumber.js +21 -12
- package/isNegativeNumber.mjs +1 -2
- package/isNull.js +21 -12
- package/isNull.mjs +1 -2
- package/isNullOrUndefined.js +23 -13
- package/isNullOrUndefined.mjs +1 -2
- package/isNumber.js +21 -14
- package/isNumber.mjs +1 -2
- package/isObject.js +21 -12
- package/isObject.mjs +1 -2
- package/isObjectLike.js +21 -14
- package/isObjectLike.mjs +1 -2
- package/isOneOf.js +19 -11
- package/isOneOf.mjs +1 -7
- package/isPlainObject.js +22 -15
- package/isPlainObject.mjs +3 -6
- package/isPositiveNumber.js +21 -12
- package/isPositiveNumber.mjs +1 -2
- package/isPrimitive.js +26 -22
- package/isPrimitive.mjs +5 -11
- package/isPromise.js +21 -12
- package/isPromise.mjs +1 -2
- package/isRegExp.js +21 -12
- package/isRegExp.mjs +1 -2
- package/isServer.js +22 -11
- package/isServer.mjs +1 -2
- package/isServerNow.js +21 -11
- package/isServerNow.mjs +1 -2
- package/isSet.js +21 -12
- package/isSet.mjs +1 -2
- package/isString.js +21 -12
- package/isString.mjs +1 -2
- package/isSymbol.js +21 -12
- package/isSymbol.mjs +1 -2
- package/isType.js +22 -17
- package/isType.mjs +3 -5
- package/isUndefined.js +21 -12
- package/isUndefined.mjs +1 -2
- package/isWeakMap.js +21 -12
- package/isWeakMap.mjs +1 -2
- package/isWeakSet.js +21 -12
- package/isWeakSet.mjs +1 -2
- package/kbToBytes.js +20 -7
- package/kbToBytes.mjs +1 -2
- package/location.js +6 -2
- package/location.mjs +3 -1
- package/lowercase.js +20 -9
- package/lowercase.mjs +1 -4
- package/mapListBy.js +21 -10
- package/mapListBy.mjs +2 -5
- package/matchSorter.js +132 -133
- package/matchSorter.mjs +108 -126
- package/mbToBytes.js +20 -7
- package/mbToBytes.mjs +1 -2
- package/mergeObjects.d.ts +1 -1
- package/mergeObjects.js +24 -26
- package/mergeObjects.mjs +12 -15
- package/mergeUrlQueryParams.js +25 -20
- package/mergeUrlQueryParams.mjs +4 -8
- package/moveSortableArrayItemByKey.js +26 -12
- package/moveSortableArrayItemByKey.mjs +8 -8
- package/noop.js +20 -7
- package/noop.mjs +1 -2
- package/normaliseUrl.js +22 -18
- package/normaliseUrl.mjs +1 -3
- package/normaliseUrlPathname.js +22 -17
- package/normaliseUrlPathname.mjs +1 -3
- package/objectOmit.js +21 -9
- package/objectOmit.mjs +3 -5
- package/objectPick.js +22 -9
- package/objectPick.mjs +4 -5
- package/package.json +7 -11
- package/parseCookie.js +29 -26
- package/parseCookie.mjs +11 -15
- package/parseURL.js +23 -10
- package/parseURL.mjs +5 -6
- package/quaranteneProps.js +24 -12
- package/quaranteneProps.mjs +6 -8
- package/randomInt.js +19 -6
- package/randomInt.mjs +1 -2
- package/randomKey.js +21 -8
- package/randomKey.mjs +3 -4
- package/readCookie.js +25 -12
- package/readCookie.mjs +7 -8
- package/removeAccents.js +24 -15
- package/removeAccents.mjs +5 -8
- package/removeCookie.js +26 -17
- package/removeCookie.mjs +6 -5
- package/removeDuplicates.js +1 -1
- package/removeDuplicates.mjs +0 -1
- package/removeDuplicatesByKey.js +24 -12
- package/removeDuplicatesByKey.mjs +5 -7
- package/removeDuplicatesComparing.js +22 -11
- package/removeDuplicatesComparing.mjs +3 -4
- package/removeIndexesFromArray.js +21 -8
- package/removeIndexesFromArray.mjs +3 -4
- package/removeTrailingSlash.js +20 -8
- package/removeTrailingSlash.mjs +1 -3
- package/removeUrlQueryParams.js +27 -20
- package/removeUrlQueryParams.mjs +5 -7
- package/render.js +61 -137
- package/render.mjs +43 -98
- package/roundTo.js +34 -22
- package/roundTo.mjs +15 -17
- package/serializeCookie.js +29 -35
- package/serializeCookie.mjs +9 -15
- package/setCookie.js +37 -31
- package/setCookie.mjs +13 -16
- package/shuffle.js +28 -14
- package/shuffle.mjs +10 -10
- package/slugify.js +33 -25
- package/slugify.mjs +13 -11
- package/split.js +18 -4
- package/swapMap.js +22 -10
- package/swapMap.mjs +3 -5
- package/throttle.d.ts +1 -0
- package/throttle.js +23 -15
- package/throttle.mjs +5 -11
- package/titleCase.js +20 -11
- package/titleCase.mjs +1 -6
- package/toNumber.js +20 -9
- package/toNumber.mjs +1 -2
- package/toRgba.js +22 -10
- package/toRgba.mjs +3 -5
- package/transformToUrlPathname.js +21 -18
- package/transformToUrlPathname.mjs +2 -5
- package/truncate.js +20 -13
- package/truncate.mjs +1 -8
- package/tryUntil.js +26 -15
- package/tryUntil.mjs +7 -10
- package/types.js +4 -1
- package/types.mjs +2 -1
- package/uid.js +21 -13
- package/uid.mjs +3 -5
- package/updateLinkParams.js +21 -14
- package/updateLinkParams.mjs +2 -3
- package/updateUrlQueryParams.js +26 -21
- package/updateUrlQueryParams.mjs +3 -7
- package/uppercase.js +20 -9
- package/uppercase.mjs +1 -4
- package/uuid.js +21 -10
- package/uuid.mjs +2 -5
- package/uuidNumeric.js +20 -7
- package/uuidNumeric.mjs +1 -2
- package/wait.js +20 -9
- package/wait.mjs +1 -4
- package/without.js +2 -3
- package/without.mjs +1 -3
package/debouncePromise.js
CHANGED
|
@@ -1,12 +1,87 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
// import { debounce as tsDebounce } from "ts-debounce";
|
|
2
|
+
// export { type Options as DebounceOptions } from "ts-debounce";
|
|
3
|
+
// export { type DebouncedFunction } from "ts-debounce";
|
|
4
|
+
// /**
|
|
5
|
+
// * Debounce function (with `Promise`)
|
|
6
|
+
// *
|
|
7
|
+
// * @category function
|
|
8
|
+
// * @borrows [chodorowicz/ts-debounce](https://github.com/chodorowicz/ts-debounce)
|
|
9
|
+
// */
|
|
10
|
+
// export const debouncePromise = tsDebounce;
|
|
11
|
+
// export default debouncePromise;
|
|
5
12
|
/**
|
|
6
|
-
*
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
+
* @file Copy pasted from https://github.com/chodorowicz/ts-debounce/blob/master/src/index.ts
|
|
14
|
+
*/ "use strict";
|
|
15
|
+
Object.defineProperty(exports, "__esModule", {
|
|
16
|
+
value: true
|
|
17
|
+
});
|
|
18
|
+
function _export(target, all) {
|
|
19
|
+
for(var name in all)Object.defineProperty(target, name, {
|
|
20
|
+
enumerable: true,
|
|
21
|
+
get: all[name]
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
_export(exports, {
|
|
25
|
+
debouncePromise: function() {
|
|
26
|
+
return debouncePromise;
|
|
27
|
+
},
|
|
28
|
+
default: function() {
|
|
29
|
+
return _default;
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
function debouncePromise(func, waitMilliseconds = 50, options = {}) {
|
|
33
|
+
let timeoutId;
|
|
34
|
+
const isImmediate = options.isImmediate ?? false;
|
|
35
|
+
const callback = options.callback ?? false;
|
|
36
|
+
const maxWait = options.maxWait;
|
|
37
|
+
let lastInvokeTime = Date.now();
|
|
38
|
+
let promises = [];
|
|
39
|
+
function nextInvokeTimeout() {
|
|
40
|
+
if (maxWait !== undefined) {
|
|
41
|
+
const timeSinceLastInvocation = Date.now() - lastInvokeTime;
|
|
42
|
+
if (timeSinceLastInvocation + waitMilliseconds >= maxWait) {
|
|
43
|
+
return maxWait - timeSinceLastInvocation;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
return waitMilliseconds;
|
|
47
|
+
}
|
|
48
|
+
const debouncedFunction = function(...args) {
|
|
49
|
+
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
|
50
|
+
const context = this;
|
|
51
|
+
return new Promise((resolve, reject)=>{
|
|
52
|
+
const invokeFunction = function() {
|
|
53
|
+
timeoutId = undefined;
|
|
54
|
+
lastInvokeTime = Date.now();
|
|
55
|
+
if (!isImmediate) {
|
|
56
|
+
const result = func.apply(context, args);
|
|
57
|
+
callback && callback(result);
|
|
58
|
+
promises.forEach(({ resolve })=>resolve(result));
|
|
59
|
+
promises = [];
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
const shouldCallNow = isImmediate && timeoutId === undefined;
|
|
63
|
+
if (timeoutId !== undefined) {
|
|
64
|
+
clearTimeout(timeoutId);
|
|
65
|
+
}
|
|
66
|
+
timeoutId = setTimeout(invokeFunction, nextInvokeTimeout());
|
|
67
|
+
if (shouldCallNow) {
|
|
68
|
+
const result = func.apply(context, args);
|
|
69
|
+
callback && callback(result);
|
|
70
|
+
return resolve(result);
|
|
71
|
+
}
|
|
72
|
+
promises.push({
|
|
73
|
+
resolve,
|
|
74
|
+
reject
|
|
75
|
+
});
|
|
76
|
+
});
|
|
77
|
+
};
|
|
78
|
+
debouncedFunction.cancel = function(reason) {
|
|
79
|
+
if (timeoutId !== undefined) {
|
|
80
|
+
clearTimeout(timeoutId);
|
|
81
|
+
}
|
|
82
|
+
promises.forEach(({ reject })=>reject(reason));
|
|
83
|
+
promises = [];
|
|
84
|
+
};
|
|
85
|
+
return debouncedFunction;
|
|
86
|
+
}
|
|
87
|
+
const _default = debouncePromise;
|
package/debouncePromise.mjs
CHANGED
|
@@ -1,9 +1,75 @@
|
|
|
1
|
-
import { debounce as tsDebounce } from "ts-debounce";
|
|
1
|
+
// import { debounce as tsDebounce } from "ts-debounce";
|
|
2
|
+
// export { type Options as DebounceOptions } from "ts-debounce";
|
|
3
|
+
// export { type DebouncedFunction } from "ts-debounce";
|
|
4
|
+
// /**
|
|
5
|
+
// * Debounce function (with `Promise`)
|
|
6
|
+
// *
|
|
7
|
+
// * @category function
|
|
8
|
+
// * @borrows [chodorowicz/ts-debounce](https://github.com/chodorowicz/ts-debounce)
|
|
9
|
+
// */
|
|
10
|
+
// export const debouncePromise = tsDebounce;
|
|
11
|
+
// export default debouncePromise;
|
|
2
12
|
/**
|
|
13
|
+
* @file Copy pasted from https://github.com/chodorowicz/ts-debounce/blob/master/src/index.ts
|
|
14
|
+
*/ /**
|
|
3
15
|
* Debounce function (with `Promise`)
|
|
4
16
|
*
|
|
5
17
|
* @category function
|
|
6
18
|
* @borrows [chodorowicz/ts-debounce](https://github.com/chodorowicz/ts-debounce)
|
|
7
|
-
|
|
8
|
-
export
|
|
19
|
+
* @license [MIT: Jakub Chodorowicz](Jakub Chodorowicz)
|
|
20
|
+
*/ export function debouncePromise(func, waitMilliseconds = 50, options = {}) {
|
|
21
|
+
let timeoutId;
|
|
22
|
+
const isImmediate = options.isImmediate ?? false;
|
|
23
|
+
const callback = options.callback ?? false;
|
|
24
|
+
const maxWait = options.maxWait;
|
|
25
|
+
let lastInvokeTime = Date.now();
|
|
26
|
+
let promises = [];
|
|
27
|
+
function nextInvokeTimeout() {
|
|
28
|
+
if (maxWait !== undefined) {
|
|
29
|
+
const timeSinceLastInvocation = Date.now() - lastInvokeTime;
|
|
30
|
+
if (timeSinceLastInvocation + waitMilliseconds >= maxWait) {
|
|
31
|
+
return maxWait - timeSinceLastInvocation;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
return waitMilliseconds;
|
|
35
|
+
}
|
|
36
|
+
const debouncedFunction = function(...args) {
|
|
37
|
+
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
|
38
|
+
const context = this;
|
|
39
|
+
return new Promise((resolve, reject)=>{
|
|
40
|
+
const invokeFunction = function() {
|
|
41
|
+
timeoutId = undefined;
|
|
42
|
+
lastInvokeTime = Date.now();
|
|
43
|
+
if (!isImmediate) {
|
|
44
|
+
const result = func.apply(context, args);
|
|
45
|
+
callback && callback(result);
|
|
46
|
+
promises.forEach(({ resolve })=>resolve(result));
|
|
47
|
+
promises = [];
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
const shouldCallNow = isImmediate && timeoutId === undefined;
|
|
51
|
+
if (timeoutId !== undefined) {
|
|
52
|
+
clearTimeout(timeoutId);
|
|
53
|
+
}
|
|
54
|
+
timeoutId = setTimeout(invokeFunction, nextInvokeTimeout());
|
|
55
|
+
if (shouldCallNow) {
|
|
56
|
+
const result = func.apply(context, args);
|
|
57
|
+
callback && callback(result);
|
|
58
|
+
return resolve(result);
|
|
59
|
+
}
|
|
60
|
+
promises.push({
|
|
61
|
+
resolve,
|
|
62
|
+
reject
|
|
63
|
+
});
|
|
64
|
+
});
|
|
65
|
+
};
|
|
66
|
+
debouncedFunction.cancel = function(reason) {
|
|
67
|
+
if (timeoutId !== undefined) {
|
|
68
|
+
clearTimeout(timeoutId);
|
|
69
|
+
}
|
|
70
|
+
promises.forEach(({ reject })=>reject(reason));
|
|
71
|
+
promises = [];
|
|
72
|
+
};
|
|
73
|
+
return debouncedFunction;
|
|
74
|
+
}
|
|
9
75
|
export default debouncePromise;
|
package/debounceRaf.js
CHANGED
|
@@ -1,31 +1,40 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.debounceRaf = void 0;
|
|
4
1
|
/**
|
|
5
2
|
* Debounce function (with `requestAnimationFrame`)
|
|
6
3
|
*
|
|
7
4
|
* (c) 2021 Chris Ferdinandi, MIT License, https://gomakethings.com
|
|
8
5
|
* @category function
|
|
9
6
|
* @borrows [vanillajstoolkit/debounce](https://vanillajstoolkit.com/helpers/debounce/)
|
|
10
|
-
*/
|
|
7
|
+
*/ "use strict";
|
|
8
|
+
Object.defineProperty(exports, "__esModule", {
|
|
9
|
+
value: true
|
|
10
|
+
});
|
|
11
|
+
function _export(target, all) {
|
|
12
|
+
for(var name in all)Object.defineProperty(target, name, {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: all[name]
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
_export(exports, {
|
|
18
|
+
debounceRaf: function() {
|
|
19
|
+
return debounceRaf;
|
|
20
|
+
},
|
|
21
|
+
default: function() {
|
|
22
|
+
return _default;
|
|
23
|
+
}
|
|
24
|
+
});
|
|
11
25
|
function debounceRaf(fn) {
|
|
12
|
-
|
|
13
|
-
return function
|
|
14
|
-
var args = [];
|
|
15
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
16
|
-
args[_i] = arguments[_i];
|
|
17
|
-
}
|
|
26
|
+
let timeout;
|
|
27
|
+
return function(...args) {
|
|
18
28
|
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
|
19
|
-
|
|
29
|
+
const context = this;
|
|
20
30
|
// If there's a timer, cancel it
|
|
21
31
|
if (timeout) {
|
|
22
32
|
window.cancelAnimationFrame(timeout);
|
|
23
33
|
}
|
|
24
34
|
// Setup the new requestAnimationFrame()
|
|
25
|
-
timeout = window.requestAnimationFrame(function
|
|
35
|
+
timeout = window.requestAnimationFrame(function() {
|
|
26
36
|
fn.apply(context, args);
|
|
27
37
|
});
|
|
28
38
|
};
|
|
29
39
|
}
|
|
30
|
-
|
|
31
|
-
exports.default = debounceRaf;
|
|
40
|
+
const _default = debounceRaf;
|
package/debounceRaf.mjs
CHANGED
|
@@ -4,22 +4,17 @@
|
|
|
4
4
|
* (c) 2021 Chris Ferdinandi, MIT License, https://gomakethings.com
|
|
5
5
|
* @category function
|
|
6
6
|
* @borrows [vanillajstoolkit/debounce](https://vanillajstoolkit.com/helpers/debounce/)
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
return function () {
|
|
11
|
-
var args = [];
|
|
12
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
13
|
-
args[_i] = arguments[_i];
|
|
14
|
-
}
|
|
7
|
+
*/ export function debounceRaf(fn) {
|
|
8
|
+
let timeout;
|
|
9
|
+
return function(...args) {
|
|
15
10
|
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
|
16
|
-
|
|
11
|
+
const context = this;
|
|
17
12
|
// If there's a timer, cancel it
|
|
18
13
|
if (timeout) {
|
|
19
14
|
window.cancelAnimationFrame(timeout);
|
|
20
15
|
}
|
|
21
16
|
// Setup the new requestAnimationFrame()
|
|
22
|
-
timeout = window.requestAnimationFrame(function
|
|
17
|
+
timeout = window.requestAnimationFrame(function() {
|
|
23
18
|
fn.apply(context, args);
|
|
24
19
|
});
|
|
25
20
|
};
|
package/decode.js
CHANGED
|
@@ -1,14 +1,27 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.decode = void 0;
|
|
4
1
|
/**
|
|
5
2
|
* @category security
|
|
6
3
|
* @see https://stackoverflow.com/a/22405578/9122820
|
|
7
|
-
*/
|
|
4
|
+
*/ "use strict";
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
function _export(target, all) {
|
|
9
|
+
for(var name in all)Object.defineProperty(target, name, {
|
|
10
|
+
enumerable: true,
|
|
11
|
+
get: all[name]
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
_export(exports, {
|
|
15
|
+
decode: function() {
|
|
16
|
+
return decode;
|
|
17
|
+
},
|
|
18
|
+
default: function() {
|
|
19
|
+
return _default;
|
|
20
|
+
}
|
|
21
|
+
});
|
|
8
22
|
function decode(str) {
|
|
9
|
-
return str.replace(/.{3}/g, function
|
|
23
|
+
return str.replace(/.{3}/g, function(c) {
|
|
10
24
|
return String.fromCharCode(parseInt(c, 10));
|
|
11
25
|
});
|
|
12
26
|
}
|
|
13
|
-
|
|
14
|
-
exports.default = decode;
|
|
27
|
+
const _default = decode;
|
package/decode.mjs
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @category security
|
|
3
3
|
* @see https://stackoverflow.com/a/22405578/9122820
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
return str.replace(/.{3}/g, function (c) {
|
|
4
|
+
*/ export function decode(str) {
|
|
5
|
+
return str.replace(/.{3}/g, function(c) {
|
|
7
6
|
return String.fromCharCode(parseInt(c, 10));
|
|
8
7
|
});
|
|
9
8
|
}
|
package/encode.js
CHANGED
|
@@ -1,14 +1,27 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.encode = void 0;
|
|
4
1
|
/**
|
|
5
2
|
* @category security
|
|
6
3
|
* @see https://stackoverflow.com/a/22405578/9122820
|
|
7
|
-
*/
|
|
4
|
+
*/ "use strict";
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
function _export(target, all) {
|
|
9
|
+
for(var name in all)Object.defineProperty(target, name, {
|
|
10
|
+
enumerable: true,
|
|
11
|
+
get: all[name]
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
_export(exports, {
|
|
15
|
+
encode: function() {
|
|
16
|
+
return encode;
|
|
17
|
+
},
|
|
18
|
+
default: function() {
|
|
19
|
+
return _default;
|
|
20
|
+
}
|
|
21
|
+
});
|
|
8
22
|
function encode(str) {
|
|
9
|
-
return str.replace(/./g, function
|
|
23
|
+
return str.replace(/./g, function(c) {
|
|
10
24
|
return ("00" + c.charCodeAt(0)).slice(-3);
|
|
11
25
|
});
|
|
12
26
|
}
|
|
13
|
-
|
|
14
|
-
exports.default = encode;
|
|
27
|
+
const _default = encode;
|
package/encode.mjs
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @category security
|
|
3
3
|
* @see https://stackoverflow.com/a/22405578/9122820
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
return str.replace(/./g, function (c) {
|
|
4
|
+
*/ export function encode(str) {
|
|
5
|
+
return str.replace(/./g, function(c) {
|
|
7
6
|
return ("00" + c.charCodeAt(0)).slice(-3);
|
|
8
7
|
});
|
|
9
8
|
}
|
package/ensureInt.js
CHANGED
|
@@ -1,13 +1,24 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ensureInt = void 0;
|
|
4
1
|
/**
|
|
5
2
|
* Ensure input to be an integer
|
|
6
3
|
*
|
|
7
4
|
* @category cast
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
|
|
5
|
+
*/ "use strict";
|
|
6
|
+
Object.defineProperty(exports, "__esModule", {
|
|
7
|
+
value: true
|
|
8
|
+
});
|
|
9
|
+
function _export(target, all) {
|
|
10
|
+
for(var name in all)Object.defineProperty(target, name, {
|
|
11
|
+
enumerable: true,
|
|
12
|
+
get: all[name]
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
_export(exports, {
|
|
16
|
+
ensureInt: function() {
|
|
17
|
+
return ensureInt;
|
|
18
|
+
},
|
|
19
|
+
default: function() {
|
|
20
|
+
return _default;
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
const ensureInt = (input)=>typeof input === "string" ? parseInt(input, 10) : Math.round(input);
|
|
24
|
+
const _default = ensureInt;
|
package/ensureInt.mjs
CHANGED
|
@@ -2,8 +2,5 @@
|
|
|
2
2
|
* Ensure input to be an integer
|
|
3
3
|
*
|
|
4
4
|
* @category cast
|
|
5
|
-
*/
|
|
6
|
-
export var ensureInt = function (input) {
|
|
7
|
-
return typeof input === "string" ? parseInt(input, 10) : Math.round(input);
|
|
8
|
-
};
|
|
5
|
+
*/ export const ensureInt = (input)=>typeof input === "string" ? parseInt(input, 10) : Math.round(input);
|
|
9
6
|
export default ensureInt;
|
package/env.js
CHANGED
package/env.mjs
CHANGED
package/errorToString.js
CHANGED
|
@@ -1,15 +1,22 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
function _export(target, all) {
|
|
6
|
+
for(var name in all)Object.defineProperty(target, name, {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: all[name]
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
_export(exports, {
|
|
12
|
+
errorToString: function() {
|
|
13
|
+
return errorToString;
|
|
14
|
+
},
|
|
15
|
+
default: function() {
|
|
16
|
+
return _default;
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
const _interop_require_default = require("@swc/helpers/_/_interop_require_default");
|
|
20
|
+
const _isString = /*#__PURE__*/ _interop_require_default._(require("./isString"));
|
|
21
|
+
const errorToString = (e)=>e instanceof Error ? e.message : (0, _isString.default)(e) ? e : "";
|
|
22
|
+
const _default = errorToString;
|
package/errorToString.mjs
CHANGED
|
@@ -3,8 +3,5 @@ import isString from "./isString";
|
|
|
3
3
|
* Ensure to transform a JavaScript `Error` into a string (uses its `message`)
|
|
4
4
|
*
|
|
5
5
|
* @category Error
|
|
6
|
-
*/
|
|
7
|
-
export var errorToString = function (e) {
|
|
8
|
-
return e instanceof Error ? e.message : isString(e) ? e : "";
|
|
9
|
-
};
|
|
6
|
+
*/ export const errorToString = (e)=>e instanceof Error ? e.message : isString(e) ? e : "";
|
|
10
7
|
export default errorToString;
|
package/findDuplicatedIndexes.js
CHANGED
|
@@ -1,18 +1,31 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.findDuplicatedIndexes = void 0;
|
|
4
1
|
/**
|
|
5
2
|
* @category array
|
|
6
|
-
*/
|
|
3
|
+
*/ "use strict";
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
function _export(target, all) {
|
|
8
|
+
for(var name in all)Object.defineProperty(target, name, {
|
|
9
|
+
enumerable: true,
|
|
10
|
+
get: all[name]
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
_export(exports, {
|
|
14
|
+
findDuplicatedIndexes: function() {
|
|
15
|
+
return findDuplicatedIndexes;
|
|
16
|
+
},
|
|
17
|
+
default: function() {
|
|
18
|
+
return _default;
|
|
19
|
+
}
|
|
20
|
+
});
|
|
7
21
|
function findDuplicatedIndexes(arr) {
|
|
8
|
-
|
|
9
|
-
for
|
|
10
|
-
|
|
22
|
+
const indexes = {};
|
|
23
|
+
for(let i = 0; i < arr.length; i++){
|
|
24
|
+
const idxInArray = arr.indexOf(arr[i]);
|
|
11
25
|
if (idxInArray !== i && idxInArray !== -1) {
|
|
12
26
|
indexes[i] = true;
|
|
13
27
|
}
|
|
14
28
|
}
|
|
15
29
|
return indexes;
|
|
16
30
|
}
|
|
17
|
-
|
|
18
|
-
exports.default = findDuplicatedIndexes;
|
|
31
|
+
const _default = findDuplicatedIndexes;
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @category array
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
var idxInArray = arr.indexOf(arr[i]);
|
|
3
|
+
*/ export function findDuplicatedIndexes(arr) {
|
|
4
|
+
const indexes = {};
|
|
5
|
+
for(let i = 0; i < arr.length; i++){
|
|
6
|
+
const idxInArray = arr.indexOf(arr[i]);
|
|
8
7
|
if (idxInArray !== i && idxInArray !== -1) {
|
|
9
8
|
indexes[i] = true;
|
|
10
9
|
}
|
package/forin.js
CHANGED
|
@@ -1,15 +1,28 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.forin = void 0;
|
|
4
1
|
/**
|
|
5
2
|
* To easily get typed native `for in`
|
|
6
3
|
*
|
|
7
4
|
* @category objects
|
|
8
|
-
*/
|
|
5
|
+
*/ "use strict";
|
|
6
|
+
Object.defineProperty(exports, "__esModule", {
|
|
7
|
+
value: true
|
|
8
|
+
});
|
|
9
|
+
function _export(target, all) {
|
|
10
|
+
for(var name in all)Object.defineProperty(target, name, {
|
|
11
|
+
enumerable: true,
|
|
12
|
+
get: all[name]
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
_export(exports, {
|
|
16
|
+
forin: function() {
|
|
17
|
+
return forin;
|
|
18
|
+
},
|
|
19
|
+
default: function() {
|
|
20
|
+
return _default;
|
|
21
|
+
}
|
|
22
|
+
});
|
|
9
23
|
function forin(object, cb) {
|
|
10
|
-
for
|
|
24
|
+
for(const key in object){
|
|
11
25
|
cb(key, object[key]);
|
|
12
26
|
}
|
|
13
27
|
}
|
|
14
|
-
|
|
15
|
-
exports.default = forin;
|
|
28
|
+
const _default = forin;
|
package/forin.mjs
CHANGED
package/gbToBytes.js
CHANGED
|
@@ -1,11 +1,24 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.gbToBytes = void 0;
|
|
4
1
|
/**
|
|
5
2
|
* Gigabytes to bytes
|
|
6
3
|
*
|
|
7
4
|
* @category format
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
5
|
+
*/ "use strict";
|
|
6
|
+
Object.defineProperty(exports, "__esModule", {
|
|
7
|
+
value: true
|
|
8
|
+
});
|
|
9
|
+
function _export(target, all) {
|
|
10
|
+
for(var name in all)Object.defineProperty(target, name, {
|
|
11
|
+
enumerable: true,
|
|
12
|
+
get: all[name]
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
_export(exports, {
|
|
16
|
+
gbToBytes: function() {
|
|
17
|
+
return gbToBytes;
|
|
18
|
+
},
|
|
19
|
+
default: function() {
|
|
20
|
+
return _default;
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
const gbToBytes = (bytes)=>bytes * 1000 * 1000 * 1000;
|
|
24
|
+
const _default = gbToBytes;
|
package/gbToBytes.mjs
CHANGED
package/getEmptyArray.js
CHANGED
|
@@ -1,20 +1,29 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
function _export(target, all) {
|
|
6
|
+
for(var name in all)Object.defineProperty(target, name, {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: all[name]
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
_export(exports, {
|
|
12
|
+
getEmptyArray: function() {
|
|
13
|
+
return getEmptyArray /* <T extends undefined | null = undefined> */ ;
|
|
14
|
+
},
|
|
15
|
+
default: function() {
|
|
16
|
+
return _default;
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
const _interop_require_default = require("@swc/helpers/_/_interop_require_default");
|
|
20
|
+
const _isNumber = /*#__PURE__*/ _interop_require_default._(require("./isNumber"));
|
|
21
|
+
function getEmptyArray(length) {
|
|
22
|
+
if (!(0, _isNumber.default)(length)) {
|
|
15
23
|
length = parseInt(length, 10);
|
|
16
24
|
}
|
|
17
|
-
return Array.from({
|
|
25
|
+
return Array.from({
|
|
26
|
+
length
|
|
27
|
+
});
|
|
18
28
|
}
|
|
19
|
-
|
|
20
|
-
exports.default = getEmptyArray;
|
|
29
|
+
const _default = getEmptyArray;
|