@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,12 +1,14 @@
1
- "use strict";
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; }
8
+ import { isArray, isArrayLike, isBoolean, isObject, isPlainObject, isString, isUndefined } from "./is.js";
9
+ import { isWindow } from "./dom.js";
10
+ import { sizeOf } from "./utils.js";
2
11
 
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.reduce = exports.merge = exports.map = exports.foreach = exports.extend = exports.each = exports.clone = void 0;
7
- var _is = require("./is.js");
8
- var _dom = require("./dom.js");
9
- var _utils = require("./utils.js");
10
12
  /**
11
13
  * @template T
12
14
  * @typedef {Array<T> | Set<T> | Map<any, T> | Object<string, T> | string} Collection
@@ -26,28 +28,48 @@ var _utils = require("./utils.js");
26
28
  * @param {any} [context] Optional "this" binding for the callback
27
29
  * @returns {typeof o} Returns the original input
28
30
  */
29
- const each = function (o, callback, context) {
30
- if ((0, _is.isPlainObject)(o)) {
31
- let index = -1;
32
- for (let i in o) if (o.hasOwnProperty(i) && false === callback.call(context ?? o[i], i, o[i], o, ++index)) return;
33
- } else if ((0, _is.isString)(o)) {
34
- const arr = o.split('');
35
- for (let i = 0; i < arr.length; i++) if (false === callback.call(context ?? arr[i], i, arr[i], o, i)) return;
31
+ export var each = function each(o, callback, context) {
32
+ if (isPlainObject(o)) {
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;
35
+ } else if (isString(o)) {
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;
36
38
  return o;
37
39
  } else if (o instanceof Map) {
38
- let index = 0;
39
- for (const [key, value] of o.entries()) {
40
- 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();
41
54
  }
42
55
  } else if (o instanceof Set) {
43
- let index = 0;
44
- for (const value of o.values()) {
45
- if (false === callback.call(context ?? value, index, value, o, index)) return;
46
- 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();
47
69
  }
48
- } else if ((0, _is.isArrayLike)(o)) {
70
+ } else if (isArrayLike(o)) {
49
71
  o = Array.from(o);
50
- 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;
51
73
  }
52
74
  return o;
53
75
  };
@@ -64,9 +86,10 @@ const each = function (o, callback, context) {
64
86
  * @param {any} [context] Optional "this" binding for the callback
65
87
  * @returns {typeof o} Returns the original input
66
88
  */
67
- exports.each = each;
68
- const foreach = function (o, callback, context) {
69
- 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);
70
93
  };
71
94
 
72
95
  /**
@@ -84,11 +107,10 @@ const foreach = function (o, callback, context) {
84
107
  * @param {any} [context] Optional "this" binding for the callback
85
108
  * @returns {Array} Returns the resulted array
86
109
  */
87
- exports.foreach = foreach;
88
- const map = function (o, callback, context) {
89
- let results = [];
110
+ export var map = function map(o, callback, context) {
111
+ var results = [];
90
112
  each(o, function (index, value, o, i) {
91
- const response = callback.call(context, index, value, o, i);
113
+ var response = callback.call(context, index, value, o, i);
92
114
  if (false === response) return false;
93
115
  if (null !== response) results.push(response);
94
116
  });
@@ -107,14 +129,15 @@ const map = function (o, callback, context) {
107
129
  * @param {R} [initialValue] la valeur initiale
108
130
  * @returns {R} Returns the accumulated value
109
131
  */
110
- exports.map = map;
111
- const reduce = function (o, callback, initialValue) {
112
- const isInitialValueDefined = !(0, _is.isUndefined)(initialValue);
113
- if (!(0, _utils.sizeOf)(o) && !isInitialValueDefined) {
132
+ export var reduce = function reduce(o, callback, initialValue) {
133
+ var isInitialValueDefined = !isUndefined(initialValue);
134
+ if (!sizeOf(o) && !isInitialValueDefined) {
114
135
  throw new Error('Nothing to reduce and no initial value');
115
136
  }
116
- let accumulator = !isInitialValueDefined ? map(o, (key, v, o, i) => i === 0 ? v : null)[0] : initialValue;
117
- 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) {
118
141
  if (i === 0 && !isInitialValueDefined) return;
119
142
  accumulator = callback(accumulator, v, key, i, o);
120
143
  });
@@ -129,24 +152,26 @@ const reduce = function (o, callback, initialValue) {
129
152
  * @param {...(boolean|T)} args
130
153
  * @returns {T} A copy of the merged result
131
154
  */
132
- exports.reduce = reduce;
133
- const extend = function (...args) {
134
- let deep = false;
135
- if ((0, _is.isBoolean)(args[0])) {
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
+ }
160
+ if (isBoolean(args[0])) {
136
161
  deep = args.shift();
137
162
  }
138
- if (args.length < 2 || (0, _is.isUndefined)(args[0]) || null === args[0]) {
163
+ if (args.length < 2 || isUndefined(args[0]) || null === args[0]) {
139
164
  return args[0];
140
165
  }
141
- let dest = args[0];
142
- if (!(0, _is.isObject)(dest)) {
166
+ var dest = args[0];
167
+ if (!isObject(dest)) {
143
168
  args[0] = dest = {};
144
169
  }
145
- foreach(args.slice(1), src => {
146
- if ((0, _is.isObject)(src)) {
147
- for (const name in src) {
148
- if (deep && (0, _is.isPlainObject)(src[name])) {
149
- dest[name] = extend(true, {}, dest[name], src[name]);
170
+ foreach(args.slice(1), function (src) {
171
+ if (isObject(src)) {
172
+ for (var name in src) {
173
+ if (deep && isPlainObject(src[name])) {
174
+ dest[name] = _extend(true, {}, dest[name], src[name]);
150
175
  } else {
151
176
  dest[name] = src[name];
152
177
  }
@@ -163,15 +188,15 @@ const extend = function (...args) {
163
188
  * @param {T} o
164
189
  * @returns {T} The copy of o
165
190
  */
166
- exports.extend = extend;
167
- const clone = function (o) {
168
- if (!(0, _is.isObject)(o) && !(0, _is.isArray)(o) || (0, _dom.isWindow)(o)) {
191
+ export { _extend as extend };
192
+ var _clone = function clone(o) {
193
+ if (!isObject(o) && !isArray(o) || isWindow(o)) {
169
194
  return o;
170
195
  }
171
- const c = (0, _is.isObject)(o) ? {} : [];
172
- each(o, (key, value) => {
173
- if ((0, _is.isObject)(value)) {
174
- c[key] = clone(value);
196
+ var c = isObject(o) ? {} : [];
197
+ each(o, function (key, value) {
198
+ if (isObject(value)) {
199
+ c[key] = _clone(value);
175
200
  } else {
176
201
  c[key] = value;
177
202
  }
@@ -188,15 +213,21 @@ const clone = function (o) {
188
213
  * @param {...Collection<T>} args Remaining collections to merge
189
214
  * @returns {Array<T>} the resulted merged array
190
215
  */
191
- exports.clone = clone;
192
- const merge = function (first, second = [], ...args) {
193
- 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
+ });
194
222
  each(second, function (i, elem) {
195
223
  result.push(elem);
196
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
+ }
197
228
  if (args.length) {
198
- return merge(result, ...args);
229
+ return _merge.apply(void 0, [result].concat(args));
199
230
  }
200
231
  return result;
201
232
  };
202
- exports.merge = merge;
233
+ export { _merge as merge };
package/dist/cjs/utils.js CHANGED
@@ -1,35 +1,32 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.throttle = exports.strParseFloat = exports.sizeOf = exports.noop = exports.flatten = exports.equals = exports.debounce = void 0;
7
- var _traversal = require("./traversal.js");
8
- var _is = require("./is.js");
9
- const equals = function (o1, o2, seen = new WeakMap()) {
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); }
2
+ import { each, map } from "./traversal.js";
3
+ import { isArray, isFunction, isObject, isUndefined } from "./is.js";
4
+ var _equals = function equals(o1, o2) {
5
+ var seen = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : new WeakMap();
10
6
  if (o1 === o2) return true;
11
- if (typeof o1 !== typeof o2 || o1 == null || o2 == null) {
7
+ if (_typeof(o1) !== _typeof(o2) || o1 == null || o2 == null) {
12
8
  return false;
13
9
  }
14
- if ((0, _is.isObject)(o1)) {
10
+ if (isObject(o1)) {
15
11
  if (seen.has(o1)) {
16
12
  return seen.get(o1) === o2;
17
13
  }
18
14
  seen.set(o1, o2);
19
- const keys1 = Object.keys(o1),
15
+ var keys1 = Object.keys(o1),
20
16
  keys2 = Object.keys(o2);
21
17
  if (keys1.length !== keys2.length) {
22
18
  return false;
23
19
  }
24
- 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
+ });
25
23
  }
26
24
  return false;
27
25
  };
28
- exports.equals = equals;
29
- const noop = function () {};
30
- exports.noop = noop;
31
- const sizeOf = function (o) {
32
- return (0, _traversal.map)(o, noop).length;
26
+ export { _equals as equals };
27
+ export var noop = function noop() {};
28
+ export var sizeOf = function sizeOf(o) {
29
+ return map(o, noop).length;
33
30
  };
34
31
 
35
32
  /**
@@ -48,36 +45,43 @@ const sizeOf = function (o) {
48
45
  * console.log(result);
49
46
  * // Output: [1, 2, 3, 4]
50
47
  */
51
- exports.sizeOf = sizeOf;
52
- const flatten = function (o) {
53
- if ((0, _is.isObject)(o) || (0, _is.isArray)(o)) {
54
- return [].concat.apply([], (0, _traversal.map)(o, (i, val) => flatten(val)));
48
+ var _flatten = function flatten(o) {
49
+ if (isObject(o) || isArray(o)) {
50
+ return [].concat.apply([], map(o, function (i, val) {
51
+ return _flatten(val);
52
+ }));
55
53
  }
56
54
  return o;
57
55
  };
58
- exports.flatten = flatten;
59
- const strParseFloat = function (val) {
56
+ export { _flatten as flatten };
57
+ export var strParseFloat = function strParseFloat(val) {
60
58
  if (!val) return 0;
61
59
  return parseFloat((val + '').replace(/\s/g, '').replace(',', '.'));
62
60
  };
63
- exports.strParseFloat = strParseFloat;
64
- const throttle = function (func, wait, leading = true, trailing = true, context = null) {
65
- let timeout = null;
66
- let lastCall = 0;
67
- return function (...args) {
68
- 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();
69
73
  if (!lastCall && !leading) {
70
74
  lastCall = now;
71
75
  }
72
- const remaining = wait - (now - lastCall);
76
+ var remaining = wait - (now - lastCall);
73
77
  if (remaining <= 0 || remaining > wait) {
74
78
  lastCall = now;
75
79
  func.apply(context || this, args);
76
80
  } else if (!timeout && trailing) {
77
- timeout = setTimeout(() => {
81
+ timeout = setTimeout(function () {
78
82
  timeout = null;
79
83
  lastCall = leading ? Date.now() : 0;
80
- func.apply(context || this, args);
84
+ func.apply(context || _this, args);
81
85
  }, remaining);
82
86
  }
83
87
  };
@@ -93,12 +97,17 @@ const throttle = function (func, wait, leading = true, trailing = true, context
93
97
  * @param {Object} [context=null] - The context to bind to `func`.
94
98
  * @returns {Function} The debounced function.
95
99
  */
96
- exports.throttle = throttle;
97
- const debounce = function (func, wait, immediate = false, context = null) {
98
- let timeout = null;
99
- let lastCall = 0;
100
- return function (...args) {
101
- 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();
102
111
  if (immediate) {
103
112
  if (!lastCall) {
104
113
  lastCall = now;
@@ -107,12 +116,11 @@ const debounce = function (func, wait, immediate = false, context = null) {
107
116
  }
108
117
  clearTimeout(timeout);
109
118
  timeout = null;
110
- timeout = setTimeout(() => {
119
+ timeout = setTimeout(function () {
111
120
  lastCall = now;
112
121
  clearTimeout(timeout);
113
122
  timeout = null;
114
- func.apply(context || this, args);
123
+ func.apply(context || _this2, args);
115
124
  }, wait);
116
125
  };
117
- };
118
- exports.debounce = debounce;
126
+ };
package/dist/esm/array.js CHANGED
@@ -24,9 +24,11 @@ import { equals } from "./utils.js";
24
24
  * inArray(5, [1, 2, 3])
25
25
  * // → false
26
26
  */
27
- export const inArray = function (value, arr, index = 0, strict = false) {
28
- let ret = false;
29
- each(arr, (i, val) => {
27
+ export var inArray = function inArray(value, arr) {
28
+ var index = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
29
+ var strict = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
30
+ var ret = false;
31
+ each(arr, function (i, val) {
30
32
  if (i >= index) {
31
33
  if (strict) {
32
34
  if (val === value) {
@@ -38,7 +40,7 @@ export const inArray = function (value, arr, index = 0, strict = false) {
38
40
  ret = equals(val, value);
39
41
  return false;
40
42
  } else if (isArray(value) && isObject(val)) {
41
- ret = compareArray(val, value);
43
+ ret = _compareArray(val, value);
42
44
  return false;
43
45
  } else if (val == value) {
44
46
  ret = true;
@@ -49,7 +51,8 @@ export const inArray = function (value, arr, index = 0, strict = false) {
49
51
  });
50
52
  return ret;
51
53
  };
52
- export const indexOf = function (arr, elt, from = 0) {
54
+ export var indexOf = function indexOf(arr, elt) {
55
+ var from = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
53
56
  from = from < 0 ? Math.ceil(from) + arr.length : Math.floor(from);
54
57
  for (; from < arr.length; from++) {
55
58
  if (from in arr && arr[from] === elt) {
@@ -58,16 +61,16 @@ export const indexOf = function (arr, elt, from = 0) {
58
61
  }
59
62
  return -1;
60
63
  };
61
- export const compareArray = function (a1, a2) {
64
+ var _compareArray = function compareArray(a1, a2) {
62
65
  if (a1.length !== a2.length) {
63
66
  return false;
64
67
  } else {
65
- for (let i = 0; i < a1.length; i++) {
68
+ for (var i = 0; i < a1.length; i++) {
66
69
  if (isArray(a1[i])) {
67
70
  if (!isArray(a2[i])) {
68
71
  return false;
69
72
  }
70
- return compareArray(a1[i], a2[i]);
73
+ return _compareArray(a1[i], a2[i]);
71
74
  } else if (a1[i] !== a2[i]) {
72
75
  return false;
73
76
  }
@@ -75,30 +78,38 @@ export const compareArray = function (a1, a2) {
75
78
  }
76
79
  return true;
77
80
  };
78
- export const arrayUnique = function (arr) {
79
- return arr.filter((el, index, arr) => index === indexOf(arr, el));
81
+ export { _compareArray as compareArray };
82
+ export var arrayUnique = function arrayUnique(arr) {
83
+ return arr.filter(function (el, index, arr) {
84
+ return index === indexOf(arr, el);
85
+ });
80
86
  };
81
- export const array_unique = arrayUnique;
82
- export const arrayDiff = (array1, array2, strict = false) => {
83
- return array1.filter(item => !inArray(item, array2, 0, strict));
87
+ export var array_unique = arrayUnique;
88
+ export var arrayDiff = function arrayDiff(array1, array2) {
89
+ var strict = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
90
+ return array1.filter(function (item) {
91
+ return !inArray(item, array2, 0, strict);
92
+ });
84
93
  };
85
- export const array_diff = arrayUnique;
86
- export const range = function (size, startAt = 0, step = 1) {
94
+ export var array_diff = arrayUnique;
95
+ export var range = function range(size) {
96
+ var startAt = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
97
+ var step = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1;
87
98
  size = round(size);
88
99
  step = round(step);
89
- const rng = [];
100
+ var rng = [];
90
101
  if (isUndefined(startAt) || size < 1 || step === 0 || size < Math.abs(step)) {
91
102
  return rng;
92
103
  }
93
- const end = size * step;
104
+ var end = size * step;
94
105
  if (isString(startAt)) {
95
106
  startAt = startAt.charCodeAt(0);
96
- for (let i = 0; step > 0 ? i < end : i > end; i += step) {
107
+ for (var i = 0; step > 0 ? i < end : i > end; i += step) {
97
108
  rng.push(String.fromCharCode(startAt + i));
98
109
  }
99
110
  } else if (isInteger(startAt)) {
100
- for (let i = 0; step > 0 ? i < end : i > end; i += step) {
101
- rng.push(startAt + i);
111
+ for (var _i = 0; step > 0 ? _i < end : _i > end; _i += step) {
112
+ rng.push(startAt + _i);
102
113
  }
103
114
  }
104
115
  return rng;