@koine/utils 2.0.0-beta.1 → 2.0.0-beta.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Defer.mjs +6 -5
- package/Emitter.d.ts +3 -1
- package/Emitter.mjs +16 -17
- package/README.md +6 -1
- package/accentSets.d.ts +3 -2
- package/accentSets.mjs +116 -31
- package/addOrReplaceAtIdx.d.ts +4 -0
- package/addOrReplaceAtIdx.mjs +13 -6
- package/areEqual.d.ts +1 -1
- package/areEqual.mjs +17 -23
- package/arrayOfAll.d.ts +1 -2
- package/arrayOfAll.mjs +2 -8
- package/arraySum.d.ts +2 -1
- package/arraySum.mjs +3 -5
- package/arrayToLookup.mjs +2 -4
- package/buildUrlQueryString.mjs +11 -14
- package/capitalize.d.ts +2 -1
- package/capitalize.mjs +5 -6
- package/changeUrlPath.mjs +2 -3
- package/chunkByChunks.d.ts +1 -1
- package/chunkByChunks.mjs +18 -21
- package/chunkBySize.mjs +3 -4
- package/clamp.mjs +1 -2
- package/clsx.d.ts +6 -2
- package/clsx.mjs +14 -15
- package/convertRange.d.ts +3 -1
- package/convertRange.mjs +5 -4
- package/cookie.d.ts +13 -1
- package/cookie.mjs +8 -3
- package/createPalette.d.ts +3 -1
- package/createPalette.mjs +17 -7
- package/debounce.mjs +9 -17
- package/debouncePromise.d.ts +22 -4
- package/debouncePromise.mjs +73 -3
- package/debounceRaf.d.ts +1 -1
- package/debounceRaf.mjs +6 -11
- package/decode.mjs +2 -3
- package/encode.mjs +2 -3
- package/ensureInt.mjs +1 -4
- package/env.mjs +0 -1
- package/errorToString.d.ts +2 -1
- package/errorToString.mjs +3 -5
- package/findDuplicatedIndexes.mjs +4 -5
- package/forin.d.ts +2 -1
- package/forin.mjs +4 -4
- package/gbToBytes.mjs +1 -2
- package/getEmptyArray.d.ts +0 -1
- package/getEmptyArray.mjs +4 -4
- package/getKeys.d.ts +2 -1
- package/getKeys.mjs +3 -3
- package/getMediaQueryWidthResolvers.d.ts +6 -0
- package/getMediaQueryWidthResolvers.mjs +49 -50
- package/getMediaQueryWidthTailwindScreens.d.ts +4 -0
- package/getMediaQueryWidthTailwindScreens.mjs +22 -15
- package/getNonce.mjs +1 -2
- package/getParamAmong.d.ts +3 -2
- package/getParamAmong.mjs +5 -6
- package/getParamAsInt.d.ts +2 -2
- package/getParamAsInt.mjs +4 -6
- package/getParamAsString.d.ts +1 -1
- package/getParamAsString.mjs +2 -3
- package/getType.d.ts +0 -3
- package/getType.mjs +2 -7
- package/getUrlHashParams.mjs +2 -4
- package/getUrlHashPathname.mjs +1 -3
- package/getUrlPathnameParts.mjs +2 -7
- package/getUrlQueryParams.d.ts +3 -4
- package/getUrlQueryParams.mjs +10 -22
- package/imgEmptyPixel.mjs +1 -2
- package/index.d.ts +5 -2
- package/index.mjs +2 -2
- package/invariant.mjs +6 -8
- package/isAnyObject.mjs +1 -2
- package/isArray.mjs +1 -2
- package/isBlob.mjs +1 -2
- package/isBoolean.mjs +1 -2
- package/isBrowser.mjs +1 -2
- package/isBrowserNow.mjs +1 -2
- package/isDate.mjs +1 -2
- package/isEmptyArray.mjs +1 -2
- package/isEmptyObject.mjs +1 -2
- package/isEmptyString.mjs +1 -2
- package/isError.mjs +1 -2
- package/isExternalUrl.mjs +4 -6
- package/isFile.mjs +1 -2
- package/isFloat.mjs +1 -2
- package/isFormData.mjs +1 -2
- package/isFullArray.mjs +1 -2
- package/isFullObject.mjs +1 -2
- package/isFullString.mjs +1 -2
- package/isFunction.mjs +1 -2
- package/isInt.mjs +1 -2
- package/isMap.mjs +1 -2
- package/isNaNValue.mjs +1 -2
- package/isNegativeNumber.mjs +1 -2
- package/isNull.mjs +1 -2
- package/isNullOrUndefined.mjs +1 -2
- package/isNumber.mjs +1 -2
- package/isObject.mjs +1 -2
- package/isObjectLike.mjs +1 -2
- package/isOneOf.mjs +1 -7
- package/isPlainObject.mjs +3 -6
- package/isPositiveNumber.mjs +1 -2
- package/isPrimitive.mjs +5 -11
- package/isPromise.mjs +1 -2
- package/isRegExp.mjs +1 -2
- package/isServer.mjs +1 -2
- package/isServerNow.mjs +1 -2
- package/isSet.mjs +1 -2
- package/isString.mjs +1 -2
- package/isSymbol.mjs +1 -2
- package/isType.mjs +3 -5
- package/isUndefined.mjs +1 -2
- package/isWeakMap.mjs +1 -2
- package/isWeakSet.mjs +1 -2
- package/kbToBytes.mjs +1 -2
- package/location.mjs +3 -1
- package/lowercase.mjs +1 -4
- package/mapListBy.mjs +2 -5
- package/matchSorter.mjs +110 -128
- package/mbToBytes.mjs +1 -2
- package/mergeObjects.d.ts +2 -2
- package/mergeObjects.mjs +13 -16
- package/mergeUrlQueryParams.d.ts +0 -1
- package/mergeUrlQueryParams.mjs +4 -9
- package/moveSortableArrayItemByKey.d.ts +1 -1
- package/moveSortableArrayItemByKey.mjs +9 -9
- package/noop.mjs +1 -2
- package/normaliseUrl.mjs +1 -3
- package/normaliseUrlPathname.mjs +1 -3
- package/objectOmit.d.ts +1 -1
- package/objectOmit.mjs +4 -6
- package/objectPick.d.ts +1 -1
- package/objectPick.mjs +5 -6
- package/package.json +7 -11
- package/parseCookie.mjs +11 -15
- package/parseURL.mjs +5 -6
- package/quaranteneProps.d.ts +1 -1
- package/quaranteneProps.mjs +7 -9
- package/randomInt.mjs +1 -2
- package/randomKey.mjs +3 -4
- package/readCookie.d.ts +5 -0
- package/readCookie.mjs +7 -8
- package/removeAccents.mjs +5 -8
- package/removeCookie.d.ts +0 -4
- package/removeCookie.mjs +6 -9
- package/removeDuplicates.mjs +0 -1
- package/removeDuplicatesByKey.mjs +5 -7
- package/removeDuplicatesComparing.mjs +3 -4
- package/removeIndexesFromArray.mjs +3 -4
- package/removeTrailingSlash.mjs +1 -3
- package/removeUrlQueryParams.d.ts +0 -1
- package/removeUrlQueryParams.mjs +5 -8
- package/render.d.ts +2 -1
- package/render.mjs +45 -99
- package/roundTo.mjs +15 -17
- package/serializeCookie.d.ts +1 -5
- package/serializeCookie.mjs +10 -20
- package/setCookie.d.ts +0 -4
- package/setCookie.mjs +13 -20
- package/shuffle.d.ts +7 -6
- package/shuffle.mjs +17 -16
- package/slugify.d.ts +2 -1
- package/slugify.mjs +15 -12
- package/split.d.ts +4 -0
- package/split.mjs +4 -1
- package/swapMap.d.ts +1 -1
- package/swapMap.mjs +4 -6
- package/throttle.d.ts +2 -1
- package/throttle.mjs +6 -12
- package/titleCase.d.ts +4 -3
- package/titleCase.mjs +5 -9
- package/toNumber.mjs +1 -2
- package/toRgba.mjs +3 -5
- package/transformToUrlPathname.mjs +2 -5
- package/truncate.d.ts +1 -1
- package/truncate.mjs +2 -9
- package/tryUntil.d.ts +4 -1
- package/tryUntil.mjs +11 -11
- package/types.mjs +2 -1
- package/typings.d.ts +1 -6
- package/uid.mjs +3 -5
- package/updateLinkParams.mjs +2 -3
- package/updateUrlQueryParams.d.ts +0 -1
- package/updateUrlQueryParams.mjs +3 -8
- package/uppercase.d.ts +1 -0
- package/uppercase.mjs +2 -4
- package/uuid.mjs +2 -5
- package/uuidNumeric.mjs +1 -2
- package/wait.mjs +1 -4
- package/without.mjs +1 -3
- package/Defer.js +0 -30
- package/Emitter.js +0 -42
- package/accentSets.js +0 -41
- package/addOrReplaceAtIdx.js +0 -23
- package/areEqual.js +0 -81
- package/arrayOfAll.js +0 -36
- package/arraySum.js +0 -13
- package/arrayToLookup.js +0 -17
- package/buildUrlQueryString.js +0 -36
- package/capitalize.js +0 -16
- package/changeUrlPath.js +0 -23
- package/chunkByChunks.js +0 -41
- package/chunkBySize.js +0 -16
- package/clamp.js +0 -14
- package/clsx.js +0 -53
- package/convertRange.js +0 -20
- package/cookie.js +0 -13
- package/createPalette.js +0 -26
- package/debounce.js +0 -33
- package/debouncePromise.js +0 -12
- package/debounceRaf.js +0 -31
- package/decode.js +0 -14
- package/encode.js +0 -14
- package/ensureInt.js +0 -13
- package/env.js +0 -3
- package/errorToString.js +0 -15
- package/findDuplicatedIndexes.js +0 -18
- package/forin.js +0 -15
- package/gbToBytes.js +0 -11
- package/getEmptyArray.js +0 -20
- package/getKeys.js +0 -12
- package/getMediaQueryWidthResolvers.js +0 -72
- package/getMediaQueryWidthTailwindScreens.js +0 -33
- package/getNonce.js +0 -13
- package/getParamAmong.js +0 -22
- package/getParamAsInt.js +0 -25
- package/getParamAsString.js +0 -19
- package/getType.js +0 -23
- package/getUrlHashParams.js +0 -20
- package/getUrlHashPathname.js +0 -17
- package/getUrlPathnameParts.js +0 -25
- package/getUrlQueryParams.js +0 -43
- package/imgEmptyPixel.js +0 -10
- package/index.js +0 -267
- package/invariant.js +0 -38
- package/isAnyObject.js +0 -15
- package/isArray.js +0 -15
- package/isBlob.js +0 -15
- package/isBoolean.js +0 -15
- package/isBrowser.js +0 -9
- package/isBrowserNow.js +0 -12
- package/isDate.js +0 -15
- package/isEmptyArray.js +0 -15
- package/isEmptyObject.js +0 -15
- package/isEmptyString.js +0 -13
- package/isError.js +0 -15
- package/isExternalUrl.js +0 -26
- package/isFile.js +0 -15
- package/isFloat.js +0 -15
- package/isFormData.js +0 -15
- package/isFullArray.js +0 -15
- package/isFullObject.js +0 -15
- package/isFullString.js +0 -15
- package/isFunction.js +0 -13
- package/isInt.js +0 -15
- package/isMap.js +0 -15
- package/isNaNValue.js +0 -15
- package/isNegativeNumber.js +0 -15
- package/isNull.js +0 -15
- package/isNullOrUndefined.js +0 -14
- package/isNumber.js +0 -17
- package/isObject.js +0 -15
- package/isObjectLike.js +0 -17
- package/isOneOf.js +0 -14
- package/isPlainObject.js +0 -18
- package/isPositiveNumber.js +0 -15
- package/isPrimitive.js +0 -25
- package/isPromise.js +0 -15
- package/isRegExp.js +0 -15
- package/isServer.js +0 -12
- package/isServerNow.js +0 -12
- package/isSet.js +0 -15
- package/isString.js +0 -15
- package/isSymbol.js +0 -15
- package/isType.js +0 -27
- package/isUndefined.js +0 -15
- package/isWeakMap.js +0 -15
- package/isWeakSet.js +0 -15
- package/kbToBytes.js +0 -11
- package/location.js +0 -2
- package/lowercase.js +0 -13
- package/mapListBy.js +0 -18
- package/matchSorter.js +0 -374
- package/mbToBytes.js +0 -11
- package/mergeObjects.js +0 -41
- package/mergeUrlQueryParams.js +0 -27
- package/moveSortableArrayItemByKey.js +0 -21
- package/noop.js +0 -11
- package/normaliseUrl.js +0 -20
- package/normaliseUrlPathname.js +0 -19
- package/objectOmit.js +0 -23
- package/objectPick.js +0 -19
- package/parseCookie.js +0 -52
- package/parseURL.js +0 -24
- package/quaranteneProps.js +0 -37
- package/randomInt.js +0 -13
- package/randomKey.js +0 -15
- package/readCookie.js +0 -38
- package/removeAccents.js +0 -19
- package/removeCookie.js +0 -19
- package/removeDuplicates.js +0 -13
- package/removeDuplicatesByKey.js +0 -24
- package/removeDuplicatesComparing.js +0 -14
- package/removeIndexesFromArray.js +0 -18
- package/removeTrailingSlash.js +0 -14
- package/removeUrlQueryParams.js +0 -26
- package/render.js +0 -169
- package/roundTo.js +0 -38
- package/serializeCookie.js +0 -108
- package/setCookie.js +0 -62
- package/shuffle.js +0 -36
- package/slugify.js +0 -27
- package/split.js +0 -8
- package/swapMap.js +0 -18
- package/throttle.js +0 -30
- package/titleCase.js +0 -15
- package/toNumber.js +0 -12
- package/toRgba.js +0 -20
- package/transformToUrlPathname.js +0 -21
- package/truncate.js +0 -17
- package/tryUntil.js +0 -31
- package/types.js +0 -2
- package/uid.js +0 -16
- package/updateLinkParams.js +0 -19
- package/updateUrlQueryParams.js +0 -23
- package/uppercase.js +0 -13
- package/uuid.js +0 -17
- package/uuidNumeric.js +0 -10
- package/wait.js +0 -13
- package/without.js +0 -56
package/Defer.mjs
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
+
* @category async
|
|
3
|
+
*/ /**
|
|
2
4
|
* @category async
|
|
3
5
|
* @see https://stackoverflow.com/a/37673534/1938970
|
|
4
6
|
* @example
|
|
@@ -8,14 +10,13 @@
|
|
|
8
10
|
* deferred.resolve();
|
|
9
11
|
* deferred.then(handleSuccess, handleError);
|
|
10
12
|
* ```
|
|
11
|
-
*/
|
|
12
|
-
export function Defer() {
|
|
13
|
+
*/ export function Defer() /* : PromiseConstructor */ {
|
|
13
14
|
// @ts-expect-error nevermind
|
|
14
|
-
|
|
15
|
-
|
|
15
|
+
const self = this || {};
|
|
16
|
+
const p = self.promise = new Promise((resolve, reject)=>{
|
|
16
17
|
self.resolve = resolve;
|
|
17
18
|
self.reject = reject;
|
|
18
|
-
})
|
|
19
|
+
});
|
|
19
20
|
self.then = p.then.bind(p);
|
|
20
21
|
self.catch = p.catch.bind(p);
|
|
21
22
|
// if (p.finally) {
|
package/Emitter.d.ts
CHANGED
|
@@ -6,9 +6,11 @@
|
|
|
6
6
|
*
|
|
7
7
|
* Adapted from https://github.com/developit/mitt
|
|
8
8
|
*
|
|
9
|
-
* Regarding typescript support
|
|
9
|
+
* Regarding typescript support see:
|
|
10
10
|
* - https://stackoverflow.com/q/53299743/1938970
|
|
11
11
|
* - https://github.com/Microsoft/TypeScript/pull/26349
|
|
12
|
+
*
|
|
13
|
+
* @category impl
|
|
12
14
|
*/
|
|
13
15
|
export declare function Emitter<EventMap extends {
|
|
14
16
|
[key: string]: any;
|
package/Emitter.mjs
CHANGED
|
@@ -6,33 +6,32 @@
|
|
|
6
6
|
*
|
|
7
7
|
* Adapted from https://github.com/developit/mitt
|
|
8
8
|
*
|
|
9
|
-
* Regarding typescript support
|
|
9
|
+
* Regarding typescript support see:
|
|
10
10
|
* - https://stackoverflow.com/q/53299743/1938970
|
|
11
11
|
* - https://github.com/Microsoft/TypeScript/pull/26349
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
*
|
|
13
|
+
* @category impl
|
|
14
|
+
*/ export function Emitter(namespace) {
|
|
15
|
+
const all = new Map();
|
|
15
16
|
return {
|
|
16
17
|
/**
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
var added = handlers && handlers.push(handler);
|
|
18
|
+
* Register an event handler for the given type.
|
|
19
|
+
*/ on (name, handler) {
|
|
20
|
+
const handlers = all.get(`${namespace}.${String(name)}`);
|
|
21
|
+
const added = handlers && handlers.push(handler);
|
|
22
22
|
if (!added) {
|
|
23
|
-
all.set(
|
|
23
|
+
all.set(`${namespace}.${String(name)}`, [
|
|
24
|
+
handler
|
|
25
|
+
]);
|
|
24
26
|
}
|
|
25
27
|
},
|
|
26
28
|
/**
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
(all.get("".concat(namespace, ".").concat(String(name))) || [])
|
|
31
|
-
.slice()
|
|
32
|
-
.map(function (handler) {
|
|
29
|
+
* Invoke all handlers for the given type.
|
|
30
|
+
*/ emit (name, data) {
|
|
31
|
+
(all.get(`${namespace}.${String(name)}`) || []).slice().map((handler)=>{
|
|
33
32
|
handler(data);
|
|
34
33
|
});
|
|
35
|
-
}
|
|
34
|
+
}
|
|
36
35
|
};
|
|
37
36
|
}
|
|
38
37
|
export default Emitter;
|
package/README.md
CHANGED
|
@@ -11,11 +11,16 @@ Libraries to encapsulate and re-export from here, the selection is based on:
|
|
|
11
11
|
- [mesqueeb/filter-anything](https://github.com/mesqueeb/filter-anything)
|
|
12
12
|
- [mesqueeb/case-anything](https://github.com/mesqueeb/case-anything)
|
|
13
13
|
- [mesqueeb/nestify-anything](https://github.com/mesqueeb/nestify-anything)
|
|
14
|
-
- [mesqueeb/fast-sort (fork)](https://github.com/mesqueeb/fast-sort
|
|
14
|
+
- [mesqueeb/fast-sort (fork)](https://github.com/mesqueeb/fast-sort "fork")
|
|
15
15
|
- [mesqueeb/compare-anything](https://github.com/mesqueeb/compare-anything)
|
|
16
16
|
- [mesqueeb/copy-anything](https://github.com/mesqueeb/copy-anything)
|
|
17
17
|
- [mesqueeb/flatten-anything](https://github.com/mesqueeb/flatten-anything)
|
|
18
18
|
|
|
19
|
+
To considerç
|
|
20
|
+
|
|
21
|
+
- [dlv](https://www.npmjs.com/package/dlv)
|
|
22
|
+
- [dset](https://github.com/lukeed/dset)
|
|
23
|
+
|
|
19
24
|
About ts utilities types @see:
|
|
20
25
|
|
|
21
26
|
- [sindresorhus/type-fest](https://github.com/sindresorhus/type-fest)
|
package/accentSets.d.ts
CHANGED
|
@@ -8,8 +8,9 @@ export type AccentsSet = [string, string];
|
|
|
8
8
|
* Accent sets
|
|
9
9
|
*
|
|
10
10
|
* @category text
|
|
11
|
-
* @
|
|
12
|
-
*
|
|
11
|
+
* @resources
|
|
12
|
+
* - https://gist.github.com/mathewbyrne/1280286#gistcomment-3498021
|
|
13
|
+
* - https://gist.github.com/eek/9c4887e80b3ede05c0e39fee4dce3747 for usage
|
|
13
14
|
* of [normalize](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/normalize)
|
|
14
15
|
*/
|
|
15
16
|
export declare const accentsSets: AccentsSet[];
|
package/accentSets.mjs
CHANGED
|
@@ -1,38 +1,123 @@
|
|
|
1
1
|
/**
|
|
2
|
+
* First value is the `to`, second is `from`, from *which* chars do we translates *to*
|
|
3
|
+
*
|
|
4
|
+
* @category text
|
|
5
|
+
*/ /**
|
|
2
6
|
* Accent sets
|
|
3
7
|
*
|
|
4
8
|
* @category text
|
|
5
|
-
* @
|
|
6
|
-
*
|
|
9
|
+
* @resources
|
|
10
|
+
* - https://gist.github.com/mathewbyrne/1280286#gistcomment-3498021
|
|
11
|
+
* - https://gist.github.com/eek/9c4887e80b3ede05c0e39fee4dce3747 for usage
|
|
7
12
|
* of [normalize](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/normalize)
|
|
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
|
-
|
|
13
|
+
*/ export const accentsSets = [
|
|
14
|
+
[
|
|
15
|
+
"a",
|
|
16
|
+
"ÀÁÂÃÅÆĀĂĄẠẢẤẦẨẪẬẮẰẲẴẶ"
|
|
17
|
+
],
|
|
18
|
+
[
|
|
19
|
+
"ae",
|
|
20
|
+
"Ä"
|
|
21
|
+
],
|
|
22
|
+
[
|
|
23
|
+
"c",
|
|
24
|
+
"ÇĆĈČ"
|
|
25
|
+
],
|
|
26
|
+
[
|
|
27
|
+
"d",
|
|
28
|
+
"ÐĎĐÞ"
|
|
29
|
+
],
|
|
30
|
+
[
|
|
31
|
+
"e",
|
|
32
|
+
"ÈÉÊËĒĔĖĘĚẸẺẼẾỀỂỄỆ"
|
|
33
|
+
],
|
|
34
|
+
[
|
|
35
|
+
"g",
|
|
36
|
+
"ĜĞĢǴ"
|
|
37
|
+
],
|
|
38
|
+
[
|
|
39
|
+
"h",
|
|
40
|
+
"ĤḦ"
|
|
41
|
+
],
|
|
42
|
+
[
|
|
43
|
+
"i",
|
|
44
|
+
"ÌÍÎÏĨĪĮİỈỊ"
|
|
45
|
+
],
|
|
46
|
+
[
|
|
47
|
+
"j",
|
|
48
|
+
"Ĵ"
|
|
49
|
+
],
|
|
50
|
+
[
|
|
51
|
+
"ij",
|
|
52
|
+
"IJ"
|
|
53
|
+
],
|
|
54
|
+
[
|
|
55
|
+
"k",
|
|
56
|
+
"Ķ"
|
|
57
|
+
],
|
|
58
|
+
[
|
|
59
|
+
"l",
|
|
60
|
+
"ĹĻĽŁ"
|
|
61
|
+
],
|
|
62
|
+
[
|
|
63
|
+
"m",
|
|
64
|
+
"Ḿ"
|
|
65
|
+
],
|
|
66
|
+
[
|
|
67
|
+
"n",
|
|
68
|
+
"ÑŃŅŇ"
|
|
69
|
+
],
|
|
70
|
+
[
|
|
71
|
+
"o",
|
|
72
|
+
"ÒÓÔÕØŌŎŐỌỎỐỒỔỖỘỚỜỞỠỢǪǬƠ"
|
|
73
|
+
],
|
|
74
|
+
[
|
|
75
|
+
"oe",
|
|
76
|
+
"΅"
|
|
77
|
+
],
|
|
78
|
+
[
|
|
79
|
+
"p",
|
|
80
|
+
"ṕ"
|
|
81
|
+
],
|
|
82
|
+
[
|
|
83
|
+
"r",
|
|
84
|
+
"ŔŖŘ"
|
|
85
|
+
],
|
|
86
|
+
[
|
|
87
|
+
"s",
|
|
88
|
+
"ŚŜŞŠ"
|
|
89
|
+
],
|
|
90
|
+
[
|
|
91
|
+
"ss",
|
|
92
|
+
"ß"
|
|
93
|
+
],
|
|
94
|
+
[
|
|
95
|
+
"t",
|
|
96
|
+
"ŢŤ"
|
|
97
|
+
],
|
|
98
|
+
[
|
|
99
|
+
"u",
|
|
100
|
+
"ÙÚÛŨŪŬŮŰŲỤỦỨỪỬỮỰƯ"
|
|
101
|
+
],
|
|
102
|
+
[
|
|
103
|
+
"ue",
|
|
104
|
+
"Ü"
|
|
105
|
+
],
|
|
106
|
+
[
|
|
107
|
+
"w",
|
|
108
|
+
"ẂŴẀẄ"
|
|
109
|
+
],
|
|
110
|
+
[
|
|
111
|
+
"x",
|
|
112
|
+
"ẍ"
|
|
113
|
+
],
|
|
114
|
+
[
|
|
115
|
+
"y",
|
|
116
|
+
"ÝŶŸỲỴỶỸ"
|
|
117
|
+
],
|
|
118
|
+
[
|
|
119
|
+
"z",
|
|
120
|
+
"ŹŻŽ"
|
|
121
|
+
]
|
|
37
122
|
];
|
|
38
123
|
export default accentsSets;
|
package/addOrReplaceAtIdx.d.ts
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
|
+
* Add or replace an item in the given array, it returns a new array (immutable).
|
|
3
|
+
* Typescript wise this is meant to keep the same type on the newly returned
|
|
4
|
+
* array, therefore the `newItem` must match the type of the `list` items.
|
|
5
|
+
*
|
|
2
6
|
* @category array
|
|
3
7
|
*/
|
|
4
8
|
export declare function addOrReplaceAtIdx<T>(list: T[], newItem: T, newIdx?: number): T[];
|
package/addOrReplaceAtIdx.mjs
CHANGED
|
@@ -1,15 +1,22 @@
|
|
|
1
|
-
import { __spreadArray } from "tslib";
|
|
2
1
|
/**
|
|
2
|
+
* Add or replace an item in the given array, it returns a new array (immutable).
|
|
3
|
+
* Typescript wise this is meant to keep the same type on the newly returned
|
|
4
|
+
* array, therefore the `newItem` must match the type of the `list` items.
|
|
5
|
+
*
|
|
3
6
|
* @category array
|
|
4
|
-
*/
|
|
5
|
-
export function addOrReplaceAtIdx(list, newItem, newIdx) {
|
|
7
|
+
*/ export function addOrReplaceAtIdx(list, newItem, newIdx) {
|
|
6
8
|
if (list.length === 0) {
|
|
7
|
-
return [
|
|
9
|
+
return [
|
|
10
|
+
newItem
|
|
11
|
+
];
|
|
8
12
|
}
|
|
9
13
|
if (typeof newIdx === "undefined" || list.length - 1 < newIdx) {
|
|
10
|
-
return
|
|
14
|
+
return [
|
|
15
|
+
...list,
|
|
16
|
+
newItem
|
|
17
|
+
];
|
|
11
18
|
}
|
|
12
|
-
return list.map(
|
|
19
|
+
return list.map((item, idx)=>{
|
|
13
20
|
if (idx === newIdx) {
|
|
14
21
|
return newItem;
|
|
15
22
|
}
|
package/areEqual.d.ts
CHANGED
|
@@ -13,7 +13,7 @@ type Comparable = ComparablePrimitive | object | Record<string, ComparablePrimit
|
|
|
13
13
|
* According to very rudimentary tests this function takes on average between
|
|
14
14
|
* 0.15 ms and 2ms to compare two averaged sizes requet body payloads.
|
|
15
15
|
*
|
|
16
|
-
* @category
|
|
16
|
+
* @category object
|
|
17
17
|
*/
|
|
18
18
|
export declare function areEqual(a: Comparable, b?: Comparable): boolean;
|
|
19
19
|
export default areEqual;
|
package/areEqual.mjs
CHANGED
|
@@ -1,31 +1,26 @@
|
|
|
1
1
|
import { isArray } from "./isArray";
|
|
2
2
|
import { isObject } from "./isObject";
|
|
3
3
|
function areEqualArrays(a, b) {
|
|
4
|
-
if (!b)
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
var bValue = b[i];
|
|
11
|
-
if (!areEqual(aValue, bValue))
|
|
12
|
-
return false;
|
|
4
|
+
if (!b) return false;
|
|
5
|
+
if (a.length !== b.length) return false;
|
|
6
|
+
for(let i = 0; i < a.length; i++){
|
|
7
|
+
const aValue = a[i];
|
|
8
|
+
const bValue = b[i];
|
|
9
|
+
if (!areEqual(aValue, bValue)) return false;
|
|
13
10
|
}
|
|
14
11
|
return true;
|
|
15
12
|
}
|
|
16
13
|
function areEqualObjects(a, b) {
|
|
17
|
-
if (!b)
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
var bKeys = Object.keys(b);
|
|
14
|
+
if (!b) return false;
|
|
15
|
+
const aKeys = Object.keys(a);
|
|
16
|
+
const bKeys = Object.keys(b);
|
|
21
17
|
if (aKeys.length !== bKeys.length) {
|
|
22
18
|
return false;
|
|
23
19
|
}
|
|
24
|
-
for (
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
var bValue = b[key];
|
|
20
|
+
for (const _key of aKeys){
|
|
21
|
+
const key = _key;
|
|
22
|
+
const aValue = a[key];
|
|
23
|
+
const bValue = b[key];
|
|
29
24
|
if (!areEqual(aValue, bValue)) {
|
|
30
25
|
return false;
|
|
31
26
|
}
|
|
@@ -45,9 +40,8 @@ function areEqualObjects(a, b) {
|
|
|
45
40
|
* According to very rudimentary tests this function takes on average between
|
|
46
41
|
* 0.15 ms and 2ms to compare two averaged sizes requet body payloads.
|
|
47
42
|
*
|
|
48
|
-
* @category
|
|
49
|
-
*/
|
|
50
|
-
export function areEqual(a, b) {
|
|
43
|
+
* @category object
|
|
44
|
+
*/ export function areEqual(a, b) {
|
|
51
45
|
if (!a && !b) {
|
|
52
46
|
// console.log(`areEqual took ${performance.now() - t0} ms`);
|
|
53
47
|
return true;
|
|
@@ -57,12 +51,12 @@ export function areEqual(a, b) {
|
|
|
57
51
|
// console.log(`areEqual took ${performance.now() - t0} ms`);
|
|
58
52
|
return false;
|
|
59
53
|
}
|
|
60
|
-
|
|
54
|
+
const areObjects = isObject(a) && isObject(b);
|
|
61
55
|
if (areObjects && !areEqualObjects(a, b)) {
|
|
62
56
|
// console.log(`areEqual took ${performance.now() - t0} ms`);
|
|
63
57
|
return false;
|
|
64
58
|
}
|
|
65
|
-
|
|
59
|
+
const areArrays = isArray(a) && isArray(b);
|
|
66
60
|
if (areArrays && !areEqualArrays(a, b)) {
|
|
67
61
|
// console.log(`areEqual took ${performance.now() - t0} ms`);
|
|
68
62
|
return false;
|
package/arrayOfAll.d.ts
CHANGED
package/arrayOfAll.mjs
CHANGED
|
@@ -5,8 +5,7 @@
|
|
|
5
5
|
* @borrows [SO comment by `CertainPerformance`](https://stackoverflow.com/a/60132060/1938970)
|
|
6
6
|
*
|
|
7
7
|
* @usage
|
|
8
|
-
*
|
|
9
|
-
* ```
|
|
8
|
+
* ```ts
|
|
10
9
|
* type Fruit = "pear" | "apple" | "orange";
|
|
11
10
|
*
|
|
12
11
|
* const arrayOfAllFruits = arrayOfAll<Fruit>();
|
|
@@ -23,10 +22,5 @@
|
|
|
23
22
|
* ]); // ts compiler fails
|
|
24
23
|
* ```
|
|
25
24
|
*
|
|
26
|
-
*/
|
|
27
|
-
export var arrayOfAll = function () {
|
|
28
|
-
return function (array) {
|
|
29
|
-
return array;
|
|
30
|
-
};
|
|
31
|
-
};
|
|
25
|
+
*/ export const arrayOfAll = ()=>(array)=>array;
|
|
32
26
|
export default arrayOfAll;
|
package/arraySum.d.ts
CHANGED
package/arraySum.mjs
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Sum array of numbers
|
|
3
3
|
*
|
|
4
|
-
* @category array
|
|
5
|
-
|
|
6
|
-
export
|
|
7
|
-
return numbers.reduce(function (sum, current) { return sum + current; }, 0);
|
|
8
|
-
};
|
|
4
|
+
* @category array
|
|
5
|
+
* @category math
|
|
6
|
+
*/ export const arraySum = (numbers)=>numbers.reduce((sum, current)=>sum + current, 0);
|
|
9
7
|
export default arraySum;
|
package/arrayToLookup.mjs
CHANGED
|
@@ -2,10 +2,8 @@
|
|
|
2
2
|
* Maps a simple flat array to a lookup dictionary object
|
|
3
3
|
*
|
|
4
4
|
* @category array
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
if (array === void 0) { array = []; }
|
|
8
|
-
return array.reduce(function (obj, item) {
|
|
5
|
+
*/ export function arrayToLookup(array = []) {
|
|
6
|
+
return array.reduce((obj, item)=>{
|
|
9
7
|
obj[item] = 1;
|
|
10
8
|
return obj;
|
|
11
9
|
}, {});
|
package/buildUrlQueryString.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import isArray from "./isArray";
|
|
1
2
|
import isNull from "./isNull";
|
|
2
3
|
import isUndefined from "./isUndefined";
|
|
3
|
-
import isArray from "./isArray";
|
|
4
4
|
/**
|
|
5
5
|
* Get clean query string for URL
|
|
6
6
|
*
|
|
@@ -9,23 +9,20 @@ import isArray from "./isArray";
|
|
|
9
9
|
* TODO: at some point replace with `URLSearchParams`, @see [caniuse](https://caniuse.com/?search=URLSearchParams)
|
|
10
10
|
*
|
|
11
11
|
* @category location
|
|
12
|
-
*/
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
for (var key in params) {
|
|
18
|
-
var value = params[key];
|
|
12
|
+
*/ export function buildUrlQueryString(params) {
|
|
13
|
+
let output = "";
|
|
14
|
+
if (!params) return output;
|
|
15
|
+
for(const key in params){
|
|
16
|
+
const value = params[key];
|
|
19
17
|
if (isArray(value)) {
|
|
20
|
-
for
|
|
21
|
-
output +=
|
|
18
|
+
for(let i = 0; i < value.length; i++){
|
|
19
|
+
output += `${key}=${encodeURIComponent(value[i] + "")}&`;
|
|
22
20
|
}
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
output += "".concat(key, "=").concat(encodeURIComponent(value + ""), "&");
|
|
21
|
+
} else if (!isNull(value) && !isUndefined(value)) {
|
|
22
|
+
output += `${key}=${encodeURIComponent(value + "")}&`;
|
|
26
23
|
}
|
|
27
24
|
}
|
|
28
25
|
// removes the last &
|
|
29
|
-
return output ?
|
|
26
|
+
return output ? `?${output.replace(/&+$/, "")}` : "";
|
|
30
27
|
}
|
|
31
28
|
export default buildUrlQueryString;
|
package/capitalize.d.ts
CHANGED
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
* Capitalize first letter of the given string.
|
|
3
3
|
*
|
|
4
4
|
* @category text
|
|
5
|
-
* @
|
|
5
|
+
* @resources
|
|
6
|
+
* - https://stackoverflow.com/a/11409944/1938970
|
|
6
7
|
*/
|
|
7
8
|
export declare function capitalize<T extends string>(string?: null | T): Capitalize<T>;
|
|
8
9
|
export default capitalize;
|
package/capitalize.mjs
CHANGED
|
@@ -2,11 +2,10 @@
|
|
|
2
2
|
* Capitalize first letter of the given string.
|
|
3
3
|
*
|
|
4
4
|
* @category text
|
|
5
|
-
* @
|
|
6
|
-
|
|
7
|
-
export function capitalize(string) {
|
|
8
|
-
|
|
9
|
-
return
|
|
10
|
-
ensuredString.slice(1));
|
|
5
|
+
* @resources
|
|
6
|
+
* - https://stackoverflow.com/a/11409944/1938970
|
|
7
|
+
*/ export function capitalize(string) {
|
|
8
|
+
const ensuredString = string || "";
|
|
9
|
+
return ensuredString.charAt(0).toUpperCase() + ensuredString.slice(1);
|
|
11
10
|
}
|
|
12
11
|
export default capitalize;
|
package/changeUrlPath.mjs
CHANGED
|
@@ -7,9 +7,8 @@ import normaliseUrlPathname from "./normaliseUrlPathname";
|
|
|
7
7
|
* @category location
|
|
8
8
|
* @param replace Replace URL instead of pushing it in the history stack. By default it pushes it.
|
|
9
9
|
* @returns {string} The new cleaned pathname
|
|
10
|
-
*/
|
|
11
|
-
|
|
12
|
-
var path = normaliseUrlPathname("/".concat(pathname, "/"));
|
|
10
|
+
*/ export function changeUrlPath(pathname, state, replace) {
|
|
11
|
+
const path = normaliseUrlPathname(`/${pathname}/`);
|
|
13
12
|
if (isBrowser) {
|
|
14
13
|
history[replace ? "replaceState" : "pushState"](state, "", path);
|
|
15
14
|
}
|
package/chunkByChunks.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* TODO: untested
|
|
3
2
|
* @category array
|
|
4
3
|
* @see https://stackoverflow.com/a/8189268/1938970
|
|
4
|
+
* @experimental TODO: untested
|
|
5
5
|
*/
|
|
6
6
|
export declare function chunkByChunks<T>(arr: T[], nrOfChunks: number, balanced?: boolean): T[][];
|
|
7
7
|
export default chunkByChunks;
|
package/chunkByChunks.mjs
CHANGED
|
@@ -1,34 +1,31 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* TODO: untested
|
|
3
2
|
* @category array
|
|
4
3
|
* @see https://stackoverflow.com/a/8189268/1938970
|
|
5
|
-
|
|
6
|
-
export function chunkByChunks(arr, nrOfChunks, balanced) {
|
|
7
|
-
if (nrOfChunks < 2)
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
4
|
+
* @experimental TODO: untested
|
|
5
|
+
*/ export function chunkByChunks(arr, nrOfChunks, balanced) {
|
|
6
|
+
if (nrOfChunks < 2) return [
|
|
7
|
+
arr
|
|
8
|
+
];
|
|
9
|
+
const len = arr.length;
|
|
10
|
+
const output = [];
|
|
11
|
+
let i = 0;
|
|
12
|
+
let size;
|
|
13
13
|
if (len % nrOfChunks === 0) {
|
|
14
14
|
size = Math.floor(len / nrOfChunks);
|
|
15
|
-
while
|
|
16
|
-
output.push(arr.slice(i,
|
|
15
|
+
while(i < len){
|
|
16
|
+
output.push(arr.slice(i, i += size));
|
|
17
17
|
}
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
while (i < len) {
|
|
18
|
+
} else if (balanced) {
|
|
19
|
+
while(i < len){
|
|
21
20
|
size = Math.ceil((len - i) / nrOfChunks--);
|
|
22
|
-
output.push(arr.slice(i,
|
|
21
|
+
output.push(arr.slice(i, i += size));
|
|
23
22
|
}
|
|
24
|
-
}
|
|
25
|
-
else {
|
|
23
|
+
} else {
|
|
26
24
|
nrOfChunks--;
|
|
27
25
|
size = Math.floor(len / nrOfChunks);
|
|
28
|
-
if (len % size === 0)
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
output.push(arr.slice(i, (i += size)));
|
|
26
|
+
if (len % size === 0) size--;
|
|
27
|
+
while(i < size * nrOfChunks){
|
|
28
|
+
output.push(arr.slice(i, i += size));
|
|
32
29
|
}
|
|
33
30
|
output.push(arr.slice(size * nrOfChunks));
|
|
34
31
|
}
|
package/chunkBySize.mjs
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @category array
|
|
3
3
|
* @see https://stackoverflow.com/a/40682136/1938970
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
for (var i = 0; i < arr.length; i += size) {
|
|
4
|
+
*/ export function chunkBySize(arr, size) {
|
|
5
|
+
const output = [];
|
|
6
|
+
for(let i = 0; i < arr.length; i += size){
|
|
8
7
|
output.push(arr.slice(i, i + size));
|
|
9
8
|
}
|
|
10
9
|
return output;
|