@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 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
@@ -28,6 +28,10 @@ export declare abstract class Queue<T> {
28
28
  * @param item - Элемент для обработки
29
29
  */
30
30
  protected abstract handle(item: T): void;
31
+ /**
32
+ * Сброс таймера шага
33
+ */
34
+ private stop;
31
35
  /**
32
36
  * Сброс очереди
33
37
  */
package/dist/queue.js CHANGED
@@ -27,22 +27,28 @@ export class Queue {
27
27
  * Запускает обработку очереди с задержкой
28
28
  */
29
29
  run() {
30
- this.reset();
30
+ this.stop();
31
31
  this.timeout = setTimeout(() => {
32
32
  if (this._queue.length === 0)
33
- return this.reset();
33
+ return this.stop();
34
34
  const item = this._queue.shift();
35
35
  this.handle(item);
36
- this._queue.length > 0 ? this.run() : this.reset();
36
+ this._queue.length > 0 ? this.run() : this.stop();
37
37
  }, this._delay);
38
38
  }
39
39
  /**
40
- * Сброс очереди
40
+ * Сброс таймера шага
41
41
  */
42
- reset() {
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
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nemigo/helpers",
3
- "version": "0.2.2",
3
+ "version": "0.3.1",
4
4
  "private": false,
5
5
  "author": {
6
6
  "name": "Vlad Logvin",