@webalternatif/js-core 1.1.2 → 1.2.0

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 (117) hide show
  1. package/dist/cjs/array.js +46 -46
  2. package/dist/cjs/dom.js +154 -123
  3. package/dist/cjs/eventDispatcher.js +126 -86
  4. package/dist/cjs/i18n/agenda/en.js +65 -0
  5. package/dist/cjs/i18n/agenda/fr.js +67 -0
  6. package/dist/cjs/i18n/agenda/index.js +2 -0
  7. package/dist/cjs/i18n/ajaxform/en.js +5 -0
  8. package/dist/cjs/i18n/ajaxform/fr.js +5 -0
  9. package/dist/cjs/i18n/ajaxform/index.js +2 -0
  10. package/dist/cjs/i18n/ajaxupload/en.js +11 -0
  11. package/dist/cjs/i18n/ajaxupload/fr.js +11 -0
  12. package/dist/cjs/i18n/ajaxupload/index.js +2 -0
  13. package/dist/cjs/i18n/autocomplete/en.js +3 -0
  14. package/dist/cjs/i18n/autocomplete/fr.js +3 -0
  15. package/dist/cjs/i18n/autocomplete/index.js +2 -0
  16. package/dist/cjs/i18n/confirm/en.js +5 -0
  17. package/dist/cjs/i18n/confirm/fr.js +5 -0
  18. package/dist/cjs/i18n/confirm/index.js +2 -0
  19. package/dist/cjs/i18n/core/en.js +4 -0
  20. package/dist/cjs/i18n/core/fr.js +4 -0
  21. package/dist/cjs/i18n/core/index.js +2 -0
  22. package/dist/cjs/i18n/datagrid/en.js +8 -0
  23. package/dist/cjs/i18n/datagrid/fr.js +8 -0
  24. package/dist/cjs/i18n/datagrid/index.js +2 -0
  25. package/dist/cjs/i18n/date/en.js +47 -0
  26. package/dist/cjs/i18n/date/fr.js +47 -0
  27. package/dist/cjs/i18n/date/index.js +2 -0
  28. package/dist/cjs/i18n/datetimepicker/en.js +27 -0
  29. package/dist/cjs/i18n/datetimepicker/fr.js +27 -0
  30. package/dist/cjs/i18n/datetimepicker/index.js +2 -0
  31. package/dist/cjs/i18n/dialog/en.js +3 -0
  32. package/dist/cjs/i18n/dialog/fr.js +3 -0
  33. package/dist/cjs/i18n/dialog/index.js +2 -0
  34. package/dist/cjs/i18n/fulldayeventagenda/en.js +65 -0
  35. package/dist/cjs/i18n/fulldayeventagenda/fr.js +67 -0
  36. package/dist/cjs/i18n/fulldayeventagenda/index.js +2 -0
  37. package/dist/cjs/i18n/index.js +30 -0
  38. package/dist/cjs/i18n/richtexteditor/en.js +56 -0
  39. package/dist/cjs/i18n/richtexteditor/fr.js +56 -0
  40. package/dist/cjs/i18n/richtexteditor/index.js +2 -0
  41. package/dist/cjs/i18n/select/en.js +3 -0
  42. package/dist/cjs/i18n/select/fr.js +3 -0
  43. package/dist/cjs/i18n/select/index.js +2 -0
  44. package/dist/cjs/i18n/timepicker/en.js +3 -0
  45. package/dist/cjs/i18n/timepicker/fr.js +3 -0
  46. package/dist/cjs/i18n/timepicker/index.js +2 -0
  47. package/dist/cjs/i18n/useragenda/en.js +65 -0
  48. package/dist/cjs/i18n/useragenda/fr.js +67 -0
  49. package/dist/cjs/i18n/useragenda/index.js +2 -0
  50. package/dist/cjs/i18n.js +16 -25
  51. package/dist/cjs/index.js +24 -54
  52. package/dist/cjs/is.js +26 -45
  53. package/dist/cjs/math.js +27 -38
  54. package/dist/cjs/random.js +10 -23
  55. package/dist/cjs/string.js +162 -166
  56. package/dist/cjs/stringPrototype.js +10 -10
  57. package/dist/cjs/traversal.js +92 -61
  58. package/dist/cjs/utils.js +51 -43
  59. package/dist/esm/array.js +31 -20
  60. package/dist/esm/dom.js +142 -102
  61. package/dist/esm/eventDispatcher.js +123 -77
  62. package/dist/esm/i18n/agenda/en.js +65 -0
  63. package/dist/esm/i18n/agenda/fr.js +67 -0
  64. package/dist/esm/i18n/agenda/index.js +2 -0
  65. package/dist/esm/i18n/ajaxform/en.js +5 -0
  66. package/dist/esm/i18n/ajaxform/fr.js +5 -0
  67. package/dist/esm/i18n/ajaxform/index.js +2 -0
  68. package/dist/esm/i18n/ajaxupload/en.js +11 -0
  69. package/dist/esm/i18n/ajaxupload/fr.js +11 -0
  70. package/dist/esm/i18n/ajaxupload/index.js +2 -0
  71. package/dist/esm/i18n/autocomplete/en.js +3 -0
  72. package/dist/esm/i18n/autocomplete/fr.js +3 -0
  73. package/dist/esm/i18n/autocomplete/index.js +2 -0
  74. package/dist/esm/i18n/confirm/en.js +5 -0
  75. package/dist/esm/i18n/confirm/fr.js +5 -0
  76. package/dist/esm/i18n/confirm/index.js +2 -0
  77. package/dist/esm/i18n/core/en.js +4 -0
  78. package/dist/esm/i18n/core/fr.js +4 -0
  79. package/dist/esm/i18n/core/index.js +2 -0
  80. package/dist/esm/i18n/datagrid/en.js +8 -0
  81. package/dist/esm/i18n/datagrid/fr.js +8 -0
  82. package/dist/esm/i18n/datagrid/index.js +2 -0
  83. package/dist/esm/i18n/date/en.js +47 -0
  84. package/dist/esm/i18n/date/fr.js +47 -0
  85. package/dist/esm/i18n/date/index.js +2 -0
  86. package/dist/esm/i18n/datetimepicker/en.js +27 -0
  87. package/dist/esm/i18n/datetimepicker/fr.js +27 -0
  88. package/dist/esm/i18n/datetimepicker/index.js +2 -0
  89. package/dist/esm/i18n/dialog/en.js +3 -0
  90. package/dist/esm/i18n/dialog/fr.js +3 -0
  91. package/dist/esm/i18n/dialog/index.js +2 -0
  92. package/dist/esm/i18n/fulldayeventagenda/en.js +65 -0
  93. package/dist/esm/i18n/fulldayeventagenda/fr.js +67 -0
  94. package/dist/esm/i18n/fulldayeventagenda/index.js +2 -0
  95. package/dist/esm/i18n/index.js +30 -0
  96. package/dist/esm/i18n/richtexteditor/en.js +56 -0
  97. package/dist/esm/i18n/richtexteditor/fr.js +56 -0
  98. package/dist/esm/i18n/richtexteditor/index.js +2 -0
  99. package/dist/esm/i18n/select/en.js +3 -0
  100. package/dist/esm/i18n/select/fr.js +3 -0
  101. package/dist/esm/i18n/select/index.js +2 -0
  102. package/dist/esm/i18n/timepicker/en.js +3 -0
  103. package/dist/esm/i18n/timepicker/fr.js +3 -0
  104. package/dist/esm/i18n/timepicker/index.js +2 -0
  105. package/dist/esm/i18n/useragenda/en.js +65 -0
  106. package/dist/esm/i18n/useragenda/fr.js +67 -0
  107. package/dist/esm/i18n/useragenda/index.js +2 -0
  108. package/dist/esm/i18n.js +11 -10
  109. package/dist/esm/index.js +14 -13
  110. package/dist/esm/is.js +23 -22
  111. package/dist/esm/math.js +14 -13
  112. package/dist/esm/random.js +9 -9
  113. package/dist/esm/string.js +134 -99
  114. package/dist/esm/stringPrototype.js +8 -5
  115. package/dist/esm/traversal.js +79 -36
  116. package/dist/esm/utils.js +45 -24
  117. package/package.json +3 -2
