@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
|
@@ -1,21 +1,35 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.moveSortableArrayItemByKey = void 0;
|
|
4
|
-
var tslib_1 = require("tslib");
|
|
5
1
|
/**
|
|
6
2
|
* Move item from one place to another in a sortable array of objects, re-ordering
|
|
7
3
|
* the array accrodingly (no swapping of position).
|
|
8
4
|
* This is useful for drag and drop functionalities
|
|
9
5
|
*
|
|
10
6
|
* @category arrays, dnd
|
|
11
|
-
*/
|
|
7
|
+
*/ "use strict";
|
|
8
|
+
Object.defineProperty(exports, "__esModule", {
|
|
9
|
+
value: true
|
|
10
|
+
});
|
|
11
|
+
function _export(target, all) {
|
|
12
|
+
for(var name in all)Object.defineProperty(target, name, {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: all[name]
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
_export(exports, {
|
|
18
|
+
moveSortableArrayItemByKey: function() {
|
|
19
|
+
return moveSortableArrayItemByKey;
|
|
20
|
+
},
|
|
21
|
+
default: function() {
|
|
22
|
+
return _default;
|
|
23
|
+
}
|
|
24
|
+
});
|
|
12
25
|
function moveSortableArrayItemByKey(items, key, fromItem, toItem) {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
26
|
+
const itemsKeys = items.map((item)=>item[key]);
|
|
27
|
+
const idxFrom = itemsKeys.indexOf(fromItem[key]);
|
|
28
|
+
const idxTo = itemsKeys.indexOf(toItem[key]);
|
|
29
|
+
const [item] = items.splice(idxFrom, 1);
|
|
17
30
|
items.splice(idxTo, 0, item);
|
|
18
|
-
return
|
|
31
|
+
return [
|
|
32
|
+
...items
|
|
33
|
+
];
|
|
19
34
|
}
|
|
20
|
-
|
|
21
|
-
exports.default = moveSortableArrayItemByKey;
|
|
35
|
+
const _default = moveSortableArrayItemByKey;
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import { __spreadArray } from "tslib";
|
|
2
1
|
/**
|
|
3
2
|
* Move item from one place to another in a sortable array of objects, re-ordering
|
|
4
3
|
* the array accrodingly (no swapping of position).
|
|
5
4
|
* This is useful for drag and drop functionalities
|
|
6
5
|
*
|
|
7
6
|
* @category arrays, dnd
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
var item = items.splice(idxFrom, 1)[0];
|
|
7
|
+
*/ export function moveSortableArrayItemByKey(items, key, fromItem, toItem) {
|
|
8
|
+
const itemsKeys = items.map((item)=>item[key]);
|
|
9
|
+
const idxFrom = itemsKeys.indexOf(fromItem[key]);
|
|
10
|
+
const idxTo = itemsKeys.indexOf(toItem[key]);
|
|
11
|
+
const [item] = items.splice(idxFrom, 1);
|
|
14
12
|
items.splice(idxTo, 0, item);
|
|
15
|
-
return
|
|
13
|
+
return [
|
|
14
|
+
...items
|
|
15
|
+
];
|
|
16
16
|
}
|
|
17
17
|
export default moveSortableArrayItemByKey;
|
package/noop.js
CHANGED
|
@@ -1,11 +1,24 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.noop = void 0;
|
|
4
1
|
/**
|
|
5
2
|
* No operation function
|
|
6
3
|
*
|
|
7
4
|
* @category native
|
|
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
|
+
noop: function() {
|
|
17
|
+
return noop;
|
|
18
|
+
},
|
|
19
|
+
default: function() {
|
|
20
|
+
return _default;
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
const noop = ()=>void 0;
|
|
24
|
+
const _default = noop;
|
package/noop.mjs
CHANGED
package/normaliseUrl.js
CHANGED
|
@@ -1,20 +1,24 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
* - removes the trailing slash
|
|
11
|
-
*
|
|
12
|
-
* @category location
|
|
13
|
-
* @see https://stackoverflow.com/a/40649435/1938970
|
|
14
|
-
*/
|
|
15
|
-
function normaliseUrl(absoluteUrl) {
|
|
16
|
-
if (absoluteUrl === void 0) { absoluteUrl = ""; }
|
|
17
|
-
return (0, removeTrailingSlash_1.default)(absoluteUrl.replace(/(:\/\/)|(\/)+/g, "$1$2"));
|
|
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
|
+
});
|
|
18
10
|
}
|
|
19
|
-
exports
|
|
20
|
-
|
|
11
|
+
_export(exports, {
|
|
12
|
+
normaliseUrl: function() {
|
|
13
|
+
return normaliseUrl;
|
|
14
|
+
},
|
|
15
|
+
default: function() {
|
|
16
|
+
return _default;
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
const _interop_require_default = require("@swc/helpers/_/_interop_require_default");
|
|
20
|
+
const _removeTrailingSlash = /*#__PURE__*/ _interop_require_default._(require("./removeTrailingSlash"));
|
|
21
|
+
function normaliseUrl(absoluteUrl = "") {
|
|
22
|
+
return (0, _removeTrailingSlash.default)(absoluteUrl.replace(/(:\/\/)|(\/)+/g, "$1$2"));
|
|
23
|
+
}
|
|
24
|
+
const _default = normaliseUrl;
|
package/normaliseUrl.mjs
CHANGED
|
@@ -7,9 +7,7 @@ import removeTralingSlash from "./removeTrailingSlash";
|
|
|
7
7
|
*
|
|
8
8
|
* @category location
|
|
9
9
|
* @see https://stackoverflow.com/a/40649435/1938970
|
|
10
|
-
*/
|
|
11
|
-
export function normaliseUrl(absoluteUrl) {
|
|
12
|
-
if (absoluteUrl === void 0) { absoluteUrl = ""; }
|
|
10
|
+
*/ export function normaliseUrl(absoluteUrl = "") {
|
|
13
11
|
return removeTralingSlash(absoluteUrl.replace(/(:\/\/)|(\/)+/g, "$1$2"));
|
|
14
12
|
}
|
|
15
13
|
export default normaliseUrl;
|
package/normaliseUrlPathname.js
CHANGED
|
@@ -1,19 +1,24 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
* - removes the trailing slash
|
|
11
|
-
*
|
|
12
|
-
* @category location
|
|
13
|
-
*/
|
|
14
|
-
function normaliseUrlPathname(pathname) {
|
|
15
|
-
if (pathname === void 0) { pathname = ""; }
|
|
16
|
-
return (0, removeTrailingSlash_1.default)(pathname.replace(/\/+/g, "/"));
|
|
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
|
+
normaliseUrlPathname: function() {
|
|
13
|
+
return normaliseUrlPathname;
|
|
14
|
+
},
|
|
15
|
+
default: function() {
|
|
16
|
+
return _default;
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
const _interop_require_default = require("@swc/helpers/_/_interop_require_default");
|
|
20
|
+
const _removeTrailingSlash = /*#__PURE__*/ _interop_require_default._(require("./removeTrailingSlash"));
|
|
21
|
+
function normaliseUrlPathname(pathname = "") {
|
|
22
|
+
return (0, _removeTrailingSlash.default)(pathname.replace(/\/+/g, "/"));
|
|
23
|
+
}
|
|
24
|
+
const _default = normaliseUrlPathname;
|
package/normaliseUrlPathname.mjs
CHANGED
|
@@ -6,9 +6,7 @@ import removeTralingSlash from "./removeTrailingSlash";
|
|
|
6
6
|
* - removes the trailing slash
|
|
7
7
|
*
|
|
8
8
|
* @category location
|
|
9
|
-
*/
|
|
10
|
-
export function normaliseUrlPathname(pathname) {
|
|
11
|
-
if (pathname === void 0) { pathname = ""; }
|
|
9
|
+
*/ export function normaliseUrlPathname(pathname = "") {
|
|
12
10
|
return removeTralingSlash(pathname.replace(/\/+/g, "/"));
|
|
13
11
|
}
|
|
14
12
|
export default normaliseUrlPathname;
|
package/objectOmit.js
CHANGED
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.objectOmit = void 0;
|
|
4
1
|
/**
|
|
5
2
|
* Omit object properties by removing the given keys, it returns a
|
|
6
3
|
* new object.
|
|
@@ -9,15 +6,30 @@ exports.objectOmit = void 0;
|
|
|
9
6
|
* use this utility only when it makes sense.
|
|
10
7
|
*
|
|
11
8
|
* @category objects
|
|
12
|
-
*/
|
|
9
|
+
*/ "use strict";
|
|
10
|
+
Object.defineProperty(exports, "__esModule", {
|
|
11
|
+
value: true
|
|
12
|
+
});
|
|
13
|
+
function _export(target, all) {
|
|
14
|
+
for(var name in all)Object.defineProperty(target, name, {
|
|
15
|
+
enumerable: true,
|
|
16
|
+
get: all[name]
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
_export(exports, {
|
|
20
|
+
objectOmit: function() {
|
|
21
|
+
return objectOmit;
|
|
22
|
+
},
|
|
23
|
+
default: function() {
|
|
24
|
+
return _default;
|
|
25
|
+
}
|
|
26
|
+
});
|
|
13
27
|
function objectOmit(object, keys) {
|
|
14
|
-
return Object.keys(object).reduce(
|
|
28
|
+
return Object.keys(object).reduce((output, key)=>{
|
|
15
29
|
if (!keys.includes(key)) {
|
|
16
|
-
output[key] =
|
|
17
|
-
object[key];
|
|
30
|
+
output[key] = object[key];
|
|
18
31
|
}
|
|
19
32
|
return output;
|
|
20
33
|
}, {});
|
|
21
34
|
}
|
|
22
|
-
|
|
23
|
-
exports.default = objectOmit;
|
|
35
|
+
const _default = objectOmit;
|
package/objectOmit.mjs
CHANGED
|
@@ -6,12 +6,10 @@
|
|
|
6
6
|
* use this utility only when it makes sense.
|
|
7
7
|
*
|
|
8
8
|
* @category objects
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
return Object.keys(object).reduce(function (output, key) {
|
|
9
|
+
*/ export function objectOmit(object, keys) {
|
|
10
|
+
return Object.keys(object).reduce((output, key)=>{
|
|
12
11
|
if (!keys.includes(key)) {
|
|
13
|
-
output[key] =
|
|
14
|
-
object[key];
|
|
12
|
+
output[key] = object[key];
|
|
15
13
|
}
|
|
16
14
|
return output;
|
|
17
15
|
}, {});
|
package/objectPick.js
CHANGED
|
@@ -1,19 +1,32 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.objectPick = void 0;
|
|
4
1
|
/**
|
|
5
2
|
* Pick object properties by selecting only the given keys, it returns a
|
|
6
3
|
* new object.
|
|
7
4
|
*
|
|
8
5
|
* @category objects
|
|
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
|
+
objectPick: function() {
|
|
18
|
+
return objectPick;
|
|
19
|
+
},
|
|
20
|
+
default: function() {
|
|
21
|
+
return _default;
|
|
22
|
+
}
|
|
23
|
+
});
|
|
10
24
|
function objectPick(object, keys) {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
while
|
|
25
|
+
const output = {};
|
|
26
|
+
let len = keys.length;
|
|
27
|
+
while(len--){
|
|
14
28
|
output[keys[len]] = object[keys[len]];
|
|
15
29
|
}
|
|
16
30
|
return output;
|
|
17
31
|
}
|
|
18
|
-
|
|
19
|
-
exports.default = objectPick;
|
|
32
|
+
const _default = objectPick;
|
package/objectPick.mjs
CHANGED
|
@@ -3,11 +3,10 @@
|
|
|
3
3
|
* new object.
|
|
4
4
|
*
|
|
5
5
|
* @category objects
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
while (len--) {
|
|
6
|
+
*/ export function objectPick(object, keys) {
|
|
7
|
+
const output = {};
|
|
8
|
+
let len = keys.length;
|
|
9
|
+
while(len--){
|
|
11
10
|
output[keys[len]] = object[keys[len]];
|
|
12
11
|
}
|
|
13
12
|
return output;
|
package/package.json
CHANGED
|
@@ -2,15 +2,18 @@
|
|
|
2
2
|
"name": "@koine/utils",
|
|
3
3
|
"sideEffects": false,
|
|
4
4
|
"dependencies": {
|
|
5
|
-
"clsx": "1.2.1",
|
|
5
|
+
"clsx": "^1.2.1",
|
|
6
6
|
"ts-debounce": "^4.0.0",
|
|
7
|
-
"type-fest": "^3.
|
|
8
|
-
},
|
|
9
|
-
"peerDependencies": {
|
|
10
|
-
"tslib": "2.5.3"
|
|
7
|
+
"type-fest": "^3.12.0"
|
|
11
8
|
},
|
|
9
|
+
"module": "./index.mjs",
|
|
12
10
|
"main": "./index.js",
|
|
11
|
+
"exports": {
|
|
12
|
+
".": {
|
|
13
|
+
"import": "./index.js",
|
|
14
|
+
"require": "./index.js"
|
|
15
|
+
}
|
|
16
|
+
},
|
|
13
17
|
"types": "./index.d.ts",
|
|
14
|
-
"version": "2.0.0-beta.
|
|
15
|
-
|
|
16
|
-
}
|
|
18
|
+
"version": "2.0.0-beta.4"
|
|
19
|
+
}
|
package/parseCookie.js
CHANGED
|
@@ -1,44 +1,48 @@
|
|
|
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
|
+
parseCookie: function() {
|
|
13
|
+
return parseCookie;
|
|
14
|
+
},
|
|
15
|
+
default: function() {
|
|
16
|
+
return _default;
|
|
17
|
+
}
|
|
18
|
+
});
|
|
4
19
|
/**
|
|
5
20
|
* Try decoding a string using a decoding function.
|
|
6
|
-
*/
|
|
7
|
-
function tryDecode(str, decode) {
|
|
21
|
+
*/ function tryDecode(str, decode) {
|
|
8
22
|
try {
|
|
9
23
|
return decode(str);
|
|
10
|
-
}
|
|
11
|
-
catch (e) {
|
|
24
|
+
} catch (e) {
|
|
12
25
|
return str;
|
|
13
26
|
}
|
|
14
27
|
}
|
|
15
|
-
|
|
16
|
-
* Parse a cookie header.
|
|
17
|
-
*
|
|
18
|
-
* Parse the given cookie header string into an object
|
|
19
|
-
* The object has the various cookies as keys(names) => values
|
|
20
|
-
*
|
|
21
|
-
* @category cookie
|
|
22
|
-
*/
|
|
23
|
-
function parseCookie(str, attributes) {
|
|
24
|
-
if (attributes === void 0) { attributes = {}; }
|
|
28
|
+
function parseCookie(str, attributes = {}) {
|
|
25
29
|
if (typeof str !== "string") {
|
|
26
30
|
throw new TypeError("argument str must be a string");
|
|
27
31
|
}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
for
|
|
32
|
-
|
|
33
|
-
|
|
32
|
+
const obj = {};
|
|
33
|
+
const pairs = str.split(";");
|
|
34
|
+
const { decode = decodeURIComponent } = attributes;
|
|
35
|
+
for(let i = 0; i < pairs.length; i++){
|
|
36
|
+
const pair = pairs[i];
|
|
37
|
+
const index = pair.indexOf("=");
|
|
34
38
|
// skip things that don't look like key=value
|
|
35
39
|
if (index < 0) {
|
|
36
40
|
continue;
|
|
37
41
|
}
|
|
38
|
-
|
|
42
|
+
const key = pair.substring(0, index).trim();
|
|
39
43
|
// only assign once
|
|
40
44
|
if (undefined == obj[key]) {
|
|
41
|
-
|
|
45
|
+
let val = pair.substring(index + 1, pair.length).trim();
|
|
42
46
|
// quoted values
|
|
43
47
|
if (val[0] === '"') {
|
|
44
48
|
val = val.slice(1, -1);
|
|
@@ -48,5 +52,4 @@ function parseCookie(str, attributes) {
|
|
|
48
52
|
}
|
|
49
53
|
return obj;
|
|
50
54
|
}
|
|
51
|
-
|
|
52
|
-
exports.default = parseCookie;
|
|
55
|
+
const _default = parseCookie;
|
package/parseCookie.mjs
CHANGED
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Try decoding a string using a decoding function.
|
|
3
|
-
*/
|
|
4
|
-
function tryDecode(str, decode) {
|
|
3
|
+
*/ function tryDecode(str, decode) {
|
|
5
4
|
try {
|
|
6
5
|
return decode(str);
|
|
7
|
-
}
|
|
8
|
-
catch (e) {
|
|
6
|
+
} catch (e) {
|
|
9
7
|
return str;
|
|
10
8
|
}
|
|
11
9
|
}
|
|
@@ -16,26 +14,24 @@ function tryDecode(str, decode) {
|
|
|
16
14
|
* The object has the various cookies as keys(names) => values
|
|
17
15
|
*
|
|
18
16
|
* @category cookie
|
|
19
|
-
*/
|
|
20
|
-
export function parseCookie(str, attributes) {
|
|
21
|
-
if (attributes === void 0) { attributes = {}; }
|
|
17
|
+
*/ export function parseCookie(str, attributes = {}) {
|
|
22
18
|
if (typeof str !== "string") {
|
|
23
19
|
throw new TypeError("argument str must be a string");
|
|
24
20
|
}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
for
|
|
29
|
-
|
|
30
|
-
|
|
21
|
+
const obj = {};
|
|
22
|
+
const pairs = str.split(";");
|
|
23
|
+
const { decode = decodeURIComponent } = attributes;
|
|
24
|
+
for(let i = 0; i < pairs.length; i++){
|
|
25
|
+
const pair = pairs[i];
|
|
26
|
+
const index = pair.indexOf("=");
|
|
31
27
|
// skip things that don't look like key=value
|
|
32
28
|
if (index < 0) {
|
|
33
29
|
continue;
|
|
34
30
|
}
|
|
35
|
-
|
|
31
|
+
const key = pair.substring(0, index).trim();
|
|
36
32
|
// only assign once
|
|
37
33
|
if (undefined == obj[key]) {
|
|
38
|
-
|
|
34
|
+
let val = pair.substring(index + 1, pair.length).trim();
|
|
39
35
|
// quoted values
|
|
40
36
|
if (val[0] === '"') {
|
|
41
37
|
val = val.slice(1, -1);
|
package/parseURL.js
CHANGED
|
@@ -1,15 +1,29 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.parseURL = void 0;
|
|
4
1
|
/**
|
|
5
2
|
* Solution without DOM or specific env native methods
|
|
6
3
|
*
|
|
7
4
|
* @category location
|
|
8
5
|
* @see https://stackoverflow.com/a/21553982/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
|
+
parseURL: function() {
|
|
18
|
+
return parseURL;
|
|
19
|
+
},
|
|
20
|
+
default: function() {
|
|
21
|
+
return _default;
|
|
22
|
+
}
|
|
23
|
+
});
|
|
10
24
|
function parseURL(url) {
|
|
11
|
-
|
|
12
|
-
return
|
|
25
|
+
const match = url.match(/^(https?:)\/\/(([^:/?#]*)(?::([0-9]+))?)([/]{0,1}[^?#]*)(\?[^#]*|)(#.*|)$/);
|
|
26
|
+
return match && {
|
|
13
27
|
href: url,
|
|
14
28
|
protocol: match[1],
|
|
15
29
|
host: match[2],
|
|
@@ -17,8 +31,7 @@ function parseURL(url) {
|
|
|
17
31
|
port: match[4],
|
|
18
32
|
pathname: match[5],
|
|
19
33
|
search: match[6],
|
|
20
|
-
hash: match[7]
|
|
21
|
-
}
|
|
34
|
+
hash: match[7]
|
|
35
|
+
};
|
|
22
36
|
}
|
|
23
|
-
|
|
24
|
-
exports.default = parseURL;
|
|
37
|
+
const _default = parseURL;
|
package/parseURL.mjs
CHANGED
|
@@ -3,10 +3,9 @@
|
|
|
3
3
|
*
|
|
4
4
|
* @category location
|
|
5
5
|
* @see https://stackoverflow.com/a/21553982/1938970
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
return (match && {
|
|
6
|
+
*/ export function parseURL(url) {
|
|
7
|
+
const match = url.match(/^(https?:)\/\/(([^:/?#]*)(?::([0-9]+))?)([/]{0,1}[^?#]*)(\?[^#]*|)(#.*|)$/);
|
|
8
|
+
return match && {
|
|
10
9
|
href: url,
|
|
11
10
|
protocol: match[1],
|
|
12
11
|
host: match[2],
|
|
@@ -14,7 +13,7 @@ export function parseURL(url) {
|
|
|
14
13
|
port: match[4],
|
|
15
14
|
pathname: match[5],
|
|
16
15
|
search: match[6],
|
|
17
|
-
hash: match[7]
|
|
18
|
-
}
|
|
16
|
+
hash: match[7]
|
|
17
|
+
};
|
|
19
18
|
}
|
|
20
19
|
export default parseURL;
|
package/quaranteneProps.js
CHANGED
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.quaranteneProps = void 0;
|
|
4
1
|
/**
|
|
5
2
|
* @category impl
|
|
6
3
|
* @usage
|
|
@@ -15,23 +12,38 @@ exports.quaranteneProps = void 0;
|
|
|
15
12
|
* "onKeyDown",
|
|
16
13
|
* ]);
|
|
17
14
|
* ```
|
|
18
|
-
*/
|
|
15
|
+
*/ "use strict";
|
|
16
|
+
Object.defineProperty(exports, "__esModule", {
|
|
17
|
+
value: true
|
|
18
|
+
});
|
|
19
|
+
function _export(target, all) {
|
|
20
|
+
for(var name in all)Object.defineProperty(target, name, {
|
|
21
|
+
enumerable: true,
|
|
22
|
+
get: all[name]
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
_export(exports, {
|
|
26
|
+
quaranteneProps: function() {
|
|
27
|
+
return quaranteneProps;
|
|
28
|
+
},
|
|
29
|
+
default: function() {
|
|
30
|
+
return _default;
|
|
31
|
+
}
|
|
32
|
+
});
|
|
19
33
|
function quaranteneProps(props, propsKeysToQuarantene) {
|
|
20
34
|
// approach 1)
|
|
21
|
-
|
|
22
|
-
_: {}
|
|
35
|
+
const healthyProps = {
|
|
36
|
+
_: {}
|
|
23
37
|
};
|
|
24
|
-
for
|
|
25
|
-
|
|
38
|
+
for(const key in props){
|
|
39
|
+
const prop = props[key];
|
|
26
40
|
if (propsKeysToQuarantene.includes(key)) {
|
|
27
41
|
healthyProps._[key] = prop;
|
|
28
|
-
}
|
|
29
|
-
else {
|
|
42
|
+
} else {
|
|
30
43
|
// @ts-expect-error nevermind
|
|
31
44
|
healthyProps[key] = prop;
|
|
32
45
|
}
|
|
33
46
|
}
|
|
34
47
|
return healthyProps;
|
|
35
48
|
}
|
|
36
|
-
|
|
37
|
-
exports.default = quaranteneProps;
|
|
49
|
+
const _default = quaranteneProps;
|
package/quaranteneProps.mjs
CHANGED
|
@@ -12,18 +12,16 @@
|
|
|
12
12
|
* "onKeyDown",
|
|
13
13
|
* ]);
|
|
14
14
|
* ```
|
|
15
|
-
*/
|
|
16
|
-
export function quaranteneProps(props, propsKeysToQuarantene) {
|
|
15
|
+
*/ export function quaranteneProps(props, propsKeysToQuarantene) {
|
|
17
16
|
// approach 1)
|
|
18
|
-
|
|
19
|
-
_: {}
|
|
17
|
+
const healthyProps = {
|
|
18
|
+
_: {}
|
|
20
19
|
};
|
|
21
|
-
for
|
|
22
|
-
|
|
20
|
+
for(const key in props){
|
|
21
|
+
const prop = props[key];
|
|
23
22
|
if (propsKeysToQuarantene.includes(key)) {
|
|
24
23
|
healthyProps._[key] = prop;
|
|
25
|
-
}
|
|
26
|
-
else {
|
|
24
|
+
} else {
|
|
27
25
|
// @ts-expect-error nevermind
|
|
28
26
|
healthyProps[key] = prop;
|
|
29
27
|
}
|