@webalternatif/js-core 1.1.1 → 1.1.3

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 (121) hide show
  1. package/dist/cjs/array.js +46 -46
  2. package/dist/cjs/dom.js +277 -147
  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 +28 -43
  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 +191 -68
  58. package/dist/cjs/utils.js +51 -43
  59. package/dist/esm/array.js +46 -46
  60. package/dist/esm/dom.js +277 -147
  61. package/dist/esm/eventDispatcher.js +126 -86
  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 +16 -25
  109. package/dist/esm/index.js +24 -54
  110. package/dist/esm/is.js +28 -43
  111. package/dist/esm/math.js +27 -38
  112. package/dist/esm/random.js +10 -23
  113. package/dist/esm/string.js +162 -166
  114. package/dist/esm/stringPrototype.js +10 -10
  115. package/dist/esm/traversal.js +191 -68
  116. package/dist/esm/utils.js +51 -43
  117. package/package.json +3 -2
  118. package/types/dom.d.ts +53 -35
  119. package/types/index.d.ts +22 -19
  120. package/types/is.d.ts +1 -0
  121. package/types/traversal.d.ts +10 -7
@@ -1,78 +1,177 @@
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
- const each = function (o, callback, context) {
11
- const oToString = Object.prototype.toString.call(o);
12
- if (oToString === '[object Set]') {
13
- o = [...o];
14
- } else if (oToString === '[object Map]') {
15
- o = Object.fromEntries(o);
16
- }
17
- if ((0, _is.isArray)(o)) {
18
- for (let i = 0; i < o.length; i++) if (false === callback.call(context || o[i], i, o[i], o, i)) return;
19
- } else if ((0, _is.isObject)(o)) {
20
- let index = -1;
21
- for (let i in o) if (o.hasOwnProperty(i) && false === callback.call(context || o[i], i, o[i], o, ++index)) return;
22
- } else if ((0, _is.isString)(o)) {
23
- const arr = o.split('');
24
- for (let i = 0; i < arr.length; i++) if (false === callback.call(context || arr[i], i, arr[i], o, i)) return;
12
+ /**
13
+ * @template T
14
+ * @typedef {Array<T> | Set<T> | Map<any, T> | Object<string, T> | string} Collection
15
+ */
16
+
17
+ /**
18
+ * Iterates over Arrays, Strings, Maps, Sets and plain Objects.
19
+ *
20
+ * The callback receives:
21
+ * (keyOrIndex, value, o, index)
22
+ *
23
+ * If the callback returns `false`, the iteration stops.
24
+ *
25
+ * @template T
26
+ * @param {Collection<T>} o
27
+ * @param {(key: number|string, value: T, o: Collection<T>, index: number) => (void|boolean)} callback
28
+ * @param {any} [context] Optional "this" binding for the callback
29
+ * @returns {typeof o} Returns the original input
30
+ */
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;
38
+ return o;
39
+ } else if (o instanceof Map) {
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();
54
+ }
55
+ } else if (o instanceof Set) {
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();
69
+ }
70
+ } else if (isArrayLike(o)) {
71
+ o = Array.from(o);
72
+ for (var _i2 = 0; _i2 < o.length; _i2++) if (false === callback.call(context || o[_i2], _i2, o[_i2], o, _i2)) return;
25
73
  }
26
74
  return o;
27
75
  };
28
- exports.each = each;
29
- const foreach = function (o, callback, context) {
30
- return each(o, (key, value, o, index) => callback.apply(context || value, [value, key, o, index]), context);
76
+
77
+ /**
78
+ * Same as each except that key and value are reversed in callback
79
+ *
80
+ * The callback receives:
81
+ * (value, keyOrIndex, o, index)
82
+ *
83
+ * @template T
84
+ * @param {Collection<T>} o
85
+ * @param {(value: T, key: number|string, o: Collection<T>, index: number) => (void|boolean)} callback
86
+ * @param {any} [context] Optional "this" binding for the callback
87
+ * @returns {typeof o} Returns the original input
88
+ */
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);
31
93
  };
