@nemigo/helpers 0.2.0 → 0.2.2

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.js CHANGED
@@ -16,6 +16,7 @@ export const delay = (ms) => new Promise((ready) => setTimeout(ready, ms));
16
16
  export const debounce = (call, delay) => {
17
17
  let timeout;
18
18
  return (...args) => {
19
+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
19
20
  if (timeout)
20
21
  clearTimeout(timeout);
21
22
  timeout = setTimeout(() => call(...args), delay);
package/dist/datetime.js CHANGED
@@ -99,7 +99,9 @@ export const formatDateTime = (datetime = Date.now(), format = "DD.DM.DY TH:TM")
99
99
  * const timestamp = toTimeStamp("11.02.2012", "13:45");
100
100
  * console.log(timestamp); // Выведет {@link Timestamp} для "11.02.2012 13:45"
101
101
  */
102
- export const toTimeStamp = (date, time = "00:00") => {
102
+ export const toTimeStamp =
103
+ // eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents
104
+ (date, time = "00:00") => {
103
105
  const [day, month, year] = date.split(".").map(Number);
104
106
  const [hours, minutes] = time.split(":").map(Number);
105
107
  // Проверка на корректность ввода (если хотя бы одно значение не число)
package/dist/format.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import type { CanBeNullable } from "./types.js";
2
- interface FormatNumberConfig {
2
+ export interface FormatNumberConfig {
3
3
  /**
4
4
  * @default 2
5
5
  */
@@ -28,4 +28,3 @@ export declare const FormatNumberRegExp: RegExp;
28
28
  * @example "1 234" или "1 234,56"
29
29
  */
30
30
  export declare const formatNumber: (amount: CanBeNullable<number | string>, { fraction, fallback, zero, postfix }?: FormatNumberConfig) => string;
31
- export {};
package/dist/html.js CHANGED
@@ -26,26 +26,26 @@ export const preventStopHook = (call, load) => (e) => {
26
26
  */
27
27
  export const enterKeyHook = (call, config = { usePreventStop: "enter" }) => (e) => {
28
28
  const isEnter = e.key === "Enter";
29
- if (config?.usePreventStop === "enter") {
29
+ if (config.usePreventStop === "enter") {
30
30
  if (isEnter)
31
31
  preventStop(e);
32
32
  }
33
33
  else {
34
- if (config?.usePreventStop !== undefined) {
35
- if (typeof config?.usePreventStop === "boolean") {
36
- if (config?.usePreventStop)
34
+ if (config.usePreventStop !== undefined) {
35
+ if (typeof config.usePreventStop === "boolean") {
36
+ if (config.usePreventStop)
37
37
  preventStop(e);
38
38
  }
39
39
  else {
40
- if (config?.usePreventStop(e, isEnter))
40
+ if (config.usePreventStop(e, isEnter))
41
41
  preventStop(e);
42
42
  }
43
43
  }
44
44
  }
45
- if (config?.load?.())
45
+ if (config.load?.())
46
46
  return;
47
- if (config?.prepare) {
48
- Promise.resolve(config?.prepare?.(e)).then((next) => {
47
+ if (config.prepare) {
48
+ void Promise.resolve(config.prepare(e)).then((next) => {
49
49
  if (next && isEnter)
50
50
  call?.(e);
51
51
  });
package/dist/url.js CHANGED
@@ -24,10 +24,10 @@ export const pushParams = (url, params, unsafe = false) => {
24
24
  url.searchParams.set(param, unsafe ? "" : "true");
25
25
  continue;
26
26
  }
27
- if (!param?.key)
27
+ if (!param.key)
28
28
  continue;
29
29
  if (typeof param.value !== "object") {
30
- if (unsafe && (param?.value === undefined || param.value === true || param.value === "")) {
30
+ if (unsafe && (param.value === undefined || param.value === true || param.value === "")) {
31
31
  url.searchParams.set(param.key, "");
32
32
  }
33
33
  else {
@@ -66,9 +66,9 @@ export const mergePushParams = (...args) => {
66
66
  acc.push({ key: param, value: true });
67
67
  continue;
68
68
  }
69
- if (!param?.key)
69
+ if (!param.key)
70
70
  continue;
71
- if (typeof param?.value !== "object") {
71
+ if (typeof param.value !== "object") {
72
72
  const existed = acc.find((v) => v.key === param.key);
73
73
  if (param.value === undefined || param.value === true || param.value === "") {
74
74
  if (existed)
@@ -107,7 +107,7 @@ export const clearParams = (url, params) => {
107
107
  url.searchParams.delete(param);
108
108
  continue;
109
109
  }
110
- if (param?.key)
110
+ if (param.key)
111
111
  url.searchParams.delete(param.key);
112
112
  }
113
113
  return url;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nemigo/helpers",
3
- "version": "0.2.0",
3
+ "version": "0.2.2",
4
4
  "private": false,
5
5
  "author": {
6
6
  "name": "Vlad Logvin",