@nemigo/helpers 0.2.2 → 0.3.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/format.d.ts +6 -0
- package/dist/format.js +6 -0
- package/dist/queue.d.ts +4 -0
- package/dist/queue.js +11 -5
- package/package.json +1 -1
package/dist/format.d.ts
CHANGED
|
@@ -28,3 +28,9 @@ 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
|
+
/**
|
|
32
|
+
* Форматирование в RUB-формат
|
|
33
|
+
*
|
|
34
|
+
* @example "1 234 ₽" или "1 234,56 ₽"
|
|
35
|
+
*/
|
|
36
|
+
export declare const formatRUB: (amount: CanBeNullable<number | string>, { fraction, fallback, zero }?: Omit<FormatNumberConfig, "postfix">) => string;
|
package/dist/format.js
CHANGED
|
@@ -18,3 +18,9 @@ export const formatNumber = (amount, { fraction = 2, fallback = "---", zero = "v
|
|
|
18
18
|
const formatted = fractional ? `${result},${fractional}` : result;
|
|
19
19
|
return postfix ? formatted + " " + postfix : formatted;
|
|
20
20
|
});
|
|
21
|
+
/**
|
|
22
|
+
* Форматирование в RUB-формат
|
|
23
|
+
*
|
|
24
|
+
* @example "1 234 ₽" или "1 234,56 ₽"
|
|
25
|
+
*/
|
|
26
|
+
export const formatRUB = (amount, { fraction = 2, fallback = "---", zero = "value" } = {}) => formatNumber(amount, { fraction, fallback, zero, postfix: "₽" });
|
package/dist/queue.d.ts
CHANGED
package/dist/queue.js
CHANGED
|
@@ -27,22 +27,28 @@ export class Queue {
|
|
|
27
27
|
* Запускает обработку очереди с задержкой
|
|
28
28
|
*/
|
|
29
29
|
run() {
|
|
30
|
-
this.
|
|
30
|
+
this.stop();
|
|
31
31
|
this.timeout = setTimeout(() => {
|
|
32
32
|
if (this._queue.length === 0)
|
|
33
|
-
return this.
|
|
33
|
+
return this.stop();
|
|
34
34
|
const item = this._queue.shift();
|
|
35
35
|
this.handle(item);
|
|
36
|
-
this._queue.length > 0 ? this.run() : this.
|
|
36
|
+
this._queue.length > 0 ? this.run() : this.stop();
|
|
37
37
|
}, this._delay);
|
|
38
38
|
}
|
|
39
39
|
/**
|
|
40
|
-
* Сброс
|
|
40
|
+
* Сброс таймера шага
|
|
41
41
|
*/
|
|
42
|
-
|
|
42
|
+
stop() {
|
|
43
43
|
if (this.timeout)
|
|
44
44
|
clearTimeout(this.timeout);
|
|
45
45
|
this.timeout = 0;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Сброс очереди
|
|
49
|
+
*/
|
|
50
|
+
reset() {
|
|
51
|
+
this.stop();
|
|
46
52
|
this._queue.length = 0;
|
|
47
53
|
}
|
|
48
54
|
}
|