@koine/utils 2.0.0-beta.1 → 2.0.0-beta.11
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.mjs +6 -5
- package/Emitter.d.ts +3 -1
- package/Emitter.mjs +16 -17
- package/README.md +6 -1
- package/accentSets.d.ts +3 -2
- package/accentSets.mjs +116 -31
- package/addOrReplaceAtIdx.d.ts +4 -0
- package/addOrReplaceAtIdx.mjs +13 -6
- package/areEqual.d.ts +1 -1
- package/areEqual.mjs +17 -23
- package/arrayOfAll.d.ts +1 -2
- package/arrayOfAll.mjs +2 -8
- package/arraySum.d.ts +2 -1
- package/arraySum.mjs +3 -5
- package/arrayToLookup.mjs +2 -4
- package/buildUrlQueryString.mjs +11 -14
- package/capitalize.d.ts +2 -1
- package/capitalize.mjs +5 -6
- package/changeUrlPath.mjs +2 -3
- package/chunkByChunks.d.ts +1 -1
- package/chunkByChunks.mjs +18 -21
- package/chunkBySize.mjs +3 -4
- package/clamp.mjs +1 -2
- package/clsx.d.ts +6 -2
- package/clsx.mjs +14 -15
- package/convertRange.d.ts +3 -1
- package/convertRange.mjs +5 -4
- package/cookie.d.ts +13 -1
- package/cookie.mjs +8 -3
- package/createPalette.d.ts +3 -1
- package/createPalette.mjs +17 -7
- package/debounce.mjs +9 -17
- package/debouncePromise.d.ts +22 -4
- package/debouncePromise.mjs +73 -3
- package/debounceRaf.d.ts +1 -1
- package/debounceRaf.mjs +6 -11
- package/decode.mjs +2 -3
- package/encode.mjs +2 -3
- package/ensureInt.mjs +1 -4
- package/env.mjs +0 -1
- package/errorToString.d.ts +2 -1
- package/errorToString.mjs +3 -5
- package/findDuplicatedIndexes.mjs +4 -5
- package/forin.d.ts +2 -1
- package/forin.mjs +4 -4
- package/gbToBytes.mjs +1 -2
- package/getEmptyArray.d.ts +0 -1
- package/getEmptyArray.mjs +4 -4
- package/getKeys.d.ts +2 -1
- package/getKeys.mjs +3 -3
- package/getMediaQueryWidthResolvers.d.ts +6 -0
- package/getMediaQueryWidthResolvers.mjs +49 -50
- package/getMediaQueryWidthTailwindScreens.d.ts +4 -0
- package/getMediaQueryWidthTailwindScreens.mjs +22 -15
- package/getNonce.mjs +1 -2
- package/getParamAmong.d.ts +3 -2
- package/getParamAmong.mjs +5 -6
- package/getParamAsInt.d.ts +2 -2
- package/getParamAsInt.mjs +4 -6
- package/getParamAsString.d.ts +1 -1
- package/getParamAsString.mjs +2 -3
- package/getType.d.ts +0 -3
- package/getType.mjs +2 -7
- package/getUrlHashParams.mjs +2 -4
- package/getUrlHashPathname.mjs +1 -3
- package/getUrlPathnameParts.mjs +2 -7
- package/getUrlQueryParams.d.ts +3 -4
- package/getUrlQueryParams.mjs +10 -22
- package/imgEmptyPixel.mjs +1 -2
- package/index.d.ts +5 -2
- package/index.mjs +2 -2
- package/invariant.mjs +6 -8
- package/isAnyObject.mjs +1 -2
- package/isArray.mjs +1 -2
- package/isBlob.mjs +1 -2
- package/isBoolean.mjs +1 -2
- package/isBrowser.mjs +1 -2
- package/isBrowserNow.mjs +1 -2
- package/isDate.mjs +1 -2
- package/isEmptyArray.mjs +1 -2
- package/isEmptyObject.mjs +1 -2
- package/isEmptyString.mjs +1 -2
- package/isError.mjs +1 -2
- package/isExternalUrl.mjs +4 -6
- package/isFile.mjs +1 -2
- package/isFloat.mjs +1 -2
- package/isFormData.mjs +1 -2
- package/isFullArray.mjs +1 -2
- package/isFullObject.mjs +1 -2
- package/isFullString.mjs +1 -2
- package/isFunction.mjs +1 -2
- package/isInt.mjs +1 -2
- package/isMap.mjs +1 -2
- package/isNaNValue.mjs +1 -2
- package/isNegativeNumber.mjs +1 -2
- package/isNull.mjs +1 -2
- package/isNullOrUndefined.mjs +1 -2
- package/isNumber.mjs +1 -2
- package/isObject.mjs +1 -2
- package/isObjectLike.mjs +1 -2
- package/isOneOf.mjs +1 -7
- package/isPlainObject.mjs +3 -6
- package/isPositiveNumber.mjs +1 -2
- package/isPrimitive.mjs +5 -11
- package/isPromise.mjs +1 -2
- package/isRegExp.mjs +1 -2
- package/isServer.mjs +1 -2
- package/isServerNow.mjs +1 -2
- package/isSet.mjs +1 -2
- package/isString.mjs +1 -2
- package/isSymbol.mjs +1 -2
- package/isType.mjs +3 -5
- package/isUndefined.mjs +1 -2
- package/isWeakMap.mjs +1 -2
- package/isWeakSet.mjs +1 -2
- package/kbToBytes.mjs +1 -2
- package/location.mjs +3 -1
- package/lowercase.mjs +1 -4
- package/mapListBy.mjs +2 -5
- package/matchSorter.mjs +110 -128
- package/mbToBytes.mjs +1 -2
- package/mergeObjects.d.ts +2 -2
- package/mergeObjects.mjs +13 -16
- package/mergeUrlQueryParams.d.ts +0 -1
- package/mergeUrlQueryParams.mjs +4 -9
- package/moveSortableArrayItemByKey.d.ts +1 -1
- package/moveSortableArrayItemByKey.mjs +9 -9
- package/noop.mjs +1 -2
- package/normaliseUrl.mjs +1 -3
- package/normaliseUrlPathname.mjs +1 -3
- package/objectOmit.d.ts +1 -1
- package/objectOmit.mjs +4 -6
- package/objectPick.d.ts +1 -1
- package/objectPick.mjs +5 -6
- package/package.json +7 -11
- package/parseCookie.mjs +11 -15
- package/parseURL.mjs +5 -6
- package/quaranteneProps.d.ts +1 -1
- package/quaranteneProps.mjs +7 -9
- package/randomInt.mjs +1 -2
- package/randomKey.mjs +3 -4
- package/readCookie.d.ts +5 -0
- package/readCookie.mjs +7 -8
- package/removeAccents.mjs +5 -8
- package/removeCookie.d.ts +0 -4
- package/removeCookie.mjs +6 -9
- package/removeDuplicates.mjs +0 -1
- package/removeDuplicatesByKey.mjs +5 -7
- package/removeDuplicatesComparing.mjs +3 -4
- package/removeIndexesFromArray.mjs +3 -4
- package/removeTrailingSlash.mjs +1 -3
- package/removeUrlQueryParams.d.ts +0 -1
- package/removeUrlQueryParams.mjs +5 -8
- package/render.d.ts +2 -1
- package/render.mjs +45 -99
- package/roundTo.mjs +15 -17
- package/serializeCookie.d.ts +1 -5
- package/serializeCookie.mjs +10 -20
- package/setCookie.d.ts +0 -4
- package/setCookie.mjs +13 -20
- package/shuffle.d.ts +7 -6
- package/shuffle.mjs +17 -16
- package/slugify.d.ts +2 -1
- package/slugify.mjs +15 -12
- package/split.d.ts +4 -0
- package/split.mjs +4 -1
- package/swapMap.d.ts +1 -1
- package/swapMap.mjs +4 -6
- package/throttle.d.ts +2 -1
- package/throttle.mjs +6 -12
- package/titleCase.d.ts +4 -3
- package/titleCase.mjs +5 -9
- package/toNumber.mjs +1 -2
- package/toRgba.mjs +3 -5
- package/transformToUrlPathname.mjs +2 -5
- package/truncate.d.ts +1 -1
- package/truncate.mjs +2 -9
- package/tryUntil.d.ts +4 -1
- package/tryUntil.mjs +11 -11
- package/types.mjs +2 -1
- package/typings.d.ts +1 -6
- package/uid.mjs +3 -5
- package/updateLinkParams.mjs +2 -3
- package/updateUrlQueryParams.d.ts +0 -1
- package/updateUrlQueryParams.mjs +3 -8
- package/uppercase.d.ts +1 -0
- package/uppercase.mjs +2 -4
- package/uuid.mjs +2 -5
- package/uuidNumeric.mjs +1 -2
- package/wait.mjs +1 -4
- package/without.mjs +1 -3
- package/Defer.js +0 -30
- package/Emitter.js +0 -42
- package/accentSets.js +0 -41
- package/addOrReplaceAtIdx.js +0 -23
- package/areEqual.js +0 -81
- package/arrayOfAll.js +0 -36
- package/arraySum.js +0 -13
- package/arrayToLookup.js +0 -17
- package/buildUrlQueryString.js +0 -36
- package/capitalize.js +0 -16
- package/changeUrlPath.js +0 -23
- package/chunkByChunks.js +0 -41
- package/chunkBySize.js +0 -16
- package/clamp.js +0 -14
- package/clsx.js +0 -53
- package/convertRange.js +0 -20
- package/cookie.js +0 -13
- package/createPalette.js +0 -26
- package/debounce.js +0 -33
- package/debouncePromise.js +0 -12
- package/debounceRaf.js +0 -31
- package/decode.js +0 -14
- package/encode.js +0 -14
- package/ensureInt.js +0 -13
- package/env.js +0 -3
- package/errorToString.js +0 -15
- package/findDuplicatedIndexes.js +0 -18
- package/forin.js +0 -15
- package/gbToBytes.js +0 -11
- package/getEmptyArray.js +0 -20
- package/getKeys.js +0 -12
- package/getMediaQueryWidthResolvers.js +0 -72
- package/getMediaQueryWidthTailwindScreens.js +0 -33
- package/getNonce.js +0 -13
- package/getParamAmong.js +0 -22
- package/getParamAsInt.js +0 -25
- package/getParamAsString.js +0 -19
- package/getType.js +0 -23
- package/getUrlHashParams.js +0 -20
- package/getUrlHashPathname.js +0 -17
- package/getUrlPathnameParts.js +0 -25
- package/getUrlQueryParams.js +0 -43
- package/imgEmptyPixel.js +0 -10
- package/index.js +0 -267
- package/invariant.js +0 -38
- package/isAnyObject.js +0 -15
- package/isArray.js +0 -15
- package/isBlob.js +0 -15
- package/isBoolean.js +0 -15
- package/isBrowser.js +0 -9
- package/isBrowserNow.js +0 -12
- package/isDate.js +0 -15
- package/isEmptyArray.js +0 -15
- package/isEmptyObject.js +0 -15
- package/isEmptyString.js +0 -13
- package/isError.js +0 -15
- package/isExternalUrl.js +0 -26
- package/isFile.js +0 -15
- package/isFloat.js +0 -15
- package/isFormData.js +0 -15
- package/isFullArray.js +0 -15
- package/isFullObject.js +0 -15
- package/isFullString.js +0 -15
- package/isFunction.js +0 -13
- package/isInt.js +0 -15
- package/isMap.js +0 -15
- package/isNaNValue.js +0 -15
- package/isNegativeNumber.js +0 -15
- package/isNull.js +0 -15
- package/isNullOrUndefined.js +0 -14
- package/isNumber.js +0 -17
- package/isObject.js +0 -15
- package/isObjectLike.js +0 -17
- package/isOneOf.js +0 -14
- package/isPlainObject.js +0 -18
- package/isPositiveNumber.js +0 -15
- package/isPrimitive.js +0 -25
- package/isPromise.js +0 -15
- package/isRegExp.js +0 -15
- package/isServer.js +0 -12
- package/isServerNow.js +0 -12
- package/isSet.js +0 -15
- package/isString.js +0 -15
- package/isSymbol.js +0 -15
- package/isType.js +0 -27
- package/isUndefined.js +0 -15
- package/isWeakMap.js +0 -15
- package/isWeakSet.js +0 -15
- package/kbToBytes.js +0 -11
- package/location.js +0 -2
- package/lowercase.js +0 -13
- package/mapListBy.js +0 -18
- package/matchSorter.js +0 -374
- package/mbToBytes.js +0 -11
- package/mergeObjects.js +0 -41
- package/mergeUrlQueryParams.js +0 -27
- package/moveSortableArrayItemByKey.js +0 -21
- package/noop.js +0 -11
- package/normaliseUrl.js +0 -20
- package/normaliseUrlPathname.js +0 -19
- package/objectOmit.js +0 -23
- package/objectPick.js +0 -19
- package/parseCookie.js +0 -52
- package/parseURL.js +0 -24
- package/quaranteneProps.js +0 -37
- package/randomInt.js +0 -13
- package/randomKey.js +0 -15
- package/readCookie.js +0 -38
- package/removeAccents.js +0 -19
- package/removeCookie.js +0 -19
- package/removeDuplicates.js +0 -13
- package/removeDuplicatesByKey.js +0 -24
- package/removeDuplicatesComparing.js +0 -14
- package/removeIndexesFromArray.js +0 -18
- package/removeTrailingSlash.js +0 -14
- package/removeUrlQueryParams.js +0 -26
- package/render.js +0 -169
- package/roundTo.js +0 -38
- package/serializeCookie.js +0 -108
- package/setCookie.js +0 -62
- package/shuffle.js +0 -36
- package/slugify.js +0 -27
- package/split.js +0 -8
- package/swapMap.js +0 -18
- package/throttle.js +0 -30
- package/titleCase.js +0 -15
- package/toNumber.js +0 -12
- package/toRgba.js +0 -20
- package/transformToUrlPathname.js +0 -21
- package/truncate.js +0 -17
- package/tryUntil.js +0 -31
- package/types.js +0 -2
- package/uid.js +0 -16
- package/updateLinkParams.js +0 -19
- package/updateUrlQueryParams.js +0 -23
- package/uppercase.js +0 -13
- package/uuid.js +0 -17
- package/uuidNumeric.js +0 -10
- package/wait.js +0 -13
- package/without.js +0 -56
package/Defer.js
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Defer = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* @category async
|
|
6
|
-
* @see https://stackoverflow.com/a/37673534/1938970
|
|
7
|
-
* @example
|
|
8
|
-
*
|
|
9
|
-
* ```ts
|
|
10
|
-
* const deferred = Defer();
|
|
11
|
-
* deferred.resolve();
|
|
12
|
-
* deferred.then(handleSuccess, handleError);
|
|
13
|
-
* ```
|
|
14
|
-
*/
|
|
15
|
-
function Defer() {
|
|
16
|
-
// @ts-expect-error nevermind
|
|
17
|
-
var self = this || {};
|
|
18
|
-
var p = (self.promise = new Promise(function (resolve, reject) {
|
|
19
|
-
self.resolve = resolve;
|
|
20
|
-
self.reject = reject;
|
|
21
|
-
}));
|
|
22
|
-
self.then = p.then.bind(p);
|
|
23
|
-
self.catch = p.catch.bind(p);
|
|
24
|
-
// if (p.finally) {
|
|
25
|
-
// self.finally = p.finally.bind(p);
|
|
26
|
-
// }
|
|
27
|
-
return self;
|
|
28
|
-
}
|
|
29
|
-
exports.Defer = Defer;
|
|
30
|
-
exports.default = Defer;
|
package/Emitter.js
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Emitter = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* Emitter super simple class
|
|
6
|
-
*
|
|
7
|
-
* Events will be prefixed with the given `namespace` plus a `.` so:
|
|
8
|
-
* `{namespace}.myevent`
|
|
9
|
-
*
|
|
10
|
-
* Adapted from https://github.com/developit/mitt
|
|
11
|
-
*
|
|
12
|
-
* Regarding typescript support @see:
|
|
13
|
-
* - https://stackoverflow.com/q/53299743/1938970
|
|
14
|
-
* - https://github.com/Microsoft/TypeScript/pull/26349
|
|
15
|
-
*/
|
|
16
|
-
function Emitter(namespace) {
|
|
17
|
-
var all = new Map();
|
|
18
|
-
return {
|
|
19
|
-
/**
|
|
20
|
-
* Register an event handler for the given type.
|
|
21
|
-
*/
|
|
22
|
-
on: function (name, handler) {
|
|
23
|
-
var handlers = all.get("".concat(namespace, ".").concat(String(name)));
|
|
24
|
-
var added = handlers && handlers.push(handler);
|
|
25
|
-
if (!added) {
|
|
26
|
-
all.set("".concat(namespace, ".").concat(String(name)), [handler]);
|
|
27
|
-
}
|
|
28
|
-
},
|
|
29
|
-
/**
|
|
30
|
-
* Invoke all handlers for the given type.
|
|
31
|
-
*/
|
|
32
|
-
emit: function (name, data) {
|
|
33
|
-
(all.get("".concat(namespace, ".").concat(String(name))) || [])
|
|
34
|
-
.slice()
|
|
35
|
-
.map(function (handler) {
|
|
36
|
-
handler(data);
|
|
37
|
-
});
|
|
38
|
-
},
|
|
39
|
-
};
|
|
40
|
-
}
|
|
41
|
-
exports.Emitter = Emitter;
|
|
42
|
-
exports.default = Emitter;
|
package/accentSets.js
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.accentsSets = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* Accent sets
|
|
6
|
-
*
|
|
7
|
-
* @category text
|
|
8
|
-
* @see https://gist.github.com/mathewbyrne/1280286#gistcomment-3498021
|
|
9
|
-
* @see https://gist.github.com/eek/9c4887e80b3ede05c0e39fee4dce3747 for usage
|
|
10
|
-
* of [normalize](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/normalize)
|
|
11
|
-
*/
|
|
12
|
-
exports.accentsSets = [
|
|
13
|
-
["a", "ÀÁÂÃÅÆĀĂĄẠẢẤẦẨẪẬẮẰẲẴẶ"],
|
|
14
|
-
["ae", "Ä"],
|
|
15
|
-
["c", "ÇĆĈČ"],
|
|
16
|
-
["d", "ÐĎĐÞ"],
|
|
17
|
-
["e", "ÈÉÊËĒĔĖĘĚẸẺẼẾỀỂỄỆ"],
|
|
18
|
-
["g", "ĜĞĢǴ"],
|
|
19
|
-
["h", "ĤḦ"],
|
|
20
|
-
["i", "ÌÍÎÏĨĪĮİỈỊ"],
|
|
21
|
-
["j", "Ĵ"],
|
|
22
|
-
["ij", "IJ"],
|
|
23
|
-
["k", "Ķ"],
|
|
24
|
-
["l", "ĹĻĽŁ"],
|
|
25
|
-
["m", "Ḿ"],
|
|
26
|
-
["n", "ÑŃŅŇ"],
|
|
27
|
-
["o", "ÒÓÔÕØŌŎŐỌỎỐỒỔỖỘỚỜỞỠỢǪǬƠ"],
|
|
28
|
-
["oe", "΅"],
|
|
29
|
-
["p", "ṕ"],
|
|
30
|
-
["r", "ŔŖŘ"],
|
|
31
|
-
["s", "ŚŜŞŠ"],
|
|
32
|
-
["ss", "ß"],
|
|
33
|
-
["t", "ŢŤ"],
|
|
34
|
-
["u", "ÙÚÛŨŪŬŮŰŲỤỦỨỪỬỮỰƯ"],
|
|
35
|
-
["ue", "Ü"],
|
|
36
|
-
["w", "ẂŴẀẄ"],
|
|
37
|
-
["x", "ẍ"],
|
|
38
|
-
["y", "ÝŶŸỲỴỶỸ"],
|
|
39
|
-
["z", "ŹŻŽ"],
|
|
40
|
-
];
|
|
41
|
-
exports.default = exports.accentsSets;
|
package/addOrReplaceAtIdx.js
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.addOrReplaceAtIdx = void 0;
|
|
4
|
-
var tslib_1 = require("tslib");
|
|
5
|
-
/**
|
|
6
|
-
* @category array
|
|
7
|
-
*/
|
|
8
|
-
function addOrReplaceAtIdx(list, newItem, newIdx) {
|
|
9
|
-
if (list.length === 0) {
|
|
10
|
-
return [newItem];
|
|
11
|
-
}
|
|
12
|
-
if (typeof newIdx === "undefined" || list.length - 1 < newIdx) {
|
|
13
|
-
return tslib_1.__spreadArray(tslib_1.__spreadArray([], list, true), [newItem], false);
|
|
14
|
-
}
|
|
15
|
-
return list.map(function (item, idx) {
|
|
16
|
-
if (idx === newIdx) {
|
|
17
|
-
return newItem;
|
|
18
|
-
}
|
|
19
|
-
return item;
|
|
20
|
-
});
|
|
21
|
-
}
|
|
22
|
-
exports.addOrReplaceAtIdx = addOrReplaceAtIdx;
|
|
23
|
-
exports.default = addOrReplaceAtIdx;
|
package/areEqual.js
DELETED
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.areEqual = void 0;
|
|
4
|
-
var isArray_1 = require("./isArray");
|
|
5
|
-
var isObject_1 = require("./isObject");
|
|
6
|
-
function areEqualArrays(a, b) {
|
|
7
|
-
if (!b)
|
|
8
|
-
return false;
|
|
9
|
-
if (a.length !== b.length)
|
|
10
|
-
return false;
|
|
11
|
-
for (var i = 0; i < a.length; i++) {
|
|
12
|
-
var aValue = a[i];
|
|
13
|
-
var bValue = b[i];
|
|
14
|
-
if (!areEqual(aValue, bValue))
|
|
15
|
-
return false;
|
|
16
|
-
}
|
|
17
|
-
return true;
|
|
18
|
-
}
|
|
19
|
-
function areEqualObjects(a, b) {
|
|
20
|
-
if (!b)
|
|
21
|
-
return false;
|
|
22
|
-
var aKeys = Object.keys(a);
|
|
23
|
-
var bKeys = Object.keys(b);
|
|
24
|
-
if (aKeys.length !== bKeys.length) {
|
|
25
|
-
return false;
|
|
26
|
-
}
|
|
27
|
-
for (var _i = 0, aKeys_1 = aKeys; _i < aKeys_1.length; _i++) {
|
|
28
|
-
var _key = aKeys_1[_i];
|
|
29
|
-
var key = _key;
|
|
30
|
-
var aValue = a[key];
|
|
31
|
-
var bValue = b[key];
|
|
32
|
-
if (!areEqual(aValue, bValue)) {
|
|
33
|
-
return false;
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
return true;
|
|
37
|
-
}
|
|
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
|
-
function areEqual(a, b) {
|
|
54
|
-
if (!a && !b) {
|
|
55
|
-
// console.log(`areEqual took ${performance.now() - t0} ms`);
|
|
56
|
-
return true;
|
|
57
|
-
}
|
|
58
|
-
// const t0 = performance.now();
|
|
59
|
-
if (!b && a !== b) {
|
|
60
|
-
// console.log(`areEqual took ${performance.now() - t0} ms`);
|
|
61
|
-
return false;
|
|
62
|
-
}
|
|
63
|
-
var areObjects = (0, isObject_1.isObject)(a) && (0, isObject_1.isObject)(b);
|
|
64
|
-
if (areObjects && !areEqualObjects(a, b)) {
|
|
65
|
-
// console.log(`areEqual took ${performance.now() - t0} ms`);
|
|
66
|
-
return false;
|
|
67
|
-
}
|
|
68
|
-
var areArrays = (0, isArray_1.isArray)(a) && (0, isArray_1.isArray)(b);
|
|
69
|
-
if (areArrays && !areEqualArrays(a, b)) {
|
|
70
|
-
// console.log(`areEqual took ${performance.now() - t0} ms`);
|
|
71
|
-
return false;
|
|
72
|
-
}
|
|
73
|
-
if (!areObjects && !areArrays && a !== b) {
|
|
74
|
-
// console.log(`areEqual took ${performance.now() - t0} ms`);
|
|
75
|
-
return false;
|
|
76
|
-
}
|
|
77
|
-
// console.log(`areEqual took ${performance.now() - t0} ms`);
|
|
78
|
-
return true;
|
|
79
|
-
}
|
|
80
|
-
exports.areEqual = areEqual;
|
|
81
|
-
exports.default = areEqual;
|
package/arrayOfAll.js
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.arrayOfAll = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* Ensure an array contains all desired values
|
|
6
|
-
*
|
|
7
|
-
* @category array
|
|
8
|
-
* @borrows [SO comment by `CertainPerformance`](https://stackoverflow.com/a/60132060/1938970)
|
|
9
|
-
*
|
|
10
|
-
* @usage
|
|
11
|
-
*
|
|
12
|
-
* ```
|
|
13
|
-
* type Fruit = "pear" | "apple" | "orange";
|
|
14
|
-
*
|
|
15
|
-
* const arrayOfAllFruits = arrayOfAll<Fruit>();
|
|
16
|
-
*
|
|
17
|
-
* const allFruits = arrayOfAllFruits([
|
|
18
|
-
* "pear",
|
|
19
|
-
* "apple",
|
|
20
|
-
* "orange"
|
|
21
|
-
* ]); // ts compiler ok
|
|
22
|
-
*
|
|
23
|
-
* const allFruits = arrayOfAllFruits([
|
|
24
|
-
* "pear",
|
|
25
|
-
* "apple",
|
|
26
|
-
* ]); // ts compiler fails
|
|
27
|
-
* ```
|
|
28
|
-
*
|
|
29
|
-
*/
|
|
30
|
-
var arrayOfAll = function () {
|
|
31
|
-
return function (array) {
|
|
32
|
-
return array;
|
|
33
|
-
};
|
|
34
|
-
};
|
|
35
|
-
exports.arrayOfAll = arrayOfAll;
|
|
36
|
-
exports.default = exports.arrayOfAll;
|
package/arraySum.js
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.arraySum = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* Sum array of numbers
|
|
6
|
-
*
|
|
7
|
-
* @category array | math
|
|
8
|
-
*/
|
|
9
|
-
var arraySum = function (numbers) {
|
|
10
|
-
return numbers.reduce(function (sum, current) { return sum + current; }, 0);
|
|
11
|
-
};
|
|
12
|
-
exports.arraySum = arraySum;
|
|
13
|
-
exports.default = exports.arraySum;
|
package/arrayToLookup.js
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.arrayToLookup = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* Maps a simple flat array to a lookup dictionary object
|
|
6
|
-
*
|
|
7
|
-
* @category array
|
|
8
|
-
*/
|
|
9
|
-
function arrayToLookup(array) {
|
|
10
|
-
if (array === void 0) { array = []; }
|
|
11
|
-
return array.reduce(function (obj, item) {
|
|
12
|
-
obj[item] = 1;
|
|
13
|
-
return obj;
|
|
14
|
-
}, {});
|
|
15
|
-
}
|
|
16
|
-
exports.arrayToLookup = arrayToLookup;
|
|
17
|
-
exports.default = arrayToLookup;
|
package/buildUrlQueryString.js
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.buildUrlQueryString = void 0;
|
|
4
|
-
var tslib_1 = require("tslib");
|
|
5
|
-
var isNull_1 = tslib_1.__importDefault(require("./isNull"));
|
|
6
|
-
var isUndefined_1 = tslib_1.__importDefault(require("./isUndefined"));
|
|
7
|
-
var isArray_1 = tslib_1.__importDefault(require("./isArray"));
|
|
8
|
-
/**
|
|
9
|
-
* Get clean query string for URL
|
|
10
|
-
*
|
|
11
|
-
* It returns the query string **with** the initial `?`
|
|
12
|
-
*
|
|
13
|
-
* TODO: at some point replace with `URLSearchParams`, @see [caniuse](https://caniuse.com/?search=URLSearchParams)
|
|
14
|
-
*
|
|
15
|
-
* @category location
|
|
16
|
-
*/
|
|
17
|
-
function buildUrlQueryString(params) {
|
|
18
|
-
var output = "";
|
|
19
|
-
if (!params)
|
|
20
|
-
return output;
|
|
21
|
-
for (var key in params) {
|
|
22
|
-
var value = params[key];
|
|
23
|
-
if ((0, isArray_1.default)(value)) {
|
|
24
|
-
for (var i = 0; i < value.length; i++) {
|
|
25
|
-
output += "".concat(key, "=").concat(encodeURIComponent(value[i] + ""), "&");
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
else if (!(0, isNull_1.default)(value) && !(0, isUndefined_1.default)(value)) {
|
|
29
|
-
output += "".concat(key, "=").concat(encodeURIComponent(value + ""), "&");
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
// removes the last &
|
|
33
|
-
return output ? "?".concat(output.replace(/&+$/, "")) : "";
|
|
34
|
-
}
|
|
35
|
-
exports.buildUrlQueryString = buildUrlQueryString;
|
|
36
|
-
exports.default = buildUrlQueryString;
|
package/capitalize.js
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.capitalize = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* Capitalize first letter of the given string.
|
|
6
|
-
*
|
|
7
|
-
* @category text
|
|
8
|
-
* @see https://stackoverflow.com/a/11409944/1938970
|
|
9
|
-
*/
|
|
10
|
-
function capitalize(string) {
|
|
11
|
-
var ensuredString = string || "";
|
|
12
|
-
return (ensuredString.charAt(0).toUpperCase() +
|
|
13
|
-
ensuredString.slice(1));
|
|
14
|
-
}
|
|
15
|
-
exports.capitalize = capitalize;
|
|
16
|
-
exports.default = capitalize;
|
package/changeUrlPath.js
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.changeUrlPath = void 0;
|
|
4
|
-
var tslib_1 = require("tslib");
|
|
5
|
-
var isBrowser_1 = tslib_1.__importDefault(require("./isBrowser"));
|
|
6
|
-
var normaliseUrlPathname_1 = tslib_1.__importDefault(require("./normaliseUrlPathname"));
|
|
7
|
-
/**
|
|
8
|
-
* Change URL path, ensures initial and ending slashes and normalise eventual
|
|
9
|
-
* consecutive slashes, it uses `history`.
|
|
10
|
-
*
|
|
11
|
-
* @category location
|
|
12
|
-
* @param replace Replace URL instead of pushing it in the history stack. By default it pushes it.
|
|
13
|
-
* @returns {string} The new cleaned pathname
|
|
14
|
-
*/
|
|
15
|
-
function changeUrlPath(pathname, state, replace) {
|
|
16
|
-
var path = (0, normaliseUrlPathname_1.default)("/".concat(pathname, "/"));
|
|
17
|
-
if (isBrowser_1.default) {
|
|
18
|
-
history[replace ? "replaceState" : "pushState"](state, "", path);
|
|
19
|
-
}
|
|
20
|
-
return path;
|
|
21
|
-
}
|
|
22
|
-
exports.changeUrlPath = changeUrlPath;
|
|
23
|
-
exports.default = changeUrlPath;
|
package/chunkByChunks.js
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.chunkByChunks = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* TODO: untested
|
|
6
|
-
* @category array
|
|
7
|
-
* @see https://stackoverflow.com/a/8189268/1938970
|
|
8
|
-
*/
|
|
9
|
-
function chunkByChunks(arr, nrOfChunks, balanced) {
|
|
10
|
-
if (nrOfChunks < 2)
|
|
11
|
-
return [arr];
|
|
12
|
-
var len = arr.length;
|
|
13
|
-
var output = [];
|
|
14
|
-
var i = 0;
|
|
15
|
-
var size;
|
|
16
|
-
if (len % nrOfChunks === 0) {
|
|
17
|
-
size = Math.floor(len / nrOfChunks);
|
|
18
|
-
while (i < len) {
|
|
19
|
-
output.push(arr.slice(i, (i += size)));
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
else if (balanced) {
|
|
23
|
-
while (i < len) {
|
|
24
|
-
size = Math.ceil((len - i) / nrOfChunks--);
|
|
25
|
-
output.push(arr.slice(i, (i += size)));
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
else {
|
|
29
|
-
nrOfChunks--;
|
|
30
|
-
size = Math.floor(len / nrOfChunks);
|
|
31
|
-
if (len % size === 0)
|
|
32
|
-
size--;
|
|
33
|
-
while (i < size * nrOfChunks) {
|
|
34
|
-
output.push(arr.slice(i, (i += size)));
|
|
35
|
-
}
|
|
36
|
-
output.push(arr.slice(size * nrOfChunks));
|
|
37
|
-
}
|
|
38
|
-
return output;
|
|
39
|
-
}
|
|
40
|
-
exports.chunkByChunks = chunkByChunks;
|
|
41
|
-
exports.default = chunkByChunks;
|
package/chunkBySize.js
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.chunkBySize = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* @category array
|
|
6
|
-
* @see https://stackoverflow.com/a/40682136/1938970
|
|
7
|
-
*/
|
|
8
|
-
function chunkBySize(arr, size) {
|
|
9
|
-
var output = [];
|
|
10
|
-
for (var i = 0; i < arr.length; i += size) {
|
|
11
|
-
output.push(arr.slice(i, i + size));
|
|
12
|
-
}
|
|
13
|
-
return output;
|
|
14
|
-
}
|
|
15
|
-
exports.chunkBySize = chunkBySize;
|
|
16
|
-
exports.default = chunkBySize;
|
package/clamp.js
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.clamp = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* Returns a number whose value is limited to the given range.
|
|
6
|
-
*
|
|
7
|
-
* @category math
|
|
8
|
-
* @see https://stackoverflow.com/a/11409944/1938970
|
|
9
|
-
*/
|
|
10
|
-
function clamp(num, min, max) {
|
|
11
|
-
return Math.min(Math.max(num, min), max);
|
|
12
|
-
}
|
|
13
|
-
exports.clamp = clamp;
|
|
14
|
-
exports.default = clamp;
|
package/clsx.js
DELETED
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.clsx = void 0;
|
|
4
|
-
// import _clsx from "clsx";
|
|
5
|
-
// export const clsx = _clsx;
|
|
6
|
-
function toVal(mix) {
|
|
7
|
-
var k, y, str = "";
|
|
8
|
-
if (typeof mix === "string" || typeof mix === "number") {
|
|
9
|
-
str += mix;
|
|
10
|
-
}
|
|
11
|
-
else if (typeof mix === "object") {
|
|
12
|
-
if (Array.isArray(mix)) {
|
|
13
|
-
for (k = 0; k < mix.length; k++) {
|
|
14
|
-
if (mix[k]) {
|
|
15
|
-
if ((y = toVal(mix[k]))) {
|
|
16
|
-
str && (str += " ");
|
|
17
|
-
str += y;
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
else {
|
|
23
|
-
for (k in mix) {
|
|
24
|
-
if (mix[k]) {
|
|
25
|
-
str && (str += " ");
|
|
26
|
-
str += k;
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
return str;
|
|
32
|
-
}
|
|
33
|
-
/**
|
|
34
|
-
* Class names utility
|
|
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) {
|
|
42
|
-
// eslint-disable-next-line prefer-rest-params
|
|
43
|
-
if ((tmp = arguments[i++])) {
|
|
44
|
-
if ((x = toVal(tmp))) {
|
|
45
|
-
str && (str += " ");
|
|
46
|
-
str += x;
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
return str;
|
|
51
|
-
};
|
|
52
|
-
exports.clsx = clsx;
|
|
53
|
-
exports.default = exports.clsx;
|
package/convertRange.js
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.convertRange = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* Convert range of a number
|
|
6
|
-
*
|
|
7
|
-
* e.g. converting number 5 in a scale/range from 0 10 to a scale/range from 50
|
|
8
|
-
* to 100 would return 75
|
|
9
|
-
* ```
|
|
10
|
-
* convertRange(5, [0, 10], [50, 100]);
|
|
11
|
-
* ```
|
|
12
|
-
*
|
|
13
|
-
* @category math
|
|
14
|
-
* @see https://stackoverflow.com/a/14224813
|
|
15
|
-
*/
|
|
16
|
-
function convertRange(num, r1, r2) {
|
|
17
|
-
return ((num - r1[0]) * (r2[1] - r2[0])) / (r1[1] - r1[0]) + r2[0];
|
|
18
|
-
}
|
|
19
|
-
exports.convertRange = convertRange;
|
|
20
|
-
exports.default = convertRange;
|
package/cookie.js
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* @file
|
|
4
|
-
*
|
|
5
|
-
* @category cookie
|
|
6
|
-
*
|
|
7
|
-
* All cookie related code is inspired and adapted from:
|
|
8
|
-
* - [js-cookie](https://github.com/js-cookie/js-cookie)
|
|
9
|
-
* - [cookie](https://github.com/jshttp/cookie)
|
|
10
|
-
*/
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.defaultAttributesClient = void 0;
|
|
13
|
-
exports.defaultAttributesClient = { path: "/" };
|
package/createPalette.js
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createPalette = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* Create palette, this is primarily thought to improve the reuse of a palette
|
|
6
|
-
* definition between TailwindCSS and straight ES imports
|
|
7
|
-
*
|
|
8
|
-
* @category styling|tailwind|colours
|
|
9
|
-
*
|
|
10
|
-
* @returns An array with: 1) A flat palette map 2) A TailwindCSS ready palette
|
|
11
|
-
* object 3) A flat array of colors (no special sorting, same order as the `shades`
|
|
12
|
-
* given as argument)
|
|
13
|
-
*/
|
|
14
|
-
var createPalette = function (name, shades) {
|
|
15
|
-
var map = shades.reduce(function (map, def) {
|
|
16
|
-
map[def[0]] = def[1];
|
|
17
|
-
return map;
|
|
18
|
-
}, {});
|
|
19
|
-
var tailwindPalette = shades.reduce(function (map, def) {
|
|
20
|
-
map["".concat(name, "-").concat(def[0])] = def[1];
|
|
21
|
-
return map;
|
|
22
|
-
}, {});
|
|
23
|
-
return [map, tailwindPalette, Object.values(map)];
|
|
24
|
-
};
|
|
25
|
-
exports.createPalette = createPalette;
|
|
26
|
-
exports.default = exports.createPalette;
|
package/debounce.js
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.debounce = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* Debounce function (with `setTimeout`)
|
|
6
|
-
*
|
|
7
|
-
* @category function
|
|
8
|
-
* @borrows [davidwalsh/debounce](https://davidwalsh.name/javascript-debounce-function)
|
|
9
|
-
*/
|
|
10
|
-
function debounce(fn, wait, immediate) {
|
|
11
|
-
var timeout;
|
|
12
|
-
return function () {
|
|
13
|
-
var args = [];
|
|
14
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
15
|
-
args[_i] = arguments[_i];
|
|
16
|
-
}
|
|
17
|
-
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
|
18
|
-
var context = this;
|
|
19
|
-
var later = function () {
|
|
20
|
-
timeout = null;
|
|
21
|
-
if (!immediate)
|
|
22
|
-
fn.apply(context, args);
|
|
23
|
-
};
|
|
24
|
-
var callNow = immediate && !timeout;
|
|
25
|
-
if (timeout)
|
|
26
|
-
clearTimeout(timeout);
|
|
27
|
-
timeout = setTimeout(later, wait);
|
|
28
|
-
if (callNow)
|
|
29
|
-
fn.apply(context, args);
|
|
30
|
-
};
|
|
31
|
-
}
|
|
32
|
-
exports.debounce = debounce;
|
|
33
|
-
exports.default = debounce;
|
package/debouncePromise.js
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.debouncePromise = void 0;
|
|
4
|
-
var ts_debounce_1 = require("ts-debounce");
|
|
5
|
-
/**
|
|
6
|
-
* Debounce function (with `Promise`)
|
|
7
|
-
*
|
|
8
|
-
* @category function
|
|
9
|
-
* @borrows [chodorowicz/ts-debounce](https://github.com/chodorowicz/ts-debounce)
|
|
10
|
-
*/
|
|
11
|
-
exports.debouncePromise = ts_debounce_1.debounce;
|
|
12
|
-
exports.default = exports.debouncePromise;
|
package/debounceRaf.js
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.debounceRaf = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* Debounce function (with `requestAnimationFrame`)
|
|
6
|
-
*
|
|
7
|
-
* (c) 2021 Chris Ferdinandi, MIT License, https://gomakethings.com
|
|
8
|
-
* @category function
|
|
9
|
-
* @borrows [vanillajstoolkit/debounce](https://vanillajstoolkit.com/helpers/debounce/)
|
|
10
|
-
*/
|
|
11
|
-
function debounceRaf(fn) {
|
|
12
|
-
var timeout;
|
|
13
|
-
return function () {
|
|
14
|
-
var args = [];
|
|
15
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
16
|
-
args[_i] = arguments[_i];
|
|
17
|
-
}
|
|
18
|
-
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
|
19
|
-
var context = this;
|
|
20
|
-
// If there's a timer, cancel it
|
|
21
|
-
if (timeout) {
|
|
22
|
-
window.cancelAnimationFrame(timeout);
|
|
23
|
-
}
|
|
24
|
-
// Setup the new requestAnimationFrame()
|
|
25
|
-
timeout = window.requestAnimationFrame(function () {
|
|
26
|
-
fn.apply(context, args);
|
|
27
|
-
});
|
|
28
|
-
};
|
|
29
|
-
}
|
|
30
|
-
exports.debounceRaf = debounceRaf;
|
|
31
|
-
exports.default = debounceRaf;
|
package/decode.js
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.decode = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* @category security
|
|
6
|
-
* @see https://stackoverflow.com/a/22405578/9122820
|
|
7
|
-
*/
|
|
8
|
-
function decode(str) {
|
|
9
|
-
return str.replace(/.{3}/g, function (c) {
|
|
10
|
-
return String.fromCharCode(parseInt(c, 10));
|
|
11
|
-
});
|
|
12
|
-
}
|
|
13
|
-
exports.decode = decode;
|
|
14
|
-
exports.default = decode;
|
package/encode.js
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.encode = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* @category security
|
|
6
|
-
* @see https://stackoverflow.com/a/22405578/9122820
|
|
7
|
-
*/
|
|
8
|
-
function encode(str) {
|
|
9
|
-
return str.replace(/./g, function (c) {
|
|
10
|
-
return ("00" + c.charCodeAt(0)).slice(-3);
|
|
11
|
-
});
|
|
12
|
-
}
|
|
13
|
-
exports.encode = encode;
|
|
14
|
-
exports.default = encode;
|