@koine/utils 1.1.10 → 1.1.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.js +6 -2
- package/{node/Defer.js → Defer.mjs} +2 -6
- package/Emitter.js +6 -2
- package/{node/Emitter.js → Emitter.mjs} +2 -6
- package/accentSets.js +5 -2
- package/{node/accentSets.js → accentSets.mjs} +2 -5
- package/addOrReplaceAtIdx.js +8 -4
- package/addOrReplaceAtIdx.mjs +19 -0
- package/areEqual.js +10 -6
- package/{node/areEqual.js → areEqual.mjs} +6 -10
- package/arrayOfAll.js +6 -2
- package/{node/arrayOfAll.js → arrayOfAll.mjs} +2 -6
- package/arraySum.js +6 -2
- package/arraySum.mjs +9 -0
- package/arrayToLookup.js +6 -2
- package/{node/arrayToLookup.js → arrayToLookup.mjs} +2 -6
- package/buildUrlQueryString.js +12 -7
- package/{node/buildUrlQueryString.js → buildUrlQueryString.mjs} +7 -12
- package/capitalize.js +6 -2
- package/{node/capitalize.js → capitalize.mjs} +2 -6
- package/changeUrlPath.js +11 -6
- package/changeUrlPath.mjs +18 -0
- package/chunkByChunks.js +6 -2
- package/{node/chunkByChunks.js → chunkByChunks.mjs} +2 -6
- package/chunkBySize.js +6 -2
- package/{node/chunkBySize.js → chunkBySize.mjs} +2 -6
- package/clamp.js +6 -2
- package/{node/clamp.js → clamp.mjs} +2 -6
- package/clsx.js +6 -2
- package/{node/clsx.js → clsx.mjs} +2 -6
- package/convertRange.js +6 -2
- package/{node/convertRange.js → convertRange.mjs} +2 -6
- package/cookie.js +4 -1
- package/{node/cookie.js → cookie.mjs} +1 -4
- package/debounce.js +6 -2
- package/{node/debounce.js → debounce.mjs} +2 -6
- package/debouncePromise.js +6 -3
- package/debouncePromise.mjs +9 -0
- package/debounceRaf.js +6 -2
- package/{node/debounceRaf.js → debounceRaf.mjs} +2 -6
- package/decode.js +6 -2
- package/{node/decode.js → decode.mjs} +2 -6
- package/encode.js +6 -2
- package/{node/encode.js → encode.mjs} +2 -6
- package/ensureInt.js +6 -2
- package/ensureInt.mjs +9 -0
- package/{node/env.js → env.mjs} +0 -0
- package/findDuplicatedIndexes.js +6 -2
- package/{node/findDuplicatedIndexes.js → findDuplicatedIndexes.mjs} +2 -6
- package/forin.js +6 -2
- package/forin.mjs +11 -0
- package/gbToBytes.js +6 -2
- package/gbToBytes.mjs +7 -0
- package/getEmptyArray.js +9 -4
- package/getEmptyArray.mjs +15 -0
- package/getKeys.js +5 -2
- package/{node/getKeys.js → getKeys.mjs} +2 -5
- package/getMediaQueryWidthResolvers.js +8 -4
- package/{node/getMediaQueryWidthResolvers.js → getMediaQueryWidthResolvers.mjs} +4 -8
- package/getMediaQueryWidthTailwindScreens.js +8 -4
- package/{node/getMediaQueryWidthTailwindScreens.js → getMediaQueryWidthTailwindScreens.mjs} +4 -8
- package/getNonce.js +8 -4
- package/getNonce.mjs +9 -0
- package/getParamAmong.js +9 -4
- package/{node/getParamAmong.js → getParamAmong.mjs} +4 -9
- package/getParamAsInt.js +9 -4
- package/{node/getParamAsInt.js → getParamAsInt.mjs} +4 -9
- package/getParamAsString.js +9 -4
- package/getParamAsString.mjs +14 -0
- package/getType.js +6 -2
- package/{node/getType.js → getType.mjs} +2 -6
- package/getUrlHashParams.js +6 -2
- package/{node/getUrlHashParams.js → getUrlHashParams.mjs} +2 -6
- package/getUrlHashPathname.js +6 -2
- package/{node/getUrlHashPathname.js → getUrlHashPathname.mjs} +2 -6
- package/getUrlPathnameParts.js +9 -4
- package/{node/getUrlPathnameParts.js → getUrlPathnameParts.mjs} +4 -9
- package/getUrlQueryParams.js +9 -4
- package/{node/getUrlQueryParams.js → getUrlQueryParams.mjs} +4 -9
- package/imgEmptyPixel.js +5 -2
- package/imgEmptyPixel.mjs +7 -0
- package/index.js +132 -129
- package/index.mjs +131 -0
- package/invariant.js +6 -2
- package/{node/invariant.js → invariant.mjs} +2 -6
- package/isAnyObject.js +9 -4
- package/isAnyObject.mjs +10 -0
- package/isArray.js +9 -4
- package/isArray.mjs +10 -0
- package/isBlob.js +9 -4
- package/isBlob.mjs +10 -0
- package/isBoolean.js +9 -4
- package/isBoolean.mjs +10 -0
- package/isBrowser.js +5 -2
- package/isBrowser.mjs +8 -0
- package/isDate.js +9 -4
- package/isDate.mjs +10 -0
- package/isEmptyArray.js +9 -4
- package/isEmptyArray.mjs +10 -0
- package/isEmptyObject.js +9 -4
- package/isEmptyObject.mjs +10 -0
- package/isEmptyString.js +6 -2
- package/isEmptyString.mjs +9 -0
- package/isError.js +9 -4
- package/isError.mjs +10 -0
- package/isExternalUrl.js +9 -4
- package/{node/isExternalUrl.js → isExternalUrl.mjs} +4 -9
- package/isFile.js +9 -4
- package/isFile.mjs +10 -0
- package/isFloat.js +9 -4
- package/isFloat.mjs +10 -0
- package/isFormData.js +9 -4
- package/isFormData.mjs +10 -0
- package/isFullArray.js +9 -4
- package/isFullArray.mjs +10 -0
- package/isFullObject.js +9 -4
- package/isFullObject.mjs +10 -0
- package/isFullString.js +9 -4
- package/isFullString.mjs +10 -0
- package/isFunction.js +6 -2
- package/isFunction.mjs +9 -0
- package/isInt.js +9 -4
- package/isInt.mjs +10 -0
- package/isMap.js +9 -4
- package/isMap.mjs +10 -0
- package/isNaNValue.js +9 -4
- package/isNaNValue.mjs +10 -0
- package/isNegativeNumber.js +9 -4
- package/isNegativeNumber.mjs +10 -0
- package/isNull.js +9 -4
- package/isNull.mjs +10 -0
- package/isNullOrUndefined.js +9 -5
- package/isNullOrUndefined.mjs +10 -0
- package/isNumber.js +9 -4
- package/isNumber.mjs +12 -0
- package/isObject.js +9 -4
- package/isObject.mjs +10 -0
- package/isObjectLike.js +9 -4
- package/isObjectLike.mjs +12 -0
- package/isOneOf.js +6 -2
- package/isOneOf.mjs +10 -0
- package/isPlainObject.js +9 -4
- package/isPlainObject.mjs +13 -0
- package/isPositiveNumber.js +9 -4
- package/isPositiveNumber.mjs +10 -0
- package/isPrimitive.js +19 -14
- package/isPrimitive.mjs +20 -0
- package/isPromise.js +9 -4
- package/isPromise.mjs +10 -0
- package/isRegExp.js +9 -4
- package/isRegExp.mjs +10 -0
- package/isServer.js +7 -3
- package/isServer.mjs +9 -0
- package/isSet.js +9 -4
- package/isSet.mjs +10 -0
- package/isString.js +9 -4
- package/isString.mjs +10 -0
- package/isSymbol.js +9 -4
- package/isSymbol.mjs +10 -0
- package/isType.js +9 -4
- package/{node/isType.js → isType.mjs} +4 -9
- package/isUndefined.js +9 -4
- package/isUndefined.mjs +10 -0
- package/isWeakMap.js +9 -4
- package/isWeakMap.mjs +10 -0
- package/isWeakSet.js +9 -4
- package/isWeakSet.mjs +10 -0
- package/kbToBytes.js +6 -2
- package/kbToBytes.mjs +7 -0
- package/location.js +2 -1
- package/location.mjs +1 -0
- package/lowercase.js +6 -2
- package/lowercase.mjs +9 -0
- package/mapListBy.js +6 -2
- package/{node/mapListBy.js → mapListBy.mjs} +2 -6
- package/matchSorter.js +11 -7
- package/{node/matchSorter.js → matchSorter.mjs} +7 -11
- package/mbToBytes.js +6 -2
- package/mbToBytes.mjs +7 -0
- package/mergeObjects.js +11 -7
- package/{node/mergeObjects.js → mergeObjects.mjs} +7 -11
- package/mergeUrlQueryParams.js +9 -4
- package/{node/mergeUrlQueryParams.js → mergeUrlQueryParams.mjs} +4 -9
- package/moveSortableArrayItemByKey.js +8 -4
- package/{node/moveSortableArrayItemByKey.js → moveSortableArrayItemByKey.mjs} +4 -8
- package/noop.js +6 -2
- package/noop.mjs +7 -0
- package/normaliseUrl.js +9 -4
- package/normaliseUrl.mjs +15 -0
- package/normaliseUrlPathname.js +9 -4
- package/normaliseUrlPathname.mjs +14 -0
- package/objectOmit.js +6 -2
- package/{node/objectOmit.js → objectOmit.mjs} +2 -6
- package/objectPick.js +6 -2
- package/{node/objectPick.js → objectPick.mjs} +2 -6
- package/package.json +4 -3
- package/parseCookie.js +6 -2
- package/{node/parseCookie.js → parseCookie.mjs} +2 -6
- package/parseURL.js +6 -2
- package/{node/parseURL.js → parseURL.mjs} +2 -6
- package/quaranteneProps.js +6 -2
- package/{node/quaranteneProps.js → quaranteneProps.mjs} +2 -6
- package/randomInt.js +6 -2
- package/randomInt.mjs +9 -0
- package/randomKey.js +6 -2
- package/{node/randomKey.js → randomKey.mjs} +2 -6
- package/readCookie.js +6 -2
- package/{node/readCookie.js → readCookie.mjs} +2 -6
- package/removeAccents.js +8 -4
- package/removeAccents.mjs +15 -0
- package/removeCookie.js +10 -6
- package/removeCookie.mjs +15 -0
- package/{node/removeDuplicates.js → removeDuplicates.mjs} +0 -0
- package/removeDuplicatesByKey.js +6 -2
- package/{node/removeDuplicatesByKey.js → removeDuplicatesByKey.mjs} +2 -6
- package/removeDuplicatesComparing.js +10 -6
- package/removeDuplicatesComparing.mjs +10 -0
- package/removeIndexesFromArray.js +6 -2
- package/removeIndexesFromArray.mjs +14 -0
- package/removeTrailingSlash.js +6 -2
- package/removeTrailingSlash.mjs +10 -0
- package/removeUrlQueryParams.js +11 -6
- package/removeUrlQueryParams.mjs +21 -0
- package/roundTo.js +6 -2
- package/{node/roundTo.js → roundTo.mjs} +2 -6
- package/serializeCookie.js +8 -4
- package/{node/serializeCookie.js → serializeCookie.mjs} +4 -8
- package/setCookie.js +14 -10
- package/{node/setCookie.js → setCookie.mjs} +10 -14
- package/shuffle.js +8 -4
- package/{node/shuffle.js → shuffle.mjs} +4 -8
- package/slugify.js +9 -5
- package/{node/slugify.js → slugify.mjs} +5 -9
- package/swapMap.js +6 -2
- package/{node/swapMap.js → swapMap.mjs} +2 -6
- package/throttle.js +8 -4
- package/{node/throttle.js → throttle.mjs} +4 -8
- package/titleCase.js +6 -2
- package/{node/titleCase.js → titleCase.mjs} +2 -6
- package/toNumber.js +8 -4
- package/toNumber.mjs +8 -0
- package/toRgba.js +6 -2
- package/{node/toRgba.js → toRgba.mjs} +2 -6
- package/transformToUrlPathname.js +9 -4
- package/transformToUrlPathname.mjs +16 -0
- package/truncate.js +6 -2
- package/truncate.mjs +13 -0
- package/tryUntil.js +6 -2
- package/{node/tryUntil.js → tryUntil.mjs} +2 -6
- package/types.js +2 -1
- package/types.mjs +1 -0
- package/uid.js +6 -2
- package/{node/uid.js → uid.mjs} +2 -6
- package/updateLinkParams.js +9 -4
- package/updateLinkParams.mjs +14 -0
- package/updateUrlQueryParams.js +12 -7
- package/updateUrlQueryParams.mjs +18 -0
- package/uppercase.js +6 -2
- package/uppercase.mjs +9 -0
- package/uuid.js +6 -2
- package/{node/uuid.js → uuid.mjs} +2 -6
- package/uuidNumeric.js +6 -2
- package/uuidNumeric.mjs +6 -0
- package/wait.js +6 -2
- package/wait.mjs +9 -0
- package/node/addOrReplaceAtIdx.js +0 -23
- package/node/arraySum.js +0 -13
- package/node/changeUrlPath.js +0 -23
- package/node/debouncePromise.js +0 -12
- package/node/ensureInt.js +0 -13
- package/node/forin.js +0 -15
- package/node/gbToBytes.js +0 -11
- package/node/getEmptyArray.js +0 -20
- package/node/getNonce.js +0 -13
- package/node/getParamAsString.js +0 -19
- package/node/imgEmptyPixel.js +0 -10
- package/node/index.js +0 -134
- package/node/isAnyObject.js +0 -15
- package/node/isArray.js +0 -15
- package/node/isBlob.js +0 -15
- package/node/isBoolean.js +0 -15
- package/node/isBrowser.js +0 -11
- package/node/isDate.js +0 -15
- package/node/isEmptyArray.js +0 -15
- package/node/isEmptyObject.js +0 -15
- package/node/isEmptyString.js +0 -13
- package/node/isError.js +0 -15
- package/node/isFile.js +0 -15
- package/node/isFloat.js +0 -15
- package/node/isFormData.js +0 -15
- package/node/isFullArray.js +0 -15
- package/node/isFullObject.js +0 -15
- package/node/isFullString.js +0 -15
- package/node/isFunction.js +0 -13
- package/node/isInt.js +0 -15
- package/node/isMap.js +0 -15
- package/node/isNaNValue.js +0 -15
- package/node/isNegativeNumber.js +0 -15
- package/node/isNull.js +0 -15
- package/node/isNullOrUndefined.js +0 -14
- package/node/isNumber.js +0 -17
- package/node/isObject.js +0 -15
- package/node/isObjectLike.js +0 -17
- package/node/isOneOf.js +0 -14
- package/node/isPlainObject.js +0 -18
- package/node/isPositiveNumber.js +0 -15
- package/node/isPrimitive.js +0 -25
- package/node/isPromise.js +0 -15
- package/node/isRegExp.js +0 -15
- package/node/isServer.js +0 -13
- package/node/isSet.js +0 -15
- package/node/isString.js +0 -15
- package/node/isSymbol.js +0 -15
- package/node/isUndefined.js +0 -15
- package/node/isWeakMap.js +0 -15
- package/node/isWeakSet.js +0 -15
- package/node/kbToBytes.js +0 -11
- package/node/location.js +0 -2
- package/node/lowercase.js +0 -13
- package/node/mbToBytes.js +0 -11
- package/node/noop.js +0 -11
- package/node/normaliseUrl.js +0 -20
- package/node/normaliseUrlPathname.js +0 -19
- package/node/randomInt.js +0 -13
- package/node/removeAccents.js +0 -19
- package/node/removeCookie.js +0 -19
- package/node/removeDuplicatesComparing.js +0 -14
- package/node/removeIndexesFromArray.js +0 -18
- package/node/removeTrailingSlash.js +0 -14
- package/node/removeUrlQueryParams.js +0 -26
- package/node/toNumber.js +0 -12
- package/node/transformToUrlPathname.js +0 -21
- package/node/truncate.js +0 -17
- package/node/types.js +0 -2
- package/node/updateLinkParams.js +0 -19
- package/node/updateUrlQueryParams.js +0 -23
- package/node/uppercase.js +0 -13
- package/node/uuidNumeric.js +0 -10
- package/node/wait.js +0 -13
package/parseURL.js
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.parseURL = void 0;
|
|
1
4
|
/**
|
|
2
5
|
* Solution without DOM or specific env native methods
|
|
3
6
|
*
|
|
4
7
|
* @category location
|
|
5
8
|
* @see https://stackoverflow.com/a/21553982/1938970
|
|
6
9
|
*/
|
|
7
|
-
|
|
10
|
+
function parseURL(url) {
|
|
8
11
|
var match = url.match(/^(https?:)\/\/(([^:/?#]*)(?::([0-9]+))?)([/]{0,1}[^?#]*)(\?[^#]*|)(#.*|)$/);
|
|
9
12
|
return (match && {
|
|
10
13
|
href: url,
|
|
@@ -17,4 +20,5 @@ export function parseURL(url) {
|
|
|
17
20
|
hash: match[7],
|
|
18
21
|
});
|
|
19
22
|
}
|
|
20
|
-
|
|
23
|
+
exports.parseURL = parseURL;
|
|
24
|
+
exports.default = parseURL;
|
|
@@ -1,13 +1,10 @@
|
|
|
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
|
*/
|
|
10
|
-
function parseURL(url) {
|
|
7
|
+
export function parseURL(url) {
|
|
11
8
|
var match = url.match(/^(https?:)\/\/(([^:/?#]*)(?::([0-9]+))?)([/]{0,1}[^?#]*)(\?[^#]*|)(#.*|)$/);
|
|
12
9
|
return (match && {
|
|
13
10
|
href: url,
|
|
@@ -20,5 +17,4 @@ function parseURL(url) {
|
|
|
20
17
|
hash: match[7],
|
|
21
18
|
});
|
|
22
19
|
}
|
|
23
|
-
|
|
24
|
-
exports.default = parseURL;
|
|
20
|
+
export default parseURL;
|
package/quaranteneProps.js
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.quaranteneProps = void 0;
|
|
1
4
|
/**
|
|
2
5
|
* @category impl
|
|
3
6
|
* @usage
|
|
@@ -13,7 +16,7 @@
|
|
|
13
16
|
* ]);
|
|
14
17
|
* ```
|
|
15
18
|
*/
|
|
16
|
-
|
|
19
|
+
function quaranteneProps(props, propsKeysToQuarantene) {
|
|
17
20
|
// approach 1)
|
|
18
21
|
var healthyProps = {
|
|
19
22
|
_: {},
|
|
@@ -30,4 +33,5 @@ export function quaranteneProps(props, propsKeysToQuarantene) {
|
|
|
30
33
|
}
|
|
31
34
|
return healthyProps;
|
|
32
35
|
}
|
|
33
|
-
|
|
36
|
+
exports.quaranteneProps = quaranteneProps;
|
|
37
|
+
exports.default = quaranteneProps;
|
|
@@ -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
|
|
@@ -16,7 +13,7 @@ exports.quaranteneProps = void 0;
|
|
|
16
13
|
* ]);
|
|
17
14
|
* ```
|
|
18
15
|
*/
|
|
19
|
-
function quaranteneProps(props, propsKeysToQuarantene) {
|
|
16
|
+
export function quaranteneProps(props, propsKeysToQuarantene) {
|
|
20
17
|
// approach 1)
|
|
21
18
|
var healthyProps = {
|
|
22
19
|
_: {},
|
|
@@ -33,5 +30,4 @@ function quaranteneProps(props, propsKeysToQuarantene) {
|
|
|
33
30
|
}
|
|
34
31
|
return healthyProps;
|
|
35
32
|
}
|
|
36
|
-
|
|
37
|
-
exports.default = quaranteneProps;
|
|
33
|
+
export default quaranteneProps;
|
package/randomInt.js
CHANGED
|
@@ -1,9 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.randomInt = void 0;
|
|
1
4
|
/**
|
|
2
5
|
* Get random int (min and max included)
|
|
3
6
|
*
|
|
4
7
|
* @category math
|
|
5
8
|
*/
|
|
6
|
-
|
|
9
|
+
function randomInt(min, max) {
|
|
7
10
|
return Math.floor(Math.random() * (max - min + 1) + min);
|
|
8
11
|
}
|
|
9
|
-
|
|
12
|
+
exports.randomInt = randomInt;
|
|
13
|
+
exports.default = randomInt;
|
package/randomInt.mjs
ADDED
package/randomKey.js
CHANGED
|
@@ -1,11 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.randomKey = void 0;
|
|
1
4
|
/**
|
|
2
5
|
* Get random key from given object
|
|
3
6
|
*
|
|
4
7
|
* @category misc
|
|
5
8
|
* @see https://stackoverflow.com/a/15106541/1938970
|
|
6
9
|
*/
|
|
7
|
-
|
|
10
|
+
function randomKey(obj) {
|
|
8
11
|
var keys = Object.keys(obj);
|
|
9
12
|
return keys[(keys.length * Math.random()) << 0];
|
|
10
13
|
}
|
|
11
|
-
|
|
14
|
+
exports.randomKey = randomKey;
|
|
15
|
+
exports.default = randomKey;
|
|
@@ -1,15 +1,11 @@
|
|
|
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
|
*/
|
|
10
|
-
function randomKey(obj) {
|
|
7
|
+
export function randomKey(obj) {
|
|
11
8
|
var keys = Object.keys(obj);
|
|
12
9
|
return keys[(keys.length * Math.random()) << 0];
|
|
13
10
|
}
|
|
14
|
-
|
|
15
|
-
exports.default = randomKey;
|
|
11
|
+
export default randomKey;
|
package/readCookie.js
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.readCookie = void 0;
|
|
1
4
|
function converterRead(value) {
|
|
2
5
|
if (value[0] === '"') {
|
|
3
6
|
value = value.slice(1, -1);
|
|
4
7
|
}
|
|
5
8
|
return value.replace(/(%[\dA-F]{2})+/gi, decodeURIComponent);
|
|
6
9
|
}
|
|
7
|
-
|
|
10
|
+
function readCookie(name) {
|
|
8
11
|
if (typeof document === "undefined") {
|
|
9
12
|
if (process.env["NODE_ENV"] !== "production") {
|
|
10
13
|
console.warn("[@koine/utils:readCookie] document is undefined");
|
|
@@ -31,4 +34,5 @@ export function readCookie(name) {
|
|
|
31
34
|
}
|
|
32
35
|
return name ? all[name] : all;
|
|
33
36
|
}
|
|
34
|
-
|
|
37
|
+
exports.readCookie = readCookie;
|
|
38
|
+
exports.default = readCookie;
|
|
@@ -1,13 +1,10 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.readCookie = void 0;
|
|
4
1
|
function converterRead(value) {
|
|
5
2
|
if (value[0] === '"') {
|
|
6
3
|
value = value.slice(1, -1);
|
|
7
4
|
}
|
|
8
5
|
return value.replace(/(%[\dA-F]{2})+/gi, decodeURIComponent);
|
|
9
6
|
}
|
|
10
|
-
function readCookie(name) {
|
|
7
|
+
export function readCookie(name) {
|
|
11
8
|
if (typeof document === "undefined") {
|
|
12
9
|
if (process.env["NODE_ENV"] !== "production") {
|
|
13
10
|
console.warn("[@koine/utils:readCookie] document is undefined");
|
|
@@ -34,5 +31,4 @@ function readCookie(name) {
|
|
|
34
31
|
}
|
|
35
32
|
return name ? all[name] : all;
|
|
36
33
|
}
|
|
37
|
-
|
|
38
|
-
exports.default = readCookie;
|
|
34
|
+
export default readCookie;
|
package/removeAccents.js
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.removeAccents = void 0;
|
|
4
|
+
var accentSets_1 = require("./accentSets");
|
|
2
5
|
/**
|
|
3
6
|
* @category text
|
|
4
7
|
*/
|
|
5
|
-
|
|
8
|
+
function removeAccents(text, sets) {
|
|
6
9
|
if (text === void 0) { text = ""; }
|
|
7
|
-
if (sets === void 0) { sets = accentsSets; }
|
|
10
|
+
if (sets === void 0) { sets = accentSets_1.accentsSets; }
|
|
8
11
|
var len = sets.length;
|
|
9
12
|
while (len--) {
|
|
10
13
|
var _a = sets[len], to = _a[0], from = _a[1];
|
|
@@ -12,4 +15,5 @@ export function removeAccents(text, sets) {
|
|
|
12
15
|
}
|
|
13
16
|
return text;
|
|
14
17
|
}
|
|
15
|
-
|
|
18
|
+
exports.removeAccents = removeAccents;
|
|
19
|
+
exports.default = removeAccents;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { accentsSets } from "./accentSets";
|
|
2
|
+
/**
|
|
3
|
+
* @category text
|
|
4
|
+
*/
|
|
5
|
+
export function removeAccents(text, sets) {
|
|
6
|
+
if (text === void 0) { text = ""; }
|
|
7
|
+
if (sets === void 0) { sets = accentsSets; }
|
|
8
|
+
var len = sets.length;
|
|
9
|
+
while (len--) {
|
|
10
|
+
var _a = sets[len], to = _a[0], from = _a[1];
|
|
11
|
+
text = text.replace(new RegExp("[".concat(from, "]"), "gi"), to);
|
|
12
|
+
}
|
|
13
|
+
return text;
|
|
14
|
+
}
|
|
15
|
+
export default removeAccents;
|
package/removeCookie.js
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.removeCookie = void 0;
|
|
4
|
+
var tslib_1 = require("tslib");
|
|
5
|
+
var cookie_1 = require("./cookie");
|
|
6
|
+
var setCookie_1 = require("./setCookie");
|
|
4
7
|
/**
|
|
5
8
|
* @category cookie
|
|
6
9
|
*
|
|
@@ -8,8 +11,9 @@ import { setCookie } from "./setCookie";
|
|
|
8
11
|
* - [js-cookie](https://github.com/js-cookie/js-cookie)
|
|
9
12
|
* - [cookie](https://github.com/jshttp/cookie)
|
|
10
13
|
*/
|
|
11
|
-
|
|
14
|
+
function removeCookie(name, attributes) {
|
|
12
15
|
if (attributes === void 0) { attributes = {}; }
|
|
13
|
-
setCookie(name, "", __assign(__assign(__assign({}, defaultAttributesClient), attributes), { expires: -1 }));
|
|
16
|
+
(0, setCookie_1.setCookie)(name, "", tslib_1.__assign(tslib_1.__assign(tslib_1.__assign({}, cookie_1.defaultAttributesClient), attributes), { expires: -1 }));
|
|
14
17
|
}
|
|
15
|
-
|
|
18
|
+
exports.removeCookie = removeCookie;
|
|
19
|
+
exports.default = removeCookie;
|
package/removeCookie.mjs
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { __assign } from "tslib";
|
|
2
|
+
import { defaultAttributesClient } from "./cookie";
|
|
3
|
+
import { setCookie } from "./setCookie";
|
|
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
|
+
export function removeCookie(name, attributes) {
|
|
12
|
+
if (attributes === void 0) { attributes = {}; }
|
|
13
|
+
setCookie(name, "", __assign(__assign(__assign({}, defaultAttributesClient), attributes), { expires: -1 }));
|
|
14
|
+
}
|
|
15
|
+
export default removeCookie;
|
|
File without changes
|
package/removeDuplicatesByKey.js
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.removeDuplicatesByKey = void 0;
|
|
1
4
|
/**
|
|
2
5
|
* Remove duplicated array objects, equality is determined by a strict (`===`)
|
|
3
6
|
* comparison of each object's given key
|
|
4
7
|
*
|
|
5
8
|
* @category array
|
|
6
9
|
*/
|
|
7
|
-
|
|
10
|
+
function removeDuplicatesByKey(array, key) {
|
|
8
11
|
if (array === void 0) { array = []; }
|
|
9
12
|
var keysMap = {};
|
|
10
13
|
var output = [];
|
|
@@ -17,4 +20,5 @@ export function removeDuplicatesByKey(array, key) {
|
|
|
17
20
|
}
|
|
18
21
|
return output;
|
|
19
22
|
}
|
|
20
|
-
|
|
23
|
+
exports.removeDuplicatesByKey = removeDuplicatesByKey;
|
|
24
|
+
exports.default = removeDuplicatesByKey;
|
|
@@ -1,13 +1,10 @@
|
|
|
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
6
|
*/
|
|
10
|
-
function removeDuplicatesByKey(array, key) {
|
|
7
|
+
export function removeDuplicatesByKey(array, key) {
|
|
11
8
|
if (array === void 0) { array = []; }
|
|
12
9
|
var keysMap = {};
|
|
13
10
|
var output = [];
|
|
@@ -20,5 +17,4 @@ function removeDuplicatesByKey(array, key) {
|
|
|
20
17
|
}
|
|
21
18
|
return output;
|
|
22
19
|
}
|
|
23
|
-
|
|
24
|
-
exports.default = removeDuplicatesByKey;
|
|
20
|
+
export default removeDuplicatesByKey;
|
|
@@ -1,10 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.removeDuplicatesComparing = void 0;
|
|
4
|
+
var removeIndexesFromArray_1 = require("./removeIndexesFromArray");
|
|
5
|
+
var findDuplicatedIndexes_1 = require("./findDuplicatedIndexes");
|
|
3
6
|
/**
|
|
4
7
|
* @category array
|
|
5
8
|
*/
|
|
6
|
-
|
|
7
|
-
var indexes = findDuplicatedIndexes(from);
|
|
8
|
-
return removeIndexesFromArray(to, indexes);
|
|
9
|
+
function removeDuplicatesComparing(from, to) {
|
|
10
|
+
var indexes = (0, findDuplicatedIndexes_1.findDuplicatedIndexes)(from);
|
|
11
|
+
return (0, removeIndexesFromArray_1.removeIndexesFromArray)(to, indexes);
|
|
9
12
|
}
|
|
10
|
-
|
|
13
|
+
exports.removeDuplicatesComparing = removeDuplicatesComparing;
|
|
14
|
+
exports.default = removeDuplicatesComparing;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { removeIndexesFromArray } from "./removeIndexesFromArray";
|
|
2
|
+
import { findDuplicatedIndexes } from "./findDuplicatedIndexes";
|
|
3
|
+
/**
|
|
4
|
+
* @category array
|
|
5
|
+
*/
|
|
6
|
+
export function removeDuplicatesComparing(from, to) {
|
|
7
|
+
var indexes = findDuplicatedIndexes(from);
|
|
8
|
+
return removeIndexesFromArray(to, indexes);
|
|
9
|
+
}
|
|
10
|
+
export default removeDuplicatesComparing;
|
|
@@ -1,7 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.removeIndexesFromArray = void 0;
|
|
1
4
|
/**
|
|
2
5
|
* @category array
|
|
3
6
|
*/
|
|
4
|
-
|
|
7
|
+
function removeIndexesFromArray(arr, indexes) {
|
|
5
8
|
var output = [];
|
|
6
9
|
for (var i = 0; i < arr.length; i++) {
|
|
7
10
|
// eslint-disable-next-line no-prototype-builtins
|
|
@@ -11,4 +14,5 @@ export function removeIndexesFromArray(arr, indexes) {
|
|
|
11
14
|
}
|
|
12
15
|
return output;
|
|
13
16
|
}
|
|
14
|
-
|
|
17
|
+
exports.removeIndexesFromArray = removeIndexesFromArray;
|
|
18
|
+
exports.default = removeIndexesFromArray;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @category array
|
|
3
|
+
*/
|
|
4
|
+
export function removeIndexesFromArray(arr, indexes) {
|
|
5
|
+
var output = [];
|
|
6
|
+
for (var i = 0; i < arr.length; i++) {
|
|
7
|
+
// eslint-disable-next-line no-prototype-builtins
|
|
8
|
+
if (!indexes.hasOwnProperty(i)) {
|
|
9
|
+
output.push(arr[i]);
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
return output;
|
|
13
|
+
}
|
|
14
|
+
export default removeIndexesFromArray;
|
package/removeTrailingSlash.js
CHANGED
|
@@ -1,10 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.removeTralingSlash = void 0;
|
|
1
4
|
/**
|
|
2
5
|
* Strips out the trailing slash
|
|
3
6
|
*
|
|
4
7
|
* @category location
|
|
5
8
|
*/
|
|
6
|
-
|
|
9
|
+
function removeTralingSlash(urlLike) {
|
|
7
10
|
if (urlLike === void 0) { urlLike = ""; }
|
|
8
11
|
return urlLike.replace(/\/*$/, "");
|
|
9
12
|
}
|
|
10
|
-
|
|
13
|
+
exports.removeTralingSlash = removeTralingSlash;
|
|
14
|
+
exports.default = removeTralingSlash;
|
package/removeUrlQueryParams.js
CHANGED
|
@@ -1,21 +1,26 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.removeUrlQueryParams = void 0;
|
|
4
|
+
var tslib_1 = require("tslib");
|
|
5
|
+
var buildUrlQueryString_1 = tslib_1.__importDefault(require("./buildUrlQueryString"));
|
|
6
|
+
var getUrlQueryParams_1 = tslib_1.__importDefault(require("./getUrlQueryParams"));
|
|
3
7
|
/**
|
|
4
8
|
* Remove the given keys from the given URL query parameters
|
|
5
9
|
*
|
|
6
10
|
* @category location
|
|
7
11
|
* @pure
|
|
8
12
|
*/
|
|
9
|
-
|
|
13
|
+
function removeUrlQueryParams(url, paramsToRemove) {
|
|
10
14
|
if (paramsToRemove === void 0) { paramsToRemove = []; }
|
|
11
15
|
var parts = url.split("?");
|
|
12
|
-
var allParams =
|
|
16
|
+
var allParams = (0, getUrlQueryParams_1.default)(url);
|
|
13
17
|
var params = {};
|
|
14
18
|
for (var key in allParams) {
|
|
15
19
|
if (!paramsToRemove.includes(key)) {
|
|
16
20
|
params[key] = allParams[key];
|
|
17
21
|
}
|
|
18
22
|
}
|
|
19
|
-
return parts[0] +
|
|
23
|
+
return parts[0] + (0, buildUrlQueryString_1.default)(params);
|
|
20
24
|
}
|
|
21
|
-
|
|
25
|
+
exports.removeUrlQueryParams = removeUrlQueryParams;
|
|
26
|
+
exports.default = removeUrlQueryParams;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import buildUrlQueryString from "./buildUrlQueryString";
|
|
2
|
+
import getUrlQueryParams from "./getUrlQueryParams";
|
|
3
|
+
/**
|
|
4
|
+
* Remove the given keys from the given URL query parameters
|
|
5
|
+
*
|
|
6
|
+
* @category location
|
|
7
|
+
* @pure
|
|
8
|
+
*/
|
|
9
|
+
export function removeUrlQueryParams(url, paramsToRemove) {
|
|
10
|
+
if (paramsToRemove === void 0) { paramsToRemove = []; }
|
|
11
|
+
var parts = url.split("?");
|
|
12
|
+
var allParams = getUrlQueryParams(url);
|
|
13
|
+
var params = {};
|
|
14
|
+
for (var key in allParams) {
|
|
15
|
+
if (!paramsToRemove.includes(key)) {
|
|
16
|
+
params[key] = allParams[key];
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
return parts[0] + buildUrlQueryString(params);
|
|
20
|
+
}
|
|
21
|
+
export default removeUrlQueryParams;
|
package/roundTo.js
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.roundTo = void 0;
|
|
1
4
|
/**
|
|
2
5
|
* Round to given number of the given number of decimals
|
|
3
6
|
*
|
|
4
7
|
* @category math
|
|
5
8
|
* @see https://stackoverflow.com/a/15762794/1938970
|
|
6
9
|
*/
|
|
7
|
-
|
|
10
|
+
function roundTo(num, decimals) {
|
|
8
11
|
if (decimals === void 0) { decimals = 2; }
|
|
9
12
|
if (isFinite(num) && !isNaN(num)) {
|
|
10
13
|
// method 1
|
|
@@ -31,4 +34,5 @@ export function roundTo(num, decimals) {
|
|
|
31
34
|
}
|
|
32
35
|
return "";
|
|
33
36
|
}
|
|
34
|
-
|
|
37
|
+
exports.roundTo = roundTo;
|
|
38
|
+
exports.default = roundTo;
|
|
@@ -1,13 +1,10 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.roundTo = void 0;
|
|
4
1
|
/**
|
|
5
2
|
* Round to given number of the given number of decimals
|
|
6
3
|
*
|
|
7
4
|
* @category math
|
|
8
5
|
* @see https://stackoverflow.com/a/15762794/1938970
|
|
9
6
|
*/
|
|
10
|
-
function roundTo(num, decimals) {
|
|
7
|
+
export function roundTo(num, decimals) {
|
|
11
8
|
if (decimals === void 0) { decimals = 2; }
|
|
12
9
|
if (isFinite(num) && !isNaN(num)) {
|
|
13
10
|
// method 1
|
|
@@ -34,5 +31,4 @@ function roundTo(num, decimals) {
|
|
|
34
31
|
}
|
|
35
32
|
return "";
|
|
36
33
|
}
|
|
37
|
-
|
|
38
|
-
exports.default = roundTo;
|
|
34
|
+
export default roundTo;
|
package/serializeCookie.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
/**
|
|
2
3
|
* @file
|
|
3
4
|
*
|
|
@@ -7,7 +8,9 @@
|
|
|
7
8
|
* - [js-cookie](https://github.com/js-cookie/js-cookie)
|
|
8
9
|
* - [cookie](https://github.com/jshttp/cookie)
|
|
9
10
|
*/
|
|
10
|
-
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.serializeCookie = void 0;
|
|
13
|
+
var isNumber_1 = require("./isNumber");
|
|
11
14
|
/**
|
|
12
15
|
* RegExp to match field-content in RFC 7230 sec 3.2
|
|
13
16
|
*
|
|
@@ -32,7 +35,7 @@ var fieldContentRegExp = /^[\u0009\u0020-\u007e\u0080-\u00ff]+$/;
|
|
|
32
35
|
* - [js-cookie](https://github.com/js-cookie/js-cookie)
|
|
33
36
|
* - [cookie](https://github.com/jshttp/cookie)
|
|
34
37
|
*/
|
|
35
|
-
|
|
38
|
+
function serializeCookie(name, val, attributes) {
|
|
36
39
|
if (attributes === void 0) { attributes = {}; }
|
|
37
40
|
var _a = attributes.encode, encode = _a === void 0 ? encodeURIComponent : _a, domain = attributes.domain, path = attributes.path, httpOnly = attributes.httpOnly, secure = attributes.secure, sameSite = attributes.sameSite;
|
|
38
41
|
var maxAge = attributes.maxAge, expires = attributes.expires;
|
|
@@ -73,7 +76,7 @@ export function serializeCookie(name, val, attributes) {
|
|
|
73
76
|
str += "; Path=" + path;
|
|
74
77
|
}
|
|
75
78
|
if (expires) {
|
|
76
|
-
if (isNumber(expires)) {
|
|
79
|
+
if ((0, isNumber_1.isNumber)(expires)) {
|
|
77
80
|
expires = new Date(Date.now() + expires * 864e5);
|
|
78
81
|
}
|
|
79
82
|
str += "; Expires=" + expires.toUTCString();
|
|
@@ -101,4 +104,5 @@ export function serializeCookie(name, val, attributes) {
|
|
|
101
104
|
}
|
|
102
105
|
return str;
|
|
103
106
|
}
|
|
104
|
-
|
|
107
|
+
exports.serializeCookie = serializeCookie;
|
|
108
|
+
exports.default = serializeCookie;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
/**
|
|
3
2
|
* @file
|
|
4
3
|
*
|
|
@@ -8,9 +7,7 @@
|
|
|
8
7
|
* - [js-cookie](https://github.com/js-cookie/js-cookie)
|
|
9
8
|
* - [cookie](https://github.com/jshttp/cookie)
|
|
10
9
|
*/
|
|
11
|
-
|
|
12
|
-
exports.serializeCookie = void 0;
|
|
13
|
-
var isNumber_1 = require("./isNumber");
|
|
10
|
+
import { isNumber } from "./isNumber";
|
|
14
11
|
/**
|
|
15
12
|
* RegExp to match field-content in RFC 7230 sec 3.2
|
|
16
13
|
*
|
|
@@ -35,7 +32,7 @@ var fieldContentRegExp = /^[\u0009\u0020-\u007e\u0080-\u00ff]+$/;
|
|
|
35
32
|
* - [js-cookie](https://github.com/js-cookie/js-cookie)
|
|
36
33
|
* - [cookie](https://github.com/jshttp/cookie)
|
|
37
34
|
*/
|
|
38
|
-
function serializeCookie(name, val, attributes) {
|
|
35
|
+
export function serializeCookie(name, val, attributes) {
|
|
39
36
|
if (attributes === void 0) { attributes = {}; }
|
|
40
37
|
var _a = attributes.encode, encode = _a === void 0 ? encodeURIComponent : _a, domain = attributes.domain, path = attributes.path, httpOnly = attributes.httpOnly, secure = attributes.secure, sameSite = attributes.sameSite;
|
|
41
38
|
var maxAge = attributes.maxAge, expires = attributes.expires;
|
|
@@ -76,7 +73,7 @@ function serializeCookie(name, val, attributes) {
|
|
|
76
73
|
str += "; Path=" + path;
|
|
77
74
|
}
|
|
78
75
|
if (expires) {
|
|
79
|
-
if (
|
|
76
|
+
if (isNumber(expires)) {
|
|
80
77
|
expires = new Date(Date.now() + expires * 864e5);
|
|
81
78
|
}
|
|
82
79
|
str += "; Expires=" + expires.toUTCString();
|
|
@@ -104,5 +101,4 @@ function serializeCookie(name, val, attributes) {
|
|
|
104
101
|
}
|
|
105
102
|
return str;
|
|
106
103
|
}
|
|
107
|
-
|
|
108
|
-
exports.default = serializeCookie;
|
|
104
|
+
export default serializeCookie;
|
package/setCookie.js
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.setCookie = void 0;
|
|
4
|
+
var tslib_1 = require("tslib");
|
|
5
|
+
var cookie_1 = require("./cookie");
|
|
6
|
+
var isNumber_1 = tslib_1.__importDefault(require("./isNumber"));
|
|
7
|
+
var isUndefined_1 = tslib_1.__importDefault(require("./isUndefined"));
|
|
5
8
|
function converterWrite(value) {
|
|
6
9
|
return encodeURIComponent(value).replace(/%(2[346BF]|3[AC-F]|40|5[BDE]|60|7[BCD])/g, decodeURIComponent);
|
|
7
10
|
}
|
|
@@ -12,18 +15,18 @@ function converterWrite(value) {
|
|
|
12
15
|
* - [js-cookie](https://github.com/js-cookie/js-cookie)
|
|
13
16
|
* - [cookie](https://github.com/jshttp/cookie)
|
|
14
17
|
*/
|
|
15
|
-
|
|
18
|
+
function setCookie(name, value, attributes) {
|
|
16
19
|
if (attributes === void 0) { attributes = {}; }
|
|
17
20
|
// eslint-disable-next-line prefer-const
|
|
18
|
-
var expires = attributes.expires, restAttrs = __rest(attributes, ["expires"]);
|
|
19
|
-
var cleanedAttrs = __assign(__assign({ expires: "" }, defaultAttributesClient), restAttrs);
|
|
20
|
-
if (
|
|
21
|
+
var expires = attributes.expires, restAttrs = tslib_1.__rest(attributes, ["expires"]);
|
|
22
|
+
var cleanedAttrs = tslib_1.__assign(tslib_1.__assign({ expires: "" }, cookie_1.defaultAttributesClient), restAttrs);
|
|
23
|
+
if ((0, isUndefined_1.default)(document)) {
|
|
21
24
|
if (process.env["NODE_ENV"] !== "production") {
|
|
22
25
|
console.warn("[@koine/utils:setCookie] document is undefined");
|
|
23
26
|
}
|
|
24
27
|
return undefined;
|
|
25
28
|
}
|
|
26
|
-
if (
|
|
29
|
+
if ((0, isNumber_1.default)(expires)) {
|
|
27
30
|
expires = new Date(Date.now() + expires * 864e5);
|
|
28
31
|
}
|
|
29
32
|
if (expires) {
|
|
@@ -55,4 +58,5 @@ export function setCookie(name, value, attributes) {
|
|
|
55
58
|
return (document.cookie =
|
|
56
59
|
name + "=" + converterWrite(value) + stringifiedAttributes);
|
|
57
60
|
}
|
|
58
|
-
|
|
61
|
+
exports.setCookie = setCookie;
|
|
62
|
+
exports.default = setCookie;
|