@koine/utils 2.0.0-beta.80 → 2.0.0-beta.83
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.cjs.js +20 -10
- package/Defer.esm.js +20 -10
- package/Emitter.cjs.js +18 -19
- package/Emitter.d.ts +1 -1
- package/Emitter.esm.js +18 -19
- package/accentsSets.cjs.d.ts +2 -0
- package/accentsSets.cjs.default.js +1 -0
- package/accentsSets.cjs.js +20 -0
- package/accentsSets.cjs.mjs +2 -0
- package/accentsSets.esm.js +15 -0
- package/addOrReplaceAtIdx.cjs.js +7 -14
- package/addOrReplaceAtIdx.esm.js +7 -14
- package/areEqual.cjs.js +28 -43
- package/areEqual.esm.js +28 -43
- package/arrayFilterFalsy.cjs.js +6 -1
- package/arrayFilterFalsy.d.ts +1 -1
- package/arrayFilterFalsy.esm.js +6 -1
- package/arrayFindLastIndex.cjs.js +13 -8
- package/arrayFindLastIndex.d.ts +1 -1
- package/arrayFindLastIndex.esm.js +13 -8
- package/arrayOfAll.cjs.js +16 -1
- package/arrayOfAll.esm.js +16 -1
- package/arraySum.cjs.js +6 -1
- package/arraySum.esm.js +6 -1
- package/arrayToLookup.cjs.js +5 -4
- package/arrayToLookup.esm.js +5 -4
- package/arrayUniqueByProperties.cjs.js +8 -1
- package/arrayUniqueByProperties.esm.js +8 -1
- package/buildUrlQueryString.cjs.js +10 -17
- package/buildUrlQueryString.esm.js +10 -17
- package/capitalize.cjs.js +7 -2
- package/capitalize.d.ts +1 -1
- package/capitalize.esm.js +7 -2
- package/changeCaseCamel.cjs.js +7 -17
- package/changeCaseCamel.esm.js +7 -17
- package/changeCaseCapital.cjs.js +7 -10
- package/changeCaseCapital.esm.js +7 -10
- package/changeCaseConstant.cjs.js +7 -6
- package/changeCaseConstant.esm.js +7 -6
- package/changeCaseDot.cjs.js +7 -1
- package/changeCaseDot.esm.js +7 -1
- package/changeCaseHelpers.cjs.js +32 -71
- package/changeCaseHelpers.esm.js +32 -71
- package/changeCaseKebab.cjs.js +7 -1
- package/changeCaseKebab.esm.js +7 -1
- package/changeCaseNone.cjs.js +7 -6
- package/changeCaseNone.esm.js +7 -6
- package/changeCasePascal.cjs.js +7 -9
- package/changeCasePascal.esm.js +7 -9
- package/changeCasePascalSnake.cjs.js +7 -1
- package/changeCasePascalSnake.esm.js +7 -1
- package/changeCasePath.cjs.js +7 -1
- package/changeCasePath.esm.js +7 -1
- package/changeCaseSentence.cjs.js +7 -15
- package/changeCaseSentence.esm.js +8 -16
- package/changeCaseSnake.cjs.js +7 -1
- package/changeCaseSnake.esm.js +7 -1
- package/changeCaseTrain.cjs.js +7 -1
- package/changeCaseTrain.esm.js +7 -1
- package/chunkByChunks.cjs.js +5 -31
- package/chunkByChunks.esm.js +5 -31
- package/chunkBySize.cjs.js +4 -7
- package/chunkBySize.esm.js +4 -7
- package/clamp.cjs.js +6 -1
- package/clamp.esm.js +6 -1
- package/clsx.cjs.js +8 -39
- package/clsx.esm.js +8 -39
- package/convertRange.cjs.js +14 -1
- package/convertRange.esm.js +14 -1
- package/cookie.cjs.js +44 -1
- package/cookie.esm.js +44 -1
- package/createPalette.cjs.js +17 -11
- package/createPalette.esm.js +17 -11
- package/debounce.cjs.js +7 -17
- package/debounce.esm.js +7 -17
- package/debouncePromise.cjs.js +16 -51
- package/debouncePromise.esm.js +16 -51
- package/debounceRaf.cjs.js +10 -12
- package/debounceRaf.esm.js +10 -12
- package/decode.cjs.js +4 -1
- package/decode.esm.js +4 -1
- package/encode.cjs.js +4 -1
- package/encode.esm.js +4 -1
- package/ensureInt.cjs.js +5 -1
- package/ensureInt.esm.js +5 -1
- package/errorToString.cjs.js +6 -1
- package/errorToString.esm.js +6 -1
- package/escapeRegExp.cjs.js +7 -1
- package/escapeRegExp.esm.js +7 -1
- package/findDuplicatedIndexes.cjs.js +3 -10
- package/findDuplicatedIndexes.esm.js +3 -10
- package/forin.cjs.js +6 -5
- package/forin.esm.js +6 -5
- package/gbToBytes.cjs.js +5 -1
- package/gbToBytes.esm.js +5 -1
- package/getEmptyArray.cjs.js +6 -3
- package/getEmptyArray.esm.js +6 -3
- package/getKeys.cjs.js +8 -1
- package/getKeys.d.ts +1 -1
- package/getKeys.esm.js +8 -1
- package/getMediaQueryWidthResolvers.cjs.js +27 -41
- package/getMediaQueryWidthResolvers.esm.js +27 -41
- package/getMediaQueryWidthTailwindScreens.cjs.js +6 -25
- package/getMediaQueryWidthTailwindScreens.esm.js +6 -25
- package/getNonce.cjs.js +4 -1
- package/getNonce.esm.js +4 -1
- package/getParamAmong.cjs.js +11 -4
- package/getParamAmong.esm.js +11 -4
- package/getParamAsInt.cjs.js +10 -7
- package/getParamAsInt.esm.js +10 -7
- package/getParamAsString.cjs.js +9 -1
- package/getParamAsString.esm.js +9 -1
- package/getType.cjs.js +13 -1
- package/getType.esm.js +13 -1
- package/getUrlHashParams.cjs.js +6 -8
- package/getUrlHashParams.esm.js +6 -8
- package/getUrlHashPathname.cjs.js +7 -1
- package/getUrlHashPathname.esm.js +7 -1
- package/getUrlPathnameParts.cjs.js +10 -4
- package/getUrlPathnameParts.esm.js +10 -4
- package/getUrlQueryParams.cjs.js +12 -20
- package/getUrlQueryParams.esm.js +12 -20
- package/hashAny.cjs.d.ts +2 -0
- package/hashAny.cjs.default.js +1 -0
- package/hashAny.cjs.js +40 -0
- package/hashAny.cjs.mjs +2 -0
- package/hashAny.d.ts +2 -0
- package/hashAny.esm.js +35 -0
- package/imgEmptyPixel.cjs.js +5 -1
- package/imgEmptyPixel.esm.js +5 -1
- package/index.cjs.js +5 -3
- package/index.d.ts +2 -1
- package/index.esm.js +3 -2
- package/invariant.cjs.js +17 -16
- package/invariant.esm.js +17 -16
- package/isAbsoluteUrl.cjs.js +5 -2
- package/isAbsoluteUrl.esm.js +5 -2
- package/isAnyObject.cjs.js +5 -1
- package/isAnyObject.esm.js +5 -1
- package/isArray.cjs.js +5 -1
- package/isArray.esm.js +5 -1
- package/isBlob.cjs.js +5 -1
- package/isBlob.esm.js +5 -1
- package/isBoolean.cjs.js +5 -1
- package/isBoolean.esm.js +5 -1
- package/isBrowser.cjs.js +4 -1
- package/isBrowser.esm.js +4 -1
- package/isBrowserNow.cjs.js +4 -1
- package/isBrowserNow.esm.js +4 -1
- package/isDate.cjs.js +5 -1
- package/isDate.esm.js +5 -1
- package/isEmptyArray.cjs.js +5 -1
- package/isEmptyArray.esm.js +5 -1
- package/isEmptyObject.cjs.js +5 -1
- package/isEmptyObject.esm.js +5 -1
- package/isEmptyString.cjs.js +5 -1
- package/isEmptyString.esm.js +5 -1
- package/isError.cjs.js +5 -1
- package/isError.esm.js +5 -1
- package/isExternalUrl.cjs.js +9 -9
- package/isExternalUrl.esm.js +9 -9
- package/isFile.cjs.js +5 -1
- package/isFile.esm.js +5 -1
- package/isFloat.cjs.js +5 -1
- package/isFloat.esm.js +5 -1
- package/isFormData.cjs.js +5 -1
- package/isFormData.esm.js +5 -1
- package/isFullArray.cjs.js +5 -1
- package/isFullArray.esm.js +5 -1
- package/isFullObject.cjs.js +5 -1
- package/isFullObject.esm.js +5 -1
- package/isFullString.cjs.js +5 -1
- package/isFullString.esm.js +5 -1
- package/isFunction.cjs.js +5 -1
- package/isFunction.esm.js +5 -1
- package/isInt.cjs.js +5 -1
- package/isInt.esm.js +5 -1
- package/isMap.cjs.js +5 -1
- package/isMap.esm.js +5 -1
- package/isNaNValue.cjs.js +5 -1
- package/isNaNValue.esm.js +5 -1
- package/isNegativeNumber.cjs.js +5 -1
- package/isNegativeNumber.esm.js +5 -1
- package/isNull.cjs.js +5 -1
- package/isNull.esm.js +5 -1
- package/isNullOrUndefined.cjs.js +5 -1
- package/isNullOrUndefined.esm.js +5 -1
- package/isNumber.cjs.js +7 -1
- package/isNumber.esm.js +7 -1
- package/isNumericLiteral.cjs.js +8 -1
- package/isNumericLiteral.esm.js +8 -1
- package/isObject.cjs.js +5 -1
- package/isObject.esm.js +5 -1
- package/isObjectLike.cjs.js +7 -1
- package/isObjectLike.esm.js +7 -1
- package/isObjectStringKeyed.cjs.js +9 -1
- package/isObjectStringKeyed.esm.js +9 -1
- package/isOneOf.cjs.js +3 -7
- package/isOneOf.esm.js +3 -7
- package/isPlainObject.cjs.js +5 -4
- package/isPlainObject.esm.js +5 -4
- package/isPositiveNumber.cjs.js +5 -1
- package/isPositiveNumber.esm.js +5 -1
- package/isPrimitive.cjs.js +5 -6
- package/isPrimitive.esm.js +5 -6
- package/isPromise.cjs.js +5 -1
- package/isPromise.esm.js +5 -1
- package/isRegExp.cjs.js +5 -1
- package/isRegExp.esm.js +5 -1
- package/isServer.cjs.js +4 -1
- package/isServer.esm.js +4 -1
- package/isServerNow.cjs.js +4 -1
- package/isServerNow.esm.js +4 -1
- package/isSet.cjs.js +5 -1
- package/isSet.esm.js +5 -1
- package/isString.cjs.js +5 -1
- package/isString.esm.js +5 -1
- package/isSymbol.cjs.js +5 -1
- package/isSymbol.esm.js +5 -1
- package/isType.cjs.js +9 -11
- package/isType.esm.js +9 -11
- package/isUndefined.cjs.js +5 -1
- package/isUndefined.esm.js +5 -1
- package/isWeakMap.cjs.js +5 -1
- package/isWeakMap.esm.js +5 -1
- package/isWeakSet.cjs.js +5 -1
- package/isWeakSet.esm.js +5 -1
- package/kbToBytes.cjs.js +5 -1
- package/kbToBytes.esm.js +5 -1
- package/lowercase.cjs.js +5 -1
- package/lowercase.d.ts +1 -1
- package/lowercase.esm.js +5 -1
- package/mapListBy.cjs.js +5 -4
- package/mapListBy.esm.js +5 -4
- package/matchSorter.cjs.js +94 -239
- package/matchSorter.d.ts +1 -1
- package/matchSorter.esm.js +92 -237
- package/mbToBytes.cjs.js +5 -1
- package/mbToBytes.esm.js +5 -1
- package/mergeObjects.cjs.js +8 -26
- package/mergeObjects.esm.js +8 -26
- package/mergeUrlQueryParams.cjs.js +5 -12
- package/mergeUrlQueryParams.esm.js +5 -12
- package/moveSortableArrayItemByKey.cjs.js +7 -8
- package/moveSortableArrayItemByKey.esm.js +7 -8
- package/noop.cjs.js +5 -1
- package/noop.esm.js +5 -1
- package/normaliseUrl.cjs.js +9 -1
- package/normaliseUrl.esm.js +9 -1
- package/normaliseUrlPathname.cjs.js +8 -1
- package/normaliseUrlPathname.esm.js +8 -1
- package/objectFlat.cjs.js +8 -16
- package/objectFlat.esm.js +8 -16
- package/objectFlip.cjs.js +4 -4
- package/objectFlip.esm.js +4 -4
- package/objectMergeWithDefaults.cjs.js +29 -19
- package/objectMergeWithDefaults.d.ts +1 -1
- package/objectMergeWithDefaults.esm.js +29 -19
- package/objectOmit.cjs.js +9 -7
- package/objectOmit.esm.js +9 -7
- package/objectPick.cjs.js +6 -8
- package/objectPick.esm.js +6 -8
- package/objectSort.cjs.js +8 -1
- package/objectSort.esm.js +8 -1
- package/objectSortByKeysMatching.cjs.js +9 -1
- package/objectSortByKeysMatching.esm.js +9 -1
- package/objectToArray.cjs.js +6 -1
- package/objectToArray.esm.js +6 -1
- package/package.json +10 -5
- package/parseCookie.cjs.js +13 -32
- package/parseCookie.esm.js +13 -32
- package/parseURL.cjs.js +6 -13
- package/parseURL.esm.js +6 -13
- package/quaranteneProps.cjs.js +17 -15
- package/quaranteneProps.esm.js +17 -15
- package/randomInt.cjs.js +5 -1
- package/randomInt.esm.js +5 -1
- package/randomKey.cjs.js +6 -4
- package/randomKey.esm.js +6 -4
- package/readCookie.cjs.js +5 -33
- package/readCookie.esm.js +5 -33
- package/removeAccents.cjs.js +4 -9
- package/removeAccents.d.ts +1 -1
- package/removeAccents.esm.js +4 -9
- package/removeCookie.cjs.js +3 -7
- package/removeCookie.esm.js +3 -7
- package/removeDuplicates.cjs.js +8 -1
- package/removeDuplicates.esm.js +8 -1
- package/removeDuplicatesByKey.cjs.js +6 -12
- package/removeDuplicatesByKey.esm.js +6 -12
- package/removeDuplicatesComparing.cjs.js +3 -4
- package/removeDuplicatesComparing.esm.js +3 -4
- package/removeIndexesFromArray.cjs.js +4 -9
- package/removeIndexesFromArray.esm.js +4 -9
- package/removeTrailingSlash.cjs.js +5 -1
- package/removeTrailingSlash.esm.js +5 -1
- package/removeUrlQueryParams.cjs.js +5 -11
- package/removeUrlQueryParams.esm.js +5 -11
- package/render.cjs.js +52 -112
- package/render.esm.js +52 -112
- package/round.cjs.js +11 -3
- package/round.esm.js +11 -3
- package/roundTo.cjs.js +22 -10
- package/roundTo.esm.js +22 -10
- package/serializeCookie.cjs.js +13 -67
- package/serializeCookie.esm.js +13 -67
- package/setCookie.cjs.js +11 -41
- package/setCookie.esm.js +11 -41
- package/shuffle.cjs.js +15 -16
- package/shuffle.esm.js +15 -16
- package/slugify.cjs.js +20 -9
- package/slugify.esm.js +20 -9
- package/split.cjs.js +6 -1
- package/split.esm.js +6 -1
- package/splitReverse.cjs.js +6 -1
- package/splitReverse.esm.js +6 -1
- package/swapMap.cjs.js +5 -7
- package/swapMap.esm.js +5 -7
- package/throttle.cjs.js +6 -14
- package/throttle.d.ts +1 -1
- package/throttle.esm.js +6 -14
- package/titleCase.cjs.js +6 -3
- package/titleCase.esm.js +6 -3
- package/toNumber.cjs.js +5 -1
- package/toNumber.esm.js +5 -1
- package/toRgba.cjs.js +5 -7
- package/toRgba.esm.js +5 -7
- package/transformToUrlPathname.cjs.js +9 -3
- package/transformToUrlPathname.esm.js +9 -3
- package/truncate.cjs.js +5 -5
- package/truncate.esm.js +5 -5
- package/tryUntil.cjs.js +14 -14
- package/tryUntil.esm.js +14 -14
- package/uid.cjs.js +5 -5
- package/uid.esm.js +5 -5
- package/updateLinkParams.cjs.js +7 -5
- package/updateLinkParams.esm.js +7 -5
- package/updateUrlQueryParams.cjs.js +5 -7
- package/updateUrlQueryParams.esm.js +5 -7
- package/uppercase.cjs.js +6 -1
- package/uppercase.d.ts +1 -1
- package/uppercase.esm.js +6 -1
- package/uuid.cjs.js +6 -4
- package/uuid.esm.js +6 -4
- package/uuidNumeric.cjs.js +4 -1
- package/uuidNumeric.esm.js +4 -1
- package/wait.cjs.js +5 -1
- package/wait.esm.js +5 -1
- package/accentSets.cjs.d.ts +0 -2
- package/accentSets.cjs.default.js +0 -1
- package/accentSets.cjs.js +0 -36
- package/accentSets.cjs.mjs +0 -2
- package/accentSets.esm.js +0 -31
- /package/{accentSets.d.ts → accentsSets.d.ts} +0 -0
package/render.esm.js
CHANGED
|
@@ -1,114 +1,54 @@
|
|
|
1
|
-
let
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
.replace(/\r|\n|\t|\/\*[\s\S]*?\*\//g, "")
|
|
54
|
-
.replace(/'|\\/g, "\\$&")
|
|
55
|
-
.replace(interpolate || skip, (_, code) => start + unescape(code) + end)
|
|
56
|
-
.replace(conditional || skip, (_, elseCase, code) => elseCase
|
|
57
|
-
? code
|
|
58
|
-
? "';}else if(" + unescape(code) + "){X+='"
|
|
59
|
-
: "';}else{X+='"
|
|
60
|
-
: code
|
|
61
|
-
? "';if(" + unescape(code) + "){X+='"
|
|
62
|
-
: "';}X+='")
|
|
63
|
-
.replace(iterate || skip, (_, arr, vName, iName) => {
|
|
64
|
-
if (!arr)
|
|
65
|
-
return "';} } X+='";
|
|
66
|
-
sid++;
|
|
67
|
-
indv = iName || "i" + sid;
|
|
68
|
-
arr = unescape(arr);
|
|
69
|
-
return ("';var arr" +
|
|
70
|
-
sid +
|
|
71
|
-
"=" +
|
|
72
|
-
arr +
|
|
73
|
-
";if(arr" +
|
|
74
|
-
sid +
|
|
75
|
-
"){var " +
|
|
76
|
-
vName +
|
|
77
|
-
"," +
|
|
78
|
-
indv +
|
|
79
|
-
"=-1,l" +
|
|
80
|
-
sid +
|
|
81
|
-
"=arr" +
|
|
82
|
-
sid +
|
|
83
|
-
".length-1;while(" +
|
|
84
|
-
indv +
|
|
85
|
-
"<l" +
|
|
86
|
-
sid +
|
|
87
|
-
"){" +
|
|
88
|
-
vName +
|
|
89
|
-
"=arr" +
|
|
90
|
-
sid +
|
|
91
|
-
"[" +
|
|
92
|
-
indv +
|
|
93
|
-
"+=1];X+='");
|
|
94
|
-
})
|
|
95
|
-
.replace(evaluate || skip, (_, code) => "';" + unescape(code) + "X+='") +
|
|
96
|
-
"';return X;")
|
|
97
|
-
.replace(/\n/g, "\\n")
|
|
98
|
-
.replace(/\t/g, "\\t")
|
|
99
|
-
.replace(/\r/g, "\\r")
|
|
100
|
-
.replace(/(\s|;|\}|^|\{)X\+='';/g, "$1")
|
|
101
|
-
.replace(/\+''/g, "");
|
|
102
|
-
try {
|
|
103
|
-
return new Function(varname, str);
|
|
104
|
-
}
|
|
105
|
-
catch (e) {
|
|
106
|
-
if (process.env["NODE_ENV"] === "development") {
|
|
107
|
-
console.log("Could not create a template function: " + str);
|
|
108
|
-
throw e;
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
return () => "";
|
|
112
|
-
};
|
|
1
|
+
let e=/<%([\s\S]+?(\}?)+)%>/g,r=/<%=([\s\S]+?)%>/g,t=/<%\?(\?)?\s*([\s\S]*?)\s*%>/g,a=/<%~\s*(?:%>|([\s\S]+?)\s*:\s*([\w$]+)\s*(?::\s*([\w$]+))?\s*%>)/g,// let encode = /<%!([\s\S]+?)%>/g;
|
|
2
|
+
l=/<%#([\s\S]+?)%>/g,n=/(^|[^\w$])def(?:\.|\[['"])([\w$.]+)(?:['"]\])?\s*:\s*([\w$.]+|"[^"]+"|'[^']+'|\{[^}]+\})/g,p=/<%##\s*([\w.$]+)\s*(:|=)([\s\S]+?)#%>/g,s=/^\s*([\w$]+):([\s\S]+)/,// let startencode = "'+encodeHTML(";
|
|
3
|
+
c=/$^/,g=(e,r)=>("string"==typeof e?e:e.toString()).replace(p||c,(e,t,a,l)=>(0===t.indexOf("def.")&&(t=t.substring(4)),t in r||(":"===a?(l.replace(s,// @ts-expect-error nevermind
|
|
4
|
+
(e,a,l)=>{r[t]={arg:a,text:l};}),// @ts-expect-error nevermind
|
|
5
|
+
t in r||(r[t]=l)):Function("def","def['"+t+"']="+l)(r)),"")).replace(l||c,(e,t)=>{let a=Function("def","return "+(t=t.replace(n,(e,t,a,l)=>{if(r[a]&&r[a].arg&&l){let e=(a+":"+l).replace(/'|\\/g,"_");return r.__exp=r.__exp||{},r.__exp[e]=r[a].text.replace(RegExp("(^|[^\\w$])"+r[a].arg+"([^\\w$])","g"),"$1"+l+"$2"),t+"def.__exp['"+e+"']"}return t})))(r);return a?g(a,r):a}),i=e=>e.replace(/\\('|\\)/g,"$1").replace(/[\r\t\n]/g," ");/**
|
|
6
|
+
* Render template (adapted from doT.js)
|
|
7
|
+
*
|
|
8
|
+
* The data made available to the template is always on the `data` key, e.g.:
|
|
9
|
+
* `renderer({ myVal: "xx" })`
|
|
10
|
+
* ... will be accessible on
|
|
11
|
+
* `<%= data.myVal %>`
|
|
12
|
+
*
|
|
13
|
+
* The default delimiters are customised to work without conflicts with Blade and Twig:
|
|
14
|
+
* ```
|
|
15
|
+
* <% %> for evaluation
|
|
16
|
+
* <%= %> for interpolation
|
|
17
|
+
* <%? %> for conditionals
|
|
18
|
+
* <%~ %> for array iteration
|
|
19
|
+
* <%# %> for compile-time evaluation/includes and partials
|
|
20
|
+
* <%## #%> for compile-time defines
|
|
21
|
+
*
|
|
22
|
+
* Unsupported:
|
|
23
|
+
* <%! %> for interpolation with encoding
|
|
24
|
+
* ```
|
|
25
|
+
*
|
|
26
|
+
* @category impl
|
|
27
|
+
* @example
|
|
28
|
+
*
|
|
29
|
+
* ```ts
|
|
30
|
+
* import { render } from "...";
|
|
31
|
+
*
|
|
32
|
+
* const data = { name: "XYZ" };
|
|
33
|
+
* const tpl = `Hello <%= data.name %>`;
|
|
34
|
+
* const renderer = render(tpl);
|
|
35
|
+
*
|
|
36
|
+
* console.log(renderer(data)); // outputs 'Hello XYZ'
|
|
37
|
+
* ```
|
|
38
|
+
*
|
|
39
|
+
* @borrows [olado/doT by Laura Doktorova](https://github.com/olado/doT)
|
|
40
|
+
* @see https://olado.github.io/doT/index.html
|
|
41
|
+
*/let render=(n,s)=>{let o,$=0,f=l||p?g(n,s||{}):n;f=("var X='"+f.replace(/(^|\r|\n)\t* +| +\t*(\r|\n|$)/g," ").replace(/\r|\n|\t|\/\*[\s\S]*?\*\//g,"").replace(/'|\\/g,"\\$&").replace(r||c,(e,r)=>"'+("+i(r)+")+'").// .replace(
|
|
42
|
+
// encode || skip,
|
|
43
|
+
// (_, code) => cse.startencode + unescape(code) + cse.end
|
|
44
|
+
// )
|
|
45
|
+
replace(t||c,(e,r,t)=>r?t?"';}else if("+i(t)+"){X+='":"';}else{X+='":t?"';if("+i(t)+"){X+='":"';}X+='").replace(a||c,(e,r,t,a)=>r?($++,o=a||"i"+$,r=i(r),"';var arr"+$+"="+r+";if(arr"+$+"){var "+t+","+o+"=-1,l"+$+"=arr"+$+".length-1;while("+o+"<l"+$+"){"+t+"=arr"+$+"["+o+"+=1];X+='"):"';} } X+='").replace(e||c,(e,r)=>"';"+i(r)+"X+='")+"';return X;").replace(/\n/g,"\\n").replace(/\t/g,"\\t").replace(/\r/g,"\\r").replace(/(\s|;|\}|^|\{)X\+='';/g,"$1").replace(/\+''/g,"");//.replace(/(\s|;|\}|^|\{)X\+=''\+/g,'$1X+=');
|
|
46
|
+
try{return Function(// RenderData;
|
|
47
|
+
/**
|
|
48
|
+
* Returned render function
|
|
49
|
+
*//**
|
|
50
|
+
* Default render function creator
|
|
51
|
+
*/// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
52
|
+
"data",f)}catch(e){if("development"===process.env.NODE_ENV)throw console.log("Could not create a template function: "+f),e}return ()=>""};
|
|
113
53
|
|
|
114
54
|
export { render as default, render };
|
package/round.cjs.js
CHANGED
|
@@ -2,9 +2,17 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
/**
|
|
6
|
+
* Round a number to the given amount of decimals
|
|
7
|
+
*
|
|
8
|
+
* If `keepZeroes` is `false` we normalises `x.00` to `x` and `x.10` to `x.1`
|
|
9
|
+
*
|
|
10
|
+
* @category number
|
|
11
|
+
*
|
|
12
|
+
* @param number
|
|
13
|
+
* @param decimals default `undefined`
|
|
14
|
+
* @param trailingZeroes default `undefined` Whether to keep trailing zeroes
|
|
15
|
+
*/let round=(e,r,t)=>r?parseFloat(e.toFixed(r).replace(t?"":/\.+0*$/,"")):parseInt(e+"",10);
|
|
8
16
|
|
|
9
17
|
exports["default"] = round;
|
|
10
18
|
exports.round = round;
|
package/round.esm.js
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Round a number to the given amount of decimals
|
|
3
|
+
*
|
|
4
|
+
* If `keepZeroes` is `false` we normalises `x.00` to `x` and `x.10` to `x.1`
|
|
5
|
+
*
|
|
6
|
+
* @category number
|
|
7
|
+
*
|
|
8
|
+
* @param number
|
|
9
|
+
* @param decimals default `undefined`
|
|
10
|
+
* @param trailingZeroes default `undefined` Whether to keep trailing zeroes
|
|
11
|
+
*/let round=(e,r,t)=>r?parseFloat(e.toFixed(r).replace(t?"":/\.+0*$/,"")):parseInt(e+"",10);
|
|
4
12
|
|
|
5
13
|
export { round as default, round };
|
package/roundTo.cjs.js
CHANGED
|
@@ -2,16 +2,28 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
5
|
+
/**
|
|
6
|
+
* Round to given number of the given number of decimals
|
|
7
|
+
*
|
|
8
|
+
* @category math
|
|
9
|
+
* @see https://stackoverflow.com/a/15762794/1938970
|
|
10
|
+
*/let roundTo=(e,n=2)=>{if(isFinite(e)&&!isNaN(e)){// method 1
|
|
11
|
+
// return Number(num).toFixed(decimals);
|
|
12
|
+
// method 2: @see https://stackoverflow.com/a/43532829/1938970
|
|
13
|
+
let o=Math.pow(10,n);return Math.round(e*o)/o+""}return("development"===// 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
|
+
process.env.NODE_ENV&&console.warn("[@koine/utils] math:roundTo -> given not a finite number as first arg"),"")};
|
|
15
27
|
|
|
16
28
|
exports["default"] = roundTo;
|
|
17
29
|
exports.roundTo = roundTo;
|
package/roundTo.esm.js
CHANGED
|
@@ -1,12 +1,24 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
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
|
+
*/let roundTo=(e,n=2)=>{if(isFinite(e)&&!isNaN(e)){// method 1
|
|
7
|
+
// return Number(num).toFixed(decimals);
|
|
8
|
+
// method 2: @see https://stackoverflow.com/a/43532829/1938970
|
|
9
|
+
let o=Math.pow(10,n);return Math.round(e*o)/o+""}return("development"===// method 3: @see https://stackoverflow.com/a/15762794/1938970
|
|
10
|
+
// let negative = false;
|
|
11
|
+
// if (num < 0) {
|
|
12
|
+
// negative = true;
|
|
13
|
+
// num = num * -1;
|
|
14
|
+
// }
|
|
15
|
+
// const multiplicator = Math.pow(10, decimals);
|
|
16
|
+
// const outputStr = parseFloat((num * multiplicator).toFixed(11));
|
|
17
|
+
// let outputNum = (Math.round(outputStr) / multiplicator).toFixed(decimals);
|
|
18
|
+
// if (negative) {
|
|
19
|
+
// return (Number(outputNum) * -1).toFixed(decimals);
|
|
20
|
+
// }
|
|
21
|
+
// return outputNum;
|
|
22
|
+
process.env.NODE_ENV&&console.warn("[@koine/utils] math:roundTo -> given not a finite number as first arg"),"")};
|
|
11
23
|
|
|
12
24
|
export { roundTo as default, roundTo };
|
package/serializeCookie.cjs.js
CHANGED
|
@@ -5,73 +5,19 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
5
5
|
var isNumber = require('./isNumber.cjs.js');
|
|
6
6
|
require('./getType.cjs.js');
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
throw new TypeError("argument val is invalid");
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
let str = name + "=" + value;
|
|
25
|
-
if (null != maxAge) {
|
|
26
|
-
maxAge = maxAge - 0;
|
|
27
|
-
if (isNaN(maxAge) || !isFinite(maxAge)) {
|
|
28
|
-
throw new TypeError("option maxAge is invalid");
|
|
29
|
-
}
|
|
30
|
-
str += "; Max-Age=" + Math.floor(maxAge);
|
|
31
|
-
}
|
|
32
|
-
if (domain) {
|
|
33
|
-
if (process.env["NODE_ENV"] === "development") {
|
|
34
|
-
if (!fieldContentRegExp.test(domain)) {
|
|
35
|
-
throw new TypeError("option domain is invalid");
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
str += "; Domain=" + domain;
|
|
39
|
-
}
|
|
40
|
-
if (path) {
|
|
41
|
-
if (process.env["NODE_ENV"] === "development") {
|
|
42
|
-
if (!fieldContentRegExp.test(path)) {
|
|
43
|
-
throw new TypeError("option path is invalid");
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
str += "; Path=" + path;
|
|
47
|
-
}
|
|
48
|
-
if (expires) {
|
|
49
|
-
if (isNumber.isNumber(expires)) {
|
|
50
|
-
expires = new Date(Date.now() + expires * 864e5);
|
|
51
|
-
}
|
|
52
|
-
str += "; Expires=" + expires.toUTCString();
|
|
53
|
-
}
|
|
54
|
-
if (httpOnly) {
|
|
55
|
-
str += "; HttpOnly";
|
|
56
|
-
}
|
|
57
|
-
if (secure) {
|
|
58
|
-
str += "; Secure";
|
|
59
|
-
}
|
|
60
|
-
if (sameSite) {
|
|
61
|
-
switch (sameSite.toLowerCase()) {
|
|
62
|
-
case "lax":
|
|
63
|
-
str += "; SameSite=Lax";
|
|
64
|
-
break;
|
|
65
|
-
case "strict":
|
|
66
|
-
str += "; SameSite=Strict";
|
|
67
|
-
break;
|
|
68
|
-
case "none":
|
|
69
|
-
str += "; SameSite=None";
|
|
70
|
-
break;
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
return str;
|
|
74
|
-
};
|
|
8
|
+
let i=/^[\u0009\u0020-\u007e\u0080-\u00ff]+$/;/**
|
|
9
|
+
* Serialize data into a cookie header.
|
|
10
|
+
*
|
|
11
|
+
* Serialize the a name value pair into a cookie string suitable for
|
|
12
|
+
* http headers. An optional attributes object specified cookie parameters.
|
|
13
|
+
*
|
|
14
|
+
* serialize('foo', 'bar', { httpOnly: true })
|
|
15
|
+
* => "foo=bar; httpOnly"
|
|
16
|
+
*
|
|
17
|
+
* @category cookie
|
|
18
|
+
*/let serializeCookie=(t,o,r={})=>{let{encode:n=encodeURIComponent,domain:a,path:s,httpOnly:p,secure:l,sameSite:f}=r,{maxAge:m,expires:c}=r,d=n(o);if("development"===process.env.NODE_ENV){if(!i.test(t))throw TypeError("argument name is invalid");if("function"!=typeof r.encode)throw TypeError("option encode is invalid");if(d&&!i.test(d))throw TypeError("argument val is invalid")}let u=t+"="+d;if(null!=m){if(isNaN(m-=0)||!isFinite(m))throw TypeError("option maxAge is invalid");u+="; Max-Age="+Math.floor(m);}if(a){if("development"===process.env.NODE_ENV&&!i.test(a))throw TypeError("option domain is invalid");u+="; Domain="+a;}if(s){if("development"===process.env.NODE_ENV&&!i.test(s))throw TypeError("option path is invalid");u+="; Path="+s;}if(c&&(isNumber.isNumber(c)&&(c=new Date(Date.now()+864e5*c)),u+="; Expires="+c.toUTCString()),p&&(u+="; HttpOnly"),l&&(u+="; Secure"),f)switch(f.toLowerCase()){case"lax":u+="; SameSite=Lax";break;case"strict":u+="; SameSite=Strict";break;case"none":u+="; SameSite=None";}// default:
|
|
19
|
+
// throw new TypeError('option sameSite is invalid');
|
|
20
|
+
return u};
|
|
75
21
|
|
|
76
22
|
exports["default"] = serializeCookie;
|
|
77
23
|
exports.serializeCookie = serializeCookie;
|
package/serializeCookie.esm.js
CHANGED
|
@@ -1,72 +1,18 @@
|
|
|
1
1
|
import { isNumber } from './isNumber.esm.js';
|
|
2
2
|
import './getType.esm.js';
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
throw new TypeError("argument val is invalid");
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
let str = name + "=" + value;
|
|
21
|
-
if (null != maxAge) {
|
|
22
|
-
maxAge = maxAge - 0;
|
|
23
|
-
if (isNaN(maxAge) || !isFinite(maxAge)) {
|
|
24
|
-
throw new TypeError("option maxAge is invalid");
|
|
25
|
-
}
|
|
26
|
-
str += "; Max-Age=" + Math.floor(maxAge);
|
|
27
|
-
}
|
|
28
|
-
if (domain) {
|
|
29
|
-
if (process.env["NODE_ENV"] === "development") {
|
|
30
|
-
if (!fieldContentRegExp.test(domain)) {
|
|
31
|
-
throw new TypeError("option domain is invalid");
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
str += "; Domain=" + domain;
|
|
35
|
-
}
|
|
36
|
-
if (path) {
|
|
37
|
-
if (process.env["NODE_ENV"] === "development") {
|
|
38
|
-
if (!fieldContentRegExp.test(path)) {
|
|
39
|
-
throw new TypeError("option path is invalid");
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
str += "; Path=" + path;
|
|
43
|
-
}
|
|
44
|
-
if (expires) {
|
|
45
|
-
if (isNumber(expires)) {
|
|
46
|
-
expires = new Date(Date.now() + expires * 864e5);
|
|
47
|
-
}
|
|
48
|
-
str += "; Expires=" + expires.toUTCString();
|
|
49
|
-
}
|
|
50
|
-
if (httpOnly) {
|
|
51
|
-
str += "; HttpOnly";
|
|
52
|
-
}
|
|
53
|
-
if (secure) {
|
|
54
|
-
str += "; Secure";
|
|
55
|
-
}
|
|
56
|
-
if (sameSite) {
|
|
57
|
-
switch (sameSite.toLowerCase()) {
|
|
58
|
-
case "lax":
|
|
59
|
-
str += "; SameSite=Lax";
|
|
60
|
-
break;
|
|
61
|
-
case "strict":
|
|
62
|
-
str += "; SameSite=Strict";
|
|
63
|
-
break;
|
|
64
|
-
case "none":
|
|
65
|
-
str += "; SameSite=None";
|
|
66
|
-
break;
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
return str;
|
|
70
|
-
};
|
|
4
|
+
let i=/^[\u0009\u0020-\u007e\u0080-\u00ff]+$/;/**
|
|
5
|
+
* Serialize data into a cookie header.
|
|
6
|
+
*
|
|
7
|
+
* Serialize the a name value pair into a cookie string suitable for
|
|
8
|
+
* http headers. An optional attributes object specified cookie parameters.
|
|
9
|
+
*
|
|
10
|
+
* serialize('foo', 'bar', { httpOnly: true })
|
|
11
|
+
* => "foo=bar; httpOnly"
|
|
12
|
+
*
|
|
13
|
+
* @category cookie
|
|
14
|
+
*/let serializeCookie=(t,o,r={})=>{let{encode:n=encodeURIComponent,domain:a,path:s,httpOnly:p,secure:l,sameSite:f}=r,{maxAge:m,expires:c}=r,d=n(o);if("development"===process.env.NODE_ENV){if(!i.test(t))throw TypeError("argument name is invalid");if("function"!=typeof r.encode)throw TypeError("option encode is invalid");if(d&&!i.test(d))throw TypeError("argument val is invalid")}let u=t+"="+d;if(null!=m){if(isNaN(m-=0)||!isFinite(m))throw TypeError("option maxAge is invalid");u+="; Max-Age="+Math.floor(m);}if(a){if("development"===process.env.NODE_ENV&&!i.test(a))throw TypeError("option domain is invalid");u+="; Domain="+a;}if(s){if("development"===process.env.NODE_ENV&&!i.test(s))throw TypeError("option path is invalid");u+="; Path="+s;}if(c&&(isNumber(c)&&(c=new Date(Date.now()+864e5*c)),u+="; Expires="+c.toUTCString()),p&&(u+="; HttpOnly"),l&&(u+="; Secure"),f)switch(f.toLowerCase()){case"lax":u+="; SameSite=Lax";break;case"strict":u+="; SameSite=Strict";break;case"none":u+="; SameSite=None";}// default:
|
|
15
|
+
// throw new TypeError('option sameSite is invalid');
|
|
16
|
+
return u};
|
|
71
17
|
|
|
72
18
|
export { serializeCookie as default, serializeCookie };
|
package/setCookie.cjs.js
CHANGED
|
@@ -7,47 +7,17 @@ var isNumber = require('./isNumber.cjs.js');
|
|
|
7
7
|
var isUndefined = require('./isUndefined.cjs.js');
|
|
8
8
|
require('./getType.cjs.js');
|
|
9
9
|
|
|
10
|
-
let
|
|
11
|
-
|
|
12
|
-
}
|
|
13
|
-
let setCookie = (
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
if (process.env["NODE_ENV"] === "development") {
|
|
22
|
-
console.warn("[@koine/utils:setCookie] document is undefined");
|
|
23
|
-
}
|
|
24
|
-
return undefined;
|
|
25
|
-
}
|
|
26
|
-
if (isNumber.isNumber(expires)) {
|
|
27
|
-
expires = new Date(Date.now() + expires * 864e5);
|
|
28
|
-
}
|
|
29
|
-
if (expires) {
|
|
30
|
-
expires.toUTCString();
|
|
31
|
-
}
|
|
32
|
-
name = encodeURIComponent(name)
|
|
33
|
-
.replace(/%(2[346B]|5E|60|7C)/g, decodeURIComponent)
|
|
34
|
-
.replace(/[()]/g, escape);
|
|
35
|
-
let stringifiedAttributes = "";
|
|
36
|
-
for (const name in attributes) {
|
|
37
|
-
const attrName = name;
|
|
38
|
-
if (!attributes[attrName]) {
|
|
39
|
-
continue;
|
|
40
|
-
}
|
|
41
|
-
stringifiedAttributes += "; " + attrName;
|
|
42
|
-
if (attributes[attrName] === true) {
|
|
43
|
-
continue;
|
|
44
|
-
}
|
|
45
|
-
stringifiedAttributes +=
|
|
46
|
-
"=" + String(attributes[attrName]).split(";")[0];
|
|
47
|
-
}
|
|
48
|
-
return (document.cookie =
|
|
49
|
-
name + "=" + converterWrite(value) + stringifiedAttributes);
|
|
50
|
-
};
|
|
10
|
+
let n=e=>encodeURIComponent(e).replace(/%(2[346BF]|3[AC-F]|40|5[BDE]|60|7[BCD])/g,decodeURIComponent);/**
|
|
11
|
+
* @category cookie
|
|
12
|
+
*/let setCookie=(r,i,p={})=>{// eslint-disable-next-line prefer-const
|
|
13
|
+
let {expires:c,...d}=p;({expires:"",...cookie.defaultAttributesClient,...d});if(isUndefined.isUndefined(document)){"development"===process.env.NODE_ENV&&console.warn("[@koine/utils:setCookie] document is undefined");return}isNumber.isNumber(c)&&(c=new Date(Date.now()+864e5*c)),c&&(c.toUTCString()),r=encodeURIComponent(r).replace(/%(2[346B]|5E|60|7C)/g,decodeURIComponent).replace(/[()]/g,escape);let s="";for(let e in p)p[e]&&(s+="; "+e,!0!==p[e]&&// Considers RFC 6265 section 5.2:
|
|
14
|
+
// ...
|
|
15
|
+
// 3. If the remaining unparsed-attributes contains a %x3B (";")
|
|
16
|
+
// character:
|
|
17
|
+
// Consume the characters of the unparsed-attributes up to,
|
|
18
|
+
// not including, the first %x3B (";") character.
|
|
19
|
+
// ...
|
|
20
|
+
(s+="="+String(p[e]).split(";")[0]));return document.cookie=r+"="+n(i)+s};
|
|
51
21
|
|
|
52
22
|
exports["default"] = setCookie;
|
|
53
23
|
exports.setCookie = setCookie;
|
package/setCookie.esm.js
CHANGED
|
@@ -3,46 +3,16 @@ import { isNumber } from './isNumber.esm.js';
|
|
|
3
3
|
import { isUndefined } from './isUndefined.esm.js';
|
|
4
4
|
import './getType.esm.js';
|
|
5
5
|
|
|
6
|
-
let
|
|
7
|
-
|
|
8
|
-
}
|
|
9
|
-
let setCookie = (
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
if (process.env["NODE_ENV"] === "development") {
|
|
18
|
-
console.warn("[@koine/utils:setCookie] document is undefined");
|
|
19
|
-
}
|
|
20
|
-
return undefined;
|
|
21
|
-
}
|
|
22
|
-
if (isNumber(expires)) {
|
|
23
|
-
expires = new Date(Date.now() + expires * 864e5);
|
|
24
|
-
}
|
|
25
|
-
if (expires) {
|
|
26
|
-
expires.toUTCString();
|
|
27
|
-
}
|
|
28
|
-
name = encodeURIComponent(name)
|
|
29
|
-
.replace(/%(2[346B]|5E|60|7C)/g, decodeURIComponent)
|
|
30
|
-
.replace(/[()]/g, escape);
|
|
31
|
-
let stringifiedAttributes = "";
|
|
32
|
-
for (const name in attributes) {
|
|
33
|
-
const attrName = name;
|
|
34
|
-
if (!attributes[attrName]) {
|
|
35
|
-
continue;
|
|
36
|
-
}
|
|
37
|
-
stringifiedAttributes += "; " + attrName;
|
|
38
|
-
if (attributes[attrName] === true) {
|
|
39
|
-
continue;
|
|
40
|
-
}
|
|
41
|
-
stringifiedAttributes +=
|
|
42
|
-
"=" + String(attributes[attrName]).split(";")[0];
|
|
43
|
-
}
|
|
44
|
-
return (document.cookie =
|
|
45
|
-
name + "=" + converterWrite(value) + stringifiedAttributes);
|
|
46
|
-
};
|
|
6
|
+
let n=e=>encodeURIComponent(e).replace(/%(2[346BF]|3[AC-F]|40|5[BDE]|60|7[BCD])/g,decodeURIComponent);/**
|
|
7
|
+
* @category cookie
|
|
8
|
+
*/let setCookie=(r,i,p={})=>{// eslint-disable-next-line prefer-const
|
|
9
|
+
let {expires:c,...d}=p;({expires:"",...defaultAttributesClient,...d});if(isUndefined(document)){"development"===process.env.NODE_ENV&&console.warn("[@koine/utils:setCookie] document is undefined");return}isNumber(c)&&(c=new Date(Date.now()+864e5*c)),c&&(c.toUTCString()),r=encodeURIComponent(r).replace(/%(2[346B]|5E|60|7C)/g,decodeURIComponent).replace(/[()]/g,escape);let s="";for(let e in p)p[e]&&(s+="; "+e,!0!==p[e]&&// Considers RFC 6265 section 5.2:
|
|
10
|
+
// ...
|
|
11
|
+
// 3. If the remaining unparsed-attributes contains a %x3B (";")
|
|
12
|
+
// character:
|
|
13
|
+
// Consume the characters of the unparsed-attributes up to,
|
|
14
|
+
// not including, the first %x3B (";") character.
|
|
15
|
+
// ...
|
|
16
|
+
(s+="="+String(p[e]).split(";")[0]));return document.cookie=r+"="+n(i)+s};
|
|
47
17
|
|
|
48
18
|
export { setCookie as default, setCookie };
|
package/shuffle.cjs.js
CHANGED
|
@@ -2,22 +2,21 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
};
|
|
5
|
+
/**
|
|
6
|
+
* Creates an array of shuffled values, using a version of the
|
|
7
|
+
* [Fisher-Yates shuffle](https://en.wikipedia.org/wiki/Fisher-Yates_shuffle).
|
|
8
|
+
*
|
|
9
|
+
* @category array
|
|
10
|
+
* @borrows [lodash.shuffle](https://github.com/lodash/lodash/blob/master/shuffle.js)
|
|
11
|
+
* @example
|
|
12
|
+
* ```ts
|
|
13
|
+
* shuffle([1, 2, 3, 4])
|
|
14
|
+
* // => [4, 1, 3, 2]
|
|
15
|
+
* ```
|
|
16
|
+
*
|
|
17
|
+
* @param array The array to shuffle.
|
|
18
|
+
* @returns The new shuffled array.
|
|
19
|
+
*/let shuffle=e=>{let t=null==e?0:e.length;if(!t)return [];let l=-1,r=t-1,f=[...e];for(;++l<t;){let e=l+Math.floor(Math.random()*(r-l+1)),t=f[e];f[e]=f[l],f[l]=t;}return f};
|
|
21
20
|
|
|
22
21
|
exports["default"] = shuffle;
|
|
23
22
|
exports.shuffle = shuffle;
|