@koine/utils 2.0.0-beta.2 → 2.0.0-beta.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Defer.js +23 -18
- package/Defer.mjs +6 -5
- package/Emitter.js +31 -20
- package/Emitter.mjs +13 -16
- package/README.md +5 -1
- package/accentSets.js +129 -37
- package/accentSets.mjs +113 -29
- package/addOrReplaceAtIdx.js +27 -10
- package/addOrReplaceAtIdx.mjs +9 -6
- package/areEqual.js +35 -41
- package/areEqual.mjs +16 -22
- package/arrayOfAll.js +20 -11
- package/arrayOfAll.mjs +1 -6
- package/arraySum.js +20 -9
- package/arraySum.mjs +1 -4
- package/arrayToLookup.js +21 -9
- package/arrayToLookup.mjs +2 -4
- package/buildUrlQueryString.js +32 -29
- package/buildUrlQueryString.mjs +11 -14
- package/capitalize.js +21 -9
- package/capitalize.mjs +3 -5
- package/changeUrlPath.js +23 -17
- package/changeUrlPath.mjs +2 -3
- package/chunkByChunks.js +35 -24
- package/chunkByChunks.mjs +17 -20
- package/chunkBySize.js +21 -8
- package/chunkBySize.mjs +3 -4
- package/clamp.js +19 -6
- package/clamp.mjs +1 -2
- package/clsx.js +29 -23
- package/clsx.mjs +11 -14
- package/convertRange.js +20 -7
- package/convertRange.mjs +2 -3
- package/cookie.js +13 -5
- package/cookie.mjs +3 -2
- package/createPalette.js +27 -19
- package/createPalette.mjs +9 -6
- package/debounce.js +27 -21
- package/debounce.mjs +9 -17
- package/debouncePromise.js +20 -11
- package/debouncePromise.mjs +1 -2
- package/debounceRaf.js +23 -14
- package/debounceRaf.mjs +5 -10
- package/decode.js +20 -7
- package/decode.mjs +2 -3
- package/encode.js +20 -7
- package/encode.mjs +2 -3
- package/ensureInt.js +20 -9
- package/ensureInt.mjs +1 -4
- package/env.js +1 -1
- package/env.mjs +0 -1
- package/errorToString.js +21 -14
- package/errorToString.mjs +1 -4
- package/findDuplicatedIndexes.js +22 -9
- package/findDuplicatedIndexes.mjs +4 -5
- package/forin.js +20 -7
- package/forin.mjs +2 -3
- package/gbToBytes.js +20 -7
- package/gbToBytes.mjs +1 -2
- package/getEmptyArray.js +25 -16
- package/getEmptyArray.mjs +4 -3
- package/getKeys.js +20 -6
- package/getKeys.mjs +1 -2
- package/getMediaQueryWidthResolvers.js +62 -53
- package/getMediaQueryWidthResolvers.mjs +44 -49
- package/getMediaQueryWidthTailwindScreens.js +36 -18
- package/getMediaQueryWidthTailwindScreens.mjs +18 -14
- package/getNonce.js +20 -10
- package/getNonce.mjs +1 -2
- package/getParamAmong.js +22 -19
- package/getParamAmong.mjs +2 -4
- package/getParamAsInt.js +22 -19
- package/getParamAsInt.mjs +2 -4
- package/getParamAsString.js +21 -16
- package/getParamAsString.mjs +1 -2
- package/getType.js +19 -12
- package/getType.mjs +2 -4
- package/getUrlHashParams.js +20 -13
- package/getUrlHashParams.mjs +2 -4
- package/getUrlHashPathname.js +20 -8
- package/getUrlHashPathname.mjs +1 -3
- package/getUrlPathnameParts.js +23 -23
- package/getUrlPathnameParts.mjs +2 -7
- package/getUrlQueryParams.js +26 -33
- package/getUrlQueryParams.mjs +7 -18
- package/imgEmptyPixel.js +20 -6
- package/imgEmptyPixel.mjs +1 -2
- package/index.js +531 -266
- package/index.mjs +2 -2
- package/invariant.js +24 -12
- package/invariant.mjs +6 -8
- package/isAnyObject.js +21 -12
- package/isAnyObject.mjs +1 -2
- package/isArray.js +21 -12
- package/isArray.mjs +1 -2
- package/isBlob.js +21 -12
- package/isBlob.mjs +1 -2
- package/isBoolean.js +21 -12
- package/isBoolean.mjs +1 -2
- package/isBrowser.js +20 -6
- package/isBrowser.mjs +1 -2
- package/isBrowserNow.js +21 -11
- package/isBrowserNow.mjs +1 -2
- package/isDate.js +21 -12
- package/isDate.mjs +1 -2
- package/isEmptyArray.js +21 -12
- package/isEmptyArray.mjs +1 -2
- package/isEmptyObject.js +21 -12
- package/isEmptyObject.mjs +1 -2
- package/isEmptyString.js +19 -6
- package/isEmptyString.mjs +1 -2
- package/isError.js +21 -12
- package/isError.mjs +1 -2
- package/isExternalUrl.js +24 -18
- package/isExternalUrl.mjs +4 -6
- package/isFile.js +21 -12
- package/isFile.mjs +1 -2
- package/isFloat.js +21 -12
- package/isFloat.mjs +1 -2
- package/isFormData.js +21 -12
- package/isFormData.mjs +1 -2
- package/isFullArray.js +21 -12
- package/isFullArray.mjs +1 -2
- package/isFullObject.js +21 -12
- package/isFullObject.mjs +1 -2
- package/isFullString.js +21 -12
- package/isFullString.mjs +1 -2
- package/isFunction.js +18 -9
- package/isFunction.mjs +1 -2
- package/isInt.js +21 -12
- package/isInt.mjs +1 -2
- package/isMap.js +21 -12
- package/isMap.mjs +1 -2
- package/isNaNValue.js +21 -12
- package/isNaNValue.mjs +1 -2
- package/isNegativeNumber.js +21 -12
- package/isNegativeNumber.mjs +1 -2
- package/isNull.js +21 -12
- package/isNull.mjs +1 -2
- package/isNullOrUndefined.js +23 -13
- package/isNullOrUndefined.mjs +1 -2
- package/isNumber.js +21 -14
- package/isNumber.mjs +1 -2
- package/isObject.js +21 -12
- package/isObject.mjs +1 -2
- package/isObjectLike.js +21 -14
- package/isObjectLike.mjs +1 -2
- package/isOneOf.js +19 -11
- package/isOneOf.mjs +1 -7
- package/isPlainObject.js +22 -15
- package/isPlainObject.mjs +3 -6
- package/isPositiveNumber.js +21 -12
- package/isPositiveNumber.mjs +1 -2
- package/isPrimitive.js +26 -22
- package/isPrimitive.mjs +5 -11
- package/isPromise.js +21 -12
- package/isPromise.mjs +1 -2
- package/isRegExp.js +21 -12
- package/isRegExp.mjs +1 -2
- package/isServer.js +22 -11
- package/isServer.mjs +1 -2
- package/isServerNow.js +21 -11
- package/isServerNow.mjs +1 -2
- package/isSet.js +21 -12
- package/isSet.mjs +1 -2
- package/isString.js +21 -12
- package/isString.mjs +1 -2
- package/isSymbol.js +21 -12
- package/isSymbol.mjs +1 -2
- package/isType.js +22 -17
- package/isType.mjs +3 -5
- package/isUndefined.js +21 -12
- package/isUndefined.mjs +1 -2
- package/isWeakMap.js +21 -12
- package/isWeakMap.mjs +1 -2
- package/isWeakSet.js +21 -12
- package/isWeakSet.mjs +1 -2
- package/kbToBytes.js +20 -7
- package/kbToBytes.mjs +1 -2
- package/location.js +6 -2
- package/location.mjs +3 -1
- package/lowercase.js +20 -9
- package/lowercase.mjs +1 -4
- package/mapListBy.js +21 -10
- package/mapListBy.mjs +2 -5
- package/matchSorter.js +132 -133
- package/matchSorter.mjs +108 -126
- package/mbToBytes.js +20 -7
- package/mbToBytes.mjs +1 -2
- package/mergeObjects.d.ts +1 -1
- package/mergeObjects.js +24 -26
- package/mergeObjects.mjs +12 -15
- package/mergeUrlQueryParams.js +25 -20
- package/mergeUrlQueryParams.mjs +4 -8
- package/moveSortableArrayItemByKey.js +26 -12
- package/moveSortableArrayItemByKey.mjs +8 -8
- package/noop.js +20 -7
- package/noop.mjs +1 -2
- package/normaliseUrl.js +22 -18
- package/normaliseUrl.mjs +1 -3
- package/normaliseUrlPathname.js +22 -17
- package/normaliseUrlPathname.mjs +1 -3
- package/objectOmit.js +21 -9
- package/objectOmit.mjs +3 -5
- package/objectPick.js +22 -9
- package/objectPick.mjs +4 -5
- package/package.json +11 -8
- package/parseCookie.js +29 -26
- package/parseCookie.mjs +11 -15
- package/parseURL.js +23 -10
- package/parseURL.mjs +5 -6
- package/quaranteneProps.js +24 -12
- package/quaranteneProps.mjs +6 -8
- package/randomInt.js +19 -6
- package/randomInt.mjs +1 -2
- package/randomKey.js +21 -8
- package/randomKey.mjs +3 -4
- package/readCookie.js +25 -12
- package/readCookie.mjs +7 -8
- package/removeAccents.js +24 -15
- package/removeAccents.mjs +5 -8
- package/removeCookie.js +26 -17
- package/removeCookie.mjs +6 -5
- package/removeDuplicates.js +1 -1
- package/removeDuplicates.mjs +0 -1
- package/removeDuplicatesByKey.js +24 -12
- package/removeDuplicatesByKey.mjs +5 -7
- package/removeDuplicatesComparing.js +22 -11
- package/removeDuplicatesComparing.mjs +3 -4
- package/removeIndexesFromArray.js +21 -8
- package/removeIndexesFromArray.mjs +3 -4
- package/removeTrailingSlash.js +20 -8
- package/removeTrailingSlash.mjs +1 -3
- package/removeUrlQueryParams.js +27 -20
- package/removeUrlQueryParams.mjs +5 -7
- package/render.js +61 -137
- package/render.mjs +43 -98
- package/roundTo.js +34 -22
- package/roundTo.mjs +15 -17
- package/serializeCookie.js +29 -35
- package/serializeCookie.mjs +9 -15
- package/setCookie.js +37 -31
- package/setCookie.mjs +13 -16
- package/shuffle.js +28 -14
- package/shuffle.mjs +10 -10
- package/slugify.js +33 -25
- package/slugify.mjs +13 -11
- package/split.js +18 -4
- package/swapMap.js +22 -10
- package/swapMap.mjs +3 -5
- package/throttle.d.ts +1 -0
- package/throttle.js +23 -15
- package/throttle.mjs +5 -11
- package/titleCase.js +20 -11
- package/titleCase.mjs +1 -6
- package/toNumber.js +20 -9
- package/toNumber.mjs +1 -2
- package/toRgba.js +22 -10
- package/toRgba.mjs +3 -5
- package/transformToUrlPathname.js +21 -18
- package/transformToUrlPathname.mjs +2 -5
- package/truncate.js +20 -13
- package/truncate.mjs +1 -8
- package/tryUntil.js +26 -15
- package/tryUntil.mjs +7 -10
- package/types.js +4 -1
- package/types.mjs +2 -1
- package/uid.js +21 -13
- package/uid.mjs +3 -5
- package/updateLinkParams.js +21 -14
- package/updateLinkParams.mjs +2 -3
- package/updateUrlQueryParams.js +26 -21
- package/updateUrlQueryParams.mjs +3 -7
- package/uppercase.js +20 -9
- package/uppercase.mjs +1 -4
- package/uuid.js +21 -10
- package/uuid.mjs +2 -5
- package/uuidNumeric.js +20 -7
- package/uuidNumeric.mjs +1 -2
- package/wait.js +20 -9
- package/wait.mjs +1 -4
- package/without.js +2 -3
- package/without.mjs +1 -3
package/serializeCookie.mjs
CHANGED
|
@@ -6,17 +6,15 @@
|
|
|
6
6
|
* All cookie related code is inspired and adapted from:
|
|
7
7
|
* - [js-cookie](https://github.com/js-cookie/js-cookie)
|
|
8
8
|
* - [cookie](https://github.com/jshttp/cookie)
|
|
9
|
-
*/
|
|
10
|
-
import { isNumber } from "./isNumber";
|
|
9
|
+
*/ import { isNumber } from "./isNumber";
|
|
11
10
|
/**
|
|
12
11
|
* RegExp to match field-content in RFC 7230 sec 3.2
|
|
13
12
|
*
|
|
14
13
|
* field-content = field-vchar [ 1*( SP / HTAB ) field-vchar ]
|
|
15
14
|
* field-vchar = VCHAR / obs-text
|
|
16
15
|
* obs-text = %x80-FF
|
|
17
|
-
*/
|
|
18
|
-
|
|
19
|
-
var fieldContentRegExp = /^[\u0009\u0020-\u007e\u0080-\u00ff]+$/;
|
|
16
|
+
*/ // eslint-disable-next-line no-control-regex
|
|
17
|
+
const fieldContentRegExp = /^[\u0009\u0020-\u007e\u0080-\u00ff]+$/;
|
|
20
18
|
/**
|
|
21
19
|
* Serialize data into a cookie header.
|
|
22
20
|
*
|
|
@@ -31,12 +29,10 @@ var fieldContentRegExp = /^[\u0009\u0020-\u007e\u0080-\u00ff]+$/;
|
|
|
31
29
|
* All cookie related code is inspired and adapted from:
|
|
32
30
|
* - [js-cookie](https://github.com/js-cookie/js-cookie)
|
|
33
31
|
* - [cookie](https://github.com/jshttp/cookie)
|
|
34
|
-
*/
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
var maxAge = attributes.maxAge, expires = attributes.expires;
|
|
39
|
-
var value = encode(val);
|
|
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);
|
|
40
36
|
if (process.env["NODE_ENV"] !== "production") {
|
|
41
37
|
if (!fieldContentRegExp.test(name)) {
|
|
42
38
|
throw new TypeError("argument name is invalid");
|
|
@@ -48,7 +44,7 @@ export function serializeCookie(name, val, attributes) {
|
|
|
48
44
|
throw new TypeError("argument val is invalid");
|
|
49
45
|
}
|
|
50
46
|
}
|
|
51
|
-
|
|
47
|
+
let str = name + "=" + value;
|
|
52
48
|
if (null != maxAge) {
|
|
53
49
|
maxAge = maxAge - 0;
|
|
54
50
|
if (isNaN(maxAge) || !isFinite(maxAge)) {
|
|
@@ -85,7 +81,7 @@ export function serializeCookie(name, val, attributes) {
|
|
|
85
81
|
str += "; Secure";
|
|
86
82
|
}
|
|
87
83
|
if (sameSite) {
|
|
88
|
-
switch
|
|
84
|
+
switch(sameSite.toLowerCase()){
|
|
89
85
|
case "lax":
|
|
90
86
|
str += "; SameSite=Lax";
|
|
91
87
|
break;
|
|
@@ -95,8 +91,6 @@ export function serializeCookie(name, val, attributes) {
|
|
|
95
91
|
case "none":
|
|
96
92
|
str += "; SameSite=None";
|
|
97
93
|
break;
|
|
98
|
-
// default:
|
|
99
|
-
// throw new TypeError('option sameSite is invalid');
|
|
100
94
|
}
|
|
101
95
|
}
|
|
102
96
|
return str;
|
package/setCookie.js
CHANGED
|
@@ -1,43 +1,52 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
var
|
|
7
|
-
|
|
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
|
+
setCookie: function() {
|
|
13
|
+
return setCookie;
|
|
14
|
+
},
|
|
15
|
+
default: function() {
|
|
16
|
+
return _default;
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
const _interop_require_default = require("@swc/helpers/_/_interop_require_default");
|
|
20
|
+
const _cookie = require("./cookie");
|
|
21
|
+
const _isNumber = /*#__PURE__*/ _interop_require_default._(require("./isNumber"));
|
|
22
|
+
const _isUndefined = /*#__PURE__*/ _interop_require_default._(require("./isUndefined"));
|
|
8
23
|
function converterWrite(value) {
|
|
9
24
|
return encodeURIComponent(value).replace(/%(2[346BF]|3[AC-F]|40|5[BDE]|60|7[BCD])/g, decodeURIComponent);
|
|
10
25
|
}
|
|
11
|
-
|
|
12
|
-
* @category cookie
|
|
13
|
-
*
|
|
14
|
-
* All cookie related code is inspired and adapted from:
|
|
15
|
-
* - [js-cookie](https://github.com/js-cookie/js-cookie)
|
|
16
|
-
* - [cookie](https://github.com/jshttp/cookie)
|
|
17
|
-
*/
|
|
18
|
-
function setCookie(name, value, attributes) {
|
|
19
|
-
if (attributes === void 0) { attributes = {}; }
|
|
26
|
+
function setCookie(name, value, attributes = {}) {
|
|
20
27
|
// eslint-disable-next-line prefer-const
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
28
|
+
let { expires, ...restAttrs } = attributes;
|
|
29
|
+
const cleanedAttrs = {
|
|
30
|
+
expires: "",
|
|
31
|
+
..._cookie.defaultAttributesClient,
|
|
32
|
+
...restAttrs
|
|
33
|
+
};
|
|
34
|
+
if ((0, _isUndefined.default)(document)) {
|
|
24
35
|
if (process.env["NODE_ENV"] !== "production") {
|
|
25
36
|
console.warn("[@koine/utils:setCookie] document is undefined");
|
|
26
37
|
}
|
|
27
38
|
return undefined;
|
|
28
39
|
}
|
|
29
|
-
if ((0,
|
|
40
|
+
if ((0, _isNumber.default)(expires)) {
|
|
30
41
|
expires = new Date(Date.now() + expires * 864e5);
|
|
31
42
|
}
|
|
32
43
|
if (expires) {
|
|
33
44
|
cleanedAttrs.expires = expires.toUTCString();
|
|
34
45
|
}
|
|
35
|
-
name = encodeURIComponent(name)
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
for (var name_1 in attributes) {
|
|
40
|
-
var attrName = name_1;
|
|
46
|
+
name = encodeURIComponent(name).replace(/%(2[346B]|5E|60|7C)/g, decodeURIComponent).replace(/[()]/g, escape);
|
|
47
|
+
let stringifiedAttributes = "";
|
|
48
|
+
for(const name in attributes){
|
|
49
|
+
const attrName = name;
|
|
41
50
|
if (!attributes[attrName]) {
|
|
42
51
|
continue;
|
|
43
52
|
}
|
|
@@ -52,11 +61,8 @@ function setCookie(name, value, attributes) {
|
|
|
52
61
|
// Consume the characters of the unparsed-attributes up to,
|
|
53
62
|
// not including, the first %x3B (";") character.
|
|
54
63
|
// ...
|
|
55
|
-
stringifiedAttributes +=
|
|
56
|
-
"=" + String(attributes[attrName]).split(";")[0];
|
|
64
|
+
stringifiedAttributes += "=" + String(attributes[attrName]).split(";")[0];
|
|
57
65
|
}
|
|
58
|
-
return
|
|
59
|
-
name + "=" + converterWrite(value) + stringifiedAttributes);
|
|
66
|
+
return document.cookie = name + "=" + converterWrite(value) + stringifiedAttributes;
|
|
60
67
|
}
|
|
61
|
-
|
|
62
|
-
exports.default = setCookie;
|
|
68
|
+
const _default = setCookie;
|
package/setCookie.mjs
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { __assign, __rest } from "tslib";
|
|
2
1
|
import { defaultAttributesClient } from "./cookie";
|
|
3
2
|
import isNumber from "./isNumber";
|
|
4
3
|
import isUndefined from "./isUndefined";
|
|
@@ -11,12 +10,14 @@ function converterWrite(value) {
|
|
|
11
10
|
* All cookie related code is inspired and adapted from:
|
|
12
11
|
* - [js-cookie](https://github.com/js-cookie/js-cookie)
|
|
13
12
|
* - [cookie](https://github.com/jshttp/cookie)
|
|
14
|
-
*/
|
|
15
|
-
export function setCookie(name, value, attributes) {
|
|
16
|
-
if (attributes === void 0) { attributes = {}; }
|
|
13
|
+
*/ export function setCookie(name, value, attributes = {}) {
|
|
17
14
|
// eslint-disable-next-line prefer-const
|
|
18
|
-
|
|
19
|
-
|
|
15
|
+
let { expires, ...restAttrs } = attributes;
|
|
16
|
+
const cleanedAttrs = {
|
|
17
|
+
expires: "",
|
|
18
|
+
...defaultAttributesClient,
|
|
19
|
+
...restAttrs
|
|
20
|
+
};
|
|
20
21
|
if (isUndefined(document)) {
|
|
21
22
|
if (process.env["NODE_ENV"] !== "production") {
|
|
22
23
|
console.warn("[@koine/utils:setCookie] document is undefined");
|
|
@@ -29,12 +30,10 @@ export function setCookie(name, value, attributes) {
|
|
|
29
30
|
if (expires) {
|
|
30
31
|
cleanedAttrs.expires = expires.toUTCString();
|
|
31
32
|
}
|
|
32
|
-
name = encodeURIComponent(name)
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
for (var name_1 in attributes) {
|
|
37
|
-
var attrName = name_1;
|
|
33
|
+
name = encodeURIComponent(name).replace(/%(2[346B]|5E|60|7C)/g, decodeURIComponent).replace(/[()]/g, escape);
|
|
34
|
+
let stringifiedAttributes = "";
|
|
35
|
+
for(const name in attributes){
|
|
36
|
+
const attrName = name;
|
|
38
37
|
if (!attributes[attrName]) {
|
|
39
38
|
continue;
|
|
40
39
|
}
|
|
@@ -49,10 +48,8 @@ export function setCookie(name, value, attributes) {
|
|
|
49
48
|
// Consume the characters of the unparsed-attributes up to,
|
|
50
49
|
// not including, the first %x3B (";") character.
|
|
51
50
|
// ...
|
|
52
|
-
stringifiedAttributes +=
|
|
53
|
-
"=" + String(attributes[attrName]).split(";")[0];
|
|
51
|
+
stringifiedAttributes += "=" + String(attributes[attrName]).split(";")[0];
|
|
54
52
|
}
|
|
55
|
-
return
|
|
56
|
-
name + "=" + converterWrite(value) + stringifiedAttributes);
|
|
53
|
+
return document.cookie = name + "=" + converterWrite(value) + stringifiedAttributes;
|
|
57
54
|
}
|
|
58
55
|
export default setCookie;
|
package/shuffle.js
CHANGED
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.shuffle = void 0;
|
|
4
|
-
var tslib_1 = require("tslib");
|
|
5
1
|
/**
|
|
6
2
|
* Creates an array of shuffled values, using a version of the
|
|
7
3
|
* [Fisher-Yates shuffle](https://en.wikipedia.org/wiki/Fisher-Yates_shuffle).
|
|
@@ -15,22 +11,40 @@ var tslib_1 = require("tslib");
|
|
|
15
11
|
*
|
|
16
12
|
* shuffle([1, 2, 3, 4])
|
|
17
13
|
* // => [4, 1, 3, 2]
|
|
18
|
-
*/
|
|
14
|
+
*/ "use strict";
|
|
15
|
+
Object.defineProperty(exports, "__esModule", {
|
|
16
|
+
value: true
|
|
17
|
+
});
|
|
18
|
+
function _export(target, all) {
|
|
19
|
+
for(var name in all)Object.defineProperty(target, name, {
|
|
20
|
+
enumerable: true,
|
|
21
|
+
get: all[name]
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
_export(exports, {
|
|
25
|
+
shuffle: function() {
|
|
26
|
+
return shuffle;
|
|
27
|
+
},
|
|
28
|
+
default: function() {
|
|
29
|
+
return _default;
|
|
30
|
+
}
|
|
31
|
+
});
|
|
19
32
|
function shuffle(array) {
|
|
20
|
-
|
|
33
|
+
const length = array == null ? 0 : array.length;
|
|
21
34
|
if (!length) {
|
|
22
35
|
return [];
|
|
23
36
|
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
37
|
+
let index = -1;
|
|
38
|
+
const lastIndex = length - 1;
|
|
39
|
+
const result = [
|
|
40
|
+
...array
|
|
41
|
+
];
|
|
42
|
+
while(++index < length){
|
|
43
|
+
const rand = index + Math.floor(Math.random() * (lastIndex - index + 1));
|
|
44
|
+
const value = result[rand];
|
|
30
45
|
result[rand] = result[index];
|
|
31
46
|
result[index] = value;
|
|
32
47
|
}
|
|
33
48
|
return result;
|
|
34
49
|
}
|
|
35
|
-
|
|
36
|
-
exports.default = shuffle;
|
|
50
|
+
const _default = shuffle;
|
package/shuffle.mjs
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { __spreadArray } from "tslib";
|
|
2
1
|
/**
|
|
3
2
|
* Creates an array of shuffled values, using a version of the
|
|
4
3
|
* [Fisher-Yates shuffle](https://en.wikipedia.org/wiki/Fisher-Yates_shuffle).
|
|
@@ -12,18 +11,19 @@ import { __spreadArray } from "tslib";
|
|
|
12
11
|
*
|
|
13
12
|
* shuffle([1, 2, 3, 4])
|
|
14
13
|
* // => [4, 1, 3, 2]
|
|
15
|
-
*/
|
|
16
|
-
|
|
17
|
-
var length = array == null ? 0 : array.length;
|
|
14
|
+
*/ export function shuffle(array) {
|
|
15
|
+
const length = array == null ? 0 : array.length;
|
|
18
16
|
if (!length) {
|
|
19
17
|
return [];
|
|
20
18
|
}
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
19
|
+
let index = -1;
|
|
20
|
+
const lastIndex = length - 1;
|
|
21
|
+
const result = [
|
|
22
|
+
...array
|
|
23
|
+
];
|
|
24
|
+
while(++index < length){
|
|
25
|
+
const rand = index + Math.floor(Math.random() * (lastIndex - index + 1));
|
|
26
|
+
const value = result[rand];
|
|
27
27
|
result[rand] = result[index];
|
|
28
28
|
result[index] = value;
|
|
29
29
|
}
|
package/slugify.js
CHANGED
|
@@ -1,27 +1,35 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
* - replaces the punctuation with dashes
|
|
11
|
-
*
|
|
12
|
-
* @category text
|
|
13
|
-
* @see https://gist.github.com/mathewbyrne/1280286#gistcomment-3498021
|
|
14
|
-
*/
|
|
15
|
-
function slugify(text, separator) {
|
|
16
|
-
if (separator === void 0) { separator = "-"; }
|
|
17
|
-
return (0, removeAccents_1.removeAccents)(text.toString().toLowerCase().trim(), accentSets_1.accentsSets.concat([["-", "[·/_,:;']"]]))
|
|
18
|
-
.replace(/\s+/g, "-") // replace spaces with -
|
|
19
|
-
.replace(/&/g, "-and-") // replace & with 'and'
|
|
20
|
-
.replace(/[^\w-]+/g, "") // remove all non-word chars
|
|
21
|
-
.replace(/--+/g, "-") // replace multiple - with single -
|
|
22
|
-
.replace(/^-+/, "") // trim - from start of text
|
|
23
|
-
.replace(/-+$/, "") // trim - from end of text
|
|
24
|
-
.replace(/-/g, separator);
|
|
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
|
+
});
|
|
25
10
|
}
|
|
26
|
-
exports
|
|
27
|
-
|
|
11
|
+
_export(exports, {
|
|
12
|
+
slugify: function() {
|
|
13
|
+
return slugify;
|
|
14
|
+
},
|
|
15
|
+
default: function() {
|
|
16
|
+
return _default;
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
const _accentSets = require("./accentSets");
|
|
20
|
+
const _removeAccents = require("./removeAccents");
|
|
21
|
+
function slugify(text, separator = "-") {
|
|
22
|
+
return (0, _removeAccents.removeAccents)(text.toString().toLowerCase().trim(), _accentSets.accentsSets.concat([
|
|
23
|
+
[
|
|
24
|
+
"-",
|
|
25
|
+
"[·/_,:;']"
|
|
26
|
+
]
|
|
27
|
+
])).replace(/\s+/g, "-") // replace spaces with -
|
|
28
|
+
.replace(/&/g, "-and-") // replace & with 'and'
|
|
29
|
+
.replace(/[^\w-]+/g, "") // remove all non-word chars
|
|
30
|
+
.replace(/--+/g, "-") // replace multiple - with single -
|
|
31
|
+
.replace(/^-+/, "") // trim - from start of text
|
|
32
|
+
.replace(/-+$/, "") // trim - from end of text
|
|
33
|
+
.replace(/-/g, separator);
|
|
34
|
+
}
|
|
35
|
+
const _default = slugify;
|
package/slugify.mjs
CHANGED
|
@@ -8,16 +8,18 @@ import { removeAccents } from "./removeAccents";
|
|
|
8
8
|
*
|
|
9
9
|
* @category text
|
|
10
10
|
* @see https://gist.github.com/mathewbyrne/1280286#gistcomment-3498021
|
|
11
|
-
*/
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
11
|
+
*/ export function slugify(text, separator = "-") {
|
|
12
|
+
return removeAccents(text.toString().toLowerCase().trim(), accentsSets.concat([
|
|
13
|
+
[
|
|
14
|
+
"-",
|
|
15
|
+
"[·/_,:;']"
|
|
16
|
+
]
|
|
17
|
+
])).replace(/\s+/g, "-") // replace spaces with -
|
|
18
|
+
.replace(/&/g, "-and-") // replace & with 'and'
|
|
19
|
+
.replace(/[^\w-]+/g, "") // remove all non-word chars
|
|
20
|
+
.replace(/--+/g, "-") // replace multiple - with single -
|
|
21
|
+
.replace(/^-+/, "") // trim - from start of text
|
|
22
|
+
.replace(/-+$/, "") // trim - from end of text
|
|
23
|
+
.replace(/-/g, separator);
|
|
22
24
|
}
|
|
23
25
|
export default slugify;
|
package/split.js
CHANGED
|
@@ -1,8 +1,22 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
function _export(target, all) {
|
|
6
|
+
for(var name in all)Object.defineProperty(target, name, {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: all[name]
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
_export(exports, {
|
|
12
|
+
split: function() {
|
|
13
|
+
return split;
|
|
14
|
+
},
|
|
15
|
+
default: function() {
|
|
16
|
+
return _default;
|
|
17
|
+
}
|
|
18
|
+
});
|
|
4
19
|
function split(str, delimiter) {
|
|
5
20
|
return str.split(delimiter);
|
|
6
21
|
}
|
|
7
|
-
|
|
8
|
-
exports.default = split;
|
|
22
|
+
const _default = split;
|
package/swapMap.js
CHANGED
|
@@ -1,18 +1,30 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.swapMap = void 0;
|
|
4
1
|
/**
|
|
5
2
|
* Swap object map key/value
|
|
6
3
|
*
|
|
7
4
|
* @category objects
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
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
|
+
swapMap: function() {
|
|
17
|
+
return swapMap;
|
|
18
|
+
},
|
|
19
|
+
default: function() {
|
|
20
|
+
return _default;
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
function swapMap(map = {}) {
|
|
24
|
+
const output = {};
|
|
25
|
+
for(const key in map){
|
|
13
26
|
output[map[key]] = key;
|
|
14
27
|
}
|
|
15
28
|
return output;
|
|
16
29
|
}
|
|
17
|
-
|
|
18
|
-
exports.default = swapMap;
|
|
30
|
+
const _default = swapMap;
|
package/swapMap.mjs
CHANGED
|
@@ -2,11 +2,9 @@
|
|
|
2
2
|
* Swap object map key/value
|
|
3
3
|
*
|
|
4
4
|
* @category objects
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
var output = {};
|
|
9
|
-
for (var key in map) {
|
|
5
|
+
*/ export function swapMap(map = {}) {
|
|
6
|
+
const output = {};
|
|
7
|
+
for(const key in map){
|
|
10
8
|
output[map[key]] = key;
|
|
11
9
|
}
|
|
12
10
|
return output;
|
package/throttle.d.ts
CHANGED
package/throttle.js
CHANGED
|
@@ -1,30 +1,38 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.throttle = void 0;
|
|
4
|
-
var tslib_1 = require("tslib");
|
|
5
1
|
/**
|
|
6
2
|
* Throttle function (e.g. for resize / scroll handlers)
|
|
7
3
|
*
|
|
8
4
|
* @category function
|
|
9
5
|
* @see https://github.com/Mobius1/Rangeable/
|
|
10
|
-
*/
|
|
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
|
+
throttle: function() {
|
|
18
|
+
return throttle;
|
|
19
|
+
},
|
|
20
|
+
default: function() {
|
|
21
|
+
return _default;
|
|
22
|
+
}
|
|
23
|
+
});
|
|
11
24
|
function throttle(fn, limit, context) {
|
|
12
|
-
|
|
13
|
-
return function
|
|
14
|
-
var args = [];
|
|
15
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
16
|
-
args[_i] = arguments[_i];
|
|
17
|
-
}
|
|
25
|
+
let wait;
|
|
26
|
+
return function(...args) {
|
|
18
27
|
context = context || this;
|
|
19
28
|
if (!wait) {
|
|
20
|
-
fn.apply
|
|
29
|
+
fn.apply(context, ...args);
|
|
21
30
|
wait = true;
|
|
22
|
-
return setTimeout(function
|
|
31
|
+
return setTimeout(function() {
|
|
23
32
|
wait = false;
|
|
24
33
|
}, limit);
|
|
25
34
|
}
|
|
26
35
|
return;
|
|
27
36
|
};
|
|
28
37
|
}
|
|
29
|
-
|
|
30
|
-
exports.default = throttle;
|
|
38
|
+
const _default = throttle;
|
package/throttle.mjs
CHANGED
|
@@ -1,22 +1,16 @@
|
|
|
1
|
-
import { __spreadArray } from "tslib";
|
|
2
1
|
/**
|
|
3
2
|
* Throttle function (e.g. for resize / scroll handlers)
|
|
4
3
|
*
|
|
5
4
|
* @category function
|
|
6
5
|
* @see https://github.com/Mobius1/Rangeable/
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
return function () {
|
|
11
|
-
var args = [];
|
|
12
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
13
|
-
args[_i] = arguments[_i];
|
|
14
|
-
}
|
|
6
|
+
*/ export function throttle(fn, limit, context) {
|
|
7
|
+
let wait;
|
|
8
|
+
return function(...args) {
|
|
15
9
|
context = context || this;
|
|
16
10
|
if (!wait) {
|
|
17
|
-
fn.apply
|
|
11
|
+
fn.apply(context, ...args);
|
|
18
12
|
wait = true;
|
|
19
|
-
return setTimeout(function
|
|
13
|
+
return setTimeout(function() {
|
|
20
14
|
wait = false;
|
|
21
15
|
}, limit);
|
|
22
16
|
}
|
package/titleCase.js
CHANGED
|
@@ -1,15 +1,24 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.titleCase = void 0;
|
|
4
1
|
/**
|
|
5
2
|
* @category typography
|
|
6
3
|
* @see https://github.com/blakeembrey/change-case/blob/master/packages/title-case/src/index.ts
|
|
7
4
|
* @author Blake Embrey (hello@blakeembrey.com)
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
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
|
+
titleCase: function() {
|
|
17
|
+
return titleCase;
|
|
18
|
+
},
|
|
19
|
+
default: function() {
|
|
20
|
+
return _default;
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
const titleCase = (input)=>input ? input.replace(/\w\S*/g, (txt)=>txt.charAt(0).toUpperCase() + txt.substring(1).toLowerCase()) : "";
|
|
24
|
+
const _default = titleCase;
|
package/titleCase.mjs
CHANGED
|
@@ -2,10 +2,5 @@
|
|
|
2
2
|
* @category typography
|
|
3
3
|
* @see https://github.com/blakeembrey/change-case/blob/master/packages/title-case/src/index.ts
|
|
4
4
|
* @author Blake Embrey (hello@blakeembrey.com)
|
|
5
|
-
*/
|
|
6
|
-
export var titleCase = function (input) {
|
|
7
|
-
return input
|
|
8
|
-
? input.replace(/\w\S*/g, function (txt) { return txt.charAt(0).toUpperCase() + txt.substring(1).toLowerCase(); })
|
|
9
|
-
: "";
|
|
10
|
-
};
|
|
5
|
+
*/ export const titleCase = (input)=>input ? input.replace(/\w\S*/g, (txt)=>txt.charAt(0).toUpperCase() + txt.substring(1).toLowerCase()) : "";
|
|
11
6
|
export default titleCase;
|
package/toNumber.js
CHANGED
|
@@ -1,12 +1,23 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
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
|
+
toNumber: function() {
|
|
13
|
+
return toNumber;
|
|
14
|
+
},
|
|
15
|
+
default: function() {
|
|
16
|
+
return _default;
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
const _isNumber = require("./isNumber");
|
|
8
20
|
function toNumber(input, fallback) {
|
|
9
|
-
return (0,
|
|
21
|
+
return (0, _isNumber.isNumber)(input) ? input : input ? parseFloat(input) : fallback || 0;
|
|
10
22
|
}
|
|
11
|
-
|
|
12
|
-
exports.default = toNumber;
|
|
23
|
+
const _default = toNumber;
|