@koine/utils 1.0.104 → 1.1.0
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.d.ts +1 -1
- package/README.md +3 -0
- package/accentSets.d.ts +1 -1
- package/areEqual.d.ts +19 -0
- package/areEqual.js +77 -0
- package/cookie.d.ts +3 -3
- package/forin.d.ts +7 -0
- package/forin.js +11 -0
- package/gbToBytes.d.ts +7 -0
- package/gbToBytes.js +7 -0
- package/getMediaQueryWidthResolvers.d.ts +1 -1
- package/getType.d.ts +5 -5
- package/index.d.ts +8 -0
- package/index.js +8 -0
- package/kbToBytes.d.ts +7 -0
- package/kbToBytes.js +7 -0
- package/location.d.ts +1 -1
- package/matchSorter.d.ts +3 -3
- package/mbToBytes.d.ts +7 -0
- package/mbToBytes.js +7 -0
- package/node/areEqual.js +81 -0
- package/node/forin.js +15 -0
- package/node/gbToBytes.js +11 -0
- package/node/index.js +8 -0
- package/node/kbToBytes.js +11 -0
- package/node/mbToBytes.js +11 -0
- package/node/noop.js +11 -0
- package/node/quaranteneProps.js +37 -0
- package/node/uuidNumeric.js +10 -0
- package/noop.d.ts +7 -0
- package/noop.js +7 -0
- package/package.json +8 -8
- package/quaranteneProps.d.ts +22 -0
- package/quaranteneProps.js +33 -0
- package/uuidNumeric.d.ts +6 -0
- package/uuidNumeric.js +6 -0
- package/createStorage.d.ts +0 -53
- package/createStorage.js +0 -137
- package/getZonedDate.d.ts +0 -16
- package/getZonedDate.js +0 -37
- package/isIE.d.ts +0 -7
- package/isIE.js +0 -18
- package/isMobile.d.ts +0 -7
- package/isMobile.js +0 -16
- package/navigateToHash.d.ts +0 -8
- package/navigateToHash.js +0 -12
- package/navigateToHashParams.d.ts +0 -9
- package/navigateToHashParams.js +0 -22
- package/navigateToMergedHashParams.d.ts +0 -8
- package/navigateToMergedHashParams.js +0 -14
- package/navigateToMergedParams.d.ts +0 -9
- package/navigateToMergedParams.js +0 -14
- package/navigateToParams.d.ts +0 -10
- package/navigateToParams.js +0 -18
- package/navigateWithoutUrlParam.d.ts +0 -8
- package/navigateWithoutUrlParam.js +0 -19
- package/pageview.d.ts +0 -9
- package/pageview.js +0 -29
- package/redirectTo.d.ts +0 -9
- package/redirectTo.js +0 -15
package/Defer.d.ts
CHANGED
package/README.md
CHANGED
|
@@ -6,6 +6,7 @@ Libraries to encapsulate and re-export from here, the selection is based on:
|
|
|
6
6
|
- [x] treeshake-ability
|
|
7
7
|
- [x] docs in source comments
|
|
8
8
|
|
|
9
|
+
- [dhmk-utils](https://github.com/dhmk083/dhmk-utils)
|
|
9
10
|
- [mesqueeb/merge-anything](https://github.com/mesqueeb/merge-anything)
|
|
10
11
|
- [mesqueeb/filter-anything](https://github.com/mesqueeb/filter-anything)
|
|
11
12
|
- [mesqueeb/case-anything](https://github.com/mesqueeb/case-anything)
|
|
@@ -34,6 +35,8 @@ anyway like [those of `yup`](https://github.com/jquense/yup/blob/master/package.
|
|
|
34
35
|
- [property-expr](https://github.com/jquense/expr/blob/master/index.js)
|
|
35
36
|
- [toposort](https://github.com/marcelklehr/toposort)
|
|
36
37
|
|
|
38
|
+
TODO: check typescript utilities in [TypeScript core](https://github.com/microsoft/TypeScript/blob/main/src/compiler/core.ts)
|
|
39
|
+
|
|
37
40
|
## Code
|
|
38
41
|
|
|
39
42
|
- Transformative functions like `truncate` or `titleCase` should allow for nullable inputs as much as possible, acceptin both `undefined` and `null`.
|
package/accentSets.d.ts
CHANGED
package/areEqual.d.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
type ComparablePrimitive = string | number | boolean;
|
|
2
|
+
type Comparable = ComparablePrimitive | object | Record<string, ComparablePrimitive> | Array<ComparablePrimitive>;
|
|
3
|
+
/**
|
|
4
|
+
* A simple and quick deep equal objects utility. This is meant to be used
|
|
5
|
+
* solely to deduplicate requests payload and perform comparison on JSON ready
|
|
6
|
+
* objects made of primitives `string`, `number` and `boolean`s.
|
|
7
|
+
*
|
|
8
|
+
* It support nested `object`s and `array`s only.
|
|
9
|
+
*
|
|
10
|
+
* NB: `undefined` and `null` values do not count in the comparison as they are
|
|
11
|
+
* usually meant to be ignored in JSON requestBody payloads.
|
|
12
|
+
*
|
|
13
|
+
* According to very rudimentary tests this function takes on average between
|
|
14
|
+
* 0.15 ms and 2ms to compare two averaged sizes requet body payloads.
|
|
15
|
+
*
|
|
16
|
+
* @category objects
|
|
17
|
+
*/
|
|
18
|
+
export declare function areEqual(a: Comparable, b?: Comparable): boolean;
|
|
19
|
+
export default areEqual;
|
package/areEqual.js
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { isArray } from "./isArray";
|
|
2
|
+
import { isObject } from "./isObject";
|
|
3
|
+
function areEqualArrays(a, b) {
|
|
4
|
+
if (!b)
|
|
5
|
+
return false;
|
|
6
|
+
if (a.length !== b.length)
|
|
7
|
+
return false;
|
|
8
|
+
for (var i = 0; i < a.length; i++) {
|
|
9
|
+
var aValue = a[i];
|
|
10
|
+
var bValue = b[i];
|
|
11
|
+
if (!areEqual(aValue, bValue))
|
|
12
|
+
return false;
|
|
13
|
+
}
|
|
14
|
+
return true;
|
|
15
|
+
}
|
|
16
|
+
function areEqualObjects(a, b) {
|
|
17
|
+
if (!b)
|
|
18
|
+
return false;
|
|
19
|
+
var aKeys = Object.keys(a);
|
|
20
|
+
var bKeys = Object.keys(b);
|
|
21
|
+
if (aKeys.length !== bKeys.length) {
|
|
22
|
+
return false;
|
|
23
|
+
}
|
|
24
|
+
for (var _i = 0, aKeys_1 = aKeys; _i < aKeys_1.length; _i++) {
|
|
25
|
+
var _key = aKeys_1[_i];
|
|
26
|
+
var key = _key;
|
|
27
|
+
var aValue = a[key];
|
|
28
|
+
var bValue = b[key];
|
|
29
|
+
if (!areEqual(aValue, bValue)) {
|
|
30
|
+
return false;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
return true;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* A simple and quick deep equal objects utility. This is meant to be used
|
|
37
|
+
* solely to deduplicate requests payload and perform comparison on JSON ready
|
|
38
|
+
* objects made of primitives `string`, `number` and `boolean`s.
|
|
39
|
+
*
|
|
40
|
+
* It support nested `object`s and `array`s only.
|
|
41
|
+
*
|
|
42
|
+
* NB: `undefined` and `null` values do not count in the comparison as they are
|
|
43
|
+
* usually meant to be ignored in JSON requestBody payloads.
|
|
44
|
+
*
|
|
45
|
+
* According to very rudimentary tests this function takes on average between
|
|
46
|
+
* 0.15 ms and 2ms to compare two averaged sizes requet body payloads.
|
|
47
|
+
*
|
|
48
|
+
* @category objects
|
|
49
|
+
*/
|
|
50
|
+
export function areEqual(a, b) {
|
|
51
|
+
if (!a && !b) {
|
|
52
|
+
// console.log(`areEqual took ${performance.now() - t0} ms`);
|
|
53
|
+
return true;
|
|
54
|
+
}
|
|
55
|
+
// const t0 = performance.now();
|
|
56
|
+
if (!b && a !== b) {
|
|
57
|
+
// console.log(`areEqual took ${performance.now() - t0} ms`);
|
|
58
|
+
return false;
|
|
59
|
+
}
|
|
60
|
+
var areObjects = isObject(a) && isObject(b);
|
|
61
|
+
if (areObjects && !areEqualObjects(a, b)) {
|
|
62
|
+
// console.log(`areEqual took ${performance.now() - t0} ms`);
|
|
63
|
+
return false;
|
|
64
|
+
}
|
|
65
|
+
var areArrays = isArray(a) && isArray(b);
|
|
66
|
+
if (areArrays && !areEqualArrays(a, b)) {
|
|
67
|
+
// console.log(`areEqual took ${performance.now() - t0} ms`);
|
|
68
|
+
return false;
|
|
69
|
+
}
|
|
70
|
+
if (!areObjects && !areArrays && a !== b) {
|
|
71
|
+
// console.log(`areEqual took ${performance.now() - t0} ms`);
|
|
72
|
+
return false;
|
|
73
|
+
}
|
|
74
|
+
// console.log(`areEqual took ${performance.now() - t0} ms`);
|
|
75
|
+
return true;
|
|
76
|
+
}
|
|
77
|
+
export default areEqual;
|
package/cookie.d.ts
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* - [js-cookie](https://github.com/js-cookie/js-cookie)
|
|
8
8
|
* - [cookie](https://github.com/jshttp/cookie)
|
|
9
9
|
*/
|
|
10
|
-
|
|
10
|
+
type CookieAttributes = {
|
|
11
11
|
/**
|
|
12
12
|
* Define when the cookie will be removed. Value can be a Number
|
|
13
13
|
* which will be interpreted as days from time of creation or a
|
|
@@ -41,13 +41,13 @@ declare type CookieAttributes = {
|
|
|
41
41
|
*/
|
|
42
42
|
sameSite?: "strict" | "Strict" | "lax" | "Lax" | "none" | "None" | undefined;
|
|
43
43
|
};
|
|
44
|
-
export
|
|
44
|
+
export type CookieAttributesServer = CookieAttributes & {
|
|
45
45
|
maxAge?: number;
|
|
46
46
|
httpOnly?: boolean;
|
|
47
47
|
encode?: (input: string) => string;
|
|
48
48
|
decode?: (input: string) => string;
|
|
49
49
|
};
|
|
50
|
-
export
|
|
50
|
+
export type CookieAttributesClient = CookieAttributes;
|
|
51
51
|
export declare const defaultAttributesClient: {
|
|
52
52
|
path: string;
|
|
53
53
|
};
|
package/forin.d.ts
ADDED
package/forin.js
ADDED
package/gbToBytes.d.ts
ADDED
package/gbToBytes.js
ADDED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export
|
|
1
|
+
export type GetMediaQueryWidthResolversBreakpoints = Record<string, number>;
|
|
2
2
|
export declare function getMediaQueryWidthResolvers<TBreakpointsConfig extends GetMediaQueryWidthResolversBreakpoints>(customBreakpoints: TBreakpointsConfig): {
|
|
3
3
|
max: (br: Extract<keyof TBreakpointsConfig, string>) => string;
|
|
4
4
|
min: (br: Extract<keyof TBreakpointsConfig, string>) => string;
|
package/getType.d.ts
CHANGED
|
@@ -7,11 +7,11 @@
|
|
|
7
7
|
* - `isInt`
|
|
8
8
|
* - `isFloat`
|
|
9
9
|
*/
|
|
10
|
-
export
|
|
11
|
-
export
|
|
12
|
-
export
|
|
13
|
-
export
|
|
14
|
-
export
|
|
10
|
+
export type AnyFunction = (...args: any[]) => any;
|
|
11
|
+
export type AnyAsyncFunction = (...args: any[]) => Promise<any>;
|
|
12
|
+
export type AnyClass = new (...args: any[]) => any;
|
|
13
|
+
export type PlainObject = Record<string | number | symbol, any>;
|
|
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
17
|
*
|
package/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export * from "./accentSets";
|
|
2
2
|
export * from "./addOrReplaceAtIdx";
|
|
3
|
+
export * from "./areEqual";
|
|
3
4
|
export * from "./arrayOfAll";
|
|
4
5
|
export * from "./arraySum";
|
|
5
6
|
export * from "./arrayToLookup";
|
|
@@ -21,6 +22,8 @@ export * from "./Emitter";
|
|
|
21
22
|
export * from "./encode";
|
|
22
23
|
export * from "./ensureInt";
|
|
23
24
|
export * from "./findDuplicatedIndexes";
|
|
25
|
+
export * from "./forin";
|
|
26
|
+
export * from "./gbToBytes";
|
|
24
27
|
export * from "./getEmptyArray";
|
|
25
28
|
export * from "./getKeys";
|
|
26
29
|
export * from "./getMediaQueryWidthResolvers";
|
|
@@ -76,19 +79,23 @@ export * from "./isType";
|
|
|
76
79
|
export * from "./isUndefined";
|
|
77
80
|
export * from "./isWeakMap";
|
|
78
81
|
export * from "./isWeakSet";
|
|
82
|
+
export * from "./kbToBytes";
|
|
79
83
|
export * from "./location";
|
|
80
84
|
export * from "./lowercase";
|
|
81
85
|
export * from "./mapListBy";
|
|
82
86
|
export * from "./matchSorter";
|
|
87
|
+
export * from "./mbToBytes";
|
|
83
88
|
export * from "./mergeObjects";
|
|
84
89
|
export * from "./mergeUrlQueryParams";
|
|
85
90
|
export * from "./moveSortableArrayItemByKey";
|
|
91
|
+
export * from "./noop";
|
|
86
92
|
export * from "./normaliseUrlPathname";
|
|
87
93
|
export * from "./normaliseUrl";
|
|
88
94
|
export * from "./objectPick";
|
|
89
95
|
export * from "./objectOmit";
|
|
90
96
|
export * from "./parseCookie";
|
|
91
97
|
export * from "./parseURL";
|
|
98
|
+
export * from "./quaranteneProps";
|
|
92
99
|
export * from "./randomInt";
|
|
93
100
|
export * from "./randomKey";
|
|
94
101
|
export * from "./readCookie";
|
|
@@ -117,5 +124,6 @@ export * from "./updateLinkParams";
|
|
|
117
124
|
export * from "./updateUrlQueryParams";
|
|
118
125
|
export * from "./uppercase";
|
|
119
126
|
export * from "./uuid";
|
|
127
|
+
export * from "./uuidNumeric";
|
|
120
128
|
export * from "./wait";
|
|
121
129
|
export type { Primitive, Class, Constructor, TypedArray, Observer, ObservableLike, Except, Writable, Merge, MergeDeep, MergeExclusive, RequireAtLeastOne, RequireExactlyOne, RequireAllOrNone, RemoveIndexSignature, PartialDeep, ReadonlyDeep, LiteralUnion, Opaque, InvariantOf, SetOptional, SetRequired, ValueOf, ConditionalKeys, ConditionalPick, ConditionalExcept, UnionToIntersection, LiteralToPrimitive, Stringified, IterableElement, Entry, Exact, Entries, SetReturnType, Simplify, Get, StringKeyOf, Schema, Jsonify, JsonPrimitive, JsonObject, JsonArray, JsonValue, Promisable, AsyncReturnType, Asyncify, Trim, Split, Includes, Join, LastArrayElement, FixedLengthArray, MultidimensionalArray, MultidimensionalReadonlyArray, PositiveInfinity, NegativeInfinity, Finite, Integer, Float, NegativeFloat, Negative, NonNegative, NegativeInteger, NonNegativeInteger, CamelCase, CamelCasedProperties, CamelCasedPropertiesDeep, KebabCase, KebabCasedProperties, KebabCasedPropertiesDeep, PascalCase, PascalCasedProperties, PascalCasedPropertiesDeep, SnakeCase, SnakeCasedProperties, SnakeCasedPropertiesDeep, ScreamingSnakeCase, DelimiterCase, DelimiterCasedProperties, DelimiterCasedPropertiesDeep, PackageJson, TsConfigJson, SetNonNullable, Spread, PartialOnUndefinedDeep, OptionalKeysOf, HasOptionalKeys, RequiredKeysOf, HasRequiredKeys, UnwrapOpaque, EmptyObject, IsEmptyObject, TupleToUnion, OmitIndexSignature, PickIndexSignature, ConditionalPickDeep, } from "type-fest";
|
package/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export * from "./accentSets";
|
|
2
2
|
export * from "./addOrReplaceAtIdx";
|
|
3
|
+
export * from "./areEqual";
|
|
3
4
|
export * from "./arrayOfAll";
|
|
4
5
|
export * from "./arraySum";
|
|
5
6
|
export * from "./arrayToLookup";
|
|
@@ -22,6 +23,8 @@ export * from "./encode";
|
|
|
22
23
|
export * from "./ensureInt";
|
|
23
24
|
// export * from "./env"
|
|
24
25
|
export * from "./findDuplicatedIndexes";
|
|
26
|
+
export * from "./forin";
|
|
27
|
+
export * from "./gbToBytes";
|
|
25
28
|
export * from "./getEmptyArray";
|
|
26
29
|
export * from "./getKeys";
|
|
27
30
|
export * from "./getMediaQueryWidthResolvers";
|
|
@@ -77,19 +80,23 @@ export * from "./isType";
|
|
|
77
80
|
export * from "./isUndefined";
|
|
78
81
|
export * from "./isWeakMap";
|
|
79
82
|
export * from "./isWeakSet";
|
|
83
|
+
export * from "./kbToBytes";
|
|
80
84
|
export * from "./location";
|
|
81
85
|
export * from "./lowercase";
|
|
82
86
|
export * from "./mapListBy";
|
|
83
87
|
export * from "./matchSorter";
|
|
88
|
+
export * from "./mbToBytes";
|
|
84
89
|
export * from "./mergeObjects";
|
|
85
90
|
export * from "./mergeUrlQueryParams";
|
|
86
91
|
export * from "./moveSortableArrayItemByKey";
|
|
92
|
+
export * from "./noop";
|
|
87
93
|
export * from "./normaliseUrlPathname";
|
|
88
94
|
export * from "./normaliseUrl";
|
|
89
95
|
export * from "./objectPick";
|
|
90
96
|
export * from "./objectOmit";
|
|
91
97
|
export * from "./parseCookie";
|
|
92
98
|
export * from "./parseURL";
|
|
99
|
+
export * from "./quaranteneProps";
|
|
93
100
|
export * from "./randomInt";
|
|
94
101
|
export * from "./randomKey";
|
|
95
102
|
export * from "./readCookie";
|
|
@@ -119,4 +126,5 @@ export * from "./updateLinkParams";
|
|
|
119
126
|
export * from "./updateUrlQueryParams";
|
|
120
127
|
export * from "./uppercase";
|
|
121
128
|
export * from "./uuid";
|
|
129
|
+
export * from "./uuidNumeric";
|
|
122
130
|
export * from "./wait";
|
package/kbToBytes.d.ts
ADDED
package/kbToBytes.js
ADDED
package/location.d.ts
CHANGED
package/matchSorter.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
type KeyAttributes = {
|
|
2
2
|
threshold?: Ranking;
|
|
3
3
|
maxRanking: Ranking;
|
|
4
4
|
minRanking: Ranking;
|
|
@@ -30,7 +30,7 @@ interface KeyAttributesOptions<ItemType> {
|
|
|
30
30
|
maxRanking?: Ranking;
|
|
31
31
|
minRanking?: Ranking;
|
|
32
32
|
}
|
|
33
|
-
|
|
33
|
+
type KeyOption<ItemType> = KeyAttributesOptions<ItemType> | ValueGetterKey<ItemType> | string;
|
|
34
34
|
interface MatchSorterOptions<ItemType = unknown> {
|
|
35
35
|
keys?: ReadonlyArray<KeyOption<ItemType>>;
|
|
36
36
|
threshold?: Ranking;
|
|
@@ -46,7 +46,7 @@ declare const RANKING_CONTAINS = 3;
|
|
|
46
46
|
declare const RANKING_ACRONYM = 2;
|
|
47
47
|
declare const RANKING_MATCHES = 1;
|
|
48
48
|
declare const RANKING_NO_MATCH = 0;
|
|
49
|
-
|
|
49
|
+
type Ranking = typeof RANKING_CASE_SENSITIVE_EQUAL | typeof RANKING_EQUAL | typeof RANKING_STARTS_WITH | typeof RANKING_WORD_STARTS_WITH | typeof RANKING_CONTAINS | typeof RANKING_ACRONYM | typeof RANKING_MATCHES | typeof RANKING_NO_MATCH;
|
|
50
50
|
declare const defaultBaseSortFn: BaseSorter<unknown>;
|
|
51
51
|
/**
|
|
52
52
|
* Takes an array of items and a value and returns a new array with the items that match the given value
|
package/mbToBytes.d.ts
ADDED
package/mbToBytes.js
ADDED
package/node/areEqual.js
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.areEqual = void 0;
|
|
4
|
+
var isArray_1 = require("./isArray");
|
|
5
|
+
var isObject_1 = require("./isObject");
|
|
6
|
+
function areEqualArrays(a, b) {
|
|
7
|
+
if (!b)
|
|
8
|
+
return false;
|
|
9
|
+
if (a.length !== b.length)
|
|
10
|
+
return false;
|
|
11
|
+
for (var i = 0; i < a.length; i++) {
|
|
12
|
+
var aValue = a[i];
|
|
13
|
+
var bValue = b[i];
|
|
14
|
+
if (!areEqual(aValue, bValue))
|
|
15
|
+
return false;
|
|
16
|
+
}
|
|
17
|
+
return true;
|
|
18
|
+
}
|
|
19
|
+
function areEqualObjects(a, b) {
|
|
20
|
+
if (!b)
|
|
21
|
+
return false;
|
|
22
|
+
var aKeys = Object.keys(a);
|
|
23
|
+
var bKeys = Object.keys(b);
|
|
24
|
+
if (aKeys.length !== bKeys.length) {
|
|
25
|
+
return false;
|
|
26
|
+
}
|
|
27
|
+
for (var _i = 0, aKeys_1 = aKeys; _i < aKeys_1.length; _i++) {
|
|
28
|
+
var _key = aKeys_1[_i];
|
|
29
|
+
var key = _key;
|
|
30
|
+
var aValue = a[key];
|
|
31
|
+
var bValue = b[key];
|
|
32
|
+
if (!areEqual(aValue, bValue)) {
|
|
33
|
+
return false;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
return true;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* A simple and quick deep equal objects utility. This is meant to be used
|
|
40
|
+
* solely to deduplicate requests payload and perform comparison on JSON ready
|
|
41
|
+
* objects made of primitives `string`, `number` and `boolean`s.
|
|
42
|
+
*
|
|
43
|
+
* It support nested `object`s and `array`s only.
|
|
44
|
+
*
|
|
45
|
+
* NB: `undefined` and `null` values do not count in the comparison as they are
|
|
46
|
+
* usually meant to be ignored in JSON requestBody payloads.
|
|
47
|
+
*
|
|
48
|
+
* According to very rudimentary tests this function takes on average between
|
|
49
|
+
* 0.15 ms and 2ms to compare two averaged sizes requet body payloads.
|
|
50
|
+
*
|
|
51
|
+
* @category objects
|
|
52
|
+
*/
|
|
53
|
+
function areEqual(a, b) {
|
|
54
|
+
if (!a && !b) {
|
|
55
|
+
// console.log(`areEqual took ${performance.now() - t0} ms`);
|
|
56
|
+
return true;
|
|
57
|
+
}
|
|
58
|
+
// const t0 = performance.now();
|
|
59
|
+
if (!b && a !== b) {
|
|
60
|
+
// console.log(`areEqual took ${performance.now() - t0} ms`);
|
|
61
|
+
return false;
|
|
62
|
+
}
|
|
63
|
+
var areObjects = (0, isObject_1.isObject)(a) && (0, isObject_1.isObject)(b);
|
|
64
|
+
if (areObjects && !areEqualObjects(a, b)) {
|
|
65
|
+
// console.log(`areEqual took ${performance.now() - t0} ms`);
|
|
66
|
+
return false;
|
|
67
|
+
}
|
|
68
|
+
var areArrays = (0, isArray_1.isArray)(a) && (0, isArray_1.isArray)(b);
|
|
69
|
+
if (areArrays && !areEqualArrays(a, b)) {
|
|
70
|
+
// console.log(`areEqual took ${performance.now() - t0} ms`);
|
|
71
|
+
return false;
|
|
72
|
+
}
|
|
73
|
+
if (!areObjects && !areArrays && a !== b) {
|
|
74
|
+
// console.log(`areEqual took ${performance.now() - t0} ms`);
|
|
75
|
+
return false;
|
|
76
|
+
}
|
|
77
|
+
// console.log(`areEqual took ${performance.now() - t0} ms`);
|
|
78
|
+
return true;
|
|
79
|
+
}
|
|
80
|
+
exports.areEqual = areEqual;
|
|
81
|
+
exports.default = areEqual;
|
package/node/forin.js
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.forin = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* To easily get typed native `for in`
|
|
6
|
+
*
|
|
7
|
+
* @category objects
|
|
8
|
+
*/
|
|
9
|
+
function forin(object, cb) {
|
|
10
|
+
for (var key in object) {
|
|
11
|
+
cb(key, object[key]);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
exports.forin = forin;
|
|
15
|
+
exports.default = forin;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.gbToBytes = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Gigabytes to bytes
|
|
6
|
+
*
|
|
7
|
+
* @category format
|
|
8
|
+
*/
|
|
9
|
+
var gbToBytes = function (bytes) { return bytes * 1000 * 1000 * 1000; };
|
|
10
|
+
exports.gbToBytes = gbToBytes;
|
|
11
|
+
exports.default = exports.gbToBytes;
|
package/node/index.js
CHANGED
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
var tslib_1 = require("tslib");
|
|
4
4
|
tslib_1.__exportStar(require("./accentSets"), exports);
|
|
5
5
|
tslib_1.__exportStar(require("./addOrReplaceAtIdx"), exports);
|
|
6
|
+
tslib_1.__exportStar(require("./areEqual"), exports);
|
|
6
7
|
tslib_1.__exportStar(require("./arrayOfAll"), exports);
|
|
7
8
|
tslib_1.__exportStar(require("./arraySum"), exports);
|
|
8
9
|
tslib_1.__exportStar(require("./arrayToLookup"), exports);
|
|
@@ -25,6 +26,8 @@ tslib_1.__exportStar(require("./encode"), exports);
|
|
|
25
26
|
tslib_1.__exportStar(require("./ensureInt"), exports);
|
|
26
27
|
// export * from "./env"
|
|
27
28
|
tslib_1.__exportStar(require("./findDuplicatedIndexes"), exports);
|
|
29
|
+
tslib_1.__exportStar(require("./forin"), exports);
|
|
30
|
+
tslib_1.__exportStar(require("./gbToBytes"), exports);
|
|
28
31
|
tslib_1.__exportStar(require("./getEmptyArray"), exports);
|
|
29
32
|
tslib_1.__exportStar(require("./getKeys"), exports);
|
|
30
33
|
tslib_1.__exportStar(require("./getMediaQueryWidthResolvers"), exports);
|
|
@@ -80,19 +83,23 @@ tslib_1.__exportStar(require("./isType"), exports);
|
|
|
80
83
|
tslib_1.__exportStar(require("./isUndefined"), exports);
|
|
81
84
|
tslib_1.__exportStar(require("./isWeakMap"), exports);
|
|
82
85
|
tslib_1.__exportStar(require("./isWeakSet"), exports);
|
|
86
|
+
tslib_1.__exportStar(require("./kbToBytes"), exports);
|
|
83
87
|
tslib_1.__exportStar(require("./location"), exports);
|
|
84
88
|
tslib_1.__exportStar(require("./lowercase"), exports);
|
|
85
89
|
tslib_1.__exportStar(require("./mapListBy"), exports);
|
|
86
90
|
tslib_1.__exportStar(require("./matchSorter"), exports);
|
|
91
|
+
tslib_1.__exportStar(require("./mbToBytes"), exports);
|
|
87
92
|
tslib_1.__exportStar(require("./mergeObjects"), exports);
|
|
88
93
|
tslib_1.__exportStar(require("./mergeUrlQueryParams"), exports);
|
|
89
94
|
tslib_1.__exportStar(require("./moveSortableArrayItemByKey"), exports);
|
|
95
|
+
tslib_1.__exportStar(require("./noop"), exports);
|
|
90
96
|
tslib_1.__exportStar(require("./normaliseUrlPathname"), exports);
|
|
91
97
|
tslib_1.__exportStar(require("./normaliseUrl"), exports);
|
|
92
98
|
tslib_1.__exportStar(require("./objectPick"), exports);
|
|
93
99
|
tslib_1.__exportStar(require("./objectOmit"), exports);
|
|
94
100
|
tslib_1.__exportStar(require("./parseCookie"), exports);
|
|
95
101
|
tslib_1.__exportStar(require("./parseURL"), exports);
|
|
102
|
+
tslib_1.__exportStar(require("./quaranteneProps"), exports);
|
|
96
103
|
tslib_1.__exportStar(require("./randomInt"), exports);
|
|
97
104
|
tslib_1.__exportStar(require("./randomKey"), exports);
|
|
98
105
|
tslib_1.__exportStar(require("./readCookie"), exports);
|
|
@@ -122,4 +129,5 @@ tslib_1.__exportStar(require("./updateLinkParams"), exports);
|
|
|
122
129
|
tslib_1.__exportStar(require("./updateUrlQueryParams"), exports);
|
|
123
130
|
tslib_1.__exportStar(require("./uppercase"), exports);
|
|
124
131
|
tslib_1.__exportStar(require("./uuid"), exports);
|
|
132
|
+
tslib_1.__exportStar(require("./uuidNumeric"), exports);
|
|
125
133
|
tslib_1.__exportStar(require("./wait"), exports);
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.kbToBytes = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Kilobytes to bytes
|
|
6
|
+
*
|
|
7
|
+
* @category format
|
|
8
|
+
*/
|
|
9
|
+
var kbToBytes = function (bytes) { return bytes * 1000; };
|
|
10
|
+
exports.kbToBytes = kbToBytes;
|
|
11
|
+
exports.default = exports.kbToBytes;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.mbToBytes = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Megabytes to bytes
|
|
6
|
+
*
|
|
7
|
+
* @category format
|
|
8
|
+
*/
|
|
9
|
+
var mbToBytes = function (bytes) { return bytes * 1000 * 1000; };
|
|
10
|
+
exports.mbToBytes = mbToBytes;
|
|
11
|
+
exports.default = exports.mbToBytes;
|
package/node/noop.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.noop = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* No operation function
|
|
6
|
+
*
|
|
7
|
+
* @category native
|
|
8
|
+
*/
|
|
9
|
+
var noop = function () { return void 0; };
|
|
10
|
+
exports.noop = noop;
|
|
11
|
+
exports.default = exports.noop;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.quaranteneProps = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* @category impl
|
|
6
|
+
* @usage
|
|
7
|
+
*
|
|
8
|
+
* ```ts
|
|
9
|
+
* const { _: { onKeyDown }, myOwnProp, ...rest } = quaranteneProps([
|
|
10
|
+
* "onPointerLeave",
|
|
11
|
+
* "onPointerMove",
|
|
12
|
+
* "onClick",
|
|
13
|
+
* "onPointerDown",
|
|
14
|
+
* "onPointerUp",
|
|
15
|
+
* "onKeyDown",
|
|
16
|
+
* ]);
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
function quaranteneProps(props, propsKeysToQuarantene) {
|
|
20
|
+
// approach 1)
|
|
21
|
+
var healthyProps = {
|
|
22
|
+
_: {},
|
|
23
|
+
};
|
|
24
|
+
for (var key in props) {
|
|
25
|
+
var prop = props[key];
|
|
26
|
+
if (propsKeysToQuarantene.includes(key)) {
|
|
27
|
+
healthyProps._[key] = prop;
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
// @ts-expect-error nevermind
|
|
31
|
+
healthyProps[key] = prop;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
return healthyProps;
|
|
35
|
+
}
|
|
36
|
+
exports.quaranteneProps = quaranteneProps;
|
|
37
|
+
exports.default = quaranteneProps;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.uuidNumeric = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* @category uid
|
|
6
|
+
* @see https://stackoverflow.com/a/18048162/1938970
|
|
7
|
+
*/
|
|
8
|
+
var uuidNumeric = function () { return new Date().valueOf(); };
|
|
9
|
+
exports.uuidNumeric = uuidNumeric;
|
|
10
|
+
exports.default = exports.uuidNumeric;
|
package/noop.d.ts
ADDED