@koine/utils 2.0.0-beta.2 → 2.0.0-beta.5
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/areEqual.js
CHANGED
|
@@ -1,55 +1,50 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
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
|
+
areEqual: function() {
|
|
13
|
+
return areEqual;
|
|
14
|
+
},
|
|
15
|
+
default: function() {
|
|
16
|
+
return _default;
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
const _isArray = require("./isArray");
|
|
20
|
+
const _isObject = require("./isObject");
|
|
6
21
|
function areEqualArrays(a, b) {
|
|
7
|
-
if (!b)
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
var bValue = b[i];
|
|
14
|
-
if (!areEqual(aValue, bValue))
|
|
15
|
-
return false;
|
|
22
|
+
if (!b) return false;
|
|
23
|
+
if (a.length !== b.length) return false;
|
|
24
|
+
for(let i = 0; i < a.length; i++){
|
|
25
|
+
const aValue = a[i];
|
|
26
|
+
const bValue = b[i];
|
|
27
|
+
if (!areEqual(aValue, bValue)) return false;
|
|
16
28
|
}
|
|
17
29
|
return true;
|
|
18
30
|
}
|
|
19
31
|
function areEqualObjects(a, b) {
|
|
20
|
-
if (!b)
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
var bKeys = Object.keys(b);
|
|
32
|
+
if (!b) return false;
|
|
33
|
+
const aKeys = Object.keys(a);
|
|
34
|
+
const bKeys = Object.keys(b);
|
|
24
35
|
if (aKeys.length !== bKeys.length) {
|
|
25
36
|
return false;
|
|
26
37
|
}
|
|
27
|
-
for (
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
var bValue = b[key];
|
|
38
|
+
for (const _key of aKeys){
|
|
39
|
+
const key = _key;
|
|
40
|
+
const aValue = a[key];
|
|
41
|
+
const bValue = b[key];
|
|
32
42
|
if (!areEqual(aValue, bValue)) {
|
|
33
43
|
return false;
|
|
34
44
|
}
|
|
35
45
|
}
|
|
36
46
|
return true;
|
|
37
47
|
}
|
|
38
|
-
/**
|
|
39
|
-
* A simple and quick deep equal objects utility. This is meant to be used
|
|
40
|
-
* solely to deduplicate requests payload and perform comparison on JSON ready
|
|
41
|
-
* objects made of primitives `string`, `number` and `boolean`s.
|
|
42
|
-
*
|
|
43
|
-
* It support nested `object`s and `array`s only.
|
|
44
|
-
*
|
|
45
|
-
* NB: `undefined` and `null` values do not count in the comparison as they are
|
|
46
|
-
* usually meant to be ignored in JSON requestBody payloads.
|
|
47
|
-
*
|
|
48
|
-
* According to very rudimentary tests this function takes on average between
|
|
49
|
-
* 0.15 ms and 2ms to compare two averaged sizes requet body payloads.
|
|
50
|
-
*
|
|
51
|
-
* @category objects
|
|
52
|
-
*/
|
|
53
48
|
function areEqual(a, b) {
|
|
54
49
|
if (!a && !b) {
|
|
55
50
|
// console.log(`areEqual took ${performance.now() - t0} ms`);
|
|
@@ -60,12 +55,12 @@ function areEqual(a, b) {
|
|
|
60
55
|
// console.log(`areEqual took ${performance.now() - t0} ms`);
|
|
61
56
|
return false;
|
|
62
57
|
}
|
|
63
|
-
|
|
58
|
+
const areObjects = (0, _isObject.isObject)(a) && (0, _isObject.isObject)(b);
|
|
64
59
|
if (areObjects && !areEqualObjects(a, b)) {
|
|
65
60
|
// console.log(`areEqual took ${performance.now() - t0} ms`);
|
|
66
61
|
return false;
|
|
67
62
|
}
|
|
68
|
-
|
|
63
|
+
const areArrays = (0, _isArray.isArray)(a) && (0, _isArray.isArray)(b);
|
|
69
64
|
if (areArrays && !areEqualArrays(a, b)) {
|
|
70
65
|
// console.log(`areEqual took ${performance.now() - t0} ms`);
|
|
71
66
|
return false;
|
|
@@ -77,5 +72,4 @@ function areEqual(a, b) {
|
|
|
77
72
|
// console.log(`areEqual took ${performance.now() - t0} ms`);
|
|
78
73
|
return true;
|
|
79
74
|
}
|
|
80
|
-
|
|
81
|
-
exports.default = areEqual;
|
|
75
|
+
const _default = areEqual;
|
package/areEqual.mjs
CHANGED
|
@@ -1,31 +1,26 @@
|
|
|
1
1
|
import { isArray } from "./isArray";
|
|
2
2
|
import { isObject } from "./isObject";
|
|
3
3
|
function areEqualArrays(a, b) {
|
|
4
|
-
if (!b)
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
var bValue = b[i];
|
|
11
|
-
if (!areEqual(aValue, bValue))
|
|
12
|
-
return false;
|
|
4
|
+
if (!b) return false;
|
|
5
|
+
if (a.length !== b.length) return false;
|
|
6
|
+
for(let i = 0; i < a.length; i++){
|
|
7
|
+
const aValue = a[i];
|
|
8
|
+
const bValue = b[i];
|
|
9
|
+
if (!areEqual(aValue, bValue)) return false;
|
|
13
10
|
}
|
|
14
11
|
return true;
|
|
15
12
|
}
|
|
16
13
|
function areEqualObjects(a, b) {
|
|
17
|
-
if (!b)
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
var bKeys = Object.keys(b);
|
|
14
|
+
if (!b) return false;
|
|
15
|
+
const aKeys = Object.keys(a);
|
|
16
|
+
const bKeys = Object.keys(b);
|
|
21
17
|
if (aKeys.length !== bKeys.length) {
|
|
22
18
|
return false;
|
|
23
19
|
}
|
|
24
|
-
for (
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
var bValue = b[key];
|
|
20
|
+
for (const _key of aKeys){
|
|
21
|
+
const key = _key;
|
|
22
|
+
const aValue = a[key];
|
|
23
|
+
const bValue = b[key];
|
|
29
24
|
if (!areEqual(aValue, bValue)) {
|
|
30
25
|
return false;
|
|
31
26
|
}
|
|
@@ -46,8 +41,7 @@ function areEqualObjects(a, b) {
|
|
|
46
41
|
* 0.15 ms and 2ms to compare two averaged sizes requet body payloads.
|
|
47
42
|
*
|
|
48
43
|
* @category objects
|
|
49
|
-
*/
|
|
50
|
-
export function areEqual(a, b) {
|
|
44
|
+
*/ export function areEqual(a, b) {
|
|
51
45
|
if (!a && !b) {
|
|
52
46
|
// console.log(`areEqual took ${performance.now() - t0} ms`);
|
|
53
47
|
return true;
|
|
@@ -57,12 +51,12 @@ export function areEqual(a, b) {
|
|
|
57
51
|
// console.log(`areEqual took ${performance.now() - t0} ms`);
|
|
58
52
|
return false;
|
|
59
53
|
}
|
|
60
|
-
|
|
54
|
+
const areObjects = isObject(a) && isObject(b);
|
|
61
55
|
if (areObjects && !areEqualObjects(a, b)) {
|
|
62
56
|
// console.log(`areEqual took ${performance.now() - t0} ms`);
|
|
63
57
|
return false;
|
|
64
58
|
}
|
|
65
|
-
|
|
59
|
+
const areArrays = isArray(a) && isArray(b);
|
|
66
60
|
if (areArrays && !areEqualArrays(a, b)) {
|
|
67
61
|
// console.log(`areEqual took ${performance.now() - t0} ms`);
|
|
68
62
|
return false;
|
package/arrayOfAll.js
CHANGED
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.arrayOfAll = void 0;
|
|
4
1
|
/**
|
|
5
2
|
* Ensure an array contains all desired values
|
|
6
3
|
*
|
|
@@ -26,11 +23,23 @@ exports.arrayOfAll = void 0;
|
|
|
26
23
|
* ]); // ts compiler fails
|
|
27
24
|
* ```
|
|
28
25
|
*
|
|
29
|
-
*/
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
26
|
+
*/ "use strict";
|
|
27
|
+
Object.defineProperty(exports, "__esModule", {
|
|
28
|
+
value: true
|
|
29
|
+
});
|
|
30
|
+
function _export(target, all) {
|
|
31
|
+
for(var name in all)Object.defineProperty(target, name, {
|
|
32
|
+
enumerable: true,
|
|
33
|
+
get: all[name]
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
_export(exports, {
|
|
37
|
+
arrayOfAll: function() {
|
|
38
|
+
return arrayOfAll;
|
|
39
|
+
},
|
|
40
|
+
default: function() {
|
|
41
|
+
return _default;
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
const arrayOfAll = ()=>(array)=>array;
|
|
45
|
+
const _default = arrayOfAll;
|
package/arrayOfAll.mjs
CHANGED
package/arraySum.js
CHANGED
|
@@ -1,13 +1,24 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.arraySum = void 0;
|
|
4
1
|
/**
|
|
5
2
|
* Sum array of numbers
|
|
6
3
|
*
|
|
7
4
|
* @category array | math
|
|
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
|
+
arraySum: function() {
|
|
17
|
+
return arraySum;
|
|
18
|
+
},
|
|
19
|
+
default: function() {
|
|
20
|
+
return _default;
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
const arraySum = (numbers)=>numbers.reduce((sum, current)=>sum + current, 0);
|
|
24
|
+
const _default = arraySum;
|
package/arraySum.mjs
CHANGED
|
@@ -2,8 +2,5 @@
|
|
|
2
2
|
* Sum array of numbers
|
|
3
3
|
*
|
|
4
4
|
* @category array | math
|
|
5
|
-
*/
|
|
6
|
-
export var arraySum = function (numbers) {
|
|
7
|
-
return numbers.reduce(function (sum, current) { return sum + current; }, 0);
|
|
8
|
-
};
|
|
5
|
+
*/ export const arraySum = (numbers)=>numbers.reduce((sum, current)=>sum + current, 0);
|
|
9
6
|
export default arraySum;
|
package/arrayToLookup.js
CHANGED
|
@@ -1,17 +1,29 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.arrayToLookup = void 0;
|
|
4
1
|
/**
|
|
5
2
|
* Maps a simple flat array to a lookup dictionary object
|
|
6
3
|
*
|
|
7
4
|
* @category array
|
|
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
|
+
arrayToLookup: function() {
|
|
17
|
+
return arrayToLookup;
|
|
18
|
+
},
|
|
19
|
+
default: function() {
|
|
20
|
+
return _default;
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
function arrayToLookup(array = []) {
|
|
24
|
+
return array.reduce((obj, item)=>{
|
|
12
25
|
obj[item] = 1;
|
|
13
26
|
return obj;
|
|
14
27
|
}, {});
|
|
15
28
|
}
|
|
16
|
-
|
|
17
|
-
exports.default = arrayToLookup;
|
|
29
|
+
const _default = arrayToLookup;
|
package/arrayToLookup.mjs
CHANGED
|
@@ -2,10 +2,8 @@
|
|
|
2
2
|
* Maps a simple flat array to a lookup dictionary object
|
|
3
3
|
*
|
|
4
4
|
* @category array
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
if (array === void 0) { array = []; }
|
|
8
|
-
return array.reduce(function (obj, item) {
|
|
5
|
+
*/ export function arrayToLookup(array = []) {
|
|
6
|
+
return array.reduce((obj, item)=>{
|
|
9
7
|
obj[item] = 1;
|
|
10
8
|
return obj;
|
|
11
9
|
}, {});
|
package/buildUrlQueryString.js
CHANGED
|
@@ -1,36 +1,39 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
var
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
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
|
+
buildUrlQueryString: function() {
|
|
13
|
+
return buildUrlQueryString;
|
|
14
|
+
},
|
|
15
|
+
default: function() {
|
|
16
|
+
return _default;
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
const _interop_require_default = require("@swc/helpers/_/_interop_require_default");
|
|
20
|
+
const _isArray = /*#__PURE__*/ _interop_require_default._(require("./isArray"));
|
|
21
|
+
const _isNull = /*#__PURE__*/ _interop_require_default._(require("./isNull"));
|
|
22
|
+
const _isUndefined = /*#__PURE__*/ _interop_require_default._(require("./isUndefined"));
|
|
17
23
|
function buildUrlQueryString(params) {
|
|
18
|
-
|
|
19
|
-
if (!params)
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
output += "".concat(key, "=").concat(encodeURIComponent(value[i] + ""), "&");
|
|
24
|
+
let output = "";
|
|
25
|
+
if (!params) return output;
|
|
26
|
+
for(const key in params){
|
|
27
|
+
const value = params[key];
|
|
28
|
+
if ((0, _isArray.default)(value)) {
|
|
29
|
+
for(let i = 0; i < value.length; i++){
|
|
30
|
+
output += `${key}=${encodeURIComponent(value[i] + "")}&`;
|
|
26
31
|
}
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
output += "".concat(key, "=").concat(encodeURIComponent(value + ""), "&");
|
|
32
|
+
} else if (!(0, _isNull.default)(value) && !(0, _isUndefined.default)(value)) {
|
|
33
|
+
output += `${key}=${encodeURIComponent(value + "")}&`;
|
|
30
34
|
}
|
|
31
35
|
}
|
|
32
36
|
// removes the last &
|
|
33
|
-
return output ?
|
|
37
|
+
return output ? `?${output.replace(/&+$/, "")}` : "";
|
|
34
38
|
}
|
|
35
|
-
|
|
36
|
-
exports.default = buildUrlQueryString;
|
|
39
|
+
const _default = buildUrlQueryString;
|
package/buildUrlQueryString.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import isArray from "./isArray";
|
|
1
2
|
import isNull from "./isNull";
|
|
2
3
|
import isUndefined from "./isUndefined";
|
|
3
|
-
import isArray from "./isArray";
|
|
4
4
|
/**
|
|
5
5
|
* Get clean query string for URL
|
|
6
6
|
*
|
|
@@ -9,23 +9,20 @@ import isArray from "./isArray";
|
|
|
9
9
|
* TODO: at some point replace with `URLSearchParams`, @see [caniuse](https://caniuse.com/?search=URLSearchParams)
|
|
10
10
|
*
|
|
11
11
|
* @category location
|
|
12
|
-
*/
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
for (var key in params) {
|
|
18
|
-
var value = params[key];
|
|
12
|
+
*/ export function buildUrlQueryString(params) {
|
|
13
|
+
let output = "";
|
|
14
|
+
if (!params) return output;
|
|
15
|
+
for(const key in params){
|
|
16
|
+
const value = params[key];
|
|
19
17
|
if (isArray(value)) {
|
|
20
|
-
for
|
|
21
|
-
output +=
|
|
18
|
+
for(let i = 0; i < value.length; i++){
|
|
19
|
+
output += `${key}=${encodeURIComponent(value[i] + "")}&`;
|
|
22
20
|
}
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
output += "".concat(key, "=").concat(encodeURIComponent(value + ""), "&");
|
|
21
|
+
} else if (!isNull(value) && !isUndefined(value)) {
|
|
22
|
+
output += `${key}=${encodeURIComponent(value + "")}&`;
|
|
26
23
|
}
|
|
27
24
|
}
|
|
28
25
|
// removes the last &
|
|
29
|
-
return output ?
|
|
26
|
+
return output ? `?${output.replace(/&+$/, "")}` : "";
|
|
30
27
|
}
|
|
31
28
|
export default buildUrlQueryString;
|
package/capitalize.js
CHANGED
|
@@ -1,16 +1,28 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.capitalize = void 0;
|
|
4
1
|
/**
|
|
5
2
|
* Capitalize first letter of the given string.
|
|
6
3
|
*
|
|
7
4
|
* @category text
|
|
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
|
+
capitalize: function() {
|
|
18
|
+
return capitalize;
|
|
19
|
+
},
|
|
20
|
+
default: function() {
|
|
21
|
+
return _default;
|
|
22
|
+
}
|
|
23
|
+
});
|
|
10
24
|
function capitalize(string) {
|
|
11
|
-
|
|
12
|
-
return
|
|
13
|
-
ensuredString.slice(1));
|
|
25
|
+
const ensuredString = string || "";
|
|
26
|
+
return ensuredString.charAt(0).toUpperCase() + ensuredString.slice(1);
|
|
14
27
|
}
|
|
15
|
-
|
|
16
|
-
exports.default = capitalize;
|
|
28
|
+
const _default = capitalize;
|
package/capitalize.mjs
CHANGED
|
@@ -3,10 +3,8 @@
|
|
|
3
3
|
*
|
|
4
4
|
* @category text
|
|
5
5
|
* @see https://stackoverflow.com/a/11409944/1938970
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
return (ensuredString.charAt(0).toUpperCase() +
|
|
10
|
-
ensuredString.slice(1));
|
|
6
|
+
*/ export function capitalize(string) {
|
|
7
|
+
const ensuredString = string || "";
|
|
8
|
+
return ensuredString.charAt(0).toUpperCase() + ensuredString.slice(1);
|
|
11
9
|
}
|
|
12
10
|
export default capitalize;
|
package/changeUrlPath.js
CHANGED
|
@@ -1,23 +1,29 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
var
|
|
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
|
+
changeUrlPath: function() {
|
|
13
|
+
return changeUrlPath;
|
|
14
|
+
},
|
|
15
|
+
default: function() {
|
|
16
|
+
return _default;
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
const _interop_require_default = require("@swc/helpers/_/_interop_require_default");
|
|
20
|
+
const _isBrowser = /*#__PURE__*/ _interop_require_default._(require("./isBrowser"));
|
|
21
|
+
const _normaliseUrlPathname = /*#__PURE__*/ _interop_require_default._(require("./normaliseUrlPathname"));
|
|
15
22
|
function changeUrlPath(pathname, state, replace) {
|
|
16
|
-
|
|
17
|
-
if (
|
|
23
|
+
const path = (0, _normaliseUrlPathname.default)(`/${pathname}/`);
|
|
24
|
+
if (_isBrowser.default) {
|
|
18
25
|
history[replace ? "replaceState" : "pushState"](state, "", path);
|
|
19
26
|
}
|
|
20
27
|
return path;
|
|
21
28
|
}
|
|
22
|
-
|
|
23
|
-
exports.default = changeUrlPath;
|
|
29
|
+
const _default = changeUrlPath;
|
package/changeUrlPath.mjs
CHANGED
|
@@ -7,9 +7,8 @@ import normaliseUrlPathname from "./normaliseUrlPathname";
|
|
|
7
7
|
* @category location
|
|
8
8
|
* @param replace Replace URL instead of pushing it in the history stack. By default it pushes it.
|
|
9
9
|
* @returns {string} The new cleaned pathname
|
|
10
|
-
*/
|
|
11
|
-
|
|
12
|
-
var path = normaliseUrlPathname("/".concat(pathname, "/"));
|
|
10
|
+
*/ export function changeUrlPath(pathname, state, replace) {
|
|
11
|
+
const path = normaliseUrlPathname(`/${pathname}/`);
|
|
13
12
|
if (isBrowser) {
|
|
14
13
|
history[replace ? "replaceState" : "pushState"](state, "", path);
|
|
15
14
|
}
|
package/chunkByChunks.js
CHANGED
|
@@ -1,41 +1,52 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.chunkByChunks = void 0;
|
|
4
1
|
/**
|
|
5
2
|
* TODO: untested
|
|
6
3
|
* @category array
|
|
7
4
|
* @see https://stackoverflow.com/a/8189268/1938970
|
|
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
|
+
chunkByChunks: function() {
|
|
17
|
+
return chunkByChunks;
|
|
18
|
+
},
|
|
19
|
+
default: function() {
|
|
20
|
+
return _default;
|
|
21
|
+
}
|
|
22
|
+
});
|
|
9
23
|
function chunkByChunks(arr, nrOfChunks, balanced) {
|
|
10
|
-
if (nrOfChunks < 2)
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
24
|
+
if (nrOfChunks < 2) return [
|
|
25
|
+
arr
|
|
26
|
+
];
|
|
27
|
+
const len = arr.length;
|
|
28
|
+
const output = [];
|
|
29
|
+
let i = 0;
|
|
30
|
+
let size;
|
|
16
31
|
if (len % nrOfChunks === 0) {
|
|
17
32
|
size = Math.floor(len / nrOfChunks);
|
|
18
|
-
while
|
|
19
|
-
output.push(arr.slice(i,
|
|
33
|
+
while(i < len){
|
|
34
|
+
output.push(arr.slice(i, i += size));
|
|
20
35
|
}
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
while (i < len) {
|
|
36
|
+
} else if (balanced) {
|
|
37
|
+
while(i < len){
|
|
24
38
|
size = Math.ceil((len - i) / nrOfChunks--);
|
|
25
|
-
output.push(arr.slice(i,
|
|
39
|
+
output.push(arr.slice(i, i += size));
|
|
26
40
|
}
|
|
27
|
-
}
|
|
28
|
-
else {
|
|
41
|
+
} else {
|
|
29
42
|
nrOfChunks--;
|
|
30
43
|
size = Math.floor(len / nrOfChunks);
|
|
31
|
-
if (len % size === 0)
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
output.push(arr.slice(i, (i += size)));
|
|
44
|
+
if (len % size === 0) size--;
|
|
45
|
+
while(i < size * nrOfChunks){
|
|
46
|
+
output.push(arr.slice(i, i += size));
|
|
35
47
|
}
|
|
36
48
|
output.push(arr.slice(size * nrOfChunks));
|
|
37
49
|
}
|
|
38
50
|
return output;
|
|
39
51
|
}
|
|
40
|
-
|
|
41
|
-
exports.default = chunkByChunks;
|
|
52
|
+
const _default = chunkByChunks;
|