@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/randomInt.js
CHANGED
|
@@ -1,13 +1,26 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.randomInt = void 0;
|
|
4
1
|
/**
|
|
5
2
|
* Get random int (min and max included)
|
|
6
3
|
*
|
|
7
4
|
* @category math
|
|
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
|
+
randomInt: function() {
|
|
17
|
+
return randomInt;
|
|
18
|
+
},
|
|
19
|
+
default: function() {
|
|
20
|
+
return _default;
|
|
21
|
+
}
|
|
22
|
+
});
|
|
9
23
|
function randomInt(min, max) {
|
|
10
24
|
return Math.floor(Math.random() * (max - min + 1) + min);
|
|
11
25
|
}
|
|
12
|
-
|
|
13
|
-
exports.default = randomInt;
|
|
26
|
+
const _default = randomInt;
|
package/randomInt.mjs
CHANGED
package/randomKey.js
CHANGED
|
@@ -1,15 +1,28 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.randomKey = void 0;
|
|
4
1
|
/**
|
|
5
2
|
* Get random key from given object
|
|
6
3
|
*
|
|
7
4
|
* @category misc
|
|
8
5
|
* @see https://stackoverflow.com/a/15106541/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
|
+
randomKey: function() {
|
|
18
|
+
return randomKey;
|
|
19
|
+
},
|
|
20
|
+
default: function() {
|
|
21
|
+
return _default;
|
|
22
|
+
}
|
|
23
|
+
});
|
|
10
24
|
function randomKey(obj) {
|
|
11
|
-
|
|
12
|
-
return keys[
|
|
25
|
+
const keys = Object.keys(obj);
|
|
26
|
+
return keys[keys.length * Math.random() << 0];
|
|
13
27
|
}
|
|
14
|
-
|
|
15
|
-
exports.default = randomKey;
|
|
28
|
+
const _default = randomKey;
|
package/randomKey.mjs
CHANGED
|
@@ -3,9 +3,8 @@
|
|
|
3
3
|
*
|
|
4
4
|
* @category misc
|
|
5
5
|
* @see https://stackoverflow.com/a/15106541/1938970
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
return keys[(keys.length * Math.random()) << 0];
|
|
6
|
+
*/ export function randomKey(obj) {
|
|
7
|
+
const keys = Object.keys(obj);
|
|
8
|
+
return keys[keys.length * Math.random() << 0];
|
|
10
9
|
}
|
|
11
10
|
export default randomKey;
|
package/readCookie.js
CHANGED
|
@@ -1,6 +1,21 @@
|
|
|
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
|
+
readCookie: function() {
|
|
13
|
+
return readCookie;
|
|
14
|
+
},
|
|
15
|
+
default: function() {
|
|
16
|
+
return _default;
|
|
17
|
+
}
|
|
18
|
+
});
|
|
4
19
|
function converterRead(value) {
|
|
5
20
|
if (value[0] === '"') {
|
|
6
21
|
value = value.slice(1, -1);
|
|
@@ -14,19 +29,18 @@ function readCookie(name) {
|
|
|
14
29
|
}
|
|
15
30
|
return name ? "" : {};
|
|
16
31
|
}
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
for
|
|
20
|
-
|
|
21
|
-
|
|
32
|
+
const cookies = document.cookie ? document.cookie.split("; ") : [];
|
|
33
|
+
const all = {};
|
|
34
|
+
for(let i = 0; i < cookies.length; i++){
|
|
35
|
+
const parts = cookies[i].split("=");
|
|
36
|
+
const value = parts.slice(1).join("=");
|
|
22
37
|
try {
|
|
23
|
-
|
|
38
|
+
const found = decodeURIComponent(parts[0]);
|
|
24
39
|
all[found] = converterRead(value);
|
|
25
40
|
if (name === found) {
|
|
26
41
|
break;
|
|
27
42
|
}
|
|
28
|
-
}
|
|
29
|
-
catch (e) {
|
|
43
|
+
} catch (e) {
|
|
30
44
|
if (process.env["NODE_ENV"] !== "production") {
|
|
31
45
|
console.warn("[@koine/utils:readCookie] failed to decode", value);
|
|
32
46
|
}
|
|
@@ -34,5 +48,4 @@ function readCookie(name) {
|
|
|
34
48
|
}
|
|
35
49
|
return name ? all[name] : all;
|
|
36
50
|
}
|
|
37
|
-
|
|
38
|
-
exports.default = readCookie;
|
|
51
|
+
const _default = readCookie;
|
package/readCookie.mjs
CHANGED
|
@@ -11,19 +11,18 @@ export function readCookie(name) {
|
|
|
11
11
|
}
|
|
12
12
|
return name ? "" : {};
|
|
13
13
|
}
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
for
|
|
17
|
-
|
|
18
|
-
|
|
14
|
+
const cookies = document.cookie ? document.cookie.split("; ") : [];
|
|
15
|
+
const all = {};
|
|
16
|
+
for(let i = 0; i < cookies.length; i++){
|
|
17
|
+
const parts = cookies[i].split("=");
|
|
18
|
+
const value = parts.slice(1).join("=");
|
|
19
19
|
try {
|
|
20
|
-
|
|
20
|
+
const found = decodeURIComponent(parts[0]);
|
|
21
21
|
all[found] = converterRead(value);
|
|
22
22
|
if (name === found) {
|
|
23
23
|
break;
|
|
24
24
|
}
|
|
25
|
-
}
|
|
26
|
-
catch (e) {
|
|
25
|
+
} catch (e) {
|
|
27
26
|
if (process.env["NODE_ENV"] !== "production") {
|
|
28
27
|
console.warn("[@koine/utils:readCookie] failed to decode", value);
|
|
29
28
|
}
|
package/removeAccents.js
CHANGED
|
@@ -1,19 +1,28 @@
|
|
|
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
|
+
removeAccents: function() {
|
|
13
|
+
return removeAccents;
|
|
14
|
+
},
|
|
15
|
+
default: function() {
|
|
16
|
+
return _default;
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
const _accentSets = require("./accentSets");
|
|
20
|
+
function removeAccents(text = "", sets = _accentSets.accentsSets) {
|
|
21
|
+
let len = sets.length;
|
|
22
|
+
while(len--){
|
|
23
|
+
const [to, from] = sets[len];
|
|
24
|
+
text = text.replace(new RegExp(`[${from}]`, "gi"), to);
|
|
15
25
|
}
|
|
16
26
|
return text;
|
|
17
27
|
}
|
|
18
|
-
|
|
19
|
-
exports.default = removeAccents;
|
|
28
|
+
const _default = removeAccents;
|
package/removeAccents.mjs
CHANGED
|
@@ -1,14 +1,11 @@
|
|
|
1
1
|
import { accentsSets } from "./accentSets";
|
|
2
2
|
/**
|
|
3
3
|
* @category text
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
while (len--) {
|
|
10
|
-
var _a = sets[len], to = _a[0], from = _a[1];
|
|
11
|
-
text = text.replace(new RegExp("[".concat(from, "]"), "gi"), to);
|
|
4
|
+
*/ export function removeAccents(text = "", sets = accentsSets) {
|
|
5
|
+
let len = sets.length;
|
|
6
|
+
while(len--){
|
|
7
|
+
const [to, from] = sets[len];
|
|
8
|
+
text = text.replace(new RegExp(`[${from}]`, "gi"), to);
|
|
12
9
|
}
|
|
13
10
|
return text;
|
|
14
11
|
}
|
package/removeCookie.js
CHANGED
|
@@ -1,19 +1,28 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
var
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
* All cookie related code is inspired and adapted from:
|
|
11
|
-
* - [js-cookie](https://github.com/js-cookie/js-cookie)
|
|
12
|
-
* - [cookie](https://github.com/jshttp/cookie)
|
|
13
|
-
*/
|
|
14
|
-
function removeCookie(name, attributes) {
|
|
15
|
-
if (attributes === void 0) { attributes = {}; }
|
|
16
|
-
(0, setCookie_1.setCookie)(name, "", tslib_1.__assign(tslib_1.__assign(tslib_1.__assign({}, cookie_1.defaultAttributesClient), attributes), { expires: -1 }));
|
|
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
|
+
});
|
|
17
10
|
}
|
|
18
|
-
exports
|
|
19
|
-
|
|
11
|
+
_export(exports, {
|
|
12
|
+
removeCookie: function() {
|
|
13
|
+
return removeCookie;
|
|
14
|
+
},
|
|
15
|
+
default: function() {
|
|
16
|
+
return _default;
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
const _cookie = require("./cookie");
|
|
20
|
+
const _setCookie = require("./setCookie");
|
|
21
|
+
function removeCookie(name, attributes = {}) {
|
|
22
|
+
(0, _setCookie.setCookie)(name, "", {
|
|
23
|
+
..._cookie.defaultAttributesClient,
|
|
24
|
+
...attributes,
|
|
25
|
+
expires: -1
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
const _default = removeCookie;
|
package/removeCookie.mjs
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { __assign } from "tslib";
|
|
2
1
|
import { defaultAttributesClient } from "./cookie";
|
|
3
2
|
import { setCookie } from "./setCookie";
|
|
4
3
|
/**
|
|
@@ -7,9 +6,11 @@ import { setCookie } from "./setCookie";
|
|
|
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
|
-
|
|
12
|
-
|
|
13
|
-
|
|
9
|
+
*/ export function removeCookie(name, attributes = {}) {
|
|
10
|
+
setCookie(name, "", {
|
|
11
|
+
...defaultAttributesClient,
|
|
12
|
+
...attributes,
|
|
13
|
+
expires: -1
|
|
14
|
+
});
|
|
14
15
|
}
|
|
15
16
|
export default removeCookie;
|
package/removeDuplicates.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
// /**
|
|
3
2
|
// * FIXME: Type 'Set<any>' can only be iterated through when using the
|
|
4
3
|
// * '--downlevelIteration' flag or with a '--target' of 'es2015' or higher.
|
|
@@ -11,3 +10,4 @@
|
|
|
11
10
|
// return [...new Set(arr)];
|
|
12
11
|
// }
|
|
13
12
|
// export default removeDuplicates;
|
|
13
|
+
"use strict";
|
package/removeDuplicates.mjs
CHANGED
package/removeDuplicatesByKey.js
CHANGED
|
@@ -1,18 +1,31 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.removeDuplicatesByKey = void 0;
|
|
4
1
|
/**
|
|
5
2
|
* Remove duplicated array objects, equality is determined by a strict (`===`)
|
|
6
3
|
* comparison of each object's given key
|
|
7
4
|
*
|
|
8
5
|
* @category array
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
for
|
|
15
|
-
|
|
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
|
+
removeDuplicatesByKey: function() {
|
|
18
|
+
return removeDuplicatesByKey;
|
|
19
|
+
},
|
|
20
|
+
default: function() {
|
|
21
|
+
return _default;
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
function removeDuplicatesByKey(array = [], key) {
|
|
25
|
+
const keysMap = {};
|
|
26
|
+
const output = [];
|
|
27
|
+
for(let i = 0; i < array.length; i++){
|
|
28
|
+
const item = array[i];
|
|
16
29
|
if (!keysMap[item[key]]) {
|
|
17
30
|
output.push(item);
|
|
18
31
|
keysMap[item[key]] = true;
|
|
@@ -20,5 +33,4 @@ function removeDuplicatesByKey(array, key) {
|
|
|
20
33
|
}
|
|
21
34
|
return output;
|
|
22
35
|
}
|
|
23
|
-
|
|
24
|
-
exports.default = removeDuplicatesByKey;
|
|
36
|
+
const _default = removeDuplicatesByKey;
|
|
@@ -3,13 +3,11 @@
|
|
|
3
3
|
* comparison of each object's given key
|
|
4
4
|
*
|
|
5
5
|
* @category array
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
for (var i = 0; i < array.length; i++) {
|
|
12
|
-
var item = array[i];
|
|
6
|
+
*/ export function removeDuplicatesByKey(array = [], key) {
|
|
7
|
+
const keysMap = {};
|
|
8
|
+
const output = [];
|
|
9
|
+
for(let i = 0; i < array.length; i++){
|
|
10
|
+
const item = array[i];
|
|
13
11
|
if (!keysMap[item[key]]) {
|
|
14
12
|
output.push(item);
|
|
15
13
|
keysMap[item[key]] = true;
|
|
@@ -1,14 +1,25 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
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
|
+
removeDuplicatesComparing: function() {
|
|
13
|
+
return removeDuplicatesComparing;
|
|
14
|
+
},
|
|
15
|
+
default: function() {
|
|
16
|
+
return _default;
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
const _findDuplicatedIndexes = require("./findDuplicatedIndexes");
|
|
20
|
+
const _removeIndexesFromArray = require("./removeIndexesFromArray");
|
|
9
21
|
function removeDuplicatesComparing(from, to) {
|
|
10
|
-
|
|
11
|
-
return (0,
|
|
22
|
+
const indexes = (0, _findDuplicatedIndexes.findDuplicatedIndexes)(from);
|
|
23
|
+
return (0, _removeIndexesFromArray.removeIndexesFromArray)(to, indexes);
|
|
12
24
|
}
|
|
13
|
-
|
|
14
|
-
exports.default = removeDuplicatesComparing;
|
|
25
|
+
const _default = removeDuplicatesComparing;
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import { removeIndexesFromArray } from "./removeIndexesFromArray";
|
|
2
1
|
import { findDuplicatedIndexes } from "./findDuplicatedIndexes";
|
|
2
|
+
import { removeIndexesFromArray } from "./removeIndexesFromArray";
|
|
3
3
|
/**
|
|
4
4
|
* @category array
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
var indexes = findDuplicatedIndexes(from);
|
|
5
|
+
*/ export function removeDuplicatesComparing(from, to) {
|
|
6
|
+
const indexes = findDuplicatedIndexes(from);
|
|
8
7
|
return removeIndexesFromArray(to, indexes);
|
|
9
8
|
}
|
|
10
9
|
export default removeDuplicatesComparing;
|
|
@@ -1,12 +1,26 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.removeIndexesFromArray = 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
|
+
removeIndexesFromArray: function() {
|
|
15
|
+
return removeIndexesFromArray;
|
|
16
|
+
},
|
|
17
|
+
default: function() {
|
|
18
|
+
return _default;
|
|
19
|
+
}
|
|
20
|
+
});
|
|
7
21
|
function removeIndexesFromArray(arr, indexes) {
|
|
8
|
-
|
|
9
|
-
for
|
|
22
|
+
const output = [];
|
|
23
|
+
for(let i = 0; i < arr.length; i++){
|
|
10
24
|
// eslint-disable-next-line no-prototype-builtins
|
|
11
25
|
if (!indexes.hasOwnProperty(i)) {
|
|
12
26
|
output.push(arr[i]);
|
|
@@ -14,5 +28,4 @@ function removeIndexesFromArray(arr, indexes) {
|
|
|
14
28
|
}
|
|
15
29
|
return output;
|
|
16
30
|
}
|
|
17
|
-
|
|
18
|
-
exports.default = removeIndexesFromArray;
|
|
31
|
+
const _default = removeIndexesFromArray;
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @category array
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
for (var i = 0; i < arr.length; i++) {
|
|
3
|
+
*/ export function removeIndexesFromArray(arr, indexes) {
|
|
4
|
+
const output = [];
|
|
5
|
+
for(let i = 0; i < arr.length; i++){
|
|
7
6
|
// eslint-disable-next-line no-prototype-builtins
|
|
8
7
|
if (!indexes.hasOwnProperty(i)) {
|
|
9
8
|
output.push(arr[i]);
|
package/removeTrailingSlash.js
CHANGED
|
@@ -1,14 +1,26 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.removeTralingSlash = void 0;
|
|
4
1
|
/**
|
|
5
2
|
* Strips out the trailing slash
|
|
6
3
|
*
|
|
7
4
|
* @category location
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
|
|
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
|
+
removeTralingSlash: function() {
|
|
17
|
+
return removeTralingSlash;
|
|
18
|
+
},
|
|
19
|
+
default: function() {
|
|
20
|
+
return _default;
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
function removeTralingSlash(urlLike = "") {
|
|
11
24
|
return urlLike.replace(/\/*$/, "");
|
|
12
25
|
}
|
|
13
|
-
|
|
14
|
-
exports.default = removeTralingSlash;
|
|
26
|
+
const _default = removeTralingSlash;
|
package/removeTrailingSlash.mjs
CHANGED
|
@@ -2,9 +2,7 @@
|
|
|
2
2
|
* Strips out the trailing slash
|
|
3
3
|
*
|
|
4
4
|
* @category location
|
|
5
|
-
*/
|
|
6
|
-
export function removeTralingSlash(urlLike) {
|
|
7
|
-
if (urlLike === void 0) { urlLike = ""; }
|
|
5
|
+
*/ export function removeTralingSlash(urlLike = "") {
|
|
8
6
|
return urlLike.replace(/\/*$/, "");
|
|
9
7
|
}
|
|
10
8
|
export default removeTralingSlash;
|
package/removeUrlQueryParams.js
CHANGED
|
@@ -1,26 +1,33 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
var
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
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
|
+
removeUrlQueryParams: function() {
|
|
13
|
+
return removeUrlQueryParams;
|
|
14
|
+
},
|
|
15
|
+
default: function() {
|
|
16
|
+
return _default;
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
const _interop_require_default = require("@swc/helpers/_/_interop_require_default");
|
|
20
|
+
const _buildUrlQueryString = /*#__PURE__*/ _interop_require_default._(require("./buildUrlQueryString"));
|
|
21
|
+
const _getUrlQueryParams = /*#__PURE__*/ _interop_require_default._(require("./getUrlQueryParams"));
|
|
22
|
+
function removeUrlQueryParams(url, paramsToRemove = []) {
|
|
23
|
+
const parts = url.split("?");
|
|
24
|
+
const allParams = (0, _getUrlQueryParams.default)(url);
|
|
25
|
+
const params = {};
|
|
26
|
+
for(const key in allParams){
|
|
19
27
|
if (!paramsToRemove.includes(key)) {
|
|
20
28
|
params[key] = allParams[key];
|
|
21
29
|
}
|
|
22
30
|
}
|
|
23
|
-
return parts[0] + (0,
|
|
31
|
+
return parts[0] + (0, _buildUrlQueryString.default)(params);
|
|
24
32
|
}
|
|
25
|
-
|
|
26
|
-
exports.default = removeUrlQueryParams;
|
|
33
|
+
const _default = removeUrlQueryParams;
|
package/removeUrlQueryParams.mjs
CHANGED
|
@@ -5,13 +5,11 @@ import getUrlQueryParams from "./getUrlQueryParams";
|
|
|
5
5
|
*
|
|
6
6
|
* @category location
|
|
7
7
|
* @pure
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
var params = {};
|
|
14
|
-
for (var key in allParams) {
|
|
8
|
+
*/ export function removeUrlQueryParams(url, paramsToRemove = []) {
|
|
9
|
+
const parts = url.split("?");
|
|
10
|
+
const allParams = getUrlQueryParams(url);
|
|
11
|
+
const params = {};
|
|
12
|
+
for(const key in allParams){
|
|
15
13
|
if (!paramsToRemove.includes(key)) {
|
|
16
14
|
params[key] = allParams[key];
|
|
17
15
|
}
|