@nemigo/helpers 2.2.0 → 2.2.1
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/queue.d.ts +1 -1
- package/dist/async/queue.js +1 -1
- package/dist/emitter.js +2 -4
- package/dist/mutate.js +2 -4
- package/dist/omitter.js +4 -8
- package/dist/promoter.js +2 -4
- package/dist/script.js +2 -10
- package/dist/xod.d.ts +0 -1
- package/dist/xod.js +0 -2
- package/package.json +2 -2
package/dist/async/queue.d.ts
CHANGED
|
@@ -14,7 +14,7 @@ export type QueueHandler<T> = (item: T, abort: () => void) => CanBePromise;
|
|
|
14
14
|
* const queue = new Queue(async (url, abort) => {
|
|
15
15
|
* try {
|
|
16
16
|
* await fetch(url);
|
|
17
|
-
* } catch
|
|
17
|
+
* } catch {
|
|
18
18
|
* abort(); // прекращает обработку оставшихся URL
|
|
19
19
|
* }
|
|
20
20
|
* }, 50);
|
package/dist/async/queue.js
CHANGED
package/dist/emitter.js
CHANGED
|
@@ -6,14 +6,12 @@
|
|
|
6
6
|
export class Emitter {
|
|
7
7
|
__listeners = new Map();
|
|
8
8
|
dispatch(event, data) {
|
|
9
|
-
|
|
10
|
-
// eslint-disable-next-line unicorn/no-array-for-each
|
|
11
|
-
this.__listeners.forEach((handler, key) => {
|
|
9
|
+
for (const [key, handler] of this.__listeners.entries()) {
|
|
12
10
|
if (event === handler.event)
|
|
13
11
|
handler.callback(data);
|
|
14
12
|
if (handler.once)
|
|
15
13
|
this.__listeners.delete(key);
|
|
16
|
-
}
|
|
14
|
+
}
|
|
17
15
|
}
|
|
18
16
|
/**
|
|
19
17
|
* @param event - Ключ события
|
package/dist/mutate.js
CHANGED
|
@@ -78,9 +78,7 @@ export const deepMutateArray = (source, target) => {
|
|
|
78
78
|
source.splice(target.length, source.length - target.length);
|
|
79
79
|
}
|
|
80
80
|
// Обновление элементов
|
|
81
|
-
|
|
82
|
-
// eslint-disable-next-line unicorn/no-array-for-each
|
|
83
|
-
target.forEach((targetItem, index) => {
|
|
81
|
+
for (const [index, targetItem] of target.entries()) {
|
|
84
82
|
const sourceItem = source[index];
|
|
85
83
|
if (Array.isArray(targetItem)) {
|
|
86
84
|
if (!Array.isArray(sourceItem))
|
|
@@ -95,7 +93,7 @@ export const deepMutateArray = (source, target) => {
|
|
|
95
93
|
else if (sourceItem !== targetItem) {
|
|
96
94
|
source[index] = targetItem;
|
|
97
95
|
}
|
|
98
|
-
}
|
|
96
|
+
}
|
|
99
97
|
// Добавление новых элементов
|
|
100
98
|
while (source.length < target.length) {
|
|
101
99
|
source.push(target[source.length]);
|
package/dist/omitter.js
CHANGED
|
@@ -41,18 +41,14 @@ export class Omitter {
|
|
|
41
41
|
const keys = Object.keys(obj);
|
|
42
42
|
if (schema < keys.length) {
|
|
43
43
|
// Стратегия по схеме: итерируемся по ключам схемы
|
|
44
|
-
|
|
45
|
-
// eslint-disable-next-line unicorn/no-array-for-each
|
|
46
|
-
structure.keys.forEach((key) => {
|
|
44
|
+
for (const key of structure.keys) {
|
|
47
45
|
delete obj[key];
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
// eslint-disable-next-line unicorn/no-array-for-each
|
|
51
|
-
structure.nested.forEach((omitter, key) => {
|
|
46
|
+
}
|
|
47
|
+
for (const [key, omitter] of structure.nested.entries()) {
|
|
52
48
|
const nested = obj[key];
|
|
53
49
|
if (nested && typeof nested === "object")
|
|
54
50
|
omitter.#process(nested, omitter.__structure);
|
|
55
|
-
}
|
|
51
|
+
}
|
|
56
52
|
}
|
|
57
53
|
else {
|
|
58
54
|
// Стратегия по объекту: итерируемся по ключам объекта
|
package/dist/promoter.js
CHANGED
|
@@ -4,13 +4,11 @@
|
|
|
4
4
|
export class Promoter {
|
|
5
5
|
__subs = new Map();
|
|
6
6
|
notify(event) {
|
|
7
|
-
|
|
8
|
-
// eslint-disable-next-line unicorn/no-array-for-each
|
|
9
|
-
this.__subs.forEach(({ callback, once }, key) => {
|
|
7
|
+
for (const [key, { callback, once }] of this.__subs.entries()) {
|
|
10
8
|
callback(event);
|
|
11
9
|
if (once)
|
|
12
10
|
this.__subs.delete(key);
|
|
13
|
-
}
|
|
11
|
+
}
|
|
14
12
|
}
|
|
15
13
|
/**
|
|
16
14
|
* @param callback - Функция подписчика
|
package/dist/script.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
/* eslint-disable no-console */
|
|
2
|
+
// oxlint-disable no-console
|
|
1
3
|
import { exec } from "node:child_process";
|
|
2
4
|
import { MS_IN_MINUTE } from "./datetime/delta.js";
|
|
3
5
|
/**
|
|
@@ -60,8 +62,6 @@ export { getProcessFlag };
|
|
|
60
62
|
* ```
|
|
61
63
|
*/
|
|
62
64
|
export const execute = (path, command, { logger = {}, timeout = 5 * MS_IN_MINUTE } = {}) => new Promise((resolve, reject) => {
|
|
63
|
-
// oxlint-disable-next-line no-console
|
|
64
|
-
// eslint-disable-next-line no-console
|
|
65
65
|
if (logger.before)
|
|
66
66
|
console.log(logger.before(path));
|
|
67
67
|
let process = null;
|
|
@@ -75,8 +75,6 @@ export const execute = (path, command, { logger = {}, timeout = 5 * MS_IN_MINUTE
|
|
|
75
75
|
if (timeout) {
|
|
76
76
|
timer = setTimeout(() => {
|
|
77
77
|
process?.kill("SIGTERM");
|
|
78
|
-
// oxlint-disable-next-line no-console
|
|
79
|
-
// eslint-disable-next-line no-console
|
|
80
78
|
if (logger.ontimeout)
|
|
81
79
|
console.error(logger.ontimeout());
|
|
82
80
|
reject(new Error("TIMEOUT"));
|
|
@@ -84,17 +82,11 @@ export const execute = (path, command, { logger = {}, timeout = 5 * MS_IN_MINUTE
|
|
|
84
82
|
}
|
|
85
83
|
process = exec(command, { cwd: path }, (error, stdout, stderr) => {
|
|
86
84
|
cleanup();
|
|
87
|
-
// oxlint-disable-next-line no-console
|
|
88
|
-
// eslint-disable-next-line no-console
|
|
89
85
|
if (stderr)
|
|
90
86
|
console.warn(stderr);
|
|
91
|
-
// oxlint-disable-next-line no-console
|
|
92
|
-
// eslint-disable-next-line no-console
|
|
93
87
|
if (stdout)
|
|
94
88
|
console.log(stdout);
|
|
95
89
|
if (error) {
|
|
96
|
-
// oxlint-disable-next-line no-console
|
|
97
|
-
// eslint-disable-next-line no-console
|
|
98
90
|
if (logger.onerror)
|
|
99
91
|
console.error(logger.onerror(error));
|
|
100
92
|
reject(error);
|
package/dist/xod.d.ts
CHANGED
package/dist/xod.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nemigo/helpers",
|
|
3
|
-
"version": "2.2.
|
|
3
|
+
"version": "2.2.1",
|
|
4
4
|
"private": false,
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Vlad Logvin",
|
|
@@ -206,6 +206,6 @@
|
|
|
206
206
|
"@std/msgpack": "npm:@jsr/std__msgpack"
|
|
207
207
|
},
|
|
208
208
|
"devDependencies": {
|
|
209
|
-
"@nemigo/configs": "2.2.
|
|
209
|
+
"@nemigo/configs": "2.2.3"
|
|
210
210
|
}
|
|
211
211
|
}
|