@koine/utils 2.0.0-beta.10 → 2.0.0-beta.12
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/Emitter.d.ts +3 -1
- package/Emitter.mjs +3 -1
- package/accentSets.d.ts +3 -2
- package/accentSets.mjs +3 -2
- package/addOrReplaceAtIdx.d.ts +4 -0
- package/addOrReplaceAtIdx.mjs +4 -0
- package/areEqual.d.ts +1 -1
- package/areEqual.mjs +1 -1
- package/arrayOfAll.d.ts +1 -2
- package/arrayOfAll.mjs +1 -2
- package/arraySum.d.ts +2 -1
- package/arraySum.mjs +2 -1
- package/capitalize.d.ts +2 -1
- package/capitalize.mjs +2 -1
- package/chunkByChunks.d.ts +1 -1
- package/chunkByChunks.mjs +1 -1
- package/clsx.d.ts +2 -1
- package/clsx.mjs +2 -1
- package/convertRange.d.ts +3 -1
- package/convertRange.mjs +3 -1
- package/cookie.d.ts +13 -1
- package/cookie.mjs +5 -1
- package/createPalette.d.ts +3 -1
- package/createPalette.mjs +3 -1
- package/debouncePromise.d.ts +10 -2
- package/debouncePromise.mjs +6 -2
- package/debounceRaf.d.ts +1 -1
- package/debounceRaf.mjs +1 -1
- package/errorToString.d.ts +2 -1
- package/errorToString.mjs +2 -1
- package/forin.d.ts +2 -1
- package/forin.mjs +2 -1
- package/getEmptyArray.d.ts +0 -1
- package/getEmptyArray.mjs +0 -1
- package/getKeys.d.ts +2 -1
- package/getKeys.mjs +2 -1
- package/getMediaQueryWidthResolvers.d.ts +6 -0
- package/getMediaQueryWidthResolvers.mjs +5 -1
- package/getMediaQueryWidthTailwindScreens.d.ts +4 -0
- package/getMediaQueryWidthTailwindScreens.mjs +4 -1
- package/getParamAmong.d.ts +3 -2
- package/getParamAmong.mjs +3 -2
- package/getParamAsInt.d.ts +2 -2
- package/getParamAsInt.mjs +2 -2
- package/getParamAsString.d.ts +1 -1
- package/getParamAsString.mjs +1 -1
- package/getType.d.ts +0 -3
- package/getType.mjs +0 -3
- package/getUrlQueryParams.d.ts +3 -4
- package/getUrlQueryParams.mjs +3 -4
- package/index.d.ts +4 -1
- package/matchSorter.mjs +2 -2
- package/mergeObjects.d.ts +1 -1
- package/mergeObjects.mjs +1 -1
- package/mergeUrlQueryParams.d.ts +0 -1
- package/mergeUrlQueryParams.mjs +0 -1
- package/moveSortableArrayItemByKey.d.ts +1 -1
- package/moveSortableArrayItemByKey.mjs +1 -1
- package/objectOmit.d.ts +1 -1
- package/objectOmit.mjs +1 -1
- package/objectPick.d.ts +1 -1
- package/objectPick.mjs +1 -1
- package/package.json +2 -2
- package/quaranteneProps.d.ts +1 -1
- package/quaranteneProps.mjs +1 -1
- package/readCookie.d.ts +5 -0
- package/removeCookie.d.ts +0 -4
- package/removeCookie.mjs +0 -4
- package/removeUrlQueryParams.d.ts +0 -1
- package/removeUrlQueryParams.mjs +0 -1
- package/render.d.ts +2 -1
- package/render.mjs +2 -1
- package/serializeCookie.d.ts +1 -5
- package/serializeCookie.mjs +1 -5
- package/setCookie.d.ts +0 -4
- package/setCookie.mjs +0 -4
- package/shuffle.d.ts +7 -6
- package/shuffle.mjs +7 -6
- package/slugify.d.ts +2 -1
- package/slugify.mjs +2 -1
- package/split.d.ts +4 -0
- package/split.mjs +4 -1
- package/swapMap.d.ts +1 -1
- package/swapMap.mjs +1 -1
- package/throttle.d.ts +1 -1
- package/throttle.mjs +1 -1
- package/titleCase.d.ts +4 -3
- package/titleCase.mjs +4 -3
- package/truncate.d.ts +1 -1
- package/truncate.mjs +1 -1
- package/tryUntil.d.ts +4 -1
- package/tryUntil.mjs +4 -1
- package/typings.d.ts +1 -6
- package/updateUrlQueryParams.d.ts +0 -1
- package/updateUrlQueryParams.mjs +0 -1
- package/uppercase.d.ts +1 -0
- package/uppercase.mjs +1 -0
- package/Defer.js +0 -35
- package/Emitter.js +0 -53
- package/accentSets.js +0 -133
- package/addOrReplaceAtIdx.js +0 -40
- package/areEqual.js +0 -75
- package/arrayOfAll.js +0 -45
- package/arraySum.js +0 -24
- package/arrayToLookup.js +0 -29
- package/buildUrlQueryString.js +0 -39
- package/capitalize.js +0 -28
- package/changeUrlPath.js +0 -29
- package/chunkByChunks.js +0 -52
- package/chunkBySize.js +0 -29
- package/clamp.js +0 -27
- package/clsx.js +0 -60
- package/convertRange.js +0 -33
- package/cookie.js +0 -21
- package/createPalette.js +0 -39
- package/debounce.js +0 -39
- package/debouncePromise.js +0 -87
- package/debounceRaf.js +0 -40
- package/decode.js +0 -27
- package/encode.js +0 -27
- package/ensureInt.js +0 -24
- package/env.js +0 -3
- package/errorToString.js +0 -22
- package/findDuplicatedIndexes.js +0 -31
- package/forin.js +0 -28
- package/gbToBytes.js +0 -24
- package/getEmptyArray.js +0 -29
- package/getKeys.js +0 -26
- package/getMediaQueryWidthResolvers.js +0 -81
- package/getMediaQueryWidthTailwindScreens.js +0 -51
- package/getNonce.js +0 -23
- package/getParamAmong.js +0 -25
- package/getParamAsInt.js +0 -28
- package/getParamAsString.js +0 -24
- package/getType.js +0 -30
- package/getUrlHashParams.js +0 -27
- package/getUrlHashPathname.js +0 -29
- package/getUrlPathnameParts.js +0 -25
- package/getUrlQueryParams.js +0 -36
- package/imgEmptyPixel.js +0 -24
- package/index.js +0 -532
- package/invariant.js +0 -50
- package/isAnyObject.js +0 -24
- package/isArray.js +0 -24
- package/isBlob.js +0 -24
- package/isBoolean.js +0 -24
- package/isBrowser.js +0 -23
- package/isBrowserNow.js +0 -22
- package/isDate.js +0 -24
- package/isEmptyArray.js +0 -24
- package/isEmptyObject.js +0 -24
- package/isEmptyString.js +0 -26
- package/isError.js +0 -24
- package/isExternalUrl.js +0 -32
- package/isFile.js +0 -24
- package/isFloat.js +0 -24
- package/isFormData.js +0 -24
- package/isFullArray.js +0 -24
- package/isFullObject.js +0 -24
- package/isFullString.js +0 -24
- package/isFunction.js +0 -22
- package/isInt.js +0 -24
- package/isMap.js +0 -24
- package/isNaNValue.js +0 -24
- package/isNegativeNumber.js +0 -24
- package/isNull.js +0 -24
- package/isNullOrUndefined.js +0 -24
- package/isNumber.js +0 -24
- package/isObject.js +0 -24
- package/isObjectLike.js +0 -24
- package/isOneOf.js +0 -22
- package/isPlainObject.js +0 -25
- package/isPositiveNumber.js +0 -24
- package/isPrimitive.js +0 -29
- package/isPromise.js +0 -24
- package/isRegExp.js +0 -24
- package/isServer.js +0 -23
- package/isServerNow.js +0 -22
- package/isSet.js +0 -24
- package/isString.js +0 -24
- package/isSymbol.js +0 -24
- package/isType.js +0 -32
- package/isUndefined.js +0 -24
- package/isWeakMap.js +0 -24
- package/isWeakSet.js +0 -24
- package/kbToBytes.js +0 -24
- package/location.js +0 -6
- package/lowercase.js +0 -24
- package/mapListBy.js +0 -29
- package/matchSorter.js +0 -373
- package/mbToBytes.js +0 -24
- package/mergeObjects.js +0 -39
- package/mergeUrlQueryParams.js +0 -32
- package/moveSortableArrayItemByKey.js +0 -35
- package/noop.js +0 -24
- package/normaliseUrl.js +0 -24
- package/normaliseUrlPathname.js +0 -24
- package/objectOmit.js +0 -35
- package/objectPick.js +0 -32
- package/parseCookie.js +0 -55
- package/parseURL.js +0 -37
- package/quaranteneProps.js +0 -49
- package/randomInt.js +0 -26
- package/randomKey.js +0 -28
- package/readCookie.js +0 -51
- package/removeAccents.js +0 -28
- package/removeCookie.js +0 -28
- package/removeDuplicates.js +0 -13
- package/removeDuplicatesByKey.js +0 -36
- package/removeDuplicatesComparing.js +0 -25
- package/removeIndexesFromArray.js +0 -31
- package/removeTrailingSlash.js +0 -26
- package/removeUrlQueryParams.js +0 -33
- package/render.js +0 -93
- package/roundTo.js +0 -50
- package/serializeCookie.js +0 -102
- package/setCookie.js +0 -68
- package/shuffle.js +0 -50
- package/slugify.js +0 -35
- package/split.js +0 -22
- package/swapMap.js +0 -30
- package/throttle.js +0 -38
- package/titleCase.js +0 -24
- package/toNumber.js +0 -23
- package/toRgba.js +0 -32
- package/transformToUrlPathname.js +0 -24
- package/truncate.js +0 -24
- package/tryUntil.js +0 -42
- package/types.js +0 -5
- package/uid.js +0 -24
- package/updateLinkParams.js +0 -26
- package/updateUrlQueryParams.js +0 -28
- package/uppercase.js +0 -24
- package/uuid.js +0 -28
- package/uuidNumeric.js +0 -23
- package/wait.js +0 -24
- package/without.js +0 -55
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,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
|
*/ export function Emitter(namespace) {
|
|
13
15
|
const all = new Map();
|
|
14
16
|
return {
|
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
|
@@ -6,8 +6,9 @@
|
|
|
6
6
|
* Accent sets
|
|
7
7
|
*
|
|
8
8
|
* @category text
|
|
9
|
-
* @
|
|
10
|
-
*
|
|
9
|
+
* @resources
|
|
10
|
+
* - https://gist.github.com/mathewbyrne/1280286#gistcomment-3498021
|
|
11
|
+
* - https://gist.github.com/eek/9c4887e80b3ede05c0e39fee4dce3747 for usage
|
|
11
12
|
* of [normalize](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/normalize)
|
|
12
13
|
*/ export const accentsSets = [
|
|
13
14
|
[
|
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,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
|
*/ export function addOrReplaceAtIdx(list, newItem, newIdx) {
|
|
4
8
|
if (list.length === 0) {
|
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
|
@@ -40,7 +40,7 @@ function areEqualObjects(a, b) {
|
|
|
40
40
|
* According to very rudimentary tests this function takes on average between
|
|
41
41
|
* 0.15 ms and 2ms to compare two averaged sizes requet body payloads.
|
|
42
42
|
*
|
|
43
|
-
* @category
|
|
43
|
+
* @category object
|
|
44
44
|
*/ export function areEqual(a, b) {
|
|
45
45
|
if (!a && !b) {
|
|
46
46
|
// console.log(`areEqual took ${performance.now() - t0} ms`);
|
package/arrayOfAll.d.ts
CHANGED
package/arrayOfAll.mjs
CHANGED
package/arraySum.d.ts
CHANGED
package/arraySum.mjs
CHANGED
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,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
|
*/ export function capitalize(string) {
|
|
7
8
|
const ensuredString = string || "";
|
|
8
9
|
return ensuredString.charAt(0).toUpperCase() + ensuredString.slice(1);
|
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
package/clsx.d.ts
CHANGED
|
@@ -5,8 +5,9 @@ export type ClsxClassValue = ClassValue;
|
|
|
5
5
|
/**
|
|
6
6
|
* Class names utility
|
|
7
7
|
*
|
|
8
|
+
* @category impl
|
|
8
9
|
* @borrows [lukeed/clsx](https://github.com/lukeed/clsx)
|
|
9
|
-
* @license
|
|
10
|
+
* @license MIT Luke Edwards https://github.com/lukeed/clsx/blob/master/license
|
|
10
11
|
*/
|
|
11
12
|
export declare const clsx: (...args: ClassValue[]) => string;
|
|
12
13
|
export default clsx;
|
package/clsx.mjs
CHANGED
|
@@ -29,8 +29,9 @@ function toVal(mix) {
|
|
|
29
29
|
/**
|
|
30
30
|
* Class names utility
|
|
31
31
|
*
|
|
32
|
+
* @category impl
|
|
32
33
|
* @borrows [lukeed/clsx](https://github.com/lukeed/clsx)
|
|
33
|
-
* @license
|
|
34
|
+
* @license MIT Luke Edwards https://github.com/lukeed/clsx/blob/master/license
|
|
34
35
|
*/ export const clsx = function() {
|
|
35
36
|
let i = 0, tmp, x, str = "";
|
|
36
37
|
while(i < arguments.length){
|
package/convertRange.d.ts
CHANGED
package/convertRange.mjs
CHANGED
package/cookie.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @
|
|
2
|
+
* @module
|
|
3
3
|
*
|
|
4
4
|
* @category cookie
|
|
5
5
|
*
|
|
@@ -7,6 +7,9 @@
|
|
|
7
7
|
* - [js-cookie](https://github.com/js-cookie/js-cookie)
|
|
8
8
|
* - [cookie](https://github.com/jshttp/cookie)
|
|
9
9
|
*/
|
|
10
|
+
/**
|
|
11
|
+
* @category cookie
|
|
12
|
+
*/
|
|
10
13
|
type CookieAttributes = {
|
|
11
14
|
/**
|
|
12
15
|
* Define when the cookie will be removed. Value can be a Number
|
|
@@ -41,13 +44,22 @@ type CookieAttributes = {
|
|
|
41
44
|
*/
|
|
42
45
|
sameSite?: "strict" | "Strict" | "lax" | "Lax" | "none" | "None" | undefined;
|
|
43
46
|
};
|
|
47
|
+
/**
|
|
48
|
+
* @category cookie
|
|
49
|
+
*/
|
|
44
50
|
export type CookieAttributesServer = CookieAttributes & {
|
|
45
51
|
maxAge?: number;
|
|
46
52
|
httpOnly?: boolean;
|
|
47
53
|
encode?: (input: string) => string;
|
|
48
54
|
decode?: (input: string) => string;
|
|
49
55
|
};
|
|
56
|
+
/**
|
|
57
|
+
* @category cookie
|
|
58
|
+
*/
|
|
50
59
|
export type CookieAttributesClient = CookieAttributes;
|
|
60
|
+
/**
|
|
61
|
+
* @category cookie
|
|
62
|
+
*/
|
|
51
63
|
export declare const defaultAttributesClient: {
|
|
52
64
|
path: string;
|
|
53
65
|
};
|
package/cookie.mjs
CHANGED
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @
|
|
2
|
+
* @module
|
|
3
3
|
*
|
|
4
4
|
* @category cookie
|
|
5
5
|
*
|
|
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
|
+
* @category cookie
|
|
11
|
+
*/ /**
|
|
12
|
+
* @category cookie
|
|
9
13
|
*/ export const defaultAttributesClient = {
|
|
10
14
|
path: "/"
|
|
11
15
|
};
|
package/createPalette.d.ts
CHANGED
|
@@ -10,7 +10,9 @@ type PaletteMap<T extends PaletteShades> = {
|
|
|
10
10
|
* Create palette, this is primarily thought to improve the reuse of a palette
|
|
11
11
|
* definition between TailwindCSS and straight ES imports
|
|
12
12
|
*
|
|
13
|
-
* @category
|
|
13
|
+
* @category colors
|
|
14
|
+
* @category tailwind
|
|
15
|
+
* @category responsive
|
|
14
16
|
*
|
|
15
17
|
* @returns An array with: 1) A flat palette map 2) A TailwindCSS ready palette
|
|
16
18
|
* object 3) A flat array of colors (no special sorting, same order as the `shades`
|
package/createPalette.mjs
CHANGED
|
@@ -2,7 +2,9 @@
|
|
|
2
2
|
* Create palette, this is primarily thought to improve the reuse of a palette
|
|
3
3
|
* definition between TailwindCSS and straight ES imports
|
|
4
4
|
*
|
|
5
|
-
* @category
|
|
5
|
+
* @category colors
|
|
6
|
+
* @category tailwind
|
|
7
|
+
* @category responsive
|
|
6
8
|
*
|
|
7
9
|
* @returns An array with: 1) A flat palette map 2) A TailwindCSS ready palette
|
|
8
10
|
* object 3) A flat array of colors (no special sorting, same order as the `shades`
|
package/debouncePromise.d.ts
CHANGED
|
@@ -1,11 +1,19 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Copy pasted from [chodorowicz/ts-debounce](https://github.com/chodorowicz/ts-debounce/blob/master/src/index.ts)
|
|
3
|
+
*
|
|
4
|
+
* @module
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* @categroy functionn
|
|
3
8
|
*/
|
|
4
9
|
export type DebounceOptions<Result> = {
|
|
5
10
|
isImmediate?: boolean;
|
|
6
11
|
maxWait?: number;
|
|
7
12
|
callback?: (data: Result) => void;
|
|
8
13
|
};
|
|
14
|
+
/**
|
|
15
|
+
* @categroy functionn
|
|
16
|
+
*/
|
|
9
17
|
export interface DebouncedFunction<Args extends any[], F extends (...args: Args) => any> {
|
|
10
18
|
(this: ThisParameterType<F>, ...args: Args & Parameters<F>): Promise<ReturnType<F>>;
|
|
11
19
|
cancel: (reason?: any) => void;
|
|
@@ -15,7 +23,7 @@ export interface DebouncedFunction<Args extends any[], F extends (...args: Args)
|
|
|
15
23
|
*
|
|
16
24
|
* @category function
|
|
17
25
|
* @borrows [chodorowicz/ts-debounce](https://github.com/chodorowicz/ts-debounce)
|
|
18
|
-
* @license
|
|
26
|
+
* @license MIT: Jakub Chodorowicz
|
|
19
27
|
*/
|
|
20
28
|
export declare function debouncePromise<Args extends any[], F extends (...args: Args) => any>(func: F, waitMilliseconds?: number, options?: DebounceOptions<ReturnType<F>>): DebouncedFunction<Args, F>;
|
|
21
29
|
export default debouncePromise;
|
package/debouncePromise.mjs
CHANGED
|
@@ -10,13 +10,17 @@
|
|
|
10
10
|
// export const debouncePromise = tsDebounce;
|
|
11
11
|
// export default debouncePromise;
|
|
12
12
|
/**
|
|
13
|
-
*
|
|
13
|
+
* Copy pasted from [chodorowicz/ts-debounce](https://github.com/chodorowicz/ts-debounce/blob/master/src/index.ts)
|
|
14
|
+
*
|
|
15
|
+
* @module
|
|
16
|
+
*/ /**
|
|
17
|
+
* @categroy functionn
|
|
14
18
|
*/ /**
|
|
15
19
|
* Debounce function (with `Promise`)
|
|
16
20
|
*
|
|
17
21
|
* @category function
|
|
18
22
|
* @borrows [chodorowicz/ts-debounce](https://github.com/chodorowicz/ts-debounce)
|
|
19
|
-
* @license
|
|
23
|
+
* @license MIT: Jakub Chodorowicz
|
|
20
24
|
*/ export function debouncePromise(func, waitMilliseconds = 50, options = {}) {
|
|
21
25
|
let timeoutId;
|
|
22
26
|
const isImmediate = options.isImmediate ?? false;
|
package/debounceRaf.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Debounce function (with `requestAnimationFrame`)
|
|
3
3
|
*
|
|
4
|
-
* (c) 2021 Chris Ferdinandi, MIT License, https://gomakethings.com
|
|
5
4
|
* @category function
|
|
6
5
|
* @borrows [vanillajstoolkit/debounce](https://vanillajstoolkit.com/helpers/debounce/)
|
|
6
|
+
* @license (c) 2021 Chris Ferdinandi, MIT License, https://gomakethings.com
|
|
7
7
|
*/
|
|
8
8
|
export declare function debounceRaf<T extends (...args: any[]) => any>(this: unknown, fn: T): (this: unknown, ...args: Parameters<T>) => void;
|
|
9
9
|
export default debounceRaf;
|
package/debounceRaf.mjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Debounce function (with `requestAnimationFrame`)
|
|
3
3
|
*
|
|
4
|
-
* (c) 2021 Chris Ferdinandi, MIT License, https://gomakethings.com
|
|
5
4
|
* @category function
|
|
6
5
|
* @borrows [vanillajstoolkit/debounce](https://vanillajstoolkit.com/helpers/debounce/)
|
|
6
|
+
* @license (c) 2021 Chris Ferdinandi, MIT License, https://gomakethings.com
|
|
7
7
|
*/ export function debounceRaf(fn) {
|
|
8
8
|
let timeout;
|
|
9
9
|
return function(...args) {
|
package/errorToString.d.ts
CHANGED
package/errorToString.mjs
CHANGED
|
@@ -2,6 +2,7 @@ import isString from "./isString";
|
|
|
2
2
|
/**
|
|
3
3
|
* Ensure to transform a JavaScript `Error` into a string (uses its `message`)
|
|
4
4
|
*
|
|
5
|
-
* @category
|
|
5
|
+
* @category error
|
|
6
|
+
* @category cast
|
|
6
7
|
*/ export const errorToString = (e)=>e instanceof Error ? e.message : isString(e) ? e : "";
|
|
7
8
|
export default errorToString;
|
package/forin.d.ts
CHANGED
package/forin.mjs
CHANGED
package/getEmptyArray.d.ts
CHANGED
package/getEmptyArray.mjs
CHANGED
package/getKeys.d.ts
CHANGED
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
* Type safe replacement for `Object.keys(myObject)` to iterate over a record
|
|
3
3
|
* without loosing the key's types in simple `string`s.
|
|
4
4
|
*
|
|
5
|
-
* @category
|
|
5
|
+
* @category native
|
|
6
|
+
* @category object
|
|
6
7
|
* @see https://stackoverflow.com/a/59459000/1938970
|
|
7
8
|
*/
|
|
8
9
|
export declare const getKeys: <T extends object>(obj: T) => (keyof T)[];
|
package/getKeys.mjs
CHANGED
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
* Type safe replacement for `Object.keys(myObject)` to iterate over a record
|
|
3
3
|
* without loosing the key's types in simple `string`s.
|
|
4
4
|
*
|
|
5
|
-
* @category
|
|
5
|
+
* @category native
|
|
6
|
+
* @category object
|
|
6
7
|
* @see https://stackoverflow.com/a/59459000/1938970
|
|
7
8
|
*/ export const getKeys = Object.keys;
|
|
8
9
|
export default getKeys;
|
|
@@ -1,4 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @category responsive
|
|
3
|
+
*/
|
|
1
4
|
export type GetMediaQueryWidthResolversBreakpoints = Record<string, number>;
|
|
5
|
+
/**
|
|
6
|
+
* @category responsive
|
|
7
|
+
*/
|
|
2
8
|
export declare function getMediaQueryWidthResolvers<TBreakpointsConfig extends GetMediaQueryWidthResolversBreakpoints>(customBreakpoints: TBreakpointsConfig): {
|
|
3
9
|
max: (br: Extract<keyof TBreakpointsConfig, string>) => string;
|
|
4
10
|
min: (br: Extract<keyof TBreakpointsConfig, string>) => string;
|
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
import { type GetMediaQueryWidthResolversBreakpoints } from "./getMediaQueryWidthResolvers";
|
|
2
|
+
/**
|
|
3
|
+
* @category responsive
|
|
4
|
+
* @category tailwind
|
|
5
|
+
*/
|
|
2
6
|
export declare function getMediaQueryWidthTailwindScreens(breakpoints: GetMediaQueryWidthResolversBreakpoints): Record<string, {
|
|
3
7
|
raw: string;
|
|
4
8
|
}>;
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import { getMediaQueryWidthResolvers } from "./getMediaQueryWidthResolvers";
|
|
2
|
-
|
|
2
|
+
/**
|
|
3
|
+
* @category responsive
|
|
4
|
+
* @category tailwind
|
|
5
|
+
*/ export function getMediaQueryWidthTailwindScreens(breakpoints) {
|
|
3
6
|
const mqWidthResolvers = getMediaQueryWidthResolvers(breakpoints);
|
|
4
7
|
// Object.keys(breakpoints).reduce((screens, br) => {
|
|
5
8
|
const screens = Object.keys(breakpoints).reduce((output, br, idx)=>{
|
package/getParamAmong.d.ts
CHANGED
|
@@ -5,8 +5,9 @@
|
|
|
5
5
|
*
|
|
6
6
|
* @category location
|
|
7
7
|
*
|
|
8
|
-
* @param
|
|
9
|
-
* @param
|
|
8
|
+
* @param raw The _raw_ query parameter
|
|
9
|
+
* @param allowedValues The list of values (as strings) that the parameter can
|
|
10
|
+
* have, if not one of them `null` is returned
|
|
10
11
|
*/
|
|
11
12
|
export declare function getParamAmong<T extends string[]>(raw?: string | string[], allowedValues?: T): T[number] | null;
|
|
12
13
|
export default getParamAmong;
|
package/getParamAmong.mjs
CHANGED
|
@@ -6,8 +6,9 @@ import getParamAsString from "./getParamAsString";
|
|
|
6
6
|
*
|
|
7
7
|
* @category location
|
|
8
8
|
*
|
|
9
|
-
* @param
|
|
10
|
-
* @param
|
|
9
|
+
* @param raw The _raw_ query parameter
|
|
10
|
+
* @param allowedValues The list of values (as strings) that the parameter can
|
|
11
|
+
* have, if not one of them `null` is returned
|
|
11
12
|
*/ export function getParamAmong(raw, allowedValues = []) {
|
|
12
13
|
const string = getParamAsString(raw);
|
|
13
14
|
return allowedValues.includes(string) ? string : null;
|
package/getParamAsInt.d.ts
CHANGED
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
*
|
|
6
6
|
* @category location
|
|
7
7
|
*
|
|
8
|
-
* @param
|
|
9
|
-
* @param
|
|
8
|
+
* @param raw The _raw_ query parameter
|
|
9
|
+
* @param fallback Fallback number, we return `null` if not provided
|
|
10
10
|
*/
|
|
11
11
|
export declare function getParamAsInt<TFallback extends number | null | undefined>(raw?: string | string[], fallback?: TFallback): number | TFallback;
|
|
12
12
|
export default getParamAsInt;
|
package/getParamAsInt.mjs
CHANGED
|
@@ -6,8 +6,8 @@ import getParamAsString from "./getParamAsString";
|
|
|
6
6
|
*
|
|
7
7
|
* @category location
|
|
8
8
|
*
|
|
9
|
-
* @param
|
|
10
|
-
* @param
|
|
9
|
+
* @param raw The _raw_ query parameter
|
|
10
|
+
* @param fallback Fallback number, we return `null` if not provided
|
|
11
11
|
*/ export function getParamAsInt(raw, fallback = null) {
|
|
12
12
|
const string = getParamAsString(raw);
|
|
13
13
|
if (string) {
|
package/getParamAsString.d.ts
CHANGED
package/getParamAsString.mjs
CHANGED
package/getType.d.ts
CHANGED
|
@@ -14,9 +14,6 @@ export type PlainObject = Record<string | number | symbol, any>;
|
|
|
14
14
|
export type TypeGuard<A, B extends A> = (payload: A) => payload is B;
|
|
15
15
|
/**
|
|
16
16
|
* Returns the object type of the given payload
|
|
17
|
-
*
|
|
18
|
-
* @param {*} payload
|
|
19
|
-
* @returns {string}
|
|
20
17
|
*/
|
|
21
18
|
export declare function getType(payload: any): string;
|
|
22
19
|
export default getType;
|
package/getType.mjs
CHANGED
package/getUrlQueryParams.d.ts
CHANGED
|
@@ -4,10 +4,9 @@ import { type AnyQueryParams } from "./location";
|
|
|
4
4
|
*
|
|
5
5
|
* @category location
|
|
6
6
|
* @param url A URL which contains a `?`, e.g. `?myparam=x` or `https://a.com?myparams=x`.
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
* the `href` of a `<a href="...">` HTML tag.
|
|
7
|
+
* If not provided it defaults reading the current URL query string with
|
|
8
|
+
* `location.search`. Through this argument you can use this same function to
|
|
9
|
+
* parse, for instance, the query params of the `href` of a `<a href="...">` HTML tag.
|
|
11
10
|
*
|
|
12
11
|
*/
|
|
13
12
|
export declare function getUrlQueryParams<T extends NonNullable<AnyQueryParams>>(url?: string): T;
|
package/getUrlQueryParams.mjs
CHANGED
|
@@ -4,10 +4,9 @@ import isBrowser from "./isBrowser";
|
|
|
4
4
|
*
|
|
5
5
|
* @category location
|
|
6
6
|
* @param url A URL which contains a `?`, e.g. `?myparam=x` or `https://a.com?myparams=x`.
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
* the `href` of a `<a href="...">` HTML tag.
|
|
7
|
+
* If not provided it defaults reading the current URL query string with
|
|
8
|
+
* `location.search`. Through this argument you can use this same function to
|
|
9
|
+
* parse, for instance, the query params of the `href` of a `<a href="...">` HTML tag.
|
|
11
10
|
*
|
|
12
11
|
*/ export function getUrlQueryParams(url) {
|
|
13
12
|
let params = {};
|