@koine/utils 1.0.26 → 1.0.29
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/{async.d.ts → Defer.d.ts} +5 -5
- package/{async.js → Defer.js} +2 -7
- package/{emitter.d.ts → Emitter.d.ts} +1 -0
- package/{emitter.js → Emitter.js} +1 -0
- package/accentSets.d.ts +16 -0
- package/accentSets.js +38 -0
- package/addOrReplaceAtIdx.d.ts +5 -0
- package/addOrReplaceAtIdx.js +19 -0
- package/arrayToLookup.d.ts +7 -0
- package/arrayToLookup.js +13 -0
- package/buildUrlQueryString.d.ts +12 -0
- package/buildUrlQueryString.js +24 -0
- package/changeUrlPath.d.ts +10 -0
- package/changeUrlPath.js +18 -0
- package/chunkByChunks.d.ts +7 -0
- package/chunkByChunks.js +37 -0
- package/chunkBySize.d.ts +6 -0
- package/chunkBySize.js +12 -0
- package/clamp.d.ts +8 -0
- package/clamp.js +10 -0
- package/clsx.d.ts +9 -0
- package/clsx.js +49 -0
- package/convertRange.d.ts +14 -0
- package/convertRange.js +16 -0
- package/cookie.d.ts +7 -26
- package/cookie.js +3 -221
- package/decode.d.ts +6 -0
- package/decode.js +10 -0
- package/encode.d.ts +6 -0
- package/encode.js +10 -0
- package/{cast.d.ts → ensureInt.d.ts} +3 -1
- package/{cast.js → ensureInt.js} +3 -4
- package/findDuplicatedIndexes.d.ts +5 -0
- package/findDuplicatedIndexes.js +14 -0
- package/getKeys.d.ts +9 -0
- package/getKeys.js +9 -0
- package/getNonce.d.ts +6 -0
- package/getNonce.js +9 -0
- package/getType.d.ts +22 -0
- package/getType.js +19 -0
- package/getUrlHashParams.d.ts +9 -0
- package/getUrlHashParams.js +16 -0
- package/getUrlHashPathname.d.ts +9 -0
- package/getUrlHashPathname.js +13 -0
- package/getUrlPathnameParts.d.ts +12 -0
- package/getUrlPathnameParts.js +20 -0
- package/getUrlQueryParams.d.ts +14 -0
- package/getUrlQueryParams.js +38 -0
- package/index.d.ts +107 -15
- package/index.js +108 -16
- package/isAnyObject.d.ts +8 -0
- package/isAnyObject.js +10 -0
- package/isArray.d.ts +7 -0
- package/isArray.js +10 -0
- package/isBlob.d.ts +7 -0
- package/isBlob.js +10 -0
- package/isBoolean.d.ts +7 -0
- package/isBoolean.js +10 -0
- package/isBrowser.d.ts +6 -0
- package/{ssr.js → isBrowser.js} +5 -2
- package/isDate.d.ts +7 -0
- package/isDate.js +10 -0
- package/isEmptyArray.d.ts +7 -0
- package/isEmptyArray.js +10 -0
- package/isEmptyObject.d.ts +9 -0
- package/isEmptyObject.js +10 -0
- package/isEmptyString.d.ts +7 -0
- package/isEmptyString.js +9 -0
- package/isError.d.ts +7 -0
- package/isError.js +10 -0
- package/isExternalUrl.d.ts +9 -0
- package/isExternalUrl.js +21 -0
- package/isFile.d.ts +7 -0
- package/isFile.js +10 -0
- package/isFloat.d.ts +7 -0
- package/isFloat.js +10 -0
- package/isFormData.d.ts +7 -0
- package/isFormData.js +10 -0
- package/isFullArray.d.ts +7 -0
- package/isFullArray.js +10 -0
- package/isFullObject.d.ts +8 -0
- package/isFullObject.js +10 -0
- package/isFullString.d.ts +7 -0
- package/isFullString.js +10 -0
- package/isFunction.d.ts +8 -0
- package/isFunction.js +9 -0
- package/{detect.d.ts → isIE.d.ts} +3 -4
- package/isIE.js +18 -0
- package/isInt.d.ts +7 -0
- package/isInt.js +10 -0
- package/isMap.d.ts +7 -0
- package/isMap.js +10 -0
- package/isMobile.d.ts +7 -0
- package/{detect.js → isMobile.js} +4 -15
- package/isNaNValue.d.ts +7 -0
- package/isNaNValue.js +10 -0
- package/isNegativeNumber.d.ts +7 -0
- package/isNegativeNumber.js +10 -0
- package/isNull.d.ts +7 -0
- package/isNull.js +10 -0
- package/isNullOrUndefined.d.ts +7 -0
- package/isNullOrUndefined.js +10 -0
- package/isNumber.d.ts +9 -0
- package/isNumber.js +12 -0
- package/isObject.d.ts +8 -0
- package/isObject.js +10 -0
- package/isObjectLike.d.ts +10 -0
- package/isObjectLike.js +12 -0
- package/isOneOf.d.ts +9 -0
- package/isOneOf.js +10 -0
- package/isPlainObject.d.ts +8 -0
- package/isPlainObject.js +13 -0
- package/isPositiveNumber.d.ts +7 -0
- package/isPositiveNumber.js +10 -0
- package/isPrimitive.d.ts +7 -0
- package/isPrimitive.js +20 -0
- package/isPromise.d.ts +7 -0
- package/isPromise.js +10 -0
- package/isRegExp.d.ts +7 -0
- package/isRegExp.js +10 -0
- package/isServer.d.ts +6 -0
- package/isServer.js +8 -0
- package/isSet.d.ts +7 -0
- package/isSet.js +10 -0
- package/isString.d.ts +7 -0
- package/isString.js +10 -0
- package/isSymbol.d.ts +7 -0
- package/isSymbol.js +10 -0
- package/isType.d.ts +11 -0
- package/isType.js +22 -0
- package/isUndefined.d.ts +7 -0
- package/isUndefined.js +10 -0
- package/isWeakMap.d.ts +7 -0
- package/isWeakMap.js +10 -0
- package/isWeakSet.d.ts +7 -0
- package/isWeakSet.js +10 -0
- package/location.d.ts +2 -145
- package/location.js +1 -299
- package/mapListBy.d.ts +7 -0
- package/mapListBy.js +14 -0
- package/{match-sorter.d.ts → matchSorter.d.ts} +1 -0
- package/{match-sorter.js → matchSorter.js} +2 -1
- package/mergeObjects.d.ts +7 -0
- package/{objects.js → mergeObjects.js} +2 -31
- package/mergeUrlQueryParams.d.ts +9 -0
- package/mergeUrlQueryParams.js +22 -0
- package/navigateToHashParams.d.ts +9 -0
- package/navigateToHashParams.js +22 -0
- package/navigateToMergedHashParams.d.ts +8 -0
- package/navigateToMergedHashParams.js +14 -0
- package/navigateToMergedParams.d.ts +9 -0
- package/navigateToMergedParams.js +14 -0
- package/navigateToParams.d.ts +10 -0
- package/navigateToParams.js +18 -0
- package/navigateWithoutUrlParam.d.ts +8 -0
- package/navigateWithoutUrlParam.js +19 -0
- package/node/{async.js → Defer.js} +3 -9
- package/node/{emitter.js → Emitter.js} +1 -0
- package/node/accentSets.js +41 -0
- package/node/addOrReplaceAtIdx.js +23 -0
- package/node/arrayToLookup.js +17 -0
- package/node/buildUrlQueryString.js +28 -0
- package/node/changeUrlPath.js +22 -0
- package/node/chunkByChunks.js +41 -0
- package/node/chunkBySize.js +16 -0
- package/node/clamp.js +14 -0
- package/node/clsx.js +53 -0
- package/node/convertRange.js +20 -0
- package/node/cookie.js +4 -227
- package/node/decode.js +14 -0
- package/node/encode.js +14 -0
- package/node/{cast.js → ensureInt.js} +4 -6
- package/node/findDuplicatedIndexes.js +18 -0
- package/node/getKeys.js +12 -0
- package/node/getNonce.js +13 -0
- package/node/getType.js +23 -0
- package/node/getUrlHashParams.js +20 -0
- package/node/getUrlHashPathname.js +17 -0
- package/node/getUrlPathnameParts.js +24 -0
- package/node/getUrlQueryParams.js +42 -0
- package/node/index.js +108 -16
- package/node/isAnyObject.js +14 -0
- package/node/isArray.js +14 -0
- package/node/isBlob.js +14 -0
- package/node/isBoolean.js +14 -0
- package/node/{ssr.js → isBrowser.js} +6 -3
- package/node/isDate.js +14 -0
- package/node/isEmptyArray.js +14 -0
- package/node/isEmptyObject.js +14 -0
- package/node/isEmptyString.js +13 -0
- package/node/isError.js +14 -0
- package/node/isExternalUrl.js +25 -0
- package/node/isFile.js +14 -0
- package/node/isFloat.js +14 -0
- package/node/isFormData.js +14 -0
- package/node/isFullArray.js +14 -0
- package/node/isFullObject.js +14 -0
- package/node/isFullString.js +14 -0
- package/node/isFunction.js +13 -0
- package/node/isIE.js +22 -0
- package/node/isInt.js +14 -0
- package/node/isMap.js +14 -0
- package/node/{detect.js → isMobile.js} +6 -18
- package/node/isNaNValue.js +14 -0
- package/node/isNegativeNumber.js +14 -0
- package/node/isNull.js +14 -0
- package/node/isNullOrUndefined.js +13 -0
- package/node/isNumber.js +16 -0
- package/node/isObject.js +14 -0
- package/node/isObjectLike.js +16 -0
- package/node/isOneOf.js +14 -0
- package/node/isPlainObject.js +17 -0
- package/node/isPositiveNumber.js +14 -0
- package/node/isPrimitive.js +24 -0
- package/node/isPromise.js +14 -0
- package/node/isRegExp.js +14 -0
- package/node/isServer.js +11 -0
- package/node/isSet.js +14 -0
- package/node/isString.js +14 -0
- package/node/isSymbol.js +14 -0
- package/node/isType.js +26 -0
- package/node/isUndefined.js +14 -0
- package/node/isWeakMap.js +14 -0
- package/node/isWeakSet.js +14 -0
- package/node/location.js +0 -321
- package/node/mapListBy.js +18 -0
- package/node/{match-sorter.js → matchSorter.js} +3 -2
- package/node/{objects.js → mergeObjects.js} +5 -36
- package/node/mergeUrlQueryParams.js +26 -0
- package/node/navigateToHashParams.js +26 -0
- package/node/navigateToMergedHashParams.js +18 -0
- package/node/navigateToMergedParams.js +18 -0
- package/node/navigateToParams.js +22 -0
- package/node/navigateWithoutUrlParam.js +23 -0
- package/node/normaliseUrl.js +18 -0
- package/node/normaliseUrlPathname.js +18 -0
- package/node/{analytics-google.js → pageview.js} +12 -10
- package/node/parseCookie.js +52 -0
- package/node/parseURL.js +24 -0
- package/node/randomInt.js +13 -0
- package/node/{misc.js → randomKey.js} +2 -0
- package/node/readCookie.js +38 -0
- package/node/redirectTo.js +19 -0
- package/node/removeAccents.js +19 -0
- package/node/removeCookie.js +19 -0
- package/node/removeDuplicatesByKey.js +25 -0
- package/node/removeDuplicatesComparing.js +14 -0
- package/node/removeIndexesFromArray.js +18 -0
- package/node/removeTrailingSlash.js +14 -0
- package/node/{math.js → roundTo.js} +3 -32
- package/node/serializeCookie.js +108 -0
- package/node/setCookie.js +61 -0
- package/node/shuffle.js +36 -0
- package/node/slugify.js +27 -0
- package/node/swapMap.js +18 -0
- package/node/{typography.js → titleCase.js} +3 -12
- package/node/toNumber.js +12 -0
- package/node/{colors.js → toRgba.js} +4 -0
- package/node/transformToUrlPathname.js +20 -0
- package/node/truncate.js +17 -0
- package/node/uid.js +4 -13
- package/node/updateLinkParams.js +18 -0
- package/node/updateUrlQueryParams.js +22 -0
- package/node/uuid.js +17 -0
- package/node/wait.js +13 -0
- package/node/whitelistObject.js +19 -0
- package/normaliseUrl.d.ts +10 -0
- package/normaliseUrl.js +14 -0
- package/normaliseUrlPathname.d.ts +10 -0
- package/normaliseUrlPathname.js +14 -0
- package/package.json +1 -1
- package/{analytics-google.d.ts → pageview.d.ts} +3 -0
- package/{analytics-google.js → pageview.js} +12 -10
- package/parseCookie.d.ts +11 -0
- package/parseCookie.js +48 -0
- package/parseURL.d.ts +17 -0
- package/parseURL.js +20 -0
- package/randomInt.d.ts +7 -0
- package/randomInt.js +9 -0
- package/{misc.d.ts → randomKey.d.ts} +2 -0
- package/{misc.js → randomKey.js} +2 -0
- package/readCookie.d.ts +3 -0
- package/readCookie.js +34 -0
- package/redirectTo.d.ts +9 -0
- package/redirectTo.js +15 -0
- package/removeAccents.d.ts +6 -0
- package/removeAccents.js +15 -0
- package/removeCookie.d.ts +10 -0
- package/removeCookie.js +15 -0
- package/removeDuplicatesByKey.d.ts +8 -0
- package/removeDuplicatesByKey.js +21 -0
- package/removeDuplicatesComparing.d.ts +5 -0
- package/removeDuplicatesComparing.js +10 -0
- package/removeIndexesFromArray.d.ts +5 -0
- package/removeIndexesFromArray.js +14 -0
- package/removeTrailingSlash.d.ts +7 -0
- package/removeTrailingSlash.js +10 -0
- package/roundTo.d.ts +8 -0
- package/{math.js → roundTo.js} +2 -28
- package/serializeCookie.d.ts +27 -0
- package/serializeCookie.js +104 -0
- package/setCookie.d.ts +10 -0
- package/setCookie.js +57 -0
- package/shuffle.d.ts +16 -0
- package/shuffle.js +32 -0
- package/{text.d.ts → slugify.d.ts} +2 -5
- package/slugify.js +23 -0
- package/swapMap.d.ts +7 -0
- package/swapMap.js +14 -0
- package/{typography.d.ts → titleCase.d.ts} +2 -4
- package/{typography.js → titleCase.js} +2 -10
- package/toNumber.d.ts +5 -0
- package/toNumber.js +8 -0
- package/{colors.d.ts → toRgba.d.ts} +4 -0
- package/{colors.js → toRgba.js} +4 -0
- package/transformToUrlPathname.d.ts +11 -0
- package/transformToUrlPathname.js +16 -0
- package/truncate.d.ts +7 -0
- package/truncate.js +13 -0
- package/uid.d.ts +3 -6
- package/uid.js +3 -11
- package/updateLinkParams.d.ts +10 -0
- package/updateLinkParams.js +14 -0
- package/updateUrlQueryParams.d.ts +9 -0
- package/updateUrlQueryParams.js +18 -0
- package/uuid.d.ts +8 -0
- package/uuid.js +13 -0
- package/wait.d.ts +7 -0
- package/wait.js +9 -0
- package/whitelistObject.d.ts +8 -0
- package/whitelistObject.js +15 -0
- package/arrays.d.ts +0 -41
- package/arrays.js +0 -153
- package/is.d.ts +0 -288
- package/is.js +0 -376
- package/math.d.ts +0 -28
- package/node/arrays.js +0 -166
- package/node/is.js +0 -417
- package/node/security.js +0 -29
- package/node/text.js +0 -70
- package/objects.d.ts +0 -22
- package/security.d.ts +0 -12
- package/security.js +0 -23
- package/ssr.d.ts +0 -2
- package/text.js +0 -65
|
@@ -1,10 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @category async
|
|
3
|
+
*/
|
|
1
4
|
export declare type Deferred<T> = Promise<T> & {
|
|
2
5
|
resolve: PromiseConstructor["resolve"];
|
|
3
6
|
reject: PromiseConstructor["reject"];
|
|
4
7
|
};
|
|
5
8
|
/**
|
|
9
|
+
* @category async
|
|
6
10
|
* @see https://stackoverflow.com/a/37673534/1938970
|
|
7
|
-
*
|
|
8
11
|
* @example
|
|
9
12
|
*
|
|
10
13
|
* ```ts
|
|
@@ -14,7 +17,4 @@ export declare type Deferred<T> = Promise<T> & {
|
|
|
14
17
|
* ```
|
|
15
18
|
*/
|
|
16
19
|
export declare function Defer<T>(): Deferred<T>;
|
|
17
|
-
|
|
18
|
-
* A promisified `setTimeout`
|
|
19
|
-
*/
|
|
20
|
-
export declare const wait: (milliseconds: number) => Promise<unknown>;
|
|
20
|
+
export default Defer;
|
package/{async.js → Defer.js}
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
+
* @category async
|
|
2
3
|
* @see https://stackoverflow.com/a/37673534/1938970
|
|
3
|
-
*
|
|
4
4
|
* @example
|
|
5
5
|
*
|
|
6
6
|
* ```ts
|
|
@@ -23,9 +23,4 @@ export function Defer() {
|
|
|
23
23
|
// }
|
|
24
24
|
return self;
|
|
25
25
|
}
|
|
26
|
-
|
|
27
|
-
* A promisified `setTimeout`
|
|
28
|
-
*/
|
|
29
|
-
export var wait = function (milliseconds) {
|
|
30
|
-
return new Promise(function (resolve) { return setTimeout(resolve, milliseconds); });
|
|
31
|
-
};
|
|
26
|
+
export default Defer;
|
package/accentSets.d.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* First value is the `to`, second is `from`, from *which* chars do we translates *to*
|
|
3
|
+
*
|
|
4
|
+
* @category text
|
|
5
|
+
*/
|
|
6
|
+
export declare type AccentsSet = [string, string];
|
|
7
|
+
/**
|
|
8
|
+
* Accent sets
|
|
9
|
+
*
|
|
10
|
+
* @category text
|
|
11
|
+
* @see https://gist.github.com/mathewbyrne/1280286#gistcomment-3498021
|
|
12
|
+
* @see https://gist.github.com/eek/9c4887e80b3ede05c0e39fee4dce3747 for usage
|
|
13
|
+
* of [normalize](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/normalize)
|
|
14
|
+
*/
|
|
15
|
+
export declare const accentsSets: AccentsSet[];
|
|
16
|
+
export default accentsSets;
|
package/accentSets.js
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Accent sets
|
|
3
|
+
*
|
|
4
|
+
* @category text
|
|
5
|
+
* @see https://gist.github.com/mathewbyrne/1280286#gistcomment-3498021
|
|
6
|
+
* @see https://gist.github.com/eek/9c4887e80b3ede05c0e39fee4dce3747 for usage
|
|
7
|
+
* of [normalize](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/normalize)
|
|
8
|
+
*/
|
|
9
|
+
export var accentsSets = [
|
|
10
|
+
["a", "ÀÁÂÃÅÆĀĂĄẠẢẤẦẨẪẬẮẰẲẴẶ"],
|
|
11
|
+
["ae", "Ä"],
|
|
12
|
+
["c", "ÇĆĈČ"],
|
|
13
|
+
["d", "ÐĎĐÞ"],
|
|
14
|
+
["e", "ÈÉÊËĒĔĖĘĚẸẺẼẾỀỂỄỆ"],
|
|
15
|
+
["g", "ĜĞĢǴ"],
|
|
16
|
+
["h", "ĤḦ"],
|
|
17
|
+
["i", "ÌÍÎÏĨĪĮİỈỊ"],
|
|
18
|
+
["j", "Ĵ"],
|
|
19
|
+
["ij", "IJ"],
|
|
20
|
+
["k", "Ķ"],
|
|
21
|
+
["l", "ĹĻĽŁ"],
|
|
22
|
+
["m", "Ḿ"],
|
|
23
|
+
["n", "ÑŃŅŇ"],
|
|
24
|
+
["o", "ÒÓÔÕØŌŎŐỌỎỐỒỔỖỘỚỜỞỠỢǪǬƠ"],
|
|
25
|
+
["oe", "΅"],
|
|
26
|
+
["p", "ṕ"],
|
|
27
|
+
["r", "ŔŖŘ"],
|
|
28
|
+
["s", "ŚŜŞŠ"],
|
|
29
|
+
["ss", "ß"],
|
|
30
|
+
["t", "ŢŤ"],
|
|
31
|
+
["u", "ÙÚÛŨŪŬŮŰŲỤỦỨỪỬỮỰƯ"],
|
|
32
|
+
["ue", "Ü"],
|
|
33
|
+
["w", "ẂŴẀẄ"],
|
|
34
|
+
["x", "ẍ"],
|
|
35
|
+
["y", "ÝŶŸỲỴỶỸ"],
|
|
36
|
+
["z", "ŹŻŽ"],
|
|
37
|
+
];
|
|
38
|
+
export default accentsSets;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { __spreadArray } from "tslib";
|
|
2
|
+
/**
|
|
3
|
+
* @category array
|
|
4
|
+
*/
|
|
5
|
+
export function addOrReplaceAtIdx(list, newItem, newIdx) {
|
|
6
|
+
if (list.length === 0) {
|
|
7
|
+
return [newItem];
|
|
8
|
+
}
|
|
9
|
+
if (typeof newIdx === "undefined" || list.length - 1 < newIdx) {
|
|
10
|
+
return __spreadArray(__spreadArray([], list, true), [newItem], false);
|
|
11
|
+
}
|
|
12
|
+
return list.map(function (item, idx) {
|
|
13
|
+
if (idx === newIdx) {
|
|
14
|
+
return newItem;
|
|
15
|
+
}
|
|
16
|
+
return item;
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
export default addOrReplaceAtIdx;
|
package/arrayToLookup.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Maps a simple flat array to a lookup dictionary object
|
|
3
|
+
*
|
|
4
|
+
* @category array
|
|
5
|
+
*/
|
|
6
|
+
export function arrayToLookup(array) {
|
|
7
|
+
if (array === void 0) { array = []; }
|
|
8
|
+
return array.reduce(function (obj, item) {
|
|
9
|
+
obj[item] = 1;
|
|
10
|
+
return obj;
|
|
11
|
+
}, {});
|
|
12
|
+
}
|
|
13
|
+
export default arrayToLookup;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { type AnyQueryParams } from "./location";
|
|
2
|
+
/**
|
|
3
|
+
* Get clean query string for URL
|
|
4
|
+
*
|
|
5
|
+
* It returns the query string **with** the initial `?`
|
|
6
|
+
*
|
|
7
|
+
* TODO: at some point replace with `URLSearchParams`, @see [caniuse](https://caniuse.com/?search=URLSearchParams)
|
|
8
|
+
*
|
|
9
|
+
* @category location
|
|
10
|
+
*/
|
|
11
|
+
export declare function buildUrlQueryString(params?: AnyQueryParams): string;
|
|
12
|
+
export default buildUrlQueryString;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import isNull from "./isNull";
|
|
2
|
+
import isUndefined from "./isUndefined";
|
|
3
|
+
/**
|
|
4
|
+
* Get clean query string for URL
|
|
5
|
+
*
|
|
6
|
+
* It returns the query string **with** the initial `?`
|
|
7
|
+
*
|
|
8
|
+
* TODO: at some point replace with `URLSearchParams`, @see [caniuse](https://caniuse.com/?search=URLSearchParams)
|
|
9
|
+
*
|
|
10
|
+
* @category location
|
|
11
|
+
*/
|
|
12
|
+
export function buildUrlQueryString(params) {
|
|
13
|
+
if (params === void 0) { params = {}; }
|
|
14
|
+
var output = "";
|
|
15
|
+
for (var key in params) {
|
|
16
|
+
var value = params[key];
|
|
17
|
+
if (!isNull(value) && !isUndefined(value)) {
|
|
18
|
+
output += "".concat(key, "=").concat(encodeURIComponent(value + ""), "&");
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
// removes the last &
|
|
22
|
+
return output ? "?".concat(output.replace(/&+$/, "")) : "";
|
|
23
|
+
}
|
|
24
|
+
export default buildUrlQueryString;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Change URL path, ensures initial and ending slashes and normalise eventual
|
|
3
|
+
* consecutive slashes, it uses `history`.
|
|
4
|
+
*
|
|
5
|
+
* @category location
|
|
6
|
+
* @param replace Replace URL instead of pushing it in the history stack. By default it pushes it.
|
|
7
|
+
* @returns {string} The new cleaned pathname
|
|
8
|
+
*/
|
|
9
|
+
export declare function changeUrlPath(pathname: string, state?: object, replace?: boolean): string;
|
|
10
|
+
export default changeUrlPath;
|
package/changeUrlPath.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import isBrowser from "./isBrowser";
|
|
2
|
+
import normaliseUrlPathname from "./normaliseUrlPathname";
|
|
3
|
+
/**
|
|
4
|
+
* Change URL path, ensures initial and ending slashes and normalise eventual
|
|
5
|
+
* consecutive slashes, it uses `history`.
|
|
6
|
+
*
|
|
7
|
+
* @category location
|
|
8
|
+
* @param replace Replace URL instead of pushing it in the history stack. By default it pushes it.
|
|
9
|
+
* @returns {string} The new cleaned pathname
|
|
10
|
+
*/
|
|
11
|
+
export function changeUrlPath(pathname, state, replace) {
|
|
12
|
+
var path = normaliseUrlPathname("/".concat(pathname, "/"));
|
|
13
|
+
if (isBrowser) {
|
|
14
|
+
history[replace ? "replaceState" : "pushState"](state, "", path);
|
|
15
|
+
}
|
|
16
|
+
return path;
|
|
17
|
+
}
|
|
18
|
+
export default changeUrlPath;
|
package/chunkByChunks.js
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TODO: untested
|
|
3
|
+
* @category array
|
|
4
|
+
* @see https://stackoverflow.com/a/8189268/1938970
|
|
5
|
+
*/
|
|
6
|
+
export function chunkByChunks(arr, nrOfChunks, balanced) {
|
|
7
|
+
if (nrOfChunks < 2)
|
|
8
|
+
return [arr];
|
|
9
|
+
var len = arr.length;
|
|
10
|
+
var output = [];
|
|
11
|
+
var i = 0;
|
|
12
|
+
var size;
|
|
13
|
+
if (len % nrOfChunks === 0) {
|
|
14
|
+
size = Math.floor(len / nrOfChunks);
|
|
15
|
+
while (i < len) {
|
|
16
|
+
output.push(arr.slice(i, (i += size)));
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
else if (balanced) {
|
|
20
|
+
while (i < len) {
|
|
21
|
+
size = Math.ceil((len - i) / nrOfChunks--);
|
|
22
|
+
output.push(arr.slice(i, (i += size)));
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
else {
|
|
26
|
+
nrOfChunks--;
|
|
27
|
+
size = Math.floor(len / nrOfChunks);
|
|
28
|
+
if (len % size === 0)
|
|
29
|
+
size--;
|
|
30
|
+
while (i < size * nrOfChunks) {
|
|
31
|
+
output.push(arr.slice(i, (i += size)));
|
|
32
|
+
}
|
|
33
|
+
output.push(arr.slice(size * nrOfChunks));
|
|
34
|
+
}
|
|
35
|
+
return output;
|
|
36
|
+
}
|
|
37
|
+
export default chunkByChunks;
|
package/chunkBySize.d.ts
ADDED
package/chunkBySize.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @category array
|
|
3
|
+
* @see https://stackoverflow.com/a/40682136/1938970
|
|
4
|
+
*/
|
|
5
|
+
export function chunkBySize(arr, size) {
|
|
6
|
+
var output = [];
|
|
7
|
+
for (var i = 0; i < arr.length; i += size) {
|
|
8
|
+
output.push(arr.slice(i, i + size));
|
|
9
|
+
}
|
|
10
|
+
return output;
|
|
11
|
+
}
|
|
12
|
+
export default chunkBySize;
|
package/clamp.d.ts
ADDED
package/clamp.js
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns a number whose value is limited to the given range.
|
|
3
|
+
*
|
|
4
|
+
* @category math
|
|
5
|
+
* @see https://stackoverflow.com/a/11409944/1938970
|
|
6
|
+
*/
|
|
7
|
+
export function clamp(num, min, max) {
|
|
8
|
+
return Math.min(Math.max(num, min), max);
|
|
9
|
+
}
|
|
10
|
+
export default clamp;
|
package/clsx.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { ClassValue } from "clsx";
|
|
2
|
+
/**
|
|
3
|
+
* Class names utility, embedded from [clsx](https://github.com/lukeed/clsx)
|
|
4
|
+
*
|
|
5
|
+
* @see https://github.com/lukeed/clsx
|
|
6
|
+
* @license [MIT: Luke Edwards](https://github.com/lukeed/clsx/blob/master/license)
|
|
7
|
+
*/
|
|
8
|
+
export declare const clsx: (...args: ClassValue[]) => string;
|
|
9
|
+
export default clsx;
|
package/clsx.js
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
// import _clsx from "clsx";
|
|
2
|
+
// export const clsx = _clsx;
|
|
3
|
+
function toVal(mix) {
|
|
4
|
+
var k, y, str = "";
|
|
5
|
+
if (typeof mix === "string" || typeof mix === "number") {
|
|
6
|
+
str += mix;
|
|
7
|
+
}
|
|
8
|
+
else if (typeof mix === "object") {
|
|
9
|
+
if (Array.isArray(mix)) {
|
|
10
|
+
for (k = 0; k < mix.length; k++) {
|
|
11
|
+
if (mix[k]) {
|
|
12
|
+
if ((y = toVal(mix[k]))) {
|
|
13
|
+
str && (str += " ");
|
|
14
|
+
str += y;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
else {
|
|
20
|
+
for (k in mix) {
|
|
21
|
+
if (mix[k]) {
|
|
22
|
+
str && (str += " ");
|
|
23
|
+
str += k;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
return str;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Class names utility, embedded from [clsx](https://github.com/lukeed/clsx)
|
|
32
|
+
*
|
|
33
|
+
* @see https://github.com/lukeed/clsx
|
|
34
|
+
* @license [MIT: Luke Edwards](https://github.com/lukeed/clsx/blob/master/license)
|
|
35
|
+
*/
|
|
36
|
+
export var clsx = function () {
|
|
37
|
+
var i = 0, tmp, x, str = "";
|
|
38
|
+
while (i < arguments.length) {
|
|
39
|
+
// eslint-disable-next-line prefer-rest-params
|
|
40
|
+
if ((tmp = arguments[i++])) {
|
|
41
|
+
if ((x = toVal(tmp))) {
|
|
42
|
+
str && (str += " ");
|
|
43
|
+
str += x;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
return str;
|
|
48
|
+
};
|
|
49
|
+
export default clsx;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Convert range of a number
|
|
3
|
+
*
|
|
4
|
+
* e.g. converting number 5 in a scale/range from 0 10 to a scale/range from 50
|
|
5
|
+
* to 100 would return 75
|
|
6
|
+
* ```
|
|
7
|
+
* convertRange(5, [0, 10], [50, 100]);
|
|
8
|
+
* ```
|
|
9
|
+
*
|
|
10
|
+
* @category math
|
|
11
|
+
* @see https://stackoverflow.com/a/14224813
|
|
12
|
+
*/
|
|
13
|
+
export declare function convertRange(num: number, r1: number[], r2: number[]): number;
|
|
14
|
+
export default convertRange;
|
package/convertRange.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Convert range of a number
|
|
3
|
+
*
|
|
4
|
+
* e.g. converting number 5 in a scale/range from 0 10 to a scale/range from 50
|
|
5
|
+
* to 100 would return 75
|
|
6
|
+
* ```
|
|
7
|
+
* convertRange(5, [0, 10], [50, 100]);
|
|
8
|
+
* ```
|
|
9
|
+
*
|
|
10
|
+
* @category math
|
|
11
|
+
* @see https://stackoverflow.com/a/14224813
|
|
12
|
+
*/
|
|
13
|
+
export function convertRange(num, r1, r2) {
|
|
14
|
+
return ((num - r1[0]) * (r2[1] - r2[0])) / (r1[1] - r1[0]) + r2[0];
|
|
15
|
+
}
|
|
16
|
+
export default convertRange;
|
package/cookie.d.ts
CHANGED
|
@@ -1,30 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @file
|
|
3
3
|
*
|
|
4
|
-
*
|
|
4
|
+
* @category cookie
|
|
5
5
|
*
|
|
6
|
+
* All cookie related code is inspired and adapted from:
|
|
6
7
|
* - [js-cookie](https://github.com/js-cookie/js-cookie)
|
|
7
|
-
* @see https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/js-cookie/index.d.ts
|
|
8
8
|
* - [cookie](https://github.com/jshttp/cookie)
|
|
9
|
-
*
|
|
10
9
|
*/
|
|
11
|
-
/**
|
|
12
|
-
* Parse a cookie header.
|
|
13
|
-
*
|
|
14
|
-
* Parse the given cookie header string into an object
|
|
15
|
-
* The object has the various cookies as keys(names) => values
|
|
16
|
-
*/
|
|
17
|
-
export declare function parseCookie<T extends Record<string, unknown> = Record<string, string>>(str: string, attributes?: CookieAttributesServer): T;
|
|
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
|
-
export declare function serializeCookie(name: string, val: string, attributes?: CookieAttributesServer): string;
|
|
28
10
|
declare type CookieAttributes = {
|
|
29
11
|
/**
|
|
30
12
|
* Define when the cookie will be removed. Value can be a Number
|
|
@@ -59,15 +41,14 @@ declare type CookieAttributes = {
|
|
|
59
41
|
*/
|
|
60
42
|
sameSite?: "strict" | "Strict" | "lax" | "Lax" | "none" | "None" | undefined;
|
|
61
43
|
};
|
|
62
|
-
declare type CookieAttributesServer = CookieAttributes & {
|
|
44
|
+
export declare type CookieAttributesServer = CookieAttributes & {
|
|
63
45
|
maxAge?: number;
|
|
64
46
|
httpOnly?: boolean;
|
|
65
47
|
encode?: (input: string) => string;
|
|
66
48
|
decode?: (input: string) => string;
|
|
67
49
|
};
|
|
68
|
-
declare type CookieAttributesClient = CookieAttributes;
|
|
69
|
-
export declare
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
export declare function removeCookie(name: string, attributes?: CookieAttributesClient): void;
|
|
50
|
+
export declare type CookieAttributesClient = CookieAttributes;
|
|
51
|
+
export declare const defaultAttributesClient: {
|
|
52
|
+
path: string;
|
|
53
|
+
};
|
|
73
54
|
export {};
|