@neovici/cosmoz-utils 6.22.1 → 6.22.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.
Files changed (2) hide show
  1. package/dist/promise.js +6 -9
  2. package/package.json +1 -1
package/dist/promise.js CHANGED
@@ -51,19 +51,16 @@ export const limit$ = (fn, limit) => {
51
51
  };
52
52
  export const debounce$ = (fn, ms) => {
53
53
  let timeoutId;
54
- const pending = [];
54
+ let resolve = null;
55
+ let reject = null;
55
56
  return (...args) => new Promise((res, rej) => {
56
57
  clearTimeout(timeoutId);
58
+ resolve = res;
59
+ reject = rej;
57
60
  timeoutId = setTimeout(() => {
58
- const currentPending = [...pending];
59
- pending.length = 0;
60
- Promise.resolve(fn(...args)).then((data) => {
61
- currentPending.forEach(({ resolve }) => resolve(data));
62
- }, (error) => {
63
- currentPending.forEach(({ reject }) => reject(error));
64
- });
61
+ Promise.resolve(fn(...args)).then(resolve, reject);
62
+ resolve = reject = null;
65
63
  }, ms);
66
- pending.push({ resolve: res, reject: rej });
67
64
  });
68
65
  };
69
66
  export const log$ = (fn) => (...args) => fn(...args).then((response) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@neovici/cosmoz-utils",
3
- "version": "6.22.1",
3
+ "version": "6.22.2",
4
4
  "description": "Date, money and template management functions commonly needed in Cosmoz views.",
5
5
  "keywords": [
6
6
  "polymer",