@webalternatif/js-core 1.0.0 → 1.1.1

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 (80) hide show
  1. package/package.json +14 -3
  2. package/.babelrc +0 -12
  3. package/.idea/inspectionProfiles/Project_Default.xml +0 -12
  4. package/.idea/js-core.iml +0 -8
  5. package/.idea/modules.xml +0 -8
  6. package/.idea/php.xml +0 -20
  7. package/.idea/vcs.xml +0 -6
  8. package/i18n/agenda/en.js +0 -73
  9. package/i18n/agenda/fr.js +0 -73
  10. package/i18n/agenda/index.js +0 -2
  11. package/i18n/ajaxform/en.js +0 -5
  12. package/i18n/ajaxform/fr.js +0 -5
  13. package/i18n/ajaxform/index.js +0 -2
  14. package/i18n/ajaxupload/en.js +0 -12
  15. package/i18n/ajaxupload/fr.js +0 -12
  16. package/i18n/ajaxupload/index.js +0 -2
  17. package/i18n/autocomplete/en.js +0 -3
  18. package/i18n/autocomplete/fr.js +0 -3
  19. package/i18n/autocomplete/index.js +0 -2
  20. package/i18n/confirm/en.js +0 -5
  21. package/i18n/confirm/fr.js +0 -5
  22. package/i18n/confirm/index.js +0 -2
  23. package/i18n/core/en.js +0 -4
  24. package/i18n/core/fr.js +0 -4
  25. package/i18n/core/index.js +0 -2
  26. package/i18n/datagrid/en.js +0 -8
  27. package/i18n/datagrid/fr.js +0 -8
  28. package/i18n/datagrid/index.js +0 -2
  29. package/i18n/date/en.js +0 -51
  30. package/i18n/date/fr.js +0 -51
  31. package/i18n/date/index.js +0 -2
  32. package/i18n/datetimepicker/en.js +0 -30
  33. package/i18n/datetimepicker/fr.js +0 -30
  34. package/i18n/datetimepicker/index.js +0 -2
  35. package/i18n/dialog/en.js +0 -3
  36. package/i18n/dialog/fr.js +0 -3
  37. package/i18n/dialog/index.js +0 -2
  38. package/i18n/fulldayeventagenda/en.js +0 -73
  39. package/i18n/fulldayeventagenda/fr.js +0 -73
  40. package/i18n/fulldayeventagenda/index.js +0 -2
  41. package/i18n/index.d.ts +0 -4
  42. package/i18n/index.js +0 -15
  43. package/i18n/richtexteditor/en.js +0 -58
  44. package/i18n/richtexteditor/fr.js +0 -58
  45. package/i18n/richtexteditor/index.js +0 -2
  46. package/i18n/select/en.js +0 -3
  47. package/i18n/select/fr.js +0 -3
  48. package/i18n/select/index.js +0 -2
  49. package/i18n/timepicker/en.js +0 -3
  50. package/i18n/timepicker/fr.js +0 -3
  51. package/i18n/timepicker/index.js +0 -2
  52. package/i18n/useragenda/en.js +0 -74
  53. package/i18n/useragenda/fr.js +0 -73
  54. package/i18n/useragenda/index.js +0 -2
  55. package/jest.config.js +0 -14
  56. package/src/array.js +0 -124
  57. package/src/dom.js +0 -569
  58. package/src/eventDispatcher.js +0 -118
  59. package/src/i18n.js +0 -55
  60. package/src/index.js +0 -33
  61. package/src/is.js +0 -89
  62. package/src/math.js +0 -109
  63. package/src/random.js +0 -40
  64. package/src/string.js +0 -576
  65. package/src/stringPrototype.js +0 -15
  66. package/src/traversal.js +0 -134
  67. package/src/utils.js +0 -130
  68. package/tests/array.test.js +0 -326
  69. package/tests/dom.test.js +0 -239
  70. package/tests/eventdispatcher.test.js +0 -177
  71. package/tests/i18n.test.js +0 -132
  72. package/tests/index.test.js +0 -29
  73. package/tests/is.test.js +0 -354
  74. package/tests/math.test.js +0 -221
  75. package/tests/random.test.js +0 -72
  76. package/tests/string.test.js +0 -1106
  77. package/tests/traversal.test.js +0 -517
  78. package/tests/utils.test.js +0 -371
  79. package/tsconfig.json +0 -16
  80. package/webpack.config.cjs +0 -31
