@sohanemon/utils 6.2.7 → 6.2.10
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/dist/index.d.mts +665 -0
- package/dist/index.mjs +664 -0
- package/package.json +42 -18
- package/dist/components/html-injector.d.ts +0 -50
- package/dist/components/html-injector.js +0 -108
- package/dist/components/index.d.ts +0 -5
- package/dist/components/index.js +0 -7
- package/dist/components/media-wrapper.d.ts +0 -10
- package/dist/components/media-wrapper.js +0 -14
- package/dist/components/responsive-indicator.d.ts +0 -2
- package/dist/components/responsive-indicator.js +0 -68
- package/dist/components/scrollable-marker.d.ts +0 -1
- package/dist/components/scrollable-marker.js +0 -56
- package/dist/functions/cookie.d.ts +0 -6
- package/dist/functions/cookie.js +0 -22
- package/dist/functions/deepmerge.d.ts +0 -59
- package/dist/functions/deepmerge.js +0 -116
- package/dist/functions/hydrate.d.ts +0 -15
- package/dist/functions/hydrate.js +0 -31
- package/dist/functions/index.d.ts +0 -8
- package/dist/functions/index.js +0 -8
- package/dist/functions/object.d.ts +0 -93
- package/dist/functions/object.js +0 -67
- package/dist/functions/poll.d.ts +0 -38
- package/dist/functions/poll.js +0 -69
- package/dist/functions/schedule.d.ts +0 -12
- package/dist/functions/schedule.js +0 -29
- package/dist/functions/shield.d.ts +0 -18
- package/dist/functions/shield.js +0 -15
- package/dist/functions/utils.d.ts +0 -243
- package/dist/functions/utils.js +0 -439
- package/dist/hooks/action.d.ts +0 -20
- package/dist/hooks/action.js +0 -84
- package/dist/hooks/async.d.ts +0 -30
- package/dist/hooks/async.js +0 -82
- package/dist/hooks/index.d.ts +0 -192
- package/dist/hooks/index.js +0 -533
- package/dist/hooks/schedule.d.ts +0 -36
- package/dist/hooks/schedule.js +0 -68
- package/dist/index.d.ts +0 -2
- package/dist/index.js +0 -2
- package/dist/types/gates.d.ts +0 -133
- package/dist/types/gates.js +0 -1
- package/dist/types/guards.d.ts +0 -6
- package/dist/types/guards.js +0 -29
- package/dist/types/index.d.ts +0 -3
- package/dist/types/index.js +0 -3
- package/dist/types/utilities.d.ts +0 -62
- package/dist/types/utilities.js +0 -1
package/dist/types/gates.d.ts
DELETED
|
@@ -1,133 +0,0 @@
|
|
|
1
|
-
import { Without } from './utilities';
|
|
2
|
-
export type BUFFER<T> = T;
|
|
3
|
-
export type IMPLIES<T, U> = T extends U ? true : false;
|
|
4
|
-
export type XOR_Binary<T, U> = T | U extends object ? (Without<T, U> & U) | (Without<U, T> & T) : T | U;
|
|
5
|
-
export type XNOR_Binary<T, U> = (T & U) | (Without<T, U> & Without<U, T>);
|
|
6
|
-
/**
|
|
7
|
-
* Computes a type-level AND (all must true) for a tuple of types.
|
|
8
|
-
*
|
|
9
|
-
* Truth table for 3 arguments:
|
|
10
|
-
*
|
|
11
|
-
* A B C = AND
|
|
12
|
-
* 1 1 1 = 1
|
|
13
|
-
* 1 1 0 = 0
|
|
14
|
-
* 1 0 1 = 0
|
|
15
|
-
* 1 0 0 = 0
|
|
16
|
-
* 0 1 1 = 0
|
|
17
|
-
* 0 1 0 = 0
|
|
18
|
-
* 0 0 1 = 0
|
|
19
|
-
* 0 0 0 = 0
|
|
20
|
-
*
|
|
21
|
-
* @template T - Tuple of boolean-like types (1/0)
|
|
22
|
-
*/
|
|
23
|
-
export type AND<T extends any[]> = T extends [infer F, ...infer R] ? R extends any[] ? F & AND<R> : F : unknown;
|
|
24
|
-
/**
|
|
25
|
-
* Computes a type-level OR (At least one) for a tuple of types.
|
|
26
|
-
*
|
|
27
|
-
* Truth table for 3 arguments:
|
|
28
|
-
*
|
|
29
|
-
* A B C = OR
|
|
30
|
-
* 1 1 1 = 1
|
|
31
|
-
* 1 1 0 = 1
|
|
32
|
-
* 1 0 1 = 1
|
|
33
|
-
* 1 0 0 = 1
|
|
34
|
-
* 0 1 1 = 1
|
|
35
|
-
* 0 1 0 = 1
|
|
36
|
-
* 0 0 1 = 1
|
|
37
|
-
* 0 0 0 = 0
|
|
38
|
-
*
|
|
39
|
-
* @template T - Tuple of boolean-like types (1/0)
|
|
40
|
-
*/
|
|
41
|
-
export type OR<T extends any[]> = T extends [infer F, ...infer R] ? R extends any[] ? F | OR<R> : F : never;
|
|
42
|
-
/**
|
|
43
|
-
* Computes a type-level XOR (only one/odd) for a tuple of types.
|
|
44
|
-
*
|
|
45
|
-
* Truth table for 3 arguments:
|
|
46
|
-
*
|
|
47
|
-
* A B C = XOR
|
|
48
|
-
* 1 1 1 = 1
|
|
49
|
-
* 1 1 0 = 0
|
|
50
|
-
* 1 0 1 = 0
|
|
51
|
-
* 1 0 0 = 1
|
|
52
|
-
* 0 1 1 = 0
|
|
53
|
-
* 0 1 0 = 1
|
|
54
|
-
* 0 0 1 = 1
|
|
55
|
-
* 0 0 0 = 0
|
|
56
|
-
*
|
|
57
|
-
* @template T - Tuple of boolean-like types (1/0)
|
|
58
|
-
*/
|
|
59
|
-
export type XOR<T extends any[]> = T extends [infer F, ...infer R] ? R extends [infer S, ...infer Rest] ? XOR<[XOR_Binary<F, S>, ...Rest]> : F : never;
|
|
60
|
-
/**
|
|
61
|
-
* Computes a type-level XNOR (All or None true) for a tuple of types.
|
|
62
|
-
*
|
|
63
|
-
* Truth table for 3 arguments:
|
|
64
|
-
*
|
|
65
|
-
* A B C = XNOR
|
|
66
|
-
* 1 1 1 = 0
|
|
67
|
-
* 1 1 0 = 1
|
|
68
|
-
* 1 0 1 = 1
|
|
69
|
-
* 1 0 0 = 0
|
|
70
|
-
* 0 1 1 = 1
|
|
71
|
-
* 0 1 0 = 0
|
|
72
|
-
* 0 0 1 = 0
|
|
73
|
-
* 0 0 0 = 1
|
|
74
|
-
*
|
|
75
|
-
* @template T - Tuple of boolean-like types (1/0)
|
|
76
|
-
*/
|
|
77
|
-
export type XNOR<T extends any[]> = T extends [infer F, ...infer R] ? R extends [infer S, ...infer Rest] ? XNOR<[XNOR_Binary<F, S>, ...Rest]> : F : never;
|
|
78
|
-
/**
|
|
79
|
-
* Computes a type-level NOT for a tuple of types.
|
|
80
|
-
*
|
|
81
|
-
* Truth table for 3 arguments:
|
|
82
|
-
*
|
|
83
|
-
* A B C = NOT
|
|
84
|
-
* 1 1 1 = 0
|
|
85
|
-
* 1 1 0 = 0
|
|
86
|
-
* 1 0 1 = 0
|
|
87
|
-
* 1 0 0 = 0
|
|
88
|
-
* 0 1 1 = 0
|
|
89
|
-
* 0 1 0 = 0
|
|
90
|
-
* 0 0 1 = 0
|
|
91
|
-
* 0 0 0 = 1
|
|
92
|
-
*
|
|
93
|
-
* @template T - Tuple of boolean-like types (1/0)
|
|
94
|
-
*/
|
|
95
|
-
export type NOT<T> = {
|
|
96
|
-
[P in keyof T]?: never;
|
|
97
|
-
};
|
|
98
|
-
/**
|
|
99
|
-
* Computes a type-level NAND for a tuple of types.
|
|
100
|
-
*
|
|
101
|
-
* Truth table for 3 arguments:
|
|
102
|
-
*
|
|
103
|
-
* A B C = NAND
|
|
104
|
-
* 1 1 1 = 0
|
|
105
|
-
* 1 1 0 = 1
|
|
106
|
-
* 1 0 1 = 1
|
|
107
|
-
* 1 0 0 = 1
|
|
108
|
-
* 0 1 1 = 1
|
|
109
|
-
* 0 1 0 = 1
|
|
110
|
-
* 0 0 1 = 1
|
|
111
|
-
* 0 0 0 = 1
|
|
112
|
-
*
|
|
113
|
-
* @template T - Tuple of boolean-like types (1/0)
|
|
114
|
-
*/
|
|
115
|
-
export type NAND<T extends any[]> = NOT<AND<T>>;
|
|
116
|
-
/**
|
|
117
|
-
* Computes a type-level NOR for a tuple of types.
|
|
118
|
-
*
|
|
119
|
-
* Truth table for 3 arguments:
|
|
120
|
-
*
|
|
121
|
-
* A B C = NOR
|
|
122
|
-
* 1 1 1 = 0
|
|
123
|
-
* 1 1 0 = 0
|
|
124
|
-
* 1 0 1 = 0
|
|
125
|
-
* 1 0 0 = 0
|
|
126
|
-
* 0 1 1 = 0
|
|
127
|
-
* 0 1 0 = 0
|
|
128
|
-
* 0 0 1 = 0
|
|
129
|
-
* 0 0 0 = 1
|
|
130
|
-
*
|
|
131
|
-
* @template T - Tuple of boolean-like types (1/0)
|
|
132
|
-
*/
|
|
133
|
-
export type NOR<T extends any[]> = NOT<OR<T>>;
|
package/dist/types/gates.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/dist/types/guards.d.ts
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
export type Primitive = string | number | bigint | boolean | symbol | null | undefined;
|
|
2
|
-
export type Falsy = false | '' | 0 | null | undefined;
|
|
3
|
-
export declare const isFalsy: (val: unknown) => val is Falsy;
|
|
4
|
-
export declare const isNullish: (val: unknown) => val is null | undefined;
|
|
5
|
-
export declare const isPrimitive: (val: unknown) => val is Primitive;
|
|
6
|
-
export declare function isPlainObject(value: unknown): value is Record<string, any>;
|
package/dist/types/guards.js
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
export const isFalsy = (val) => !val;
|
|
2
|
-
export const isNullish = (val) => val == null;
|
|
3
|
-
export const isPrimitive = (val) => {
|
|
4
|
-
if (val === null || val === undefined) {
|
|
5
|
-
return true;
|
|
6
|
-
}
|
|
7
|
-
switch (typeof val) {
|
|
8
|
-
case 'string':
|
|
9
|
-
case 'number':
|
|
10
|
-
case 'bigint':
|
|
11
|
-
case 'boolean':
|
|
12
|
-
case 'symbol': {
|
|
13
|
-
return true;
|
|
14
|
-
}
|
|
15
|
-
default:
|
|
16
|
-
return false;
|
|
17
|
-
}
|
|
18
|
-
};
|
|
19
|
-
export function isPlainObject(value) {
|
|
20
|
-
if (typeof value !== 'object' || value === null) {
|
|
21
|
-
return false;
|
|
22
|
-
}
|
|
23
|
-
if (Object.prototype.toString.call(value) !== '[object Object]') {
|
|
24
|
-
return false;
|
|
25
|
-
}
|
|
26
|
-
// Objects with null prototype are still plain objects
|
|
27
|
-
const proto = Object.getPrototypeOf(value);
|
|
28
|
-
return proto === null || proto === Object.prototype;
|
|
29
|
-
}
|
package/dist/types/index.d.ts
DELETED
package/dist/types/index.js
DELETED
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
export type Keys<T extends object> = keyof T;
|
|
2
|
-
export type Values<T extends object> = T[keyof T];
|
|
3
|
-
export type DeepPartial<T> = T extends Function ? T : T extends Array<infer U> ? Array<DeepPartial<U>> : T extends object ? {
|
|
4
|
-
[K in keyof T]?: DeepPartial<T[K]>;
|
|
5
|
-
} : T;
|
|
6
|
-
export type SelectivePartial<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
|
|
7
|
-
export type DeepRequired<T> = T extends Function ? T : T extends Array<infer U> ? Array<DeepRequired<U>> : T extends object ? {
|
|
8
|
-
[K in keyof T]-?: DeepRequired<T[K]>;
|
|
9
|
-
} : T;
|
|
10
|
-
export type SelectiveRequired<T, K extends keyof T> = Omit<T, K> & Required<Pick<T, K>>;
|
|
11
|
-
export type Never<T> = {
|
|
12
|
-
[K in keyof T]: never;
|
|
13
|
-
};
|
|
14
|
-
export type Nullable<T> = T extends object ? {
|
|
15
|
-
[P in keyof T]: Nullable<T[P]>;
|
|
16
|
-
} : T | null;
|
|
17
|
-
export type Optional<T> = T extends object ? {
|
|
18
|
-
[P in keyof T]: Optional<T[P]>;
|
|
19
|
-
} : T | undefined;
|
|
20
|
-
export type Nullish<T> = T extends object ? {
|
|
21
|
-
[P in keyof T]: Nullish<T[P]>;
|
|
22
|
-
} : T | null | undefined;
|
|
23
|
-
export type Maybe<T> = T extends object ? {
|
|
24
|
-
[P in keyof T]?: Nullish<T[P]>;
|
|
25
|
-
} : T | null | undefined;
|
|
26
|
-
export type DeepReadonly<T> = T extends Function ? T : T extends Array<infer U> ? ReadonlyArray<DeepReadonly<U>> : T extends object ? {
|
|
27
|
-
readonly [K in keyof T]: DeepReadonly<T[K]>;
|
|
28
|
-
} : T;
|
|
29
|
-
export type Mutable<T> = {
|
|
30
|
-
-readonly [P in keyof T]: T[P];
|
|
31
|
-
};
|
|
32
|
-
export type KeysOfType<T, U> = {
|
|
33
|
-
[K in keyof T]: T[K] extends U ? K : never;
|
|
34
|
-
}[keyof T];
|
|
35
|
-
export type OmitByType<T, U> = {
|
|
36
|
-
[K in keyof T as T[K] extends U ? never : K]: T[K];
|
|
37
|
-
};
|
|
38
|
-
export type RequiredKeys<T, K extends keyof T> = Omit<T, K> & Required<Pick<T, K>>;
|
|
39
|
-
export type Diff<T, U> = Omit<T, keyof U> & Omit<U, keyof T>;
|
|
40
|
-
export type Intersection<T extends object, U extends object> = Pick<T, Extract<keyof T, keyof U> & Extract<keyof U, keyof T>>;
|
|
41
|
-
export type Merge<T extends object, U extends object, I = Diff<T, U> & Intersection<U, T> & Diff<U, T>> = Pick<I, keyof I>;
|
|
42
|
-
export type Substract<T extends object, U extends object> = Omit<T, keyof U>;
|
|
43
|
-
export type AllOrNone<T> = T | {
|
|
44
|
-
[P in keyof T]?: never;
|
|
45
|
-
};
|
|
46
|
-
export type OneOf<T> = {
|
|
47
|
-
[K in keyof T]: Pick<T, K>;
|
|
48
|
-
}[keyof T];
|
|
49
|
-
export type TwoOf<T> = {
|
|
50
|
-
[K in keyof T]: {
|
|
51
|
-
[L in Exclude<keyof T, K>]: Pick<T, K | L>;
|
|
52
|
-
}[Exclude<keyof T, K>];
|
|
53
|
-
}[keyof T];
|
|
54
|
-
export type Prettify<T> = {
|
|
55
|
-
[K in keyof T]: T[K];
|
|
56
|
-
} & {};
|
|
57
|
-
export type NestedKeyOf<ObjectType extends object, IgnoreKeys extends string = never> = {
|
|
58
|
-
[Key in keyof ObjectType & string]: Key extends IgnoreKeys ? never : ObjectType[Key] extends object ? ObjectType[Key] extends Array<any> ? Key : `${Key}` | `${Key}.${NestedKeyOf<ObjectType[Key], IgnoreKeys>}` : `${Key}`;
|
|
59
|
-
}[keyof ObjectType & string];
|
|
60
|
-
export type Without<T, U> = {
|
|
61
|
-
[P in Exclude<keyof T, keyof U>]?: never;
|
|
62
|
-
};
|
package/dist/types/utilities.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|