@nemigo/helpers 0.1.0 → 0.2.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/dist/async.d.ts +2 -2
- package/dist/async.js +2 -2
- package/dist/format.js +1 -1
- package/dist/html.d.ts +1 -1
- package/dist/xod.d.ts +7 -5
- package/dist/xod.js +7 -5
- package/package.json +1 -1
package/dist/async.d.ts
CHANGED
|
@@ -25,10 +25,10 @@ export declare const debounce: <T extends (...args: any[]) => any>(call: T, dela
|
|
|
25
25
|
*
|
|
26
26
|
* mode = `"urgent"`:
|
|
27
27
|
* - первый вызов исполняется сразу
|
|
28
|
-
* - повторные вызовы возвращают тот же
|
|
28
|
+
* - повторные вызовы возвращают тот же промисс в течение `ms` (даже после завершения)
|
|
29
29
|
* - после `ms` можно снова вызвать
|
|
30
30
|
*/
|
|
31
|
-
export declare const
|
|
31
|
+
export declare const throttle: <F extends (...args: any[]) => any>(call: F, mode: "urgent" | "delay", ms: number) => ((...args: Parameters<F>) => Promise<Awaited<ReturnType<F>>>);
|
|
32
32
|
/**
|
|
33
33
|
* Создаёт функцию-замыкание, которая гарантирует однократное выполнение асинхронной операции
|
|
34
34
|
*
|
package/dist/async.js
CHANGED
|
@@ -32,10 +32,10 @@ export const debounce = (call, delay) => {
|
|
|
32
32
|
*
|
|
33
33
|
* mode = `"urgent"`:
|
|
34
34
|
* - первый вызов исполняется сразу
|
|
35
|
-
* - повторные вызовы возвращают тот же
|
|
35
|
+
* - повторные вызовы возвращают тот же промисс в течение `ms` (даже после завершения)
|
|
36
36
|
* - после `ms` можно снова вызвать
|
|
37
37
|
*/
|
|
38
|
-
export const
|
|
38
|
+
export const throttle = (call, mode, ms) => {
|
|
39
39
|
let _promise = null;
|
|
40
40
|
let _args = [];
|
|
41
41
|
return (...args) => {
|
package/dist/format.js
CHANGED
|
@@ -7,7 +7,7 @@ export const FormatNumberRegExp = /\B(?=(\d{3})+(?!\d))/g;
|
|
|
7
7
|
* @example "1 234" или "1 234,56"
|
|
8
8
|
*/
|
|
9
9
|
export const formatNumber = (amount, { fraction = 2, fallback = "---", zero = "value", postfix } = {}) => caseNumber(amount, (v) => {
|
|
10
|
-
if (v ===
|
|
10
|
+
if (v === null)
|
|
11
11
|
return zero === "always" ? (postfix ? "0 " + postfix : "0") : fallback;
|
|
12
12
|
if (v === 0)
|
|
13
13
|
return zero === "never" ? fallback : postfix ? "0 " + postfix : "0";
|
package/dist/html.d.ts
CHANGED
package/dist/xod.d.ts
CHANGED
|
@@ -15,10 +15,12 @@ declare const _default: {
|
|
|
15
15
|
message: string;
|
|
16
16
|
expected: string;
|
|
17
17
|
}) => never;
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
18
|
+
null: z.ZodPipe<z.ZodOptional<z.ZodNull>, z.ZodTransform<undefined, null | undefined>>;
|
|
19
|
+
boolean: z.ZodPipe<z.ZodBoolean, z.ZodTransform<boolean, boolean>>;
|
|
20
|
+
booleanOptional: z.ZodUnion<readonly [z.ZodPipe<z.ZodOptional<z.ZodNull>, z.ZodTransform<undefined, null | undefined>>, z.ZodPipe<z.ZodBoolean, z.ZodTransform<boolean, boolean>>]>;
|
|
21
|
+
number: z.ZodPipe<z.ZodUnion<[z.ZodNumber, z.ZodString]>, z.ZodTransform<number, string | number>>;
|
|
22
|
+
numberOptional: z.ZodUnion<readonly [z.ZodPipe<z.ZodOptional<z.ZodNull>, z.ZodTransform<undefined, null | undefined>>, z.ZodPipe<z.ZodUnion<[z.ZodNumber, z.ZodString]>, z.ZodTransform<number, string | number>>]>;
|
|
23
|
+
string: z.ZodUnion<[z.ZodString, z.ZodPipe<z.ZodNumber, z.ZodTransform<string, number>>]>;
|
|
24
|
+
stringOptional: z.ZodUnion<readonly [z.ZodPipe<z.ZodOptional<z.ZodNull>, z.ZodTransform<undefined, null | undefined>>, z.ZodUnion<[z.ZodString, z.ZodPipe<z.ZodNumber, z.ZodTransform<string, number>>]>]>;
|
|
23
25
|
};
|
|
24
26
|
export default _default;
|
package/dist/xod.js
CHANGED
|
@@ -53,9 +53,11 @@ export const stringSchemaOptional = z.union([nullSchema, stringSchema]);
|
|
|
53
53
|
//...
|
|
54
54
|
export default {
|
|
55
55
|
invalid,
|
|
56
|
-
nullSchema,
|
|
57
|
-
booleanSchema,
|
|
58
|
-
booleanSchemaOptional,
|
|
59
|
-
numberSchema,
|
|
60
|
-
numberSchemaOptional,
|
|
56
|
+
null: nullSchema,
|
|
57
|
+
boolean: booleanSchema,
|
|
58
|
+
booleanOptional: booleanSchemaOptional,
|
|
59
|
+
number: numberSchema,
|
|
60
|
+
numberOptional: numberSchemaOptional,
|
|
61
|
+
string: stringSchema,
|
|
62
|
+
stringOptional: stringSchemaOptional,
|
|
61
63
|
};
|