@@ -1,3 +1,10 @@
1
+ function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
2
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
3
+ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
4
+ function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
5
+ function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t["return"] || t["return"](); } finally { if (u) throw o; } } }; }
6
+ function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
7
+ function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
1
8
  import { isArray, isArrayLike, isBoolean, isObject, isPlainObject, isString, isUndefined } from "./is.js";
2
9
  import { isWindow } from "./dom.js";
3
10
  import { sizeOf } from "./utils.js";
@@ -21,28 +28,48 @@ import { sizeOf } from "./utils.js";
21
28
  * @param {any} [context] Optional "this" binding for the callback
22
29
  * @returns {typeof o} Returns the original input
23
30
  */
24
- export const each = function (o, callback, context) {
31
+ export var each = function each(o, callback, context) {
25
32
  if (isPlainObject(o)) {
26
- let index = -1;
27
- for (let i in o) if (o.hasOwnProperty(i) && false === callback.call(context ?? o[i], i, o[i], o, ++index)) return;
33
+ var index = -1;
34
+ for (var i in o) if (o.hasOwnProperty(i) && false === callback.call(context !== null && context !== void 0 ? context : o[i], i, o[i], o, ++index)) return;
28
35
  } else if (isString(o)) {
29
- const arr = o.split('');
30
- for (let i = 0; i < arr.length; i++) if (false === callback.call(context ?? arr[i], i, arr[i], o, i)) return;
36
+ var arr = o.split('');
37
+ for (var _i = 0; _i < arr.length; _i++) if (false === callback.call(context !== null && context !== void 0 ? context : arr[_i], _i, arr[_i], o, _i)) return;
31
38
  return o;
32
39
  } else if (o instanceof Map) {
33
- let index = 0;
34
- for (const [key, value] of o.entries()) {
35
- if (false === callback.call(context ?? value, key, value, o, index++)) return;
40
+ var _index = 0;
41
+ var _iterator = _createForOfIteratorHelper(o.entries()),
42
+ _step;
43
+ try {
44
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
45
+ var _step$value = _slicedToArray(_step.value, 2),
46
+ key = _step$value[0],
47
+ value = _step$value[1];
48
+ if (false === callback.call(context !== null && context !== void 0 ? context : value, key, value, o, _index++)) return;
49
+ }
50
+ } catch (err) {
51
+ _iterator.e(err);
52
+ } finally {
53
+ _iterator.f();
36
54
  }
37
55
  } else if (o instanceof Set) {
38
- let index = 0;
39
- for (const value of o.values()) {
40
- if (false === callback.call(context ?? value, index, value, o, index)) return;
41
- index++;
56
+ var _index2 = 0;
57
+ var _iterator2 = _createForOfIteratorHelper(o.values()),
58
+ _step2;
59
+ try {
60
+ for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
61
+ var _value = _step2.value;
62
+ if (false === callback.call(context !== null && context !== void 0 ? context : _value, _index2, _value, o, _index2)) return;
63
+ _index2++;
64
+ }
65
+ } catch (err) {
66
+ _iterator2.e(err);
67
+ } finally {
68
+ _iterator2.f();
42
69
  }
43
70
  } else if (isArrayLike(o)) {
44
71
  o = Array.from(o);
45
- for (let i = 0; i < o.length; i++) if (false === callback.call(context || o[i], i, o[i], o, i)) return;
72
+ for (var _i2 = 0; _i2 < o.length; _i2++) if (false === callback.call(context || o[_i2], _i2, o[_i2], o, _i2)) return;
46
73
  }
47
74
  return o;
48
75
  };
@@ -59,8 +86,10 @@ export const each = function (o, callback, context) {
59
86
  * @param {any} [context] Optional "this" binding for the callback
60
87
  * @returns {typeof o} Returns the original input
61
88
  */
62
- export const foreach = function (o, callback, context) {
63
- return each(o, (key, value, o, index) => callback.apply(context || value, [value, key, o, index]), context);
89
+ export var foreach = function foreach(o, callback, context) {
90
+ return each(o, function (key, value, o, index) {
91
+ return callback.apply(context || value, [value, key, o, index]);
92
+ }, context);
64
93
  };
65
94
 
66
95
  /**
@@ -78,10 +107,10 @@ export const foreach = function (o, callback, context) {
78
107
  * @param {any} [context] Optional "this" binding for the callback
79
108
  * @returns {Array} Returns the resulted array
80
109
  */
81
- export const map = function (o, callback, context) {
82
- let results = [];
110
+ export var map = function map(o, callback, context) {
111
+ var results = [];
83
112
  each(o, function (index, value, o, i) {
84
- const response = callback.call(context, index, value, o, i);
113
+ var response = callback.call(context, index, value, o, i);
85
114
  if (false === response) return false;
86
115
  if (null !== response) results.push(response);
87
116
  });
@@ -100,13 +129,15 @@ export const map = function (o, callback, context) {
100
129
  * @param {R} [initialValue] la valeur initiale
101
130
  * @returns {R} Returns the accumulated value
102
131
  */
103
- export const reduce = function (o, callback, initialValue) {
104
- const isInitialValueDefined = !isUndefined(initialValue);
132
+ export var reduce = function reduce(o, callback, initialValue) {
133
+ var isInitialValueDefined = !isUndefined(initialValue);
105
134
  if (!sizeOf(o) && !isInitialValueDefined) {
106
135
  throw new Error('Nothing to reduce and no initial value');
107
136
  }
108
- let accumulator = !isInitialValueDefined ? map(o, (key, v, o, i) => i === 0 ? v : null)[0] : initialValue;
109
- each(o, (key, v, o, i) => {
137
+ var accumulator = !isInitialValueDefined ? map(o, function (key, v, o, i) {
138
+ return i === 0 ? v : null;
139
+ })[0] : initialValue;
140
+ each(o, function (key, v, o, i) {
110
141
  if (i === 0 && !isInitialValueDefined) return;
111
142
  accumulator = callback(accumulator, v, key, i, o);
112
143
  });
@@ -121,23 +152,26 @@ export const reduce = function (o, callback, initialValue) {
121
152
  * @param {...(boolean|T)} args
122
153
  * @returns {T} A copy of the merged result
123
154
  */
124
- export const extend = function (...args) {
125
- let deep = false;
155
+ var _extend = function extend() {
156
+ var deep = false;
157
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
158
+ args[_key] = arguments[_key];
159
+ }
126
160
  if (isBoolean(args[0])) {
127
161
  deep = args.shift();
128
162
  }
129
163
  if (args.length < 2 || isUndefined(args[0]) || null === args[0]) {
130
164
  return args[0];
131
165
  }
132
- let dest = args[0];
166
+ var dest = args[0];
133
167
  if (!isObject(dest)) {
134
168
  args[0] = dest = {};
135
169
  }
136
- foreach(args.slice(1), src => {
170
+ foreach(args.slice(1), function (src) {
137
171
  if (isObject(src)) {
138
- for (const name in src) {
172
+ for (var name in src) {
139
173
  if (deep && isPlainObject(src[name])) {
140
- dest[name] = extend(true, {}, dest[name], src[name]);
174
+ dest[name] = _extend(true, {}, dest[name], src[name]);
141
175
  } else {
142
176
  dest[name] = src[name];
143
177
  }
@@ -154,14 +188,15 @@ export const extend = function (...args) {
154
188
  * @param {T} o
155
189
  * @returns {T} The copy of o
156
190
  */
157
- export const clone = function (o) {
191
+ export { _extend as extend };
192
+ var _clone = function clone(o) {
158
193
  if (!isObject(o) && !isArray(o) || isWindow(o)) {
159
194
  return o;
160
195
  }
161
- const c = isObject(o) ? {} : [];
162
- each(o, (key, value) => {
196
+ var c = isObject(o) ? {} : [];
197
+ each(o, function (key, value) {
163
198
  if (isObject(value)) {
164
- c[key] = clone(value);
199
+ c[key] = _clone(value);
165
200
  } else {
166
201
  c[key] = value;
167
202
  }
@@ -178,13 +213,21 @@ export const clone = function (o) {
178
213
  * @param {...Collection<T>} args Remaining collections to merge
179
214
  * @returns {Array<T>} the resulted merged array
180
215
  */
181
- export const merge = function (first, second = [], ...args) {
182
- const result = map(first, (i, elem) => elem);
216
+ export { _clone as clone };
217
+ var _merge = function merge(first) {
218
+ var second = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
219
+ var result = map(first, function (i, elem) {
220
+ return elem;
221
+ });
183
222
  each(second, function (i, elem) {
184
223
  result.push(elem);
185
224
  });
225
+ for (var _len2 = arguments.length, args = new Array(_len2 > 2 ? _len2 - 2 : 0), _key2 = 2; _key2 < _len2; _key2++) {
226
+ args[_key2 - 2] = arguments[_key2];
227
+ }
186
228
  if (args.length) {
187
- return merge(result, ...args);
229
+ return _merge.apply(void 0, [result].concat(args));
188
230
  }
189
231
  return result;
190
- };
232
+ };
233
+ export { _merge as merge };
package/dist/esm/utils.js CHANGED
@@ -1,8 +1,10 @@
1
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
1
2
  import { each, map } from "./traversal.js";
2
3
  import { isArray, isFunction, isObject, isUndefined } from "./is.js";
3
- export const equals = function (o1, o2, seen = new WeakMap()) {
4
+ var _equals = function equals(o1, o2) {
5
+ var seen = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : new WeakMap();
4
6
  if (o1 === o2) return true;
5
- if (typeof o1 !== typeof o2 || o1 == null || o2 == null) {
7
+ if (_typeof(o1) !== _typeof(o2) || o1 == null || o2 == null) {
6
8
  return false;
7
9
  }
8
10
  if (isObject(o1)) {
@@ -10,17 +12,20 @@ export const equals = function (o1, o2, seen = new WeakMap()) {
10
12
  return seen.get(o1) === o2;
11
13
  }
12
14
  seen.set(o1, o2);
13
- const keys1 = Object.keys(o1),
15
+ var keys1 = Object.keys(o1),
14
16
  keys2 = Object.keys(o2);
15
17
  if (keys1.length !== keys2.length) {
16
18
  return false;
17
19
  }
18
- return keys1.every(key => equals(o1[key], o2[key], seen));
20
+ return keys1.every(function (key) {
21
+ return _equals(o1[key], o2[key], seen);
22
+ });
19
23
  }
20
24
  return false;
21
25
  };
22
- export const noop = function () {};
23
- export const sizeOf = function (o) {
26
+ export { _equals as equals };
27
+ export var noop = function noop() {};
28
+ export var sizeOf = function sizeOf(o) {
24
29
  return map(o, noop).length;
25
30
  };
26
31
 
@@ -40,33 +45,43 @@ export const sizeOf = function (o) {
40
45
  * console.log(result);
41
46
  * // Output: [1, 2, 3, 4]
42
47
  */
43
- export const flatten = function (o) {
48
+ var _flatten = function flatten(o) {
44
49
  if (isObject(o) || isArray(o)) {
45
- return [].concat.apply([], map(o, (i, val) => flatten(val)));
50
+ return [].concat.apply([], map(o, function (i, val) {
51
+ return _flatten(val);
52
+ }));
46
53
  }
47
54
  return o;
48
55
  };
49
- export const strParseFloat = function (val) {
56
+ export { _flatten as flatten };
57
+ export var strParseFloat = function strParseFloat(val) {
50
58
  if (!val) return 0;
51
59
  return parseFloat((val + '').replace(/\s/g, '').replace(',', '.'));
52
60
  };
53
- export const throttle = function (func, wait, leading = true, trailing = true, context = null) {
54
- let timeout = null;
55
- let lastCall = 0;
56
- return function (...args) {
57
- const now = Date.now();
61
+ export var throttle = function throttle(func, wait) {
62
+ var leading = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
63
+ var trailing = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : true;
64
+ var context = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : null;
65
+ var timeout = null;
66
+ var lastCall = 0;
67
+ return function () {
68
+ var _this = this;
69
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
70
+ args[_key] = arguments[_key];
71
+ }
72
+ var now = Date.now();
58
73
  if (!lastCall && !leading) {
59
74
  lastCall = now;
60
75
  }
61
- const remaining = wait - (now - lastCall);
76
+ var remaining = wait - (now - lastCall);
62
77
  if (remaining <= 0 || remaining > wait) {
63
78
  lastCall = now;
64
79
  func.apply(context || this, args);
65
80
  } else if (!timeout && trailing) {
66
- timeout = setTimeout(() => {
81
+ timeout = setTimeout(function () {
67
82
  timeout = null;
68
83
  lastCall = leading ? Date.now() : 0;
69
- func.apply(context || this, args);
84
+ func.apply(context || _this, args);
70
85
  }, remaining);
71
86
  }
72
87
  };
@@ -82,11 +97,17 @@ export const throttle = function (func, wait, leading = true, trailing = true, c
82
97
  * @param {Object} [context=null] - The context to bind to `func`.
83
98
  * @returns {Function} The debounced function.
84
99
  */
85
- export const debounce = function (func, wait, immediate = false, context = null) {
86
- let timeout = null;
87
- let lastCall = 0;
88
- return function (...args) {
89
- const now = Date.now();
100
+ export var debounce = function debounce(func, wait) {
101
+ var immediate = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
102
+ var context = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null;
103
+ var timeout = null;
104
+ var lastCall = 0;
105
+ return function () {
106
+ var _this2 = this;
107
+ for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
108
+ args[_key2] = arguments[_key2];
109
+ }
110
+ var now = Date.now();
90
111
  if (immediate) {
91
112
  if (!lastCall) {
92
113
  lastCall = now;
@@ -95,11 +116,11 @@ export const debounce = function (func, wait, immediate = false, context = null)
95
116
  }
96
117
  clearTimeout(timeout);
97
118
  timeout = null;
98
- timeout = setTimeout(() => {
119
+ timeout = setTimeout(function () {
99
120
  lastCall = now;
100
121
  clearTimeout(timeout);
101
122
  timeout = null;
102
- func.apply(context || this, args);
123
+ func.apply(context || _this2, args);
103
124
  }, wait);
104
125
  };
105
126
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webalternatif/js-core",
3
- "version": "1.1.2",
3
+ "version": "1.2.0",
4
4
  "type": "module",
5
5
  "types": "types/index.d.ts",
6
6
  "main": "dist/cjs/index.js",
@@ -16,7 +16,7 @@
16
16
  "test": "jest --coverage",
17
17
  "test:watch": "jest --watch",
18
18
  "build:esm": "babel src --out-dir dist/esm --extensions .js",
19
- "build:cjs": "babel src --out-dir dist/cjs --extensions .js --plugins @babel/plugin-transform-modules-commonjs",
19
+ "build:cjs": "babel src --out-dir dist/cjs --extensions .js",
20
20
  "types": "tsc",
21
21
  "build": "yarn build:esm && yarn build:cjs && yarn types",
22
22
  "readme": "documentation readme src/index.js --section=API --github"
@@ -24,6 +24,7 @@
24
24
  "devDependencies": {
25
25
  "@babel/cli": "^7.28.3",
26
26
  "@babel/core": "^7.26.0",
27
+ "@babel/plugin-transform-export-namespace-from": "^7.27.1",
27
28
  "@babel/preset-env": "^7.26.0",
28
29
  "@testing-library/dom": "^10.4.1",
29
30
  "@types/jest": "^29.5.14",