@koine/utils 2.0.0-beta.4 → 2.0.0-beta.42
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.d.ts +0 -15
- package/Emitter.d.ts +2 -21
- package/README.md +4 -2
- package/accentSets.d.ts +1 -15
- package/addOrReplaceAtIdx.d.ts +1 -5
- package/areEqual.d.ts +2 -17
- package/arrayFilterFalsy.d.ts +1 -0
- package/arrayOfAll.d.ts +1 -28
- package/arraySum.d.ts +1 -7
- package/arrayToLookup.d.ts +1 -7
- package/arrayUniqueByProperties.d.ts +1 -0
- package/buildUrlQueryString.d.ts +2 -12
- package/capitalize.d.ts +1 -8
- package/changeCaseCamel.d.ts +2 -0
- package/changeCaseCapital.d.ts +2 -0
- package/changeCaseConstant.d.ts +2 -0
- package/changeCaseDot.d.ts +2 -0
- package/changeCaseHelpers.d.ts +19 -0
- package/changeCaseKebab.d.ts +2 -0
- package/changeCaseNone.d.ts +2 -0
- package/changeCasePascal.d.ts +2 -0
- package/changeCasePascalSnake.d.ts +2 -0
- package/changeCasePath.d.ts +2 -0
- package/changeCaseSentence.d.ts +2 -0
- package/changeCaseSnake.d.ts +2 -0
- package/changeCaseTrain.d.ts +2 -0
- package/chunkByChunks.d.ts +1 -7
- package/chunkBySize.d.ts +1 -6
- package/clamp.d.ts +1 -8
- package/clsx.d.ts +6 -9
- package/convertRange.d.ts +1 -14
- package/cookie.d.ts +1 -37
- package/createPalette.d.ts +2 -12
- package/debounce.d.ts +1 -8
- package/debouncePromise.d.ts +10 -11
- package/debounceRaf.d.ts +0 -8
- package/decode.d.ts +1 -6
- package/encode.d.ts +1 -6
- package/ensureInt.d.ts +1 -7
- package/env.d.ts +0 -0
- package/errorToString.d.ts +1 -7
- package/findDuplicatedIndexes.d.ts +1 -5
- package/forin.d.ts +1 -7
- package/gbToBytes.d.ts +1 -7
- package/getEmptyArray.d.ts +1 -9
- package/getKeys.d.ts +1 -9
- package/getMediaQueryWidthResolvers.d.ts +1 -2
- package/getMediaQueryWidthTailwindScreens.d.ts +1 -2
- package/getNonce.d.ts +1 -6
- package/getParamAmong.d.ts +1 -12
- package/getParamAsInt.d.ts +1 -12
- package/getParamAsString.d.ts +1 -11
- package/getType.d.ts +4 -17
- package/getUrlHashParams.d.ts +1 -9
- package/getUrlHashPathname.d.ts +1 -9
- package/getUrlPathnameParts.d.ts +1 -12
- package/getUrlQueryParams.d.ts +1 -14
- package/imgEmptyPixel.d.ts +1 -7
- package/index.cjs.d.ts +1 -0
- package/index.cjs.default.js +1 -0
- package/index.cjs.js +482 -0
- package/index.cjs.mjs +2 -0
- package/index.d.ts +24 -5
- package/index.esm.js +330 -0
- package/invariant.d.ts +1 -19
- package/isAnyObject.d.ts +2 -8
- package/isArray.d.ts +1 -7
- package/isBlob.d.ts +1 -7
- package/isBoolean.d.ts +1 -7
- package/isBrowser.d.ts +1 -6
- package/isBrowserNow.d.ts +1 -6
- package/isDate.d.ts +1 -7
- package/isEmptyArray.d.ts +1 -7
- package/isEmptyObject.d.ts +4 -8
- package/isEmptyString.d.ts +1 -7
- package/isError.d.ts +1 -7
- package/isExternalUrl.d.ts +1 -9
- package/isFile.d.ts +1 -7
- package/isFloat.d.ts +1 -7
- package/isFormData.d.ts +1 -7
- package/isFullArray.d.ts +1 -7
- package/isFullObject.d.ts +2 -8
- package/isFullString.d.ts +1 -7
- package/isFunction.d.ts +2 -8
- package/isInt.d.ts +1 -7
- package/isMap.d.ts +1 -7
- package/isNaNValue.d.ts +1 -7
- package/isNegativeNumber.d.ts +1 -7
- package/isNull.d.ts +1 -7
- package/isNullOrUndefined.d.ts +1 -7
- package/isNumber.d.ts +1 -9
- package/isNumericLiteral.d.ts +1 -0
- package/isObject.d.ts +2 -8
- package/isObjectLike.d.ts +2 -10
- package/isObjectStringKeyed.d.ts +2 -0
- package/isOneOf.d.ts +1 -5
- package/isPlainObject.d.ts +2 -8
- package/isPositiveNumber.d.ts +1 -7
- package/isPrimitive.d.ts +1 -7
- package/isPromise.d.ts +1 -7
- package/isRegExp.d.ts +1 -7
- package/isServer.d.ts +1 -6
- package/isServerNow.d.ts +1 -6
- package/isSet.d.ts +1 -7
- package/isString.d.ts +1 -7
- package/isSymbol.d.ts +1 -7
- package/isType.d.ts +2 -11
- package/isUndefined.d.ts +1 -7
- package/isWeakMap.d.ts +1 -7
- package/isWeakSet.d.ts +1 -7
- package/kbToBytes.d.ts +1 -7
- package/location.d.ts +0 -3
- package/lowercase.d.ts +1 -7
- package/mapListBy.d.ts +1 -7
- package/matchSorter.d.ts +2 -10
- package/mbToBytes.d.ts +1 -7
- package/mergeObjects.d.ts +1 -7
- package/mergeUrlQueryParams.d.ts +2 -9
- package/moveSortableArrayItemByKey.d.ts +1 -9
- package/noop.d.ts +1 -7
- package/normaliseUrl.d.ts +1 -11
- package/normaliseUrlPathname.d.ts +1 -10
- package/objectFlat.d.ts +3 -0
- package/objectFlip.d.ts +1 -0
- package/objectOmit.d.ts +1 -11
- package/objectPick.d.ts +1 -8
- package/objectSortByKeysMatching.d.ts +3 -0
- package/objectToArray.d.ts +1 -0
- package/package.json +9 -10
- package/parseCookie.d.ts +2 -11
- package/parseURL.d.ts +1 -8
- package/quaranteneProps.d.ts +2 -17
- package/randomInt.d.ts +1 -7
- package/randomKey.d.ts +1 -8
- package/readCookie.d.ts +0 -1
- package/removeAccents.d.ts +2 -6
- package/removeCookie.d.ts +1 -9
- package/removeDuplicates.d.ts +0 -0
- package/removeDuplicatesByKey.d.ts +1 -8
- package/removeDuplicatesComparing.d.ts +1 -5
- package/removeIndexesFromArray.d.ts +1 -5
- package/removeTrailingSlash.d.ts +1 -7
- package/removeUrlQueryParams.d.ts +1 -8
- package/render.d.ts +2 -41
- package/round.d.ts +2 -0
- package/roundTo.d.ts +1 -8
- package/serializeCookie.d.ts +2 -27
- package/setCookie.d.ts +1 -9
- package/shuffle.d.ts +1 -16
- package/slugify.d.ts +1 -11
- package/split.d.ts +1 -2
- package/splitReverse.d.ts +4 -0
- package/swapMap.d.ts +1 -7
- package/throttle.d.ts +1 -8
- package/titleCase.d.ts +1 -7
- package/toNumber.d.ts +1 -5
- package/toRgba.d.ts +1 -5
- package/transformToUrlPathname.d.ts +1 -11
- package/truncate.d.ts +1 -7
- package/tryUntil.d.ts +1 -8
- package/types.d.ts +1 -18
- package/typings.d.ts +31 -5
- package/uid.d.ts +1 -7
- package/updateLinkParams.d.ts +2 -10
- package/updateUrlQueryParams.d.ts +2 -9
- package/uppercase.d.ts +1 -7
- package/uuid.d.ts +1 -8
- package/uuidNumeric.d.ts +1 -6
- package/wait.d.ts +1 -7
- package/without.d.ts +0 -0
- package/Defer.js +0 -35
- package/Defer.mjs +0 -27
- package/Emitter.js +0 -53
- package/Emitter.mjs +0 -35
- package/accentSets.js +0 -133
- package/accentSets.mjs +0 -122
- package/addOrReplaceAtIdx.js +0 -40
- package/addOrReplaceAtIdx.mjs +0 -22
- package/areEqual.js +0 -75
- package/areEqual.mjs +0 -71
- package/arrayOfAll.js +0 -45
- package/arrayOfAll.mjs +0 -27
- package/arraySum.js +0 -24
- package/arraySum.mjs +0 -6
- package/arrayToLookup.js +0 -29
- package/arrayToLookup.mjs +0 -11
- package/buildUrlQueryString.js +0 -39
- package/buildUrlQueryString.mjs +0 -28
- package/capitalize.js +0 -28
- package/capitalize.mjs +0 -10
- package/changeUrlPath.d.ts +0 -10
- package/changeUrlPath.js +0 -29
- package/changeUrlPath.mjs +0 -17
- package/chunkByChunks.js +0 -52
- package/chunkByChunks.mjs +0 -34
- package/chunkBySize.js +0 -29
- package/chunkBySize.mjs +0 -11
- package/clamp.js +0 -27
- package/clamp.mjs +0 -9
- package/clsx.js +0 -59
- package/clsx.mjs +0 -46
- package/convertRange.js +0 -33
- package/convertRange.mjs +0 -15
- package/cookie.js +0 -21
- package/cookie.mjs +0 -11
- package/createPalette.js +0 -34
- package/createPalette.mjs +0 -25
- package/debounce.js +0 -39
- package/debounce.mjs +0 -21
- package/debouncePromise.js +0 -21
- package/debouncePromise.mjs +0 -8
- package/debounceRaf.js +0 -40
- package/debounceRaf.mjs +0 -22
- package/decode.js +0 -27
- package/decode.mjs +0 -9
- package/encode.js +0 -27
- package/encode.mjs +0 -9
- package/ensureInt.js +0 -24
- package/ensureInt.mjs +0 -6
- package/env.js +0 -3
- package/env.mjs +0 -2
- package/errorToString.js +0 -22
- package/errorToString.mjs +0 -7
- package/findDuplicatedIndexes.js +0 -31
- package/findDuplicatedIndexes.mjs +0 -13
- package/forin.js +0 -28
- package/forin.mjs +0 -10
- package/gbToBytes.js +0 -24
- package/gbToBytes.mjs +0 -6
- package/getEmptyArray.js +0 -29
- package/getEmptyArray.mjs +0 -16
- package/getKeys.js +0 -26
- package/getKeys.mjs +0 -8
- package/getMediaQueryWidthResolvers.js +0 -81
- package/getMediaQueryWidthResolvers.mjs +0 -63
- package/getMediaQueryWidthTailwindScreens.js +0 -51
- package/getMediaQueryWidthTailwindScreens.mjs +0 -33
- package/getNonce.js +0 -23
- package/getNonce.mjs +0 -8
- package/getParamAmong.js +0 -25
- package/getParamAmong.mjs +0 -15
- package/getParamAsInt.js +0 -28
- package/getParamAsInt.mjs +0 -18
- package/getParamAsString.js +0 -24
- package/getParamAsString.mjs +0 -13
- package/getType.js +0 -30
- package/getType.mjs +0 -17
- package/getUrlHashParams.js +0 -27
- package/getUrlHashParams.mjs +0 -14
- package/getUrlHashPathname.js +0 -29
- package/getUrlHashPathname.mjs +0 -11
- package/getUrlPathnameParts.js +0 -25
- package/getUrlPathnameParts.mjs +0 -15
- package/getUrlQueryParams.js +0 -36
- package/getUrlQueryParams.mjs +0 -27
- package/imgEmptyPixel.js +0 -24
- package/imgEmptyPixel.mjs +0 -6
- package/index.js +0 -532
- package/index.mjs +0 -132
- package/invariant.js +0 -50
- package/invariant.mjs +0 -32
- package/isAnyObject.js +0 -24
- package/isAnyObject.mjs +0 -9
- package/isArray.js +0 -24
- package/isArray.mjs +0 -9
- package/isBlob.js +0 -24
- package/isBlob.mjs +0 -9
- package/isBoolean.js +0 -24
- package/isBoolean.mjs +0 -9
- package/isBrowser.js +0 -23
- package/isBrowser.mjs +0 -5
- package/isBrowserNow.js +0 -22
- package/isBrowserNow.mjs +0 -6
- package/isDate.js +0 -24
- package/isDate.mjs +0 -9
- package/isEmptyArray.js +0 -24
- package/isEmptyArray.mjs +0 -9
- package/isEmptyObject.js +0 -24
- package/isEmptyObject.mjs +0 -9
- package/isEmptyString.js +0 -26
- package/isEmptyString.mjs +0 -8
- package/isError.js +0 -24
- package/isError.mjs +0 -9
- package/isExternalUrl.js +0 -32
- package/isExternalUrl.mjs +0 -19
- package/isFile.js +0 -24
- package/isFile.mjs +0 -9
- package/isFloat.js +0 -24
- package/isFloat.mjs +0 -9
- package/isFormData.js +0 -24
- package/isFormData.mjs +0 -9
- package/isFullArray.js +0 -24
- package/isFullArray.mjs +0 -9
- package/isFullObject.js +0 -24
- package/isFullObject.mjs +0 -9
- package/isFullString.js +0 -24
- package/isFullString.mjs +0 -9
- package/isFunction.js +0 -22
- package/isFunction.mjs +0 -8
- package/isInt.js +0 -24
- package/isInt.mjs +0 -9
- package/isMap.js +0 -24
- package/isMap.mjs +0 -9
- package/isNaNValue.js +0 -24
- package/isNaNValue.mjs +0 -9
- package/isNegativeNumber.js +0 -24
- package/isNegativeNumber.mjs +0 -9
- package/isNull.js +0 -24
- package/isNull.mjs +0 -9
- package/isNullOrUndefined.js +0 -24
- package/isNullOrUndefined.mjs +0 -9
- package/isNumber.js +0 -24
- package/isNumber.mjs +0 -11
- package/isObject.js +0 -24
- package/isObject.mjs +0 -9
- package/isObjectLike.js +0 -24
- package/isObjectLike.mjs +0 -11
- package/isOneOf.js +0 -22
- package/isOneOf.mjs +0 -4
- package/isPlainObject.js +0 -25
- package/isPlainObject.mjs +0 -10
- package/isPositiveNumber.js +0 -24
- package/isPositiveNumber.mjs +0 -9
- package/isPrimitive.js +0 -29
- package/isPrimitive.mjs +0 -14
- package/isPromise.js +0 -24
- package/isPromise.mjs +0 -9
- package/isRegExp.js +0 -24
- package/isRegExp.mjs +0 -9
- package/isServer.js +0 -23
- package/isServer.mjs +0 -7
- package/isServerNow.js +0 -22
- package/isServerNow.mjs +0 -6
- package/isSet.js +0 -24
- package/isSet.mjs +0 -9
- package/isString.js +0 -24
- package/isString.mjs +0 -9
- package/isSymbol.js +0 -24
- package/isSymbol.mjs +0 -9
- package/isType.js +0 -32
- package/isType.mjs +0 -20
- package/isUndefined.js +0 -24
- package/isUndefined.mjs +0 -9
- package/isWeakMap.js +0 -24
- package/isWeakMap.mjs +0 -9
- package/isWeakSet.js +0 -24
- package/isWeakSet.mjs +0 -9
- package/kbToBytes.js +0 -24
- package/kbToBytes.mjs +0 -6
- package/location.js +0 -6
- package/location.mjs +0 -3
- package/lowercase.js +0 -24
- package/lowercase.mjs +0 -6
- package/mapListBy.js +0 -29
- package/mapListBy.mjs +0 -11
- package/matchSorter.js +0 -373
- package/matchSorter.mjs +0 -352
- package/mbToBytes.js +0 -24
- package/mbToBytes.mjs +0 -6
- package/mergeObjects.js +0 -39
- package/mergeObjects.mjs +0 -34
- package/mergeUrlQueryParams.js +0 -32
- package/mergeUrlQueryParams.mjs +0 -18
- package/moveSortableArrayItemByKey.js +0 -35
- package/moveSortableArrayItemByKey.mjs +0 -17
- package/noop.js +0 -24
- package/noop.mjs +0 -6
- package/normaliseUrl.js +0 -24
- package/normaliseUrl.mjs +0 -13
- package/normaliseUrlPathname.js +0 -24
- package/normaliseUrlPathname.mjs +0 -12
- package/objectOmit.js +0 -35
- package/objectOmit.mjs +0 -17
- package/objectPick.js +0 -32
- package/objectPick.mjs +0 -14
- package/parseCookie.js +0 -55
- package/parseCookie.mjs +0 -44
- package/parseURL.js +0 -37
- package/parseURL.mjs +0 -19
- package/quaranteneProps.js +0 -49
- package/quaranteneProps.mjs +0 -31
- package/randomInt.js +0 -26
- package/randomInt.mjs +0 -8
- package/randomKey.js +0 -28
- package/randomKey.mjs +0 -10
- package/readCookie.js +0 -51
- package/readCookie.mjs +0 -33
- package/removeAccents.js +0 -28
- package/removeAccents.mjs +0 -12
- package/removeCookie.js +0 -28
- package/removeCookie.mjs +0 -16
- package/removeDuplicates.js +0 -13
- package/removeDuplicates.mjs +0 -12
- package/removeDuplicatesByKey.js +0 -36
- package/removeDuplicatesByKey.mjs +0 -18
- package/removeDuplicatesComparing.js +0 -25
- package/removeDuplicatesComparing.mjs +0 -9
- package/removeIndexesFromArray.js +0 -31
- package/removeIndexesFromArray.mjs +0 -13
- package/removeTrailingSlash.js +0 -26
- package/removeTrailingSlash.mjs +0 -8
- package/removeUrlQueryParams.js +0 -33
- package/removeUrlQueryParams.mjs +0 -19
- package/render.js +0 -93
- package/render.mjs +0 -110
- package/roundTo.js +0 -50
- package/roundTo.mjs +0 -32
- package/serializeCookie.js +0 -102
- package/serializeCookie.mjs +0 -98
- package/setCookie.js +0 -68
- package/setCookie.mjs +0 -55
- package/shuffle.js +0 -50
- package/shuffle.mjs +0 -32
- package/slugify.js +0 -35
- package/slugify.mjs +0 -25
- package/split.js +0 -22
- package/split.mjs +0 -4
- package/swapMap.js +0 -30
- package/swapMap.mjs +0 -12
- package/throttle.js +0 -38
- package/throttle.mjs +0 -20
- package/titleCase.js +0 -24
- package/titleCase.mjs +0 -6
- package/toNumber.js +0 -23
- package/toNumber.mjs +0 -7
- package/toRgba.js +0 -32
- package/toRgba.mjs +0 -14
- package/transformToUrlPathname.js +0 -24
- package/transformToUrlPathname.mjs +0 -13
- package/truncate.js +0 -24
- package/truncate.mjs +0 -6
- package/tryUntil.js +0 -42
- package/tryUntil.mjs +0 -24
- package/types.js +0 -5
- package/types.mjs +0 -2
- package/uid.js +0 -24
- package/uid.mjs +0 -10
- package/updateLinkParams.js +0 -26
- package/updateLinkParams.mjs +0 -13
- package/updateUrlQueryParams.js +0 -28
- package/updateUrlQueryParams.mjs +0 -14
- package/uppercase.js +0 -24
- package/uppercase.mjs +0 -6
- package/uuid.js +0 -28
- package/uuid.mjs +0 -10
- package/uuidNumeric.js +0 -23
- package/uuidNumeric.mjs +0 -5
- package/wait.js +0 -24
- package/wait.mjs +0 -6
- package/without.js +0 -55
- package/without.mjs +0 -54
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
value: true
|
|
4
|
-
});
|
|
5
|
-
function _export(target, all) {
|
|
6
|
-
for(var name in all)Object.defineProperty(target, name, {
|
|
7
|
-
enumerable: true,
|
|
8
|
-
get: all[name]
|
|
9
|
-
});
|
|
10
|
-
}
|
|
11
|
-
_export(exports, {
|
|
12
|
-
removeDuplicatesComparing: function() {
|
|
13
|
-
return removeDuplicatesComparing;
|
|
14
|
-
},
|
|
15
|
-
default: function() {
|
|
16
|
-
return _default;
|
|
17
|
-
}
|
|
18
|
-
});
|
|
19
|
-
const _findDuplicatedIndexes = require("./findDuplicatedIndexes");
|
|
20
|
-
const _removeIndexesFromArray = require("./removeIndexesFromArray");
|
|
21
|
-
function removeDuplicatesComparing(from, to) {
|
|
22
|
-
const indexes = (0, _findDuplicatedIndexes.findDuplicatedIndexes)(from);
|
|
23
|
-
return (0, _removeIndexesFromArray.removeIndexesFromArray)(to, indexes);
|
|
24
|
-
}
|
|
25
|
-
const _default = removeDuplicatesComparing;
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { findDuplicatedIndexes } from "./findDuplicatedIndexes";
|
|
2
|
-
import { removeIndexesFromArray } from "./removeIndexesFromArray";
|
|
3
|
-
/**
|
|
4
|
-
* @category array
|
|
5
|
-
*/ export function removeDuplicatesComparing(from, to) {
|
|
6
|
-
const indexes = findDuplicatedIndexes(from);
|
|
7
|
-
return removeIndexesFromArray(to, indexes);
|
|
8
|
-
}
|
|
9
|
-
export default removeDuplicatesComparing;
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @category array
|
|
3
|
-
*/ "use strict";
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
function _export(target, all) {
|
|
8
|
-
for(var name in all)Object.defineProperty(target, name, {
|
|
9
|
-
enumerable: true,
|
|
10
|
-
get: all[name]
|
|
11
|
-
});
|
|
12
|
-
}
|
|
13
|
-
_export(exports, {
|
|
14
|
-
removeIndexesFromArray: function() {
|
|
15
|
-
return removeIndexesFromArray;
|
|
16
|
-
},
|
|
17
|
-
default: function() {
|
|
18
|
-
return _default;
|
|
19
|
-
}
|
|
20
|
-
});
|
|
21
|
-
function removeIndexesFromArray(arr, indexes) {
|
|
22
|
-
const output = [];
|
|
23
|
-
for(let i = 0; i < arr.length; i++){
|
|
24
|
-
// eslint-disable-next-line no-prototype-builtins
|
|
25
|
-
if (!indexes.hasOwnProperty(i)) {
|
|
26
|
-
output.push(arr[i]);
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
return output;
|
|
30
|
-
}
|
|
31
|
-
const _default = removeIndexesFromArray;
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @category array
|
|
3
|
-
*/ export function removeIndexesFromArray(arr, indexes) {
|
|
4
|
-
const output = [];
|
|
5
|
-
for(let i = 0; i < arr.length; i++){
|
|
6
|
-
// eslint-disable-next-line no-prototype-builtins
|
|
7
|
-
if (!indexes.hasOwnProperty(i)) {
|
|
8
|
-
output.push(arr[i]);
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
return output;
|
|
12
|
-
}
|
|
13
|
-
export default removeIndexesFromArray;
|
package/removeTrailingSlash.js
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Strips out the trailing slash
|
|
3
|
-
*
|
|
4
|
-
* @category location
|
|
5
|
-
*/ "use strict";
|
|
6
|
-
Object.defineProperty(exports, "__esModule", {
|
|
7
|
-
value: true
|
|
8
|
-
});
|
|
9
|
-
function _export(target, all) {
|
|
10
|
-
for(var name in all)Object.defineProperty(target, name, {
|
|
11
|
-
enumerable: true,
|
|
12
|
-
get: all[name]
|
|
13
|
-
});
|
|
14
|
-
}
|
|
15
|
-
_export(exports, {
|
|
16
|
-
removeTralingSlash: function() {
|
|
17
|
-
return removeTralingSlash;
|
|
18
|
-
},
|
|
19
|
-
default: function() {
|
|
20
|
-
return _default;
|
|
21
|
-
}
|
|
22
|
-
});
|
|
23
|
-
function removeTralingSlash(urlLike = "") {
|
|
24
|
-
return urlLike.replace(/\/*$/, "");
|
|
25
|
-
}
|
|
26
|
-
const _default = removeTralingSlash;
|
package/removeTrailingSlash.mjs
DELETED
package/removeUrlQueryParams.js
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
value: true
|
|
4
|
-
});
|
|
5
|
-
function _export(target, all) {
|
|
6
|
-
for(var name in all)Object.defineProperty(target, name, {
|
|
7
|
-
enumerable: true,
|
|
8
|
-
get: all[name]
|
|
9
|
-
});
|
|
10
|
-
}
|
|
11
|
-
_export(exports, {
|
|
12
|
-
removeUrlQueryParams: function() {
|
|
13
|
-
return removeUrlQueryParams;
|
|
14
|
-
},
|
|
15
|
-
default: function() {
|
|
16
|
-
return _default;
|
|
17
|
-
}
|
|
18
|
-
});
|
|
19
|
-
const _interop_require_default = require("@swc/helpers/_/_interop_require_default");
|
|
20
|
-
const _buildUrlQueryString = /*#__PURE__*/ _interop_require_default._(require("./buildUrlQueryString"));
|
|
21
|
-
const _getUrlQueryParams = /*#__PURE__*/ _interop_require_default._(require("./getUrlQueryParams"));
|
|
22
|
-
function removeUrlQueryParams(url, paramsToRemove = []) {
|
|
23
|
-
const parts = url.split("?");
|
|
24
|
-
const allParams = (0, _getUrlQueryParams.default)(url);
|
|
25
|
-
const params = {};
|
|
26
|
-
for(const key in allParams){
|
|
27
|
-
if (!paramsToRemove.includes(key)) {
|
|
28
|
-
params[key] = allParams[key];
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
return parts[0] + (0, _buildUrlQueryString.default)(params);
|
|
32
|
-
}
|
|
33
|
-
const _default = removeUrlQueryParams;
|
package/removeUrlQueryParams.mjs
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
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
|
-
*/ export function removeUrlQueryParams(url, paramsToRemove = []) {
|
|
9
|
-
const parts = url.split("?");
|
|
10
|
-
const allParams = getUrlQueryParams(url);
|
|
11
|
-
const params = {};
|
|
12
|
-
for(const key in allParams){
|
|
13
|
-
if (!paramsToRemove.includes(key)) {
|
|
14
|
-
params[key] = allParams[key];
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
return parts[0] + buildUrlQueryString(params);
|
|
18
|
-
}
|
|
19
|
-
export default removeUrlQueryParams;
|
package/render.js
DELETED
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
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
|
-
render: function() {
|
|
13
|
-
return render;
|
|
14
|
-
},
|
|
15
|
-
default: function() {
|
|
16
|
-
return _default;
|
|
17
|
-
}
|
|
18
|
-
});
|
|
19
|
-
const varname = "data";
|
|
20
|
-
const evaluate = /<%([\s\S]+?(\}?)+)%>/g;
|
|
21
|
-
const interpolate = /<%=([\s\S]+?)%>/g;
|
|
22
|
-
const conditional = /<%\?(\?)?\s*([\s\S]*?)\s*%>/g;
|
|
23
|
-
const iterate = /<%~\s*(?:%>|([\s\S]+?)\s*:\s*([\w$]+)\s*(?::\s*([\w$]+))?\s*%>)/g;
|
|
24
|
-
// const encode = /<%!([\s\S]+?)%>/g;
|
|
25
|
-
const use = /<%#([\s\S]+?)%>/g;
|
|
26
|
-
const useParams = /(^|[^\w$])def(?:\.|\[['"])([\w$.]+)(?:['"]\])?\s*:\s*([\w$.]+|"[^"]+"|'[^']+'|\{[^}]+\})/g;
|
|
27
|
-
const define = /<%##\s*([\w.$]+)\s*(:|=)([\s\S]+?)#%>/g;
|
|
28
|
-
const defineParams = /^\s*([\w$]+):([\s\S]+)/;
|
|
29
|
-
const start = "'+(";
|
|
30
|
-
const end = ")+'";
|
|
31
|
-
// const startencode = "'+encodeHTML(";
|
|
32
|
-
const skip = /$^/;
|
|
33
|
-
const resolveDefs = (block, def)=>(typeof block === "string" ? block : block.toString()).replace(define || skip, (_, code, assign, value)=>{
|
|
34
|
-
if (code.indexOf("def.") === 0) {
|
|
35
|
-
code = code.substring(4);
|
|
36
|
-
}
|
|
37
|
-
if (!(code in def)) {
|
|
38
|
-
if (assign === ":") {
|
|
39
|
-
value.replace(defineParams, // @ts-expect-error nevermind
|
|
40
|
-
(_, param, v)=>{
|
|
41
|
-
def[code] = {
|
|
42
|
-
arg: param,
|
|
43
|
-
text: v
|
|
44
|
-
};
|
|
45
|
-
});
|
|
46
|
-
// @ts-expect-error nevermind
|
|
47
|
-
if (!(code in def)) def[code] = value;
|
|
48
|
-
} else {
|
|
49
|
-
new Function("def", "def['" + code + "']=" + value)(def);
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
return "";
|
|
53
|
-
}).replace(use || skip, (_, code)=>{
|
|
54
|
-
code = code.replace(useParams, (_, s, d, param)=>{
|
|
55
|
-
if (def[d] && def[d].arg && param) {
|
|
56
|
-
const rw = (d + ":" + param).replace(/'|\\/g, "_");
|
|
57
|
-
def.__exp = def.__exp || {};
|
|
58
|
-
def.__exp[rw] = def[d].text.replace(new RegExp("(^|[^\\w$])" + def[d].arg + "([^\\w$])", "g"), "$1" + param + "$2");
|
|
59
|
-
return s + "def.__exp['" + rw + "']";
|
|
60
|
-
}
|
|
61
|
-
return s;
|
|
62
|
-
});
|
|
63
|
-
const v = new Function("def", "return " + code)(def);
|
|
64
|
-
return v ? resolveDefs(v, def) : v;
|
|
65
|
-
});
|
|
66
|
-
const unescape = (code)=>code.replace(/\\('|\\)/g, "$1").replace(/[\r\t\n]/g, " ");
|
|
67
|
-
const render = (tmpl, def)=>{
|
|
68
|
-
let sid = 0;
|
|
69
|
-
let indv;
|
|
70
|
-
let str = use || define ? resolveDefs(tmpl, def || {}) : tmpl;
|
|
71
|
-
str = ("var X='" + str.replace(/(^|\r|\n)\t* +| +\t*(\r|\n|$)/g, " ").replace(/\r|\n|\t|\/\*[\s\S]*?\*\//g, "").replace(/'|\\/g, "\\$&").replace(interpolate || skip, (_, code)=>start + unescape(code) + end)// .replace(
|
|
72
|
-
// encode || skip,
|
|
73
|
-
// (_, code) => cse.startencode + unescape(code) + cse.end
|
|
74
|
-
// )
|
|
75
|
-
.replace(conditional || skip, (_, elseCase, code)=>elseCase ? code ? "';}else if(" + unescape(code) + "){X+='" : "';}else{X+='" : code ? "';if(" + unescape(code) + "){X+='" : "';}X+='").replace(iterate || skip, (_, arr, vName, iName)=>{
|
|
76
|
-
if (!arr) return "';} } X+='";
|
|
77
|
-
sid++;
|
|
78
|
-
indv = iName || "i" + sid;
|
|
79
|
-
arr = unescape(arr);
|
|
80
|
-
return "';var arr" + sid + "=" + arr + ";if(arr" + sid + "){var " + vName + "," + indv + "=-1,l" + sid + "=arr" + sid + ".length-1;while(" + indv + "<l" + sid + "){" + vName + "=arr" + sid + "[" + indv + "+=1];X+='";
|
|
81
|
-
}).replace(evaluate || skip, (_, code)=>"';" + unescape(code) + "X+='") + "';return X;").replace(/\n/g, "\\n").replace(/\t/g, "\\t").replace(/\r/g, "\\r").replace(/(\s|;|\}|^|\{)X\+='';/g, "$1").replace(/\+''/g, "");
|
|
82
|
-
//.replace(/(\s|;|\}|^|\{)X\+=''\+/g,'$1X+=');
|
|
83
|
-
try {
|
|
84
|
-
return new Function(varname, str);
|
|
85
|
-
} catch (e) {
|
|
86
|
-
if (process.env["NODE_ENV"] !== "production") {
|
|
87
|
-
console.log("Could not create a template function: " + str);
|
|
88
|
-
throw e;
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
return ()=>"";
|
|
92
|
-
};
|
|
93
|
-
const _default = render;
|
package/render.mjs
DELETED
|
@@ -1,110 +0,0 @@
|
|
|
1
|
-
const varname = "data";
|
|
2
|
-
const evaluate = /<%([\s\S]+?(\}?)+)%>/g;
|
|
3
|
-
const interpolate = /<%=([\s\S]+?)%>/g;
|
|
4
|
-
const conditional = /<%\?(\?)?\s*([\s\S]*?)\s*%>/g;
|
|
5
|
-
const iterate = /<%~\s*(?:%>|([\s\S]+?)\s*:\s*([\w$]+)\s*(?::\s*([\w$]+))?\s*%>)/g;
|
|
6
|
-
// const encode = /<%!([\s\S]+?)%>/g;
|
|
7
|
-
const use = /<%#([\s\S]+?)%>/g;
|
|
8
|
-
const useParams = /(^|[^\w$])def(?:\.|\[['"])([\w$.]+)(?:['"]\])?\s*:\s*([\w$.]+|"[^"]+"|'[^']+'|\{[^}]+\})/g;
|
|
9
|
-
const define = /<%##\s*([\w.$]+)\s*(:|=)([\s\S]+?)#%>/g;
|
|
10
|
-
const defineParams = /^\s*([\w$]+):([\s\S]+)/;
|
|
11
|
-
const start = "'+(";
|
|
12
|
-
const end = ")+'";
|
|
13
|
-
// const startencode = "'+encodeHTML(";
|
|
14
|
-
const skip = /$^/;
|
|
15
|
-
const resolveDefs = (block, def)=>(typeof block === "string" ? block : block.toString()).replace(define || skip, (_, code, assign, value)=>{
|
|
16
|
-
if (code.indexOf("def.") === 0) {
|
|
17
|
-
code = code.substring(4);
|
|
18
|
-
}
|
|
19
|
-
if (!(code in def)) {
|
|
20
|
-
if (assign === ":") {
|
|
21
|
-
value.replace(defineParams, // @ts-expect-error nevermind
|
|
22
|
-
(_, param, v)=>{
|
|
23
|
-
def[code] = {
|
|
24
|
-
arg: param,
|
|
25
|
-
text: v
|
|
26
|
-
};
|
|
27
|
-
});
|
|
28
|
-
// @ts-expect-error nevermind
|
|
29
|
-
if (!(code in def)) def[code] = value;
|
|
30
|
-
} else {
|
|
31
|
-
new Function("def", "def['" + code + "']=" + value)(def);
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
return "";
|
|
35
|
-
}).replace(use || skip, (_, code)=>{
|
|
36
|
-
code = code.replace(useParams, (_, s, d, param)=>{
|
|
37
|
-
if (def[d] && def[d].arg && param) {
|
|
38
|
-
const rw = (d + ":" + param).replace(/'|\\/g, "_");
|
|
39
|
-
def.__exp = def.__exp || {};
|
|
40
|
-
def.__exp[rw] = def[d].text.replace(new RegExp("(^|[^\\w$])" + def[d].arg + "([^\\w$])", "g"), "$1" + param + "$2");
|
|
41
|
-
return s + "def.__exp['" + rw + "']";
|
|
42
|
-
}
|
|
43
|
-
return s;
|
|
44
|
-
});
|
|
45
|
-
const v = new Function("def", "return " + code)(def);
|
|
46
|
-
return v ? resolveDefs(v, def) : v;
|
|
47
|
-
});
|
|
48
|
-
const unescape = (code)=>code.replace(/\\('|\\)/g, "$1").replace(/[\r\t\n]/g, " ");
|
|
49
|
-
/**
|
|
50
|
-
* Render template (adapted from doT.js)
|
|
51
|
-
*
|
|
52
|
-
* The data made available to the template is always on the `data` key, e.g.:
|
|
53
|
-
* `renderer({ myVal: "xx" })`
|
|
54
|
-
* ... will be accessible on
|
|
55
|
-
* `<%= data.myVal %>`
|
|
56
|
-
*
|
|
57
|
-
* The default delimiters are customised to work without conflicts with Blade and Twig:
|
|
58
|
-
* ```
|
|
59
|
-
* <% %> for evaluation
|
|
60
|
-
* <%= %> for interpolation
|
|
61
|
-
* <%? %> for conditionals
|
|
62
|
-
* <%~ %> for array iteration
|
|
63
|
-
* <%# %> for compile-time evaluation/includes and partials
|
|
64
|
-
* <%## #%> for compile-time defines
|
|
65
|
-
*
|
|
66
|
-
* Unsupported:
|
|
67
|
-
* <%! %> for interpolation with encoding
|
|
68
|
-
* ```
|
|
69
|
-
*
|
|
70
|
-
* @example
|
|
71
|
-
*
|
|
72
|
-
* ```js
|
|
73
|
-
* import { render } from "...";
|
|
74
|
-
*
|
|
75
|
-
* const data = { name: "XYZ" };
|
|
76
|
-
* const tpl = `Hello <%= data.name %>`;
|
|
77
|
-
* const renderer = render(tpl);
|
|
78
|
-
*
|
|
79
|
-
* console.log(renderer(data)); // outputs 'Hello XYZ'
|
|
80
|
-
* ```
|
|
81
|
-
*
|
|
82
|
-
* @borrows [olado/doT by Laura Doktorova](https://github.com/olado/doT)
|
|
83
|
-
* @see https://olado.github.io/doT/index.html
|
|
84
|
-
*/ export const render = (tmpl, def)=>{
|
|
85
|
-
let sid = 0;
|
|
86
|
-
let indv;
|
|
87
|
-
let str = use || define ? resolveDefs(tmpl, def || {}) : tmpl;
|
|
88
|
-
str = ("var X='" + str.replace(/(^|\r|\n)\t* +| +\t*(\r|\n|$)/g, " ").replace(/\r|\n|\t|\/\*[\s\S]*?\*\//g, "").replace(/'|\\/g, "\\$&").replace(interpolate || skip, (_, code)=>start + unescape(code) + end)// .replace(
|
|
89
|
-
// encode || skip,
|
|
90
|
-
// (_, code) => cse.startencode + unescape(code) + cse.end
|
|
91
|
-
// )
|
|
92
|
-
.replace(conditional || skip, (_, elseCase, code)=>elseCase ? code ? "';}else if(" + unescape(code) + "){X+='" : "';}else{X+='" : code ? "';if(" + unescape(code) + "){X+='" : "';}X+='").replace(iterate || skip, (_, arr, vName, iName)=>{
|
|
93
|
-
if (!arr) return "';} } X+='";
|
|
94
|
-
sid++;
|
|
95
|
-
indv = iName || "i" + sid;
|
|
96
|
-
arr = unescape(arr);
|
|
97
|
-
return "';var arr" + sid + "=" + arr + ";if(arr" + sid + "){var " + vName + "," + indv + "=-1,l" + sid + "=arr" + sid + ".length-1;while(" + indv + "<l" + sid + "){" + vName + "=arr" + sid + "[" + indv + "+=1];X+='";
|
|
98
|
-
}).replace(evaluate || skip, (_, code)=>"';" + unescape(code) + "X+='") + "';return X;").replace(/\n/g, "\\n").replace(/\t/g, "\\t").replace(/\r/g, "\\r").replace(/(\s|;|\}|^|\{)X\+='';/g, "$1").replace(/\+''/g, "");
|
|
99
|
-
//.replace(/(\s|;|\}|^|\{)X\+=''\+/g,'$1X+=');
|
|
100
|
-
try {
|
|
101
|
-
return new Function(varname, str);
|
|
102
|
-
} catch (e) {
|
|
103
|
-
if (process.env["NODE_ENV"] !== "production") {
|
|
104
|
-
console.log("Could not create a template function: " + str);
|
|
105
|
-
throw e;
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
return ()=>"";
|
|
109
|
-
};
|
|
110
|
-
export default render;
|
package/roundTo.js
DELETED
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Round to given number of the given number of decimals
|
|
3
|
-
*
|
|
4
|
-
* @category math
|
|
5
|
-
* @see https://stackoverflow.com/a/15762794/1938970
|
|
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
|
-
roundTo: function() {
|
|
18
|
-
return roundTo;
|
|
19
|
-
},
|
|
20
|
-
default: function() {
|
|
21
|
-
return _default;
|
|
22
|
-
}
|
|
23
|
-
});
|
|
24
|
-
function roundTo(num, decimals = 2) {
|
|
25
|
-
if (isFinite(num) && !isNaN(num)) {
|
|
26
|
-
// method 1
|
|
27
|
-
// return Number(num).toFixed(decimals);
|
|
28
|
-
// method 2: @see https://stackoverflow.com/a/43532829/1938970
|
|
29
|
-
const multiplicator = Math.pow(10, decimals);
|
|
30
|
-
return Math.round(num * multiplicator) / multiplicator + "";
|
|
31
|
-
// method 3: @see https://stackoverflow.com/a/15762794/1938970
|
|
32
|
-
// let negative = false;
|
|
33
|
-
// if (num < 0) {
|
|
34
|
-
// negative = true;
|
|
35
|
-
// num = num * -1;
|
|
36
|
-
// }
|
|
37
|
-
// const multiplicator = Math.pow(10, decimals);
|
|
38
|
-
// const outputStr = parseFloat((num * multiplicator).toFixed(11));
|
|
39
|
-
// let outputNum = (Math.round(outputStr) / multiplicator).toFixed(decimals);
|
|
40
|
-
// if (negative) {
|
|
41
|
-
// return (Number(outputNum) * -1).toFixed(decimals);
|
|
42
|
-
// }
|
|
43
|
-
// return outputNum;
|
|
44
|
-
}
|
|
45
|
-
if (process.env["NODE_ENV"] !== "production") {
|
|
46
|
-
console.warn("[@koine/utils] math:roundTo -> given not a finite number as first arg");
|
|
47
|
-
}
|
|
48
|
-
return "";
|
|
49
|
-
}
|
|
50
|
-
const _default = roundTo;
|
package/roundTo.mjs
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Round to given number of the given number of decimals
|
|
3
|
-
*
|
|
4
|
-
* @category math
|
|
5
|
-
* @see https://stackoverflow.com/a/15762794/1938970
|
|
6
|
-
*/ export function roundTo(num, decimals = 2) {
|
|
7
|
-
if (isFinite(num) && !isNaN(num)) {
|
|
8
|
-
// method 1
|
|
9
|
-
// return Number(num).toFixed(decimals);
|
|
10
|
-
// method 2: @see https://stackoverflow.com/a/43532829/1938970
|
|
11
|
-
const multiplicator = Math.pow(10, decimals);
|
|
12
|
-
return Math.round(num * multiplicator) / multiplicator + "";
|
|
13
|
-
// method 3: @see https://stackoverflow.com/a/15762794/1938970
|
|
14
|
-
// let negative = false;
|
|
15
|
-
// if (num < 0) {
|
|
16
|
-
// negative = true;
|
|
17
|
-
// num = num * -1;
|
|
18
|
-
// }
|
|
19
|
-
// const multiplicator = Math.pow(10, decimals);
|
|
20
|
-
// const outputStr = parseFloat((num * multiplicator).toFixed(11));
|
|
21
|
-
// let outputNum = (Math.round(outputStr) / multiplicator).toFixed(decimals);
|
|
22
|
-
// if (negative) {
|
|
23
|
-
// return (Number(outputNum) * -1).toFixed(decimals);
|
|
24
|
-
// }
|
|
25
|
-
// return outputNum;
|
|
26
|
-
}
|
|
27
|
-
if (process.env["NODE_ENV"] !== "production") {
|
|
28
|
-
console.warn("[@koine/utils] math:roundTo -> given not a finite number as first arg");
|
|
29
|
-
}
|
|
30
|
-
return "";
|
|
31
|
-
}
|
|
32
|
-
export default roundTo;
|
package/serializeCookie.js
DELETED
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @file
|
|
3
|
-
*
|
|
4
|
-
* @category cookie
|
|
5
|
-
*
|
|
6
|
-
* All cookie related code is inspired and adapted from:
|
|
7
|
-
* - [js-cookie](https://github.com/js-cookie/js-cookie)
|
|
8
|
-
* - [cookie](https://github.com/jshttp/cookie)
|
|
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
|
-
serializeCookie: function() {
|
|
21
|
-
return serializeCookie;
|
|
22
|
-
},
|
|
23
|
-
default: function() {
|
|
24
|
-
return _default;
|
|
25
|
-
}
|
|
26
|
-
});
|
|
27
|
-
const _isNumber = require("./isNumber");
|
|
28
|
-
/**
|
|
29
|
-
* RegExp to match field-content in RFC 7230 sec 3.2
|
|
30
|
-
*
|
|
31
|
-
* field-content = field-vchar [ 1*( SP / HTAB ) field-vchar ]
|
|
32
|
-
* field-vchar = VCHAR / obs-text
|
|
33
|
-
* obs-text = %x80-FF
|
|
34
|
-
*/ // eslint-disable-next-line no-control-regex
|
|
35
|
-
const fieldContentRegExp = /^[\u0009\u0020-\u007e\u0080-\u00ff]+$/;
|
|
36
|
-
function serializeCookie(name, val, attributes = {}) {
|
|
37
|
-
const { encode = encodeURIComponent, domain, path, httpOnly, secure, sameSite } = attributes;
|
|
38
|
-
let { maxAge, expires } = attributes;
|
|
39
|
-
const value = encode(val);
|
|
40
|
-
if (process.env["NODE_ENV"] !== "production") {
|
|
41
|
-
if (!fieldContentRegExp.test(name)) {
|
|
42
|
-
throw new TypeError("argument name is invalid");
|
|
43
|
-
}
|
|
44
|
-
if (typeof attributes.encode !== "function") {
|
|
45
|
-
throw new TypeError("option encode is invalid");
|
|
46
|
-
}
|
|
47
|
-
if (value && !fieldContentRegExp.test(value)) {
|
|
48
|
-
throw new TypeError("argument val is invalid");
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
let str = name + "=" + value;
|
|
52
|
-
if (null != maxAge) {
|
|
53
|
-
maxAge = maxAge - 0;
|
|
54
|
-
if (isNaN(maxAge) || !isFinite(maxAge)) {
|
|
55
|
-
throw new TypeError("option maxAge is invalid");
|
|
56
|
-
}
|
|
57
|
-
str += "; Max-Age=" + Math.floor(maxAge);
|
|
58
|
-
}
|
|
59
|
-
if (domain) {
|
|
60
|
-
if (process.env["NODE_ENV"] !== "production") {
|
|
61
|
-
if (!fieldContentRegExp.test(domain)) {
|
|
62
|
-
throw new TypeError("option domain is invalid");
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
str += "; Domain=" + domain;
|
|
66
|
-
}
|
|
67
|
-
if (path) {
|
|
68
|
-
if (process.env["NODE_ENV"] !== "production") {
|
|
69
|
-
if (!fieldContentRegExp.test(path)) {
|
|
70
|
-
throw new TypeError("option path is invalid");
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
str += "; Path=" + path;
|
|
74
|
-
}
|
|
75
|
-
if (expires) {
|
|
76
|
-
if ((0, _isNumber.isNumber)(expires)) {
|
|
77
|
-
expires = new Date(Date.now() + expires * 864e5);
|
|
78
|
-
}
|
|
79
|
-
str += "; Expires=" + expires.toUTCString();
|
|
80
|
-
}
|
|
81
|
-
if (httpOnly) {
|
|
82
|
-
str += "; HttpOnly";
|
|
83
|
-
}
|
|
84
|
-
if (secure) {
|
|
85
|
-
str += "; Secure";
|
|
86
|
-
}
|
|
87
|
-
if (sameSite) {
|
|
88
|
-
switch(sameSite.toLowerCase()){
|
|
89
|
-
case "lax":
|
|
90
|
-
str += "; SameSite=Lax";
|
|
91
|
-
break;
|
|
92
|
-
case "strict":
|
|
93
|
-
str += "; SameSite=Strict";
|
|
94
|
-
break;
|
|
95
|
-
case "none":
|
|
96
|
-
str += "; SameSite=None";
|
|
97
|
-
break;
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
return str;
|
|
101
|
-
}
|
|
102
|
-
const _default = serializeCookie;
|
package/serializeCookie.mjs
DELETED
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @file
|
|
3
|
-
*
|
|
4
|
-
* @category cookie
|
|
5
|
-
*
|
|
6
|
-
* All cookie related code is inspired and adapted from:
|
|
7
|
-
* - [js-cookie](https://github.com/js-cookie/js-cookie)
|
|
8
|
-
* - [cookie](https://github.com/jshttp/cookie)
|
|
9
|
-
*/ import { isNumber } from "./isNumber";
|
|
10
|
-
/**
|
|
11
|
-
* RegExp to match field-content in RFC 7230 sec 3.2
|
|
12
|
-
*
|
|
13
|
-
* field-content = field-vchar [ 1*( SP / HTAB ) field-vchar ]
|
|
14
|
-
* field-vchar = VCHAR / obs-text
|
|
15
|
-
* obs-text = %x80-FF
|
|
16
|
-
*/ // eslint-disable-next-line no-control-regex
|
|
17
|
-
const fieldContentRegExp = /^[\u0009\u0020-\u007e\u0080-\u00ff]+$/;
|
|
18
|
-
/**
|
|
19
|
-
* Serialize data into a cookie header.
|
|
20
|
-
*
|
|
21
|
-
* Serialize the a name value pair into a cookie string suitable for
|
|
22
|
-
* http headers. An optional attributes object specified cookie parameters.
|
|
23
|
-
*
|
|
24
|
-
* serialize('foo', 'bar', { httpOnly: true })
|
|
25
|
-
* => "foo=bar; httpOnly"
|
|
26
|
-
*
|
|
27
|
-
* @category cookie
|
|
28
|
-
*
|
|
29
|
-
* All cookie related code is inspired and adapted from:
|
|
30
|
-
* - [js-cookie](https://github.com/js-cookie/js-cookie)
|
|
31
|
-
* - [cookie](https://github.com/jshttp/cookie)
|
|
32
|
-
*/ export function serializeCookie(name, val, attributes = {}) {
|
|
33
|
-
const { encode = encodeURIComponent, domain, path, httpOnly, secure, sameSite } = attributes;
|
|
34
|
-
let { maxAge, expires } = attributes;
|
|
35
|
-
const value = encode(val);
|
|
36
|
-
if (process.env["NODE_ENV"] !== "production") {
|
|
37
|
-
if (!fieldContentRegExp.test(name)) {
|
|
38
|
-
throw new TypeError("argument name is invalid");
|
|
39
|
-
}
|
|
40
|
-
if (typeof attributes.encode !== "function") {
|
|
41
|
-
throw new TypeError("option encode is invalid");
|
|
42
|
-
}
|
|
43
|
-
if (value && !fieldContentRegExp.test(value)) {
|
|
44
|
-
throw new TypeError("argument val is invalid");
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
let str = name + "=" + value;
|
|
48
|
-
if (null != maxAge) {
|
|
49
|
-
maxAge = maxAge - 0;
|
|
50
|
-
if (isNaN(maxAge) || !isFinite(maxAge)) {
|
|
51
|
-
throw new TypeError("option maxAge is invalid");
|
|
52
|
-
}
|
|
53
|
-
str += "; Max-Age=" + Math.floor(maxAge);
|
|
54
|
-
}
|
|
55
|
-
if (domain) {
|
|
56
|
-
if (process.env["NODE_ENV"] !== "production") {
|
|
57
|
-
if (!fieldContentRegExp.test(domain)) {
|
|
58
|
-
throw new TypeError("option domain is invalid");
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
str += "; Domain=" + domain;
|
|
62
|
-
}
|
|
63
|
-
if (path) {
|
|
64
|
-
if (process.env["NODE_ENV"] !== "production") {
|
|
65
|
-
if (!fieldContentRegExp.test(path)) {
|
|
66
|
-
throw new TypeError("option path is invalid");
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
str += "; Path=" + path;
|
|
70
|
-
}
|
|
71
|
-
if (expires) {
|
|
72
|
-
if (isNumber(expires)) {
|
|
73
|
-
expires = new Date(Date.now() + expires * 864e5);
|
|
74
|
-
}
|
|
75
|
-
str += "; Expires=" + expires.toUTCString();
|
|
76
|
-
}
|
|
77
|
-
if (httpOnly) {
|
|
78
|
-
str += "; HttpOnly";
|
|
79
|
-
}
|
|
80
|
-
if (secure) {
|
|
81
|
-
str += "; Secure";
|
|
82
|
-
}
|
|
83
|
-
if (sameSite) {
|
|
84
|
-
switch(sameSite.toLowerCase()){
|
|
85
|
-
case "lax":
|
|
86
|
-
str += "; SameSite=Lax";
|
|
87
|
-
break;
|
|
88
|
-
case "strict":
|
|
89
|
-
str += "; SameSite=Strict";
|
|
90
|
-
break;
|
|
91
|
-
case "none":
|
|
92
|
-
str += "; SameSite=None";
|
|
93
|
-
break;
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
return str;
|
|
97
|
-
}
|
|
98
|
-
export default serializeCookie;
|