@koine/utils 2.0.0-beta.2 → 2.0.0-beta.4
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 +5 -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.js +29 -23
- package/clsx.mjs +11 -14
- package/convertRange.js +20 -7
- package/convertRange.mjs +2 -3
- package/cookie.js +13 -5
- package/cookie.mjs +3 -2
- package/createPalette.js +27 -19
- package/createPalette.mjs +9 -6
- package/debounce.js +27 -21
- package/debounce.mjs +9 -17
- package/debouncePromise.js +20 -11
- package/debouncePromise.mjs +1 -2
- 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.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 +11 -8
- 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/chunkByChunks.mjs
CHANGED
|
@@ -2,33 +2,30 @@
|
|
|
2
2
|
* TODO: untested
|
|
3
3
|
* @category array
|
|
4
4
|
* @see https://stackoverflow.com/a/8189268/1938970
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
5
|
+
*/ export function chunkByChunks(arr, nrOfChunks, balanced) {
|
|
6
|
+
if (nrOfChunks < 2) return [
|
|
7
|
+
arr
|
|
8
|
+
];
|
|
9
|
+
const len = arr.length;
|
|
10
|
+
const output = [];
|
|
11
|
+
let i = 0;
|
|
12
|
+
let size;
|
|
13
13
|
if (len % nrOfChunks === 0) {
|
|
14
14
|
size = Math.floor(len / nrOfChunks);
|
|
15
|
-
while
|
|
16
|
-
output.push(arr.slice(i,
|
|
15
|
+
while(i < len){
|
|
16
|
+
output.push(arr.slice(i, i += size));
|
|
17
17
|
}
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
while (i < len) {
|
|
18
|
+
} else if (balanced) {
|
|
19
|
+
while(i < len){
|
|
21
20
|
size = Math.ceil((len - i) / nrOfChunks--);
|
|
22
|
-
output.push(arr.slice(i,
|
|
21
|
+
output.push(arr.slice(i, i += size));
|
|
23
22
|
}
|
|
24
|
-
}
|
|
25
|
-
else {
|
|
23
|
+
} else {
|
|
26
24
|
nrOfChunks--;
|
|
27
25
|
size = Math.floor(len / nrOfChunks);
|
|
28
|
-
if (len % size === 0)
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
output.push(arr.slice(i, (i += size)));
|
|
26
|
+
if (len % size === 0) size--;
|
|
27
|
+
while(i < size * nrOfChunks){
|
|
28
|
+
output.push(arr.slice(i, i += size));
|
|
32
29
|
}
|
|
33
30
|
output.push(arr.slice(size * nrOfChunks));
|
|
34
31
|
}
|
package/chunkBySize.js
CHANGED
|
@@ -1,16 +1,29 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.chunkBySize = void 0;
|
|
4
1
|
/**
|
|
5
2
|
* @category array
|
|
6
3
|
* @see https://stackoverflow.com/a/40682136/1938970
|
|
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
|
+
chunkBySize: function() {
|
|
16
|
+
return chunkBySize;
|
|
17
|
+
},
|
|
18
|
+
default: function() {
|
|
19
|
+
return _default;
|
|
20
|
+
}
|
|
21
|
+
});
|
|
8
22
|
function chunkBySize(arr, size) {
|
|
9
|
-
|
|
10
|
-
for
|
|
23
|
+
const output = [];
|
|
24
|
+
for(let i = 0; i < arr.length; i += size){
|
|
11
25
|
output.push(arr.slice(i, i + size));
|
|
12
26
|
}
|
|
13
27
|
return output;
|
|
14
28
|
}
|
|
15
|
-
|
|
16
|
-
exports.default = chunkBySize;
|
|
29
|
+
const _default = chunkBySize;
|
package/chunkBySize.mjs
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @category array
|
|
3
3
|
* @see https://stackoverflow.com/a/40682136/1938970
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
for (var i = 0; i < arr.length; i += size) {
|
|
4
|
+
*/ export function chunkBySize(arr, size) {
|
|
5
|
+
const output = [];
|
|
6
|
+
for(let i = 0; i < arr.length; i += size){
|
|
8
7
|
output.push(arr.slice(i, i + size));
|
|
9
8
|
}
|
|
10
9
|
return output;
|
package/clamp.js
CHANGED
|
@@ -1,14 +1,27 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.clamp = void 0;
|
|
4
1
|
/**
|
|
5
2
|
* Returns a number whose value is limited to the given range.
|
|
6
3
|
*
|
|
7
4
|
* @category math
|
|
8
5
|
* @see https://stackoverflow.com/a/11409944/1938970
|
|
9
|
-
*/
|
|
6
|
+
*/ "use strict";
|
|
7
|
+
Object.defineProperty(exports, "__esModule", {
|
|
8
|
+
value: true
|
|
9
|
+
});
|
|
10
|
+
function _export(target, all) {
|
|
11
|
+
for(var name in all)Object.defineProperty(target, name, {
|
|
12
|
+
enumerable: true,
|
|
13
|
+
get: all[name]
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
_export(exports, {
|
|
17
|
+
clamp: function() {
|
|
18
|
+
return clamp;
|
|
19
|
+
},
|
|
20
|
+
default: function() {
|
|
21
|
+
return _default;
|
|
22
|
+
}
|
|
23
|
+
});
|
|
10
24
|
function clamp(num, min, max) {
|
|
11
25
|
return Math.min(Math.max(num, min), max);
|
|
12
26
|
}
|
|
13
|
-
|
|
14
|
-
exports.default = clamp;
|
|
27
|
+
const _default = clamp;
|
package/clamp.mjs
CHANGED
package/clsx.js
CHANGED
|
@@ -1,26 +1,39 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
|
|
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
|
+
clsx: function() {
|
|
13
|
+
return clsx;
|
|
14
|
+
},
|
|
15
|
+
default: function() {
|
|
16
|
+
return _default;
|
|
17
|
+
}
|
|
18
|
+
});
|
|
4
19
|
// import _clsx from "clsx";
|
|
5
20
|
// export const clsx = _clsx;
|
|
6
21
|
function toVal(mix) {
|
|
7
|
-
|
|
22
|
+
let k, y, str = "";
|
|
8
23
|
if (typeof mix === "string" || typeof mix === "number") {
|
|
9
24
|
str += mix;
|
|
10
|
-
}
|
|
11
|
-
else if (typeof mix === "object") {
|
|
25
|
+
} else if (typeof mix === "object") {
|
|
12
26
|
if (Array.isArray(mix)) {
|
|
13
|
-
for
|
|
27
|
+
for(k = 0; k < mix.length; k++){
|
|
14
28
|
if (mix[k]) {
|
|
15
|
-
if (
|
|
29
|
+
if (y = toVal(mix[k])) {
|
|
16
30
|
str && (str += " ");
|
|
17
31
|
str += y;
|
|
18
32
|
}
|
|
19
33
|
}
|
|
20
34
|
}
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
for (k in mix) {
|
|
35
|
+
} else {
|
|
36
|
+
for(k in mix){
|
|
24
37
|
if (mix[k]) {
|
|
25
38
|
str && (str += " ");
|
|
26
39
|
str += k;
|
|
@@ -30,18 +43,12 @@ function toVal(mix) {
|
|
|
30
43
|
}
|
|
31
44
|
return str;
|
|
32
45
|
}
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
* @borrows [lukeed/clsx](https://github.com/lukeed/clsx)
|
|
37
|
-
* @license [MIT: Luke Edwards](https://github.com/lukeed/clsx/blob/master/license)
|
|
38
|
-
*/
|
|
39
|
-
var clsx = function () {
|
|
40
|
-
var i = 0, tmp, x, str = "";
|
|
41
|
-
while (i < arguments.length) {
|
|
46
|
+
const clsx = function() {
|
|
47
|
+
let i = 0, tmp, x, str = "";
|
|
48
|
+
while(i < arguments.length){
|
|
42
49
|
// eslint-disable-next-line prefer-rest-params
|
|
43
|
-
if (
|
|
44
|
-
if (
|
|
50
|
+
if (tmp = arguments[i++]) {
|
|
51
|
+
if (x = toVal(tmp)) {
|
|
45
52
|
str && (str += " ");
|
|
46
53
|
str += x;
|
|
47
54
|
}
|
|
@@ -49,5 +56,4 @@ var clsx = function () {
|
|
|
49
56
|
}
|
|
50
57
|
return str;
|
|
51
58
|
};
|
|
52
|
-
|
|
53
|
-
exports.default = exports.clsx;
|
|
59
|
+
const _default = clsx;
|
package/clsx.mjs
CHANGED
|
@@ -1,23 +1,21 @@
|
|
|
1
1
|
// import _clsx from "clsx";
|
|
2
2
|
// export const clsx = _clsx;
|
|
3
3
|
function toVal(mix) {
|
|
4
|
-
|
|
4
|
+
let k, y, str = "";
|
|
5
5
|
if (typeof mix === "string" || typeof mix === "number") {
|
|
6
6
|
str += mix;
|
|
7
|
-
}
|
|
8
|
-
else if (typeof mix === "object") {
|
|
7
|
+
} else if (typeof mix === "object") {
|
|
9
8
|
if (Array.isArray(mix)) {
|
|
10
|
-
for
|
|
9
|
+
for(k = 0; k < mix.length; k++){
|
|
11
10
|
if (mix[k]) {
|
|
12
|
-
if (
|
|
11
|
+
if (y = toVal(mix[k])) {
|
|
13
12
|
str && (str += " ");
|
|
14
13
|
str += y;
|
|
15
14
|
}
|
|
16
15
|
}
|
|
17
16
|
}
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
for (k in mix) {
|
|
17
|
+
} else {
|
|
18
|
+
for(k in mix){
|
|
21
19
|
if (mix[k]) {
|
|
22
20
|
str && (str += " ");
|
|
23
21
|
str += k;
|
|
@@ -32,13 +30,12 @@ function toVal(mix) {
|
|
|
32
30
|
*
|
|
33
31
|
* @borrows [lukeed/clsx](https://github.com/lukeed/clsx)
|
|
34
32
|
* @license [MIT: Luke Edwards](https://github.com/lukeed/clsx/blob/master/license)
|
|
35
|
-
*/
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
while (i < arguments.length) {
|
|
33
|
+
*/ export const clsx = function() {
|
|
34
|
+
let i = 0, tmp, x, str = "";
|
|
35
|
+
while(i < arguments.length){
|
|
39
36
|
// eslint-disable-next-line prefer-rest-params
|
|
40
|
-
if (
|
|
41
|
-
if (
|
|
37
|
+
if (tmp = arguments[i++]) {
|
|
38
|
+
if (x = toVal(tmp)) {
|
|
42
39
|
str && (str += " ");
|
|
43
40
|
str += x;
|
|
44
41
|
}
|
package/convertRange.js
CHANGED
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.convertRange = void 0;
|
|
4
1
|
/**
|
|
5
2
|
* Convert range of a number
|
|
6
3
|
*
|
|
@@ -12,9 +9,25 @@ exports.convertRange = void 0;
|
|
|
12
9
|
*
|
|
13
10
|
* @category math
|
|
14
11
|
* @see https://stackoverflow.com/a/14224813
|
|
15
|
-
*/
|
|
12
|
+
*/ "use strict";
|
|
13
|
+
Object.defineProperty(exports, "__esModule", {
|
|
14
|
+
value: true
|
|
15
|
+
});
|
|
16
|
+
function _export(target, all) {
|
|
17
|
+
for(var name in all)Object.defineProperty(target, name, {
|
|
18
|
+
enumerable: true,
|
|
19
|
+
get: all[name]
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
_export(exports, {
|
|
23
|
+
convertRange: function() {
|
|
24
|
+
return convertRange;
|
|
25
|
+
},
|
|
26
|
+
default: function() {
|
|
27
|
+
return _default;
|
|
28
|
+
}
|
|
29
|
+
});
|
|
16
30
|
function convertRange(num, r1, r2) {
|
|
17
|
-
return (
|
|
31
|
+
return (num - r1[0]) * (r2[1] - r2[0]) / (r1[1] - r1[0]) + r2[0];
|
|
18
32
|
}
|
|
19
|
-
|
|
20
|
-
exports.default = convertRange;
|
|
33
|
+
const _default = convertRange;
|
package/convertRange.mjs
CHANGED
|
@@ -9,8 +9,7 @@
|
|
|
9
9
|
*
|
|
10
10
|
* @category math
|
|
11
11
|
* @see https://stackoverflow.com/a/14224813
|
|
12
|
-
*/
|
|
13
|
-
|
|
14
|
-
return ((num - r1[0]) * (r2[1] - r2[0])) / (r1[1] - r1[0]) + r2[0];
|
|
12
|
+
*/ export function convertRange(num, r1, r2) {
|
|
13
|
+
return (num - r1[0]) * (r2[1] - r2[0]) / (r1[1] - r1[0]) + r2[0];
|
|
15
14
|
}
|
|
16
15
|
export default convertRange;
|
package/cookie.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
/**
|
|
3
2
|
* @file
|
|
4
3
|
*
|
|
@@ -7,7 +6,16 @@
|
|
|
7
6
|
* All cookie related code is inspired and adapted from:
|
|
8
7
|
* - [js-cookie](https://github.com/js-cookie/js-cookie)
|
|
9
8
|
* - [cookie](https://github.com/jshttp/cookie)
|
|
10
|
-
*/
|
|
11
|
-
Object.defineProperty(exports, "__esModule", {
|
|
12
|
-
|
|
13
|
-
|
|
9
|
+
*/ "use strict";
|
|
10
|
+
Object.defineProperty(exports, "__esModule", {
|
|
11
|
+
value: true
|
|
12
|
+
});
|
|
13
|
+
Object.defineProperty(exports, "defaultAttributesClient", {
|
|
14
|
+
enumerable: true,
|
|
15
|
+
get: function() {
|
|
16
|
+
return defaultAttributesClient;
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
const defaultAttributesClient = {
|
|
20
|
+
path: "/"
|
|
21
|
+
};
|
package/cookie.mjs
CHANGED
|
@@ -6,5 +6,6 @@
|
|
|
6
6
|
* All cookie related code is inspired and adapted from:
|
|
7
7
|
* - [js-cookie](https://github.com/js-cookie/js-cookie)
|
|
8
8
|
* - [cookie](https://github.com/jshttp/cookie)
|
|
9
|
-
*/
|
|
10
|
-
|
|
9
|
+
*/ export const defaultAttributesClient = {
|
|
10
|
+
path: "/"
|
|
11
|
+
};
|
package/createPalette.js
CHANGED
|
@@ -1,26 +1,34 @@
|
|
|
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
|
+
createPalette: function() {
|
|
13
|
+
return createPalette;
|
|
14
|
+
},
|
|
15
|
+
default: function() {
|
|
16
|
+
return _default;
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
const createPalette = (name, shades)=>{
|
|
20
|
+
const map = shades.reduce((map, def)=>{
|
|
16
21
|
map[def[0]] = def[1];
|
|
17
22
|
return map;
|
|
18
23
|
}, {});
|
|
19
|
-
|
|
20
|
-
map[
|
|
24
|
+
const tailwindPalette = shades.reduce((map, def)=>{
|
|
25
|
+
map[`${name}-${def[0]}`] = def[1];
|
|
21
26
|
return map;
|
|
22
27
|
}, {});
|
|
23
|
-
return [
|
|
28
|
+
return [
|
|
29
|
+
map,
|
|
30
|
+
tailwindPalette,
|
|
31
|
+
Object.values(map)
|
|
32
|
+
];
|
|
24
33
|
};
|
|
25
|
-
|
|
26
|
-
exports.default = exports.createPalette;
|
|
34
|
+
const _default = createPalette;
|
package/createPalette.mjs
CHANGED
|
@@ -7,16 +7,19 @@
|
|
|
7
7
|
* @returns An array with: 1) A flat palette map 2) A TailwindCSS ready palette
|
|
8
8
|
* object 3) A flat array of colors (no special sorting, same order as the `shades`
|
|
9
9
|
* given as argument)
|
|
10
|
-
*/
|
|
11
|
-
|
|
12
|
-
var map = shades.reduce(function (map, def) {
|
|
10
|
+
*/ export const createPalette = (name, shades)=>{
|
|
11
|
+
const map = shades.reduce((map, def)=>{
|
|
13
12
|
map[def[0]] = def[1];
|
|
14
13
|
return map;
|
|
15
14
|
}, {});
|
|
16
|
-
|
|
17
|
-
map[
|
|
15
|
+
const tailwindPalette = shades.reduce((map, def)=>{
|
|
16
|
+
map[`${name}-${def[0]}`] = def[1];
|
|
18
17
|
return map;
|
|
19
18
|
}, {});
|
|
20
|
-
return [
|
|
19
|
+
return [
|
|
20
|
+
map,
|
|
21
|
+
tailwindPalette,
|
|
22
|
+
Object.values(map)
|
|
23
|
+
];
|
|
21
24
|
};
|
|
22
25
|
export default createPalette;
|
package/debounce.js
CHANGED
|
@@ -1,33 +1,39 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.debounce = void 0;
|
|
4
1
|
/**
|
|
5
2
|
* Debounce function (with `setTimeout`)
|
|
6
3
|
*
|
|
7
4
|
* @category function
|
|
8
5
|
* @borrows [davidwalsh/debounce](https://davidwalsh.name/javascript-debounce-function)
|
|
9
|
-
*/
|
|
6
|
+
*/ "use strict";
|
|
7
|
+
Object.defineProperty(exports, "__esModule", {
|
|
8
|
+
value: true
|
|
9
|
+
});
|
|
10
|
+
function _export(target, all) {
|
|
11
|
+
for(var name in all)Object.defineProperty(target, name, {
|
|
12
|
+
enumerable: true,
|
|
13
|
+
get: all[name]
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
_export(exports, {
|
|
17
|
+
debounce: function() {
|
|
18
|
+
return debounce;
|
|
19
|
+
},
|
|
20
|
+
default: function() {
|
|
21
|
+
return _default;
|
|
22
|
+
}
|
|
23
|
+
});
|
|
10
24
|
function debounce(fn, wait, immediate) {
|
|
11
|
-
|
|
12
|
-
return function
|
|
13
|
-
var args = [];
|
|
14
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
15
|
-
args[_i] = arguments[_i];
|
|
16
|
-
}
|
|
25
|
+
let timeout;
|
|
26
|
+
return function(...args) {
|
|
17
27
|
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
|
18
|
-
|
|
19
|
-
|
|
28
|
+
const context = this;
|
|
29
|
+
const later = function() {
|
|
20
30
|
timeout = null;
|
|
21
|
-
if (!immediate)
|
|
22
|
-
fn.apply(context, args);
|
|
31
|
+
if (!immediate) fn.apply(context, args);
|
|
23
32
|
};
|
|
24
|
-
|
|
25
|
-
if (timeout)
|
|
26
|
-
clearTimeout(timeout);
|
|
33
|
+
const callNow = immediate && !timeout;
|
|
34
|
+
if (timeout) clearTimeout(timeout);
|
|
27
35
|
timeout = setTimeout(later, wait);
|
|
28
|
-
if (callNow)
|
|
29
|
-
fn.apply(context, args);
|
|
36
|
+
if (callNow) fn.apply(context, args);
|
|
30
37
|
};
|
|
31
38
|
}
|
|
32
|
-
|
|
33
|
-
exports.default = debounce;
|
|
39
|
+
const _default = debounce;
|
package/debounce.mjs
CHANGED
|
@@ -3,27 +3,19 @@
|
|
|
3
3
|
*
|
|
4
4
|
* @category function
|
|
5
5
|
* @borrows [davidwalsh/debounce](https://davidwalsh.name/javascript-debounce-function)
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
return function () {
|
|
10
|
-
var args = [];
|
|
11
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
12
|
-
args[_i] = arguments[_i];
|
|
13
|
-
}
|
|
6
|
+
*/ export function debounce(fn, wait, immediate) {
|
|
7
|
+
let timeout;
|
|
8
|
+
return function(...args) {
|
|
14
9
|
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
|
15
|
-
|
|
16
|
-
|
|
10
|
+
const context = this;
|
|
11
|
+
const later = function() {
|
|
17
12
|
timeout = null;
|
|
18
|
-
if (!immediate)
|
|
19
|
-
fn.apply(context, args);
|
|
13
|
+
if (!immediate) fn.apply(context, args);
|
|
20
14
|
};
|
|
21
|
-
|
|
22
|
-
if (timeout)
|
|
23
|
-
clearTimeout(timeout);
|
|
15
|
+
const callNow = immediate && !timeout;
|
|
16
|
+
if (timeout) clearTimeout(timeout);
|
|
24
17
|
timeout = setTimeout(later, wait);
|
|
25
|
-
if (callNow)
|
|
26
|
-
fn.apply(context, args);
|
|
18
|
+
if (callNow) fn.apply(context, args);
|
|
27
19
|
};
|
|
28
20
|
}
|
|
29
21
|
export default debounce;
|
package/debouncePromise.js
CHANGED
|
@@ -1,12 +1,21 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
exports
|
|
12
|
-
|
|
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
|
+
debouncePromise: function() {
|
|
13
|
+
return debouncePromise;
|
|
14
|
+
},
|
|
15
|
+
default: function() {
|
|
16
|
+
return _default;
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
const _tsdebounce = require("ts-debounce");
|
|
20
|
+
const debouncePromise = _tsdebounce.debounce;
|
|
21
|
+
const _default = debouncePromise;
|
package/debouncePromise.mjs
CHANGED
|
@@ -4,6 +4,5 @@ import { debounce as tsDebounce } from "ts-debounce";
|
|
|
4
4
|
*
|
|
5
5
|
* @category function
|
|
6
6
|
* @borrows [chodorowicz/ts-debounce](https://github.com/chodorowicz/ts-debounce)
|
|
7
|
-
*/
|
|
8
|
-
export var debouncePromise = tsDebounce;
|
|
7
|
+
*/ export const debouncePromise = tsDebounce;
|
|
9
8
|
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;
|