32
- exports.foreach = foreach;
33
- const map = function (o, callback, context) {
34
- let results = [];
94
+
95
+ /**
96
+ * Iterates over Arrays, Strings, Maps, Sets and plain Objects.
97
+ * Returns an array from the callback results.
98
+ * Values strictly equal to `null` are skipped.
99
+ * Values strictly equal to `false` stops the iteration.
100
+ *
101
+ * The callback receives:
102
+ * (keyOrIndex, value, o, index)
103
+ *
104
+ * @template T,R
105
+ * @param {Collection<T>} o
106
+ * @param {(key: number|string, value: T, o: Collection<T>, index: number) => (R|null|false)} callback
107
+ * @param {any} [context] Optional "this" binding for the callback
108
+ * @returns {Array} Returns the resulted array
109
+ */
110
+ export var map = function map(o, callback, context) {
111
+ var results = [];
35
112
  each(o, function (index, value, o, i) {
36
- const response = callback.call(context, index, value, o, i);
37
- if (response !== null) {
38
- results.push(response);
39
- }
113
+ var response = callback.call(context, index, value, o, i);
114
+ if (false === response) return false;
115
+ if (null !== response) results.push(response);
40
116
  });
41
117
  return results;
42
118
  };
43
- exports.map = map;
44
- const reduce = function (o, callback, initialValue) {
45
- const isInitialValueDefined = !(0, _is.isUndefined)(initialValue);
46
- if (!(0, _utils.sizeOf)(o) && !isInitialValueDefined) {
119
+
120
+ /**
121
+ * Reduces a collection to a single value
122
+ *
123
+ * The reducer receives:
124
+ * (accumulator, value, index, source)
125
+ *
126
+ * @template T,R
127
+ * @param {Collection<T>} o
128
+ * @param {(accumulator: R|T, value: T, key: any, index: number, o: Collection<T>) => R} callback
129
+ * @param {R} [initialValue] la valeur initiale
130
+ * @returns {R} Returns the accumulated value
131
+ */
132
+ export var reduce = function reduce(o, callback, initialValue) {
133
+ var isInitialValueDefined = !isUndefined(initialValue);
134
+ if (!sizeOf(o) && !isInitialValueDefined) {
47
135
  throw new Error('Nothing to reduce and no initial value');
48
136
  }
49
- let accumulator = !isInitialValueDefined ? map(o, (i, v) => i === 0 ? v : null)[0] : initialValue;
50
- each(o, (i, v) => {
51
- if (i === 0 && !isInitialValueDefined) {
52
- return true;
53
- }
54
- accumulator = callback(accumulator, v, i, o);
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) {
141
+ if (i === 0 && !isInitialValueDefined) return;
142
+ accumulator = callback(accumulator, v, key, i, o);
55
143
  });
56
144
  return accumulator;
57
145
  };
58
- exports.reduce = reduce;
59
- const extend = function (...args) {
60
- let deep = false;
61
- if ((0, _is.isBoolean)(args[0])) {
146
+
147
+ /**
148
+ * Creates a shallow or deep copy of one or more objects or arrays
149
+ * If the first argument is `true`, nested plain objects are merged recursively.
150
+ *
151
+ * @template T
152
+ * @param {...(boolean|T)} args
153
+ * @returns {T} A copy of the merged result
154
+ */
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])) {
62
161
  deep = args.shift();
63
162
  }
64
- if (args.length < 2 || (0, _is.isUndefined)(args[0]) || null === args[0]) {
163
+ if (args.length < 2 || isUndefined(args[0]) || null === args[0]) {
65
164
  return args[0];
66
165
  }
67
- let dest = args[0];
68
- if (!(0, _is.isObject)(dest)) {
166
+ var dest = args[0];
167
+ if (!isObject(dest)) {
69
168
  args[0] = dest = {};
70
169
  }
71
- each(args.slice(1), (i, src) => {
72
- if ((0, _is.isObject)(src)) {
73
- for (let name in src) {
74
- if (deep && (0, _is.isPlainObject)(src[name])) {
75
- 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]);
76
175
  } else {
77
176
  dest[name] = src[name];
78
177
  }
@@ -81,30 +180,54 @@ const extend = function (...args) {
81
180
  });
82
181
  return dest;
83
182
  };
84
- exports.extend = extend;
85
- const clone = function (o) {
86
- if (!(0, _is.isObject)(o) && !(0, _is.isArray)(o) || (0, _dom.isWindow)(o)) {
183
+
184
+ /**
185
+ * Creates a deep copy of an Object or Array
186
+ *
187
+ * @template T
188
+ * @param {T} o
189
+ * @returns {T} The copy of o
190
+ */
191
+ export { _extend as extend };
192
+ var _clone = function clone(o) {
193
+ if (!isObject(o) && !isArray(o) || isWindow(o)) {
87
194
  return o;
88
195
  }
89
- const c = (0, _is.isObject)(o) ? {} : [];
90
- each(o, (i, value) => {
91
- if ((0, _is.isObject)(value)) {
92
- c[i] = clone(value);
196
+ var c = isObject(o) ? {} : [];
197
+ each(o, function (key, value) {
198
+ if (isObject(value)) {
199
+ c[key] = _clone(value);
93
200
  } else {
94
- c[i] = value;
201
+ c[key] = value;
95
202
  }
96
203
  });
97
204
  return c;
98
205
  };
99
- exports.clone = clone;
100
- const merge = function (first, second = [], ...args) {
101
- const result = map(first, (i, elem) => elem);
206
+
207
+ /**
208
+ * Merge multiple collections into a single array
209
+ *
210
+ * @template T
211
+ * @param {Collection<T>} first
212
+ * @param {Collection<T>} [second]
213
+ * @param {...Collection<T>} args Remaining collections to merge
214
+ * @returns {Array<T>} the resulted merged array
215
+ */
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
+ });
102
222
  each(second, function (i, elem) {
103
223
  result.push(elem);
104
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
+ }
105
228
  if (args.length) {
106
- return merge(result, ...args);
229
+ return _merge.apply(void 0, [result].concat(args));
107
230
  }
108
231
  return result;
109
232
  };
110
- 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
@@ -1,13 +1,8 @@
1
- "use strict";
1
+ import { each } from "./traversal.js";
2
+ import { isArray, isInteger, isObject, isString, isUndefined } from "./is.js";
3
+ import { round } from "./math.js";
4
+ import { equals } from "./utils.js";
2
5
 
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.range = exports.indexOf = exports.inArray = exports.compareArray = exports.array_unique = exports.array_diff = exports.arrayUnique = exports.arrayDiff = void 0;
7
- var _traversal = require("./traversal.js");
8
- var _is = require("./is.js");
9
- var _math = require("./math.js");
10
- var _utils = require("./utils.js");
11
6
  /**
12
7
  * Checks if a value exists in an array or an object
13
8
  *
@@ -29,9 +24,11 @@ var _utils = require("./utils.js");
29
24
  * inArray(5, [1, 2, 3])
30
25
  * // → false
31
26
  */
32
- const inArray = function (value, arr, index = 0, strict = false) {
33
- let ret = false;
34
- (0, _traversal.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) {
35
32
  if (i >= index) {
36
33
  if (strict) {
37
34
  if (val === value) {
@@ -39,11 +36,11 @@ const inArray = function (value, arr, index = 0, strict = false) {
39
36
  return false;
40
37
  }
41
38
  } else {
42
- if ((0, _is.isObject)(value) && (0, _is.isObject)(val)) {
43
- ret = (0, _utils.equals)(val, value);
39
+ if (isObject(value) && isObject(val)) {
40
+ ret = equals(val, value);
44
41
  return false;
45
- } else if ((0, _is.isArray)(value) && (0, _is.isObject)(val)) {
46
- ret = compareArray(val, value);
42
+ } else if (isArray(value) && isObject(val)) {
43
+ ret = _compareArray(val, value);
47
44
  return false;
48
45
  } else if (val == value) {
49
46
  ret = true;
@@ -54,8 +51,8 @@ const inArray = function (value, arr, index = 0, strict = false) {
54
51
  });
55
52
  return ret;
56
53
  };
57
- exports.inArray = inArray;
58
- 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;
59
56
  from = from < 0 ? Math.ceil(from) + arr.length : Math.floor(from);
60
57
  for (; from < arr.length; from++) {
61
58
  if (from in arr && arr[from] === elt) {
@@ -64,17 +61,16 @@ const indexOf = function (arr, elt, from = 0) {
64
61
  }
65
62
  return -1;
66
63
  };
67
- exports.indexOf = indexOf;
68
- const compareArray = function (a1, a2) {
64
+ var _compareArray = function compareArray(a1, a2) {
69
65
  if (a1.length !== a2.length) {
70
66
  return false;
71
67
  } else {
72
- for (let i = 0; i < a1.length; i++) {
73
- if ((0, _is.isArray)(a1[i])) {
74
- if (!(0, _is.isArray)(a2[i])) {
68
+ for (var i = 0; i < a1.length; i++) {
69
+ if (isArray(a1[i])) {
70
+ if (!isArray(a2[i])) {
75
71
  return false;
76
72
  }
77
- return compareArray(a1[i], a2[i]);
73
+ return _compareArray(a1[i], a2[i]);
78
74
  } else if (a1[i] !== a2[i]) {
79
75
  return false;
80
76
  }
@@ -82,35 +78,39 @@ const compareArray = function (a1, a2) {
82
78
  }
83
79
  return true;
84
80
  };
85
- exports.compareArray = compareArray;
86
- const arrayUnique = function (arr) {
87
- 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
+ });
88
86
  };
89
- exports.arrayUnique = arrayUnique;
90
- const array_unique = exports.array_unique = arrayUnique;
91
- const arrayDiff = (array1, array2, strict = false) => {
92
- 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
+ });
93
93
  };
94
- exports.arrayDiff = arrayDiff;
95
- const array_diff = exports.array_diff = arrayUnique;
96
- const range = function (size, startAt = 0, step = 1) {
97
- size = (0, _math.round)(size);
98
- step = (0, _math.round)(step);
99
- const rng = [];
100
- if ((0, _is.isUndefined)(startAt) || size < 1 || step === 0 || size < Math.abs(step)) {
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;
98
+ size = round(size);
99
+ step = round(step);
100
+ var rng = [];
101
+ if (isUndefined(startAt) || size < 1 || step === 0 || size < Math.abs(step)) {
101
102
  return rng;
102
103
  }
103
- const end = size * step;
104
- if ((0, _is.isString)(startAt)) {
104
+ var end = size * step;
105
+ if (isString(startAt)) {
105
106
  startAt = startAt.charCodeAt(0);
106
- 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) {
107
108
  rng.push(String.fromCharCode(startAt + i));
108
109
  }
109
- } else if ((0, _is.isInteger)(startAt)) {
110
- for (let i = 0; step > 0 ? i < end : i > end; i += step) {
111
- rng.push(startAt + i);
110
+ } else if (isInteger(startAt)) {
111
+ for (var _i = 0; step > 0 ? _i < end : _i > end; _i += step) {
112
+ rng.push(startAt + _i);
112
113
  }
113
114
  }
114
115
  return rng;
115
- };
116
- exports.range = range;
116
+ };