package/src/traversal.js DELETED
@@ -1,134 +0,0 @@
1
- import {isArray, isBoolean, isObject, isPlainObject, isString, isUndefined} from "./is.js";
2
- import {isWindow} from "./dom.js";
3
- import {sizeOf} from "./utils.js";
4
-
5
- export const each = function(o, callback, context) {
6
- const oToString = Object.prototype.toString.call(o);
7
-
8
- if (oToString === '[object Set]') {
9
- o = [...o];
10
- } else if (oToString === '[object Map]') {
11
- o = Object.fromEntries(o);
12
- }
13
-
14
- if (isArray(o)) {
15
- for (let i = 0; i < o.length; i++)
16
- if (false === callback.call(context || o[i], i, o[i], o, i))
17
- return;
18
- } else if (isObject(o)) {
19
- let index = -1;
20
-
21
- for (let i in o)
22
- if (o.hasOwnProperty(i) && false === callback.call(context || o[i], i, o[i], o, ++index))
23
- return;
24
- } else if (isString(o)) {
25
- const arr = o.split('');
26
-
27
- for (let i = 0; i < arr.length; i++)
28
- if (false === callback.call(context || arr[i], i, arr[i], o, i))
29
- return;
30
- }
31
-
32
- return o;
33
- }
34
-
35
- export const foreach = function(o, callback, context) {
36
- return each(o, (key, value, o, index) => callback.apply(context || value, [value, key, o, index]), context)
37
- }
38
-
39
- export const map = function(o, callback, context) {
40
- let results = [];
41
-
42
- each(o, function(index, value, o, i) {
43
- const response = callback.call(context, index, value, o, i);
44
-
45
- if (response !== null) {
46
- results.push(response);
47
- }
48
- });
49
-
50
- return results;
51
- }
52
-
53
- export const reduce = function(o, callback, initialValue) {
54
- const isInitialValueDefined = !isUndefined(initialValue);
55
-
56
- if (!sizeOf(o) && !isInitialValueDefined) {
57
- throw new Error('Nothing to reduce and no initial value');
58
- }
59
-
60
- let accumulator = !isInitialValueDefined ? map(o, (i, v) => i === 0 ? v : null)[0] : initialValue;
61
-
62
- each(o, (i, v) => {
63
- if (i === 0 && !isInitialValueDefined) {
64
- return true;
65
- }
66
-
67
- accumulator = callback(accumulator, v, i, o);
68
- })
69
-
70
- return accumulator;
71
- }
72
-
73
- export const extend = function(...args) {
74
- let deep = false;
75
- if (isBoolean(args[0])) {
76
- deep = args.shift();
77
- }
78
-
79
- if (args.length < 2 || isUndefined(args[0]) || null === args[0]) {
80
- return args[0];
81
- }
82
-
83
- let dest = args[0];
84
- if (!isObject(dest)) {
85
- args[0] = dest = {};
86
- }
87
-
88
- each(args.slice(1), (i, src) => {
89
- if (isObject(src)) {
90
- for (let name in src) {
91
- if (deep && isPlainObject(src[name])) {
92
- dest[name] = extend(true, {}, dest[name], src[name]);
93
- } else {
94
- dest[name] = src[name];
95
- }
96
- }
97
- }
98
- })
99
-
100
- return dest;
101
- }
102
-
103
- export const clone = function(o) {
104
- if ((!isObject(o) && !isArray(o)) || isWindow(o)) {
105
- return o;
106
- }
107
-
108
- const c = isObject(o) ? {} : [];
109
-
110
- each(o, (i, value) => {
111
- if (isObject(value)) {
112
- c[i] = clone(value);
113
- } else {
114
- c[i] = value;
115
- }
116
- })
117
-
118
- return c;
119
- }
120
-
121
- export const merge = function(first, second = [], ...args)
122
- {
123
- const result = map(first, (i, elem) => elem);
124
-
125
- each(second, function(i, elem) {
126
- result.push(elem);
127
- });
128
-
129
- if (args.length) {
130
- return merge(result, ...args);
131
- }
132
-
133
- return result;
134
- }
package/src/utils.js DELETED
@@ -1,130 +0,0 @@
1
- import {each, map} from "./traversal.js";
2
- import {isArray, isFunction, isObject, isUndefined} from "./is.js";
3
-
4
- export const equals = function(o1, o2, seen = new WeakMap()) {
5
- if (o1 === o2) return true;
6
-
7
- if (typeof o1 !== typeof o2 || o1 == null || o2 == null) {
8
- return false;
9
- }
10
-
11
- if (isObject(o1)) {
12
- if (seen.has(o1)) {
13
- return seen.get(o1) === o2;
14
- }
15
-
16
- seen.set(o1, o2);
17
-
18
- const keys1 = Object.keys(o1),
19
- keys2 = Object.keys(o2);
20
-
21
- if (keys1.length !== keys2.length) {
22
- return false;
23
- }
24
-
25
- return keys1.every((key) => equals(o1[key], o2[key], seen));
26
- }
27
-
28
- return false;
29
- }
30
-
31
- export const noop = function() {}
32
-
33
- export const sizeOf = function(o) {
34
- return map(o, noop).length;
35
- }
36
-
37
- /**
38
- * Recursively flattens an object or array into a single-level array.
39
- *
40
- * @param {Object|Array} o - The object or array to flatten.
41
- * @returns {Array} A flattened array containing all the values from the input object or array.
42
- *
43
- * @example <caption>Flatten an array of arrays</caption>
44
- * const result = flatten([1, [2, [3, 4]], 5]);
45
- * console.log(result);
46
- * // Output: [1, 2, 3, 4, 5]
47
- *
48
- * @example <caption>Flatten an object</caption>
49
- * const result = flatten({ a: 1, b: [2, { c: 3 }], d: 4 });
50
- * console.log(result);
51
- * // Output: [1, 2, 3, 4]
52
- */
53
- export const flatten = function(o)
54
- {
55
- if (isObject(o) || isArray(o)) {
56
- return [].concat.apply([], map(o, (i, val) => flatten(val)))
57
- }
58
-
59
- return o;
60
- }
61
-
62
- export const strParseFloat = function(val) {
63
- if (!val) return 0;
64
-
65
- return parseFloat((val + '')
66
- .replace(/\s/g, '')
67
- .replace(',', '.'));
68
- }
69
-
70
- export const throttle = function(func, wait, leading = true, trailing = true, context = null) {
71
- let timeout = null;
72
- let lastCall = 0;
73
-
74
- return function (...args) {
75
- const now = Date.now();
76
-
77
- if (!lastCall && !leading) {
78
- lastCall = now;
79
- }
80
-
81
- const remaining = wait - (now - lastCall);
82
-
83
- if (remaining <= 0 || remaining > wait) {
84
- lastCall = now;
85
- func.apply(context || this, args);
86
- } else if (!timeout && trailing) {
87
- timeout = setTimeout(() => {
88
- timeout = null;
89
- lastCall = leading ? Date.now() : 0;
90
- func.apply(context || this, args);
91
- }, remaining);
92
- }
93
- }
94
- }
95
-
96
- /**
97
- * Creates a debounced function that delays the invocation of `func` until after `wait` milliseconds
98
- * have elapsed since the last time the debounced function was invoked.
99
- *
100
- * @param {Function} func - The function to debounce.
101
- * @param {number} wait - The number of milliseconds to delay.
102
- * @param {boolean} [immediate=false] - If true, execute `func` on the leading edge instead of the trailing.
103
- * @param {Object} [context=null] - The context to bind to `func`.
104
- * @returns {Function} The debounced function.
105
- */
106
- export const debounce = function(func, wait, immediate = false, context = null) {
107
- let timeout = null;
108
- let lastCall = 0;
109
-
110
- return function (...args) {
111
- const now = Date.now();
112
-
113
- if (immediate) {
114
- if (!lastCall) {
115
- lastCall = now;
116
- func.apply(context || this, args);
117
- }
118
- }
119
-
120
- clearTimeout(timeout);
121
- timeout = null;
122
-
123
- timeout = setTimeout(() => {
124
- lastCall = now;
125
- clearTimeout(timeout);
126
- timeout = null;
127
- func.apply(context || this, args);
128
- }, wait);
129
- }
130
- }
@@ -1,326 +0,0 @@
1
- import * as traversal from "../src/traversal.js";
2
- import {arrayDiff, arrayUnique, compareArray, inArray, indexOf, range} from "../src/array.js";
3
- import {each} from "../src/traversal.js";
4
-
5
- describe('array methods', () => {
6
- beforeEach(() => {
7
- jest.spyOn(traversal, 'each');
8
- })
9
-
10
- afterEach(() => {
11
- jest.restoreAllMocks();
12
- })
13
-
14
- describe('inArray()', () => {
15
- it('should return true if the value exists in the array (non-strict)', () => {
16
- const arr = [1, '2', 3];
17
- const result = inArray(2, arr);
18
- expect(result).toBe(true);
19
- })
20
-
21
- it('should return false if the value does not exist in the array (non-strict)', () => {
22
- const arr = [1, '3', 4];
23
- const result = inArray(2, arr);
24
- expect(result).toBe(false);
25
- })
26
-
27
- it('should return true if the value exists in the array (strict)', () => {
28
- const arr = [1, 2, 3];
29
- const result = inArray(2, arr, 0, true);
30
- expect(result).toBe(true);
31
- })
32
-
33
- it('should return false if the value does not exist in the array (strict)', () => {
34
- const arr = [1, '2', 3];
35
- const result = inArray(2, arr, 0, true);
36
- expect(result).toBe(false);
37
- })
38
-
39
- it('should start searching from the specified index', () => {
40
- const arr = [1, 2, 3, 4];
41
- const result = inArray(2, arr, 2);
42
- expect(result).toBe(false);
43
- })
44
-
45
- it('should return false for an empty array', () => {
46
- const arr = [];
47
- const result = inArray(1, arr);
48
- expect(result).toBe(false);
49
- })
50
-
51
- it('should stop iteration when the value is found', () => {
52
- const arr = [1, 2, 3];
53
- const mockEach = jest.fn((array, callback) => {
54
- callback(0, 1);
55
- callback(1, 2);
56
- })
57
- each.mockImplementation(mockEach);
58
-
59
- const result = inArray(2, arr);
60
-
61
- expect(result).toBe(true);
62
- expect(mockEach).toHaveBeenCalledTimes(1);
63
- })
64
-
65
- it('should handle complex values (e.g., objects)', () => {
66
- const obj = { id: 1 };
67
- const arr = [{ id: 2 }, obj, { id: 3 }];
68
- const result = inArray(obj, arr, 0, true);
69
- expect(result).toBe(true);
70
- })
71
-
72
- it('should return false for objects with loose equality but different references', () => {
73
- const obj = { id: 1 };
74
- const arr = [{ id: 1 }, { id: 2 }];
75
- const result = inArray(obj, arr, 0, true);
76
- expect(result).toBe(false);
77
- })
78
- })
79
-
80
- describe('indexOf()', () => {
81
- it('should return the correct index of an element in the array', () => {
82
- const arr = [10, 20, 30, 40, 50];
83
- expect(indexOf(arr, 30)).toBe(2);
84
- })
85
-
86
- it('should return -1 if the element is not in the array', () => {
87
- const arr = [10, 20, 30, 40, 50];
88
- expect(indexOf(arr, 60)).toBe(-1);
89
- })
90
-
91
- it('should start searching from the given index', () => {
92
- const arr = [10, 20, 30, 40, 50];
93
- expect(indexOf(arr, 30, 3)).toBe(-1);
94
- expect(indexOf(arr, 50, 3)).toBe(4);
95
- })
96
-
97
- it('should handle negative start indices', () => {
98
- const arr = [10, 20, 30, 40, 50];
99
- expect(indexOf(arr, 30, -3)).toBe(2);
100
- expect(indexOf(arr, 10, -5)).toBe(0);
101
- })
102
-
103
- it('should return -1 for an empty array', () => {
104
- const arr = [];
105
- expect(indexOf(arr, 10)).toBe(-1);
106
- })
107
-
108
- it('should skip holes in sparse arrays', () => {
109
- const arr = [10, , 30, , 50]; // Sparse array
110
- expect(indexOf(arr, undefined)).toBe(-1); // undefined is not explicitly in the array
111
- expect(indexOf(arr, 30)).toBe(2); // Finds 30 despite the holes
112
- })
113
-
114
- it('should return the first occurrence of the element', () => {
115
- const arr = [10, 20, 30, 20, 10];
116
- expect(indexOf(arr, 20)).toBe(1); // Returns the first occurrence
117
- })
118
-
119
- it('should work when from is larger than the array length', () => {
120
- const arr = [10, 20, 30];
121
- expect(indexOf(arr, 20, 10)).toBe(-1); // Starts beyond the array, no search
122
- })
123
-
124
- it('should work when from is exactly the array length', () => {
125
- const arr = [10, 20, 30];
126
- expect(indexOf(arr, 30, 3)).toBe(-1); // Starts at the end, no search
127
- })
128
- })
129
-
130
- describe('compareArray()', () => {
131
- it('should return true for identical arrays', () => {
132
- const arr1 = [1, 2, 3];
133
- const arr2 = [1, 2, 3];
134
- expect(compareArray(arr1, arr2)).toBe(true);
135
- })
136
-
137
- it('should return false for arrays with different lengths', () => {
138
- const arr1 = [1, 2, 3];
139
- const arr2 = [1, 2];
140
- expect(compareArray(arr1, arr2)).toBe(false);
141
- })
142
-
143
- it('should return true for nested identical arrays', () => {
144
- const arr1 = [1, [2, 3], 4];
145
- const arr2 = [1, [2, 3], 4];
146
- expect(compareArray(arr1, arr2)).toBe(true);
147
- })
148
-
149
- it('should return false for nested arrays with different values', () => {
150
- const arr1 = [1, [2, 3], 4];
151
- const arr2 = [1, [2, 4], 4];
152
- expect(compareArray(arr1, arr2)).toBe(false);
153
- })
154
-
155
- it('should return false if one array has nested arrays and the other does not', () => {
156
- const arr1 = [1, [2, 3], 4, 5];
157
- const arr2 = [1, 2, 3, 4];
158
- expect(compareArray(arr1, arr2)).toBe(false);
159
- expect(compareArray(arr2, arr1)).toBe(false);
160
- })
161
-
162
- it('should return true for empty arrays', () => {
163
- const arr1 = [];
164
- const arr2 = [];
165
- expect(compareArray(arr1, arr2)).toBe(true);
166
- })
167
-
168
- it('should return false for arrays with different primitive values', () => {
169
- const arr1 = [1, 2, 3];
170
- const arr2 = [1, 2, 4];
171
- expect(compareArray(arr1, arr2)).toBe(false);
172
- })
173
-
174
- it('should return false for deeply nested arrays with differences', () => {
175
- const arr1 = [1, [2, [3, 4]], 5];
176
- const arr2 = [1, [2, [3, 5]], 5];
177
- expect(compareArray(arr1, arr2)).toBe(false);
178
- })
179
-
180
- it('should return true for deeply identical nested arrays', () => {
181
- const arr1 = [1, [2, [3, 4]], 5];
182
- const arr2 = [1, [2, [3, 4]], 5];
183
- expect(compareArray(arr1, arr2)).toBe(true);
184
- })
185
-
186
- it('should handle arrays with mixed types correctly', () => {
187
- const arr1 = [1, "hello", [true, null], { key: "value" }];
188
- const arr2 = [1, "hello", [true, null], { key: "value" }];
189
- expect(compareArray(arr1, arr2)).toBe(true);
190
- })
191
- })
192
-
193
- describe('range()', () => {
194
- it('should generate a range of numbers starting from 0', () => {
195
- expect(range(5)).toEqual([0, 1, 2, 3, 4]);
196
- })
197
-
198
- it('should generate a range of numbers starting from a specific number', () => {
199
- expect(range(5, 10)).toEqual([10, 11, 12, 13, 14]);
200
- })
201
-
202
- it('should generate a range of numbers with a specific step', () => {
203
- expect(range(5, 0, 2)).toEqual([0, 2, 4, 6, 8]);
204
- })
205
-
206
- it('should generate a descending range of numbers with a negative step', () => {
207
- expect(range(5, 10, -2)).toEqual([10, 8, 6, 4, 2]);
208
- })
209
-
210
- it('should generate a range of characters starting from a given character', () => {
211
- expect(range(5, 'A')).toEqual(['A', 'B', 'C', 'D', 'E']);
212
- })
213
-
214
- it('should generate a range of characters with a specific step', () => {
215
- expect(range(5, 'a', 2)).toEqual(['a', 'c', 'e', 'g', 'i']);
216
- })
217
-
218
- it('should generate a descending range of characters with a negative step', () => {
219
- expect(range(5, 'E', -1)).toEqual(['E', 'D', 'C', 'B', 'A']);
220
- })
221
-
222
- it('should use the first character of a string when startAt is multiple characters', () => {
223
- expect(range(5, 'hello')).toEqual(['h', 'i', 'j', 'k', 'l']);
224
- })
225
-
226
- it('should return an empty array if size is less than 1', () => {
227
- expect(range(0)).toEqual([]);
228
- })
229
-
230
- it('should return an empty array if step is 0', () => {
231
- expect(range(5, 0, 0)).toEqual([]);
232
- })
233
-
234
- it('should return an empty array if startAt is not a string or integer', () => {
235
- expect(range(5, [])).toEqual([]);
236
- expect(range(5, {})).toEqual([]);
237
- expect(range(5, null)).toEqual([]);
238
- })
239
-
240
- it('should generate a single-element range if size is 1', () => {
241
- expect(range(1, 5)).toEqual([5]);
242
- expect(range(1, 'A')).toEqual(['A']);
243
- })
244
- })
245
-
246
- describe('arrayUnique()', () => {
247
- it('should return an array with unique values', () => {
248
- const arr = [1, 2, 2, 3, 4, 4, 5];
249
- expect(arrayUnique(arr)).toEqual([1, 2, 3, 4, 5]);
250
- })
251
-
252
- it('should handle an empty array', () => {
253
- const arr = [];
254
- expect(arrayUnique(arr)).toEqual([]);
255
- })
256
-
257
- it('should handle an array with all unique values', () => {
258
- const arr = [1, 2, 3, 4, 5];
259
- expect(arrayUnique(arr)).toEqual([1, 2, 3, 4, 5]);
260
- })
261
-
262
- it('should handle an array with all duplicate values', () => {
263
- const arr = [1, 1, 1, 1];
264
- expect(arrayUnique(arr)).toEqual([1]);
265
- })
266
-
267
- it('should handle an array with mixed types', () => {
268
- const arr = [1, '1', 1, true, true, false, 'true'];
269
- expect(arrayUnique(arr)).toEqual([1, '1', true, false, 'true']);
270
- })
271
-
272
- it('should handle an array with nested arrays or objects', () => {
273
- const arr = [[1], [1], { a: 1 }, { a: 1 }];
274
- expect(arrayUnique(arr)).toEqual([[1], [1], { a: 1 }, { a: 1 }]); // Objects and arrays are not strictly equal
275
- })
276
-
277
- it('should preserve the order of the first occurrence of elements', () => {
278
- const arr = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5];
279
- expect(arrayUnique(arr)).toEqual([3, 1, 4, 5, 9, 2, 6]);
280
- })
281
- })
282
-
283
- describe('arrayDiff()', () => {
284
- it('should return the difference of two arrays', () => {
285
- const array1 = [1, 2, 3, 4];
286
- const array2 = [2, 4];
287
- expect(arrayDiff(array1, array2)).toEqual([1, 3]);
288
- })
289
-
290
- it('should return the original array if there is no overlap', () => {
291
- const array1 = [1, 2, 3];
292
- const array2 = [4, 5, 6];
293
- expect(arrayDiff(array1, array2)).toEqual([1, 2, 3]);
294
- })
295
-
296
- it('should return an empty array if the first array is empty', () => {
297
- const array1 = [];
298
- const array2 = [1, 2, 3];
299
- expect(arrayDiff(array1, array2)).toEqual([]);
300
- })
301
-
302
- it('should return the first array if the second array is empty', () => {
303
- const array1 = [1, 2, 3];
304
- const array2 = [];
305
- expect(arrayDiff(array1, array2)).toEqual([1, 2, 3]);
306
- })
307
-
308
- it('should handle arrays with mixed types with strict mode', () => {
309
- const array1 = [1, '1', true, null];
310
- const array2 = [true, null];
311
- expect(arrayDiff(array1, array2, true)).toEqual([1, '1']);
312
- })
313
-
314
- it('should handle arrays with nested arrays or objects', () => {
315
- const array1 = [[1], { a: 1 }, 3];
316
- const array2 = [{ a: 1 }];
317
- expect(arrayDiff(array1, array2)).toEqual([[1], 3]);
318
- })
319
-
320
- it('should return an empty array if both arrays are empty', () => {
321
- const array1 = [];
322
- const array2 = [];
323
- expect(arrayDiff(array1, array2)).toEqual([]);
324
- })
325
- })
326
- })