@nemigo/helpers 0.0.20 → 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 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
- * - повторные вызовы возвращают тот же промиcс в течение `ms` (даже после завершения)
28
+ * - повторные вызовы возвращают тот же промисс в течение `ms` (даже после завершения)
29
29
  * - после `ms` можно снова вызвать
30
30
  */
31
- export declare const trottling: <F extends (...args: any[]) => any>(call: F, mode: "urgent" | "delay", ms: number) => ((...args: Parameters<F>) => Promise<Awaited<ReturnType<F>>>);
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
- * - повторные вызовы возвращают тот же промиcс в течение `ms` (даже после завершения)
35
+ * - повторные вызовы возвращают тот же промисс в течение `ms` (даже после завершения)
36
36
  * - после `ms` можно снова вызвать
37
37
  */
38
- export const trottling = (call, mode, ms) => {
38
+ export const throttle = (call, mode, ms) => {
39
39
  let _promise = null;
40
40
  let _args = [];
41
41
  return (...args) => {
package/dist/datetime.js CHANGED
@@ -86,6 +86,7 @@ export const formatDateTime = (datetime = Date.now(), format = "DD.DM.DY TH:TM")
86
86
  }
87
87
  return result.join("");
88
88
  };
89
+ //...
89
90
  /**
90
91
  * Конвертирует строковые представления даты и времени в {@link Timestamp}
91
92
  *
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 === undefined)
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
@@ -1,4 +1,4 @@
1
- import type { CanBeNullable, CanBePromise, KEYS } from "./types";
1
+ import type { CanBeNullable, CanBePromise, KEYS } from "./types.js";
2
2
  /**
3
3
  * Проверка по глобальному `window`
4
4
  */
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
- nullSchema: z.ZodPipe<z.ZodOptional<z.ZodNull>, z.ZodTransform<undefined, null | undefined>>;
19
- booleanSchema: z.ZodPipe<z.ZodBoolean, z.ZodTransform<boolean, boolean>>;
20
- booleanSchemaOptional: z.ZodUnion<readonly [z.ZodPipe<z.ZodOptional<z.ZodNull>, z.ZodTransform<undefined, null | undefined>>, z.ZodPipe<z.ZodBoolean, z.ZodTransform<boolean, boolean>>]>;
21
- numberSchema: z.ZodPipe<z.ZodUnion<[z.ZodNumber, z.ZodString]>, z.ZodTransform<number, string | number>>;
22
- numberSchemaOptional: 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>>]>;
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
@@ -43,9 +43,9 @@ export const numberSchema = z.unknown().transform((value, ctx) => caseNumber(val
43
43
  : result));
44
44
  export const numberSchemaOptional = z.union([nullSchema, numberSchema]);
45
45
  //...
46
- export const stringSchema = z.unknown().transform((value, ctx) => caseString(value, (result) => result === null
46
+ export const stringSchema = z.unknown().transform((value, ctx) => caseString(value, (result) => result === null || result === ""
47
47
  ? invalid(value, ctx, {
48
- message: "It isn't a string",
48
+ message: "It isn't a string or empty string",
49
49
  expected: "string (or number)",
50
50
  })
51
51
  : result));
@@ -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
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nemigo/helpers",
3
- "version": "0.0.20",
3
+ "version": "0.2.0",
4
4
  "private": false,
5
5
  "author": {
6
6
  "name": "Vlad Logvin",