@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/esm/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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webalternatif/js-core",
3
- "version": "1.1.1",
3
+ "version": "1.1.3",
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",
package/types/dom.d.ts CHANGED
@@ -15,29 +15,29 @@ declare namespace _default {
15
15
  */
16
16
  function child(el: Element, selector?: string): Element | null;
17
17
  /**
18
- * @param {Element|Document|string} refEl
19
- * @param {string} [selector='*']
20
- * @returns {NodeList}
18
+ * @param {Element|Document} refEl
19
+ * @param {string|Element|NodeList|Array<Element>} [selector]
20
+ * @returns {Element|null}
21
21
  */
22
- function find(refEl: Element | Document | string, selector?: string): NodeList;
22
+ function findOne(refEl: Element | Document, selector?: string | Element | NodeList | Array<Element>): Element | null;
23
23
  /**
24
- * @param {Element|Document|string} refEl
25
- * @param {string} [selector='*']
26
- * @returns {Element|null}
24
+ * @param {Element|Document} refEl
25
+ * @param {string|Element|NodeList|Array<Element>} selector
26
+ * @returns {Array<Element>}
27
27
  */
28
- function findOne(refEl: Element | Document | string, selector?: string): Element | null;
28
+ function find(refEl: Element | Document, selector: string | Element | NodeList | Array<Element>): Array<Element>;
29
29
  /**
30
- * @param {Element} el
30
+ * @param {Element|NodeList|Array<Element>} el
31
31
  * @param {string} className
32
- * @returns {Element}
32
+ * @returns {Element|NodeList|Array<Element>}
33
33
  */
34
- function addClass(el: Element, className: string): Element;
34
+ function addClass(el: Element | NodeList | Array<Element>, className: string): Element | NodeList | Array<Element>;
35
35
  /**
36
- * @param {Element} el
37
- * @param {string} classNames
38
- * @returns {Element}
36
+ * @param {Element|NodeList|Array<Element>} el
37
+ * @param {string} className
38
+ * @returns {Element|NodeList|Array<Element>}
39
39
  */
40
- function removeClass(el: Element, classNames: string): Element;
40
+ function removeClass(el: Element | NodeList | Array<Element>, className: string): Element | NodeList | Array<Element>;
41
41
  /**
42
42
  * @param {Element} el
43
43
  * @param {string} classNames
@@ -52,28 +52,28 @@ declare namespace _default {
52
52
  */
53
53
  function hasClass(el: Element, classNames: string): boolean;
54
54
  /**
55
- * @param {Element} el
56
- * @param {Element} child
57
- * @returns {Element}
55
+ * @param {Node} node
56
+ * @param {...Node} children
57
+ * @returns {Node}
58
58
  */
59
- function append(el: Element, child: Element): Element;
59
+ function append(node: Node, ...children: Node[]): Node;
60
60
  /**
61
- * @param {Element} el
62
- * @param {Element} child
63
- * @returns {Element}
61
+ * @param {Node} node
62
+ * @param {...Node} children
63
+ * @returns {Node}
64
64
  */
65
- function prepend(el: Element, child: Element): Element;
65
+ function prepend(node: Node, ...children: Node[]): Node;
66
66
  /**
67
- * @param {Element} el
67
+ * @param {Element|NodeList|Array<Element>|string} els
68
68
  * @returns {void}
69
69
  */
70
- function remove(el: Element): void;
70
+ function remove(...els: Element | NodeList | Array<Element> | string): void;
71
71
  /**
72
72
  * @param {Element} el
73
- * @param {string} [selector]
73
+ * @param {string|Element} selector
74
74
  * @returns {Element|null}
75
75
  */
76
- function closest(el: Element, selector?: string): Element | null;
76
+ function closest(el: Element, selector: string | Element): Element | null;
77
77
  /**
78
78
  * @param {Element} el
79
79
  * @param {string} [selector]
@@ -98,6 +98,18 @@ declare namespace _default {
98
98
  * @returns {Element[]}
99
99
  */
100
100
  function prevAll(el: Element, selector?: string): Element[];
101
+ /**
102
+ * @param {Element} el
103
+ * @param {Element|string} selector
104
+ * @returns {Element[]}
105
+ */
106
+ function nextUntil(el: Element, selector: Element | string): Element[];
107
+ /**
108
+ * @param {Element} el
109
+ * @param {Element|string} selector
110
+ * @returns {Element[]}
111
+ */
112
+ function prevUntil(el: Element, selector: Element | string): Element[];
101
113
  /**
102
114
  * @param {Element} el
103
115
  * @param {Element} wrappingElement
@@ -149,11 +161,11 @@ declare namespace _default {
149
161
  * @param {Element} el
150
162
  * @param {Object<string, string>|string} name
151
163
  * @param {string} [value]
152
- * @returns {Element}
164
+ * @returns {Element|DOMStringMap}
153
165
  */
154
166
  function data(el: Element, name: {
155
167
  [x: string]: string;
156
- } | string, value?: string): Element;
168
+ } | string, value?: string): Element | DOMStringMap;
157
169
  /**
158
170
  * @param {Element} el
159
171
  * @param {string} name
@@ -178,11 +190,11 @@ declare namespace _default {
178
190
  function off(el: Element | Document | Window, event: string, handler: Function, options: Object): Element;
179
191
  /**
180
192
  * @param {HTMLElement} el
181
- * @param {Object<string, string>|string} styles
193
+ * @param {Object<string, string>|string} style
182
194
  * @param {string} [value]
183
195
  * @returns {Element}
184
196
  */
185
- function css(el: HTMLElement, styles: {
197
+ function css(el: HTMLElement, style: {
186
198
  [x: string]: string;
187
199
  } | string, value?: string): Element;
188
200
  /**
@@ -205,15 +217,15 @@ declare namespace _default {
205
217
  */
206
218
  function first(nodeList: NodeList): Element | null;
207
219
  /**
208
- * @param {NodeList} nodeList
220
+ * @param {NodeList|Array<Element>} nodeList
209
221
  * @returns {Element|null}
210
222
  */
211
- function last(nodeList: NodeList): Element | null;
223
+ function last(nodeList: NodeList | Array<Element>): Element | null;
212
224
  /**
213
225
  * @param {string} html
214
- * @returns {Element}
226
+ * @returns {Element|null}
215
227
  */
216
- function create(html: string): Element;
228
+ function create(html: string): Element | null;
217
229
  /**
218
230
  * @param {NodeList} nodeList
219
231
  * @param {number} [index=0]
@@ -237,5 +249,11 @@ declare namespace _default {
237
249
  * @returns {Element}
238
250
  */
239
251
  function empty(el: Element): Element;
252
+ /**
253
+ * @param {Element|NodeList} el
254
+ * @param {string|Element} selector
255
+ * @return {Element[]}
256
+ */
257
+ function not(el: Element | NodeList, selector: string | Element): Element[];
240
258
  }
241
259
  export default _default;