@futdevpro/fsm-dynamo 1.9.47 → 1.9.49

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 (25) hide show
  1. package/.github/workflows/main.yml +49 -0
  2. package/build/_collections/utils/array.util.js +2 -2
  3. package/build/_collections/utils/array.util.js.map +1 -1
  4. package/build/_collections/utils/array.util.spec.js +244 -0
  5. package/build/_collections/utils/array.util.spec.js.map +1 -1
  6. package/build/_collections/utils/math/box-bounds.spec.d.ts +2 -0
  7. package/build/_collections/utils/math/box-bounds.spec.d.ts.map +1 -0
  8. package/build/_collections/utils/math/box-bounds.spec.js +60 -0
  9. package/build/_collections/utils/math/box-bounds.spec.js.map +1 -0
  10. package/build/_collections/utils/math/box-bounds.util.d.ts +2 -2
  11. package/build/_collections/utils/math/box-bounds.util.d.ts.map +1 -1
  12. package/build/_collections/utils/math/box-bounds.util.js.map +1 -1
  13. package/build/_models/control-models/data-property-params.control-model.d.ts +1 -1
  14. package/build/_models/control-models/data-property-params.control-model.d.ts.map +1 -1
  15. package/build/_models/control-models/data-property-params.control-model.js.map +1 -1
  16. package/build/_models/control-models/error.control-model.d.ts +26 -26
  17. package/futdevpro-fsm-dynamo-01.09.49.tgz +0 -0
  18. package/package.json +2 -2
  19. package/src/_collections/utils/array.util.spec.ts +317 -3
  20. package/src/_collections/utils/array.util.ts +3 -3
  21. package/src/_collections/utils/math/box-bounds.spec.ts +79 -0
  22. package/src/_collections/utils/math/box-bounds.util.ts +2 -2
  23. package/src/_models/control-models/data-property-params.control-model.ts +1 -1
  24. package/src/_models/control-models/error.control-model.ts +26 -26
  25. package/futdevpro-fsm-dynamo-01.09.47.tgz +0 -0
@@ -87,7 +87,7 @@ export declare class DyFM_Error extends DyFM_Metadata {
87
87
  * fs
88
88
  * daf
89
89
  * d as
90
- * dafs // asd sa `sadf ` sadf asd******* asdf asd f asd
90
+ * dafs // asd"" sa `sadf ` sadf asd******* asdf asd"" f asd
91
91
  * a
92
92
  * @beta
93
93
  * v
@@ -95,7 +95,7 @@ export declare class DyFM_Error extends DyFM_Metadata {
95
95
  * fs
96
96
  * daf
97
97
  * d as
98
- * dafs // asd sa `sadf ` sadf asd******* asdf asd f asd
98
+ * dafs // asd"" sa `sadf ` sadf asd******* asdf asd"" f asd
99
99
  * b
100
100
  * @decorator
101
101
  * v
@@ -103,7 +103,7 @@ export declare class DyFM_Error extends DyFM_Metadata {
103
103
  * fs
104
104
  * daf
105
105
  * d as
106
- * dafs // asd sa `sadf ` sadf asd******* asdf asd f asd
106
+ * dafs // asd"" sa `sadf ` sadf asd******* asdf asd"" f asd
107
107
  * dc
108
108
  * @deprecated
109
109
  * v
@@ -111,7 +111,7 @@ export declare class DyFM_Error extends DyFM_Metadata {
111
111
  * fs
112
112
  * daf
113
113
  * d as
114
- * dafs // asd sa `sadf ` sadf asd******* asdf asd f asd
114
+ * dafs // asd"" sa `sadf ` sadf asd******* asdf asd"" f asd
115
115
  * dp
116
116
  * @defaultValue
117
117
  * v
@@ -119,7 +119,7 @@ export declare class DyFM_Error extends DyFM_Metadata {
119
119
  * fs
120
120
  * daf
121
121
  * d as
122
- * dafs // asd sa `sadf ` sadf asd******* asdf asd f asd
122
+ * dafs // asd"" sa `sadf ` sadf asd******* asdf asd"" f asd
123
123
  * dv
124
124
  * @eventProperty
125
125
  * v
@@ -127,7 +127,7 @@ export declare class DyFM_Error extends DyFM_Metadata {
127
127
  * fs
128
128
  * daf
129
129
  * d as
130
- * dafs // asd sa `sadf ` sadf asd******* asdf asd f asd
130
+ * dafs // asd"" sa `sadf ` sadf asd******* asdf asd"" f asd
131
131
  * ep
132
132
  * @example
133
133
  * v
@@ -135,7 +135,7 @@ export declare class DyFM_Error extends DyFM_Metadata {
135
135
  * fs
136
136
  * daf
137
137
  * d as
138
- * dafs // asd sa `sadf ` sadf asd******* asdf asd f asd
138
+ * dafs // asd"" sa `sadf ` sadf asd******* asdf asd"" f asd
139
139
  * ex
140
140
  * @experimental
141
141
  * v
@@ -143,7 +143,7 @@ export declare class DyFM_Error extends DyFM_Metadata {
143
143
  * fs
144
144
  * daf
145
145
  * d as
146
- * dafs // asd sa `sadf ` sadf asd******* asdf asd f asd
146
+ * dafs // asd"" sa `sadf ` sadf asd******* asdf asd"" f asd
147
147
  * exp
148
148
  * @inheritDoc
149
149
  * v
@@ -151,7 +151,7 @@ export declare class DyFM_Error extends DyFM_Metadata {
151
151
  * fs
152
152
  * daf
153
153
  * d as
154
- * dafs // asd sa `sadf ` sadf asd******* asdf asd f asd
154
+ * dafs // asd"" sa `sadf ` sadf asd******* asdf asd"" f asd
155
155
  * in
156
156
  * @internal
157
157
  * v
@@ -159,7 +159,7 @@ export declare class DyFM_Error extends DyFM_Metadata {
159
159
  * fs
160
160
  * daf
161
161
  * d as
162
- * dafs // asd sa `sadf ` sadf asd******* asdf asd f asd
162
+ * dafs // asd"" sa `sadf ` sadf asd******* asdf asd"" f asd
163
163
  * int
164
164
  * @label
165
165
  * v
@@ -167,7 +167,7 @@ export declare class DyFM_Error extends DyFM_Metadata {
167
167
  * fs
168
168
  * daf
169
169
  * d as
170
- * dafs // asd sa `sadf ` sadf asd******* asdf asd f asd
170
+ * dafs // asd"" sa `sadf ` sadf asd******* asdf asd"" f asd
171
171
  * lab
172
172
  * @link
173
173
  * v
@@ -175,7 +175,7 @@ export declare class DyFM_Error extends DyFM_Metadata {
175
175
  * fs
176
176
  * daf
177
177
  * d as
178
- * dafs // asd sa `sadf ` sadf asd******* asdf asd f asd
178
+ * dafs // asd"" sa `sadf ` sadf asd******* asdf asd"" f asd
179
179
  * li
180
180
  * @override
181
181
  * v
@@ -183,13 +183,13 @@ export declare class DyFM_Error extends DyFM_Metadata {
183
183
  * fs
184
184
  * daf
185
185
  * d as
186
- * dafs // asd sa `sadf ` sadf asd******* asdf asd f asd
186
+ * dafs // asd"" sa `sadf ` sadf asd******* asdf asd"" f asd
187
187
  * v
188
188
  * sadfas d
189
189
  * fs
190
190
  * daf
191
191
  * d as
192
- * dafs // asd sa `sadf ` sadf asd******* asdf asd f asd
192
+ * dafs // asd"" sa `sadf ` sadf asd******* asdf asd"" f asd
193
193
  * ov
194
194
  * @packageDocumentation
195
195
  * v
@@ -197,7 +197,7 @@ export declare class DyFM_Error extends DyFM_Metadata {
197
197
  * fs
198
198
  * daf
199
199
  * d as
200
- * dafs // asd sa `sadf ` sadf asd******* asdf asd f asd
200
+ * dafs // asd"" sa `sadf ` sadf asd******* asdf asd"" f asd
201
201
  * pad
202
202
  * @param
203
203
  * v
@@ -205,7 +205,7 @@ export declare class DyFM_Error extends DyFM_Metadata {
205
205
  * fs
206
206
  * daf
207
207
  * d as
208
- * dafs // asd sa `sadf ` sadf asd******* asdf asd f asd
208
+ * dafs // asd"" sa `sadf ` sadf asd******* asdf asd"" f asd
209
209
  * par
210
210
  * @privateRemarks
211
211
  * v
@@ -213,7 +213,7 @@ export declare class DyFM_Error extends DyFM_Metadata {
213
213
  * fs
214
214
  * daf
215
215
  * d as
216
- * dafs // asd sa `sadf ` sadf asd******* asdf asd f asd
216
+ * dafs // asd"" sa `sadf ` sadf asd******* asdf asd"" f asd
217
217
  * pr
218
218
  * @public
219
219
  * v
@@ -221,7 +221,7 @@ export declare class DyFM_Error extends DyFM_Metadata {
221
221
  * fs
222
222
  * daf
223
223
  * d as
224
- * dafs // asd sa `sadf ` sadf asd******* asdf asd f asd
224
+ * dafs // asd"" sa `sadf ` sadf asd******* asdf asd"" f asd
225
225
  * p
226
226
  * @readonly
227
227
  * v
@@ -229,7 +229,7 @@ export declare class DyFM_Error extends DyFM_Metadata {
229
229
  * fs
230
230
  * daf
231
231
  * d as
232
- * dafs // asd sa `sadf ` sadf asd******* asdf asd f asd
232
+ * dafs // asd"" sa `sadf ` sadf asd******* asdf asd"" f asd
233
233
  * re
234
234
  * @remarks
235
235
  * v
@@ -237,7 +237,7 @@ export declare class DyFM_Error extends DyFM_Metadata {
237
237
  * fs
238
238
  * daf
239
239
  * d as
240
- * dafs // asd sa `sadf ` sadf asd******* asdf asd f asd
240
+ * dafs // asd"" sa `sadf ` sadf asd******* asdf asd"" f asd
241
241
  * rem
242
242
  * @returns
243
243
  * v
@@ -245,7 +245,7 @@ export declare class DyFM_Error extends DyFM_Metadata {
245
245
  * fs
246
246
  * daf
247
247
  * d as
248
- * dafs // asd sa `sadf ` sadf asd******* asdf asd f asd
248
+ * dafs // asd"" sa `sadf ` sadf asd******* asdf asd"" f asd
249
249
  * ret
250
250
  * @sealed
251
251
  * v
@@ -253,7 +253,7 @@ export declare class DyFM_Error extends DyFM_Metadata {
253
253
  * fs
254
254
  * daf
255
255
  * d as
256
- * dafs // asd sa `sadf ` sadf asd******* asdf asd f asd
256
+ * dafs // asd"" sa `sadf ` sadf asd******* asdf asd"" f asd
257
257
  * sea
258
258
  * @see
259
259
  * v
@@ -261,7 +261,7 @@ export declare class DyFM_Error extends DyFM_Metadata {
261
261
  * fs
262
262
  * daf
263
263
  * d as
264
- * dafs // asd sa `sadf ` sadf asd******* asdf asd f asd
264
+ * dafs // asd"" sa `sadf ` sadf asd******* asdf asd"" f asd
265
265
  * see
266
266
  * @throws
267
267
  * v
@@ -269,7 +269,7 @@ export declare class DyFM_Error extends DyFM_Metadata {
269
269
  * fs
270
270
  * daf
271
271
  * d as
272
- * dafs // asd sa `sadf ` sadf asd******* asdf asd f asd
272
+ * dafs // asd"" sa `sadf ` sadf asd******* asdf asd"" f asd
273
273
  * th
274
274
  * @typeParam
275
275
  * v
@@ -277,7 +277,7 @@ export declare class DyFM_Error extends DyFM_Metadata {
277
277
  * fs
278
278
  * daf
279
279
  * d as
280
- * dafs // asd sa `sadf ` sadf asd******* asdf asd f asd
280
+ * dafs // asd"" sa `sadf ` sadf asd******* asdf asd"" f asd
281
281
  * typ
282
282
  * @virtual
283
283
  * v
@@ -285,7 +285,7 @@ export declare class DyFM_Error extends DyFM_Metadata {
285
285
  * fs
286
286
  * daf
287
287
  * d as
288
- * dafs // asd sa `sadf ` sadf asd******* asdf asd f asd
288
+ * dafs // asd"" sa `sadf ` sadf asd******* asdf asd"" f asd
289
289
  *
290
290
  *
291
291
  * @see {@link http://example.com/@internal LINK}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@futdevpro/fsm-dynamo",
3
- "version": "01.09.47",
3
+ "version": "01.09.49",
4
4
  "description": "Full Stack Model Collection for Dynamic (NodeJS-Typescript) Framework called Dynamo, by Future Development Ltd.",
5
5
  "scripts": {
6
6
  "prep": "npm i pnpm -g && npm i rimraf nodemon -g",
@@ -106,7 +106,7 @@
106
106
  "@types/jasmine": "~4.3.5",
107
107
  "@typescript-eslint/eslint-plugin": "~6.7.4",
108
108
  "@typescript-eslint/parser": "~6.7.4",
109
- "eslint": "~8.51.0",
109
+ "eslint": "~9.17.0",
110
110
  "eslint-plugin-max-params-no-constructor": "~0.0.4",
111
111
  "eslint-plugin-unused-imports": "~3.0.0",
112
112
  "jasmine": "~5.1.0",
@@ -1,5 +1,6 @@
1
1
 
2
2
 
3
+ import { DyFM_Paged } from '../../_models/interfaces/paged.interface';
3
4
  import { DyFM_Array } from './array.util';
4
5
  import { DyFM_delay } from './utilities.util';
5
6
 
@@ -7,7 +8,7 @@ describe('DyFM_Array', (): void => {
7
8
 
8
9
  describe('asyncForEach', (): void => {
9
10
  it('should call the function for each element in the list', async (): Promise<void> => {
10
- const list = [1, 2, 3];
11
+ const list = [ 1, 2, 3 ];
11
12
  const result = [];
12
13
  const func = async (e, i): Promise<void> => {
13
14
  await DyFM_delay(30);
@@ -22,7 +23,7 @@ describe('DyFM_Array', (): void => {
22
23
 
23
24
  describe('asyncMapArray', (): void => {
24
25
  it('should call the function for each element in the list', async (): Promise<void> => {
25
- const list = [1, 2, 3];
26
+ const list = [ 1, 2, 3 ];
26
27
 
27
28
  const func = async (e, i): Promise<number> => {
28
29
  await DyFM_delay(30);
@@ -32,8 +33,321 @@ describe('DyFM_Array', (): void => {
32
33
 
33
34
  const result = await DyFM_Array.asyncMap(list, func);
34
35
 
35
- expect(result).toEqual([2, 4, 6]);
36
+ expect(result).toEqual([ 2, 4, 6 ]);
36
37
  });
37
38
  });
39
+
40
+ describe('shuffle', () => {
41
+ it('should shuffle the elements in the array', () => {
42
+ const inputArray = [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ];
43
+ const shuffledArray = [ ...inputArray ];
38
44
 
45
+ DyFM_Array.shuffle(shuffledArray);
46
+
47
+ // Check if the elements are shuffled (at least one position is different)
48
+ let samePositionCount = 0;
49
+
50
+ for (let i = 0; i < inputArray.length; i++) {
51
+ if (inputArray[i] === shuffledArray[i]) {
52
+ samePositionCount++;
53
+ }
54
+ }
55
+ expect(samePositionCount).toBeLessThan(inputArray.length);
56
+
57
+ // Check if all elements are still present after shuffle
58
+ expect(shuffledArray.sort()).toEqual(inputArray.sort());
59
+ });
60
+
61
+ it('should handle empty array', () => {
62
+ const inputArray: number[] = [];
63
+ const shuffledArray = DyFM_Array.shuffle(inputArray);
64
+
65
+ expect(shuffledArray).toEqual([]);
66
+ });
67
+ });
68
+
69
+ describe('page function', () => {
70
+ const array = [ 1, 2, 3, 4, 5, 6, 7, 8 ];
71
+ const pageSize = 2;
72
+
73
+ it('should return the correct page of items based on pageIndex and pageSize', () => {
74
+ expect(DyFM_Array.page(array, 0, pageSize)).toEqual([ 1, 2 ]);
75
+ expect(DyFM_Array.page(array, 1, pageSize)).toEqual([ 3, 4 ]);
76
+ expect(DyFM_Array.page(array, 2, pageSize)).toEqual([ 5, 6 ]);
77
+ expect(DyFM_Array.page(array, 3, pageSize)).toEqual([ 7, 8 ]);
78
+ });
79
+
80
+ it('should return an empty array if the page is out of bounds', () => {
81
+ expect(DyFM_Array.page(array, 4, pageSize)).toEqual([]);
82
+ expect(DyFM_Array.page(array, -1, pageSize)).toEqual([]);
83
+ });
84
+ });
85
+
86
+ describe('paged function', () => {
87
+ it('should return a paginated array', () => {
88
+ const array = [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ];
89
+ const pageIndex = 1;
90
+ const pageSize = 4;
91
+ const expected: DyFM_Paged<any> = {
92
+ pageIndex: 1,
93
+ pageSize: 4,
94
+ total: 10,
95
+ totalPageCount: 3,
96
+ items: [ 5, 6, 7, 8 ],
97
+ };
98
+
99
+ const result = DyFM_Array.paged(array, pageIndex, pageSize);
100
+
101
+ expect(result).toEqual(expected);
102
+ });
103
+
104
+ it('should handle edge cases like empty array', () => {
105
+ const array = [];
106
+ const pageIndex = 1;
107
+ const pageSize = 5;
108
+ const expected: DyFM_Paged<any> = {
109
+ pageIndex: 1,
110
+ pageSize: 5,
111
+ total: 0,
112
+ totalPageCount: 0,
113
+ items: [],
114
+ };
115
+
116
+ const result = DyFM_Array.paged(array, pageIndex, pageSize);
117
+
118
+ expect(result).toEqual(expected);
119
+ });
120
+ });
121
+
122
+ describe('swap function test', () => {
123
+ it('should swap elements in the array correctly', () => {
124
+ const array = [ 1, 2, 3, 4 ];
125
+ const indexA = 0;
126
+ const indexB = 2;
127
+ const expectedArray = [ 3, 2, 1, 4 ];
128
+
129
+ expect(DyFM_Array.swap(array, indexA, indexB)).toEqual(expectedArray);
130
+ });
131
+
132
+ it('should return the same array if same indexes are provided', () => {
133
+ const array = [ 1, 2, 3, 4 ];
134
+ const indexA = 0;
135
+ const indexB = 0;
136
+
137
+ expect(DyFM_Array.swap(array, indexA, indexB)).toEqual(array);
138
+ });
139
+
140
+ // Add more test cases as needed
141
+ });
142
+
143
+ xdescribe('getRoundListOppositeIndex', () => {
144
+ it('should return the correct opposite index when roundUp is false', () => {
145
+ const arrayLength = 5;
146
+ const index = 2;
147
+ const expectedOppositeIndex = 4; // 2 + Math.floor(5 / 2)
148
+
149
+ expect(DyFM_Array.getRoundListOppositeIndex(arrayLength, index)).toBe(expectedOppositeIndex);
150
+ });
151
+
152
+ it('should return the correct opposite index when roundUp is true', () => {
153
+ const arrayLength = 5;
154
+ const index = 2;
155
+ const roundUp = true;
156
+ const expectedOppositeIndex = 5; // 2 + Math.ceil(5 / 2)
157
+
158
+ expect(DyFM_Array.getRoundListOppositeIndex(arrayLength, index, roundUp)).toBe(expectedOppositeIndex);
159
+ });
160
+
161
+ it('should handle cases where oppositeIndex is greater than arrayLength', () => {
162
+ const arrayLength = 5;
163
+ const index = 3;
164
+ const roundUp = true; // roundUp doesn't matter in this case
165
+ const expectedOppositeIndex = 3; // 3
166
+
167
+ expect(DyFM_Array.getRoundListOppositeIndex(arrayLength, index, roundUp)).toBe(expectedOppositeIndex);
168
+ });
169
+ });
170
+
171
+ xdescribe('getRoundListOutboundIndex function', () => {
172
+ it('should return the correct element in the array', () => {
173
+ const array = [ 1, 2, 3, 4, 5 ];
174
+
175
+ expect(DyFM_Array.getRoundListOutboundIndex(array, 3)).toBe(4);
176
+ expect(DyFM_Array.getRoundListOutboundIndex(array, 7)).toBe(3); // index wraps around
177
+ expect(DyFM_Array.getRoundListOutboundIndex(array, -2)).toBe(4); // negative index wraps around
178
+ });
179
+
180
+ it('should return null for invalid input', () => {
181
+ const emptyArray: number[] = [];
182
+
183
+ expect(DyFM_Array.getRoundListOutboundIndex(emptyArray, 0)).toBe(null); // empty array
184
+ expect(DyFM_Array.getRoundListOutboundIndex(null, 0)).toBe(null); // null array
185
+ });
186
+ });
187
+
188
+ describe('stringListHasMultiplications', () => {
189
+ it('should return true if input string array contains duplicates', () => {
190
+ const input1 = [ 'apple', 'banana', 'apple', 'orange' ];
191
+
192
+ expect(DyFM_Array.stringListHasMultiplications(input1)).toBe(true);
193
+
194
+ const input2 = [ 'apple', 'banana', 'orange' ];
195
+
196
+ expect(DyFM_Array.stringListHasMultiplications(input2)).toBe(false);
197
+ });
198
+ });
199
+
200
+ describe('filterStringMultiplications', () => {
201
+ xit('should return an array with duplicates filtered out', () => {
202
+ const inputList = [ 'abc', 'def', 'abc', 'ghi', 'abc' ];
203
+ const expectedOutput = [ 'abc' ];
204
+
205
+ const result = DyFM_Array.filterStringMultiplications(inputList);
206
+
207
+ expect(result).toEqual(expectedOutput);
208
+ });
209
+
210
+ it('should return an empty array if no duplicates are present', () => {
211
+ const inputList = [ 'abc', 'def', 'ghi' ];
212
+ const expectedOutput: string[] = [];
213
+
214
+ const result = DyFM_Array.filterStringMultiplications(inputList);
215
+
216
+ expect(result).toEqual(expectedOutput);
217
+ });
218
+
219
+ it('should handle empty input array and return empty array', () => {
220
+ const inputList: string[] = [];
221
+ const expectedOutput: string[] = [];
222
+
223
+ const result = DyFM_Array.filterStringMultiplications(inputList);
224
+
225
+ expect(result).toEqual(expectedOutput);
226
+ });
227
+ });
228
+
229
+ describe('gatherStringMultiplications', () => {
230
+ it('should return an array of arrays containing duplicated strings', () => {
231
+ const input = [ 'apple', 'banana', 'apple', 'cherry', 'banana', 'banana' ];
232
+ const expectedOutput = [[ 'apple', 'apple' ], [ 'banana', 'banana', 'banana' ]];
233
+
234
+ expect(DyFM_Array.gatherStringMultiplications(input)).toEqual(expectedOutput);
235
+ });
236
+
237
+ it('should return an empty array for no duplicated strings', () => {
238
+ const input = [ 'apple', 'banana', 'cherry' ];
239
+ const expectedOutput = [];
240
+
241
+ expect(DyFM_Array.gatherStringMultiplications(input)).toEqual(expectedOutput);
242
+ });
243
+
244
+ it('should return empty array for an empty input array', () => {
245
+ const input: string[] = [];
246
+ const expectedOutput: string[][] = [];
247
+
248
+ expect(DyFM_Array.gatherStringMultiplications(input)).toEqual(expectedOutput);
249
+ });
250
+
251
+ // Add more test cases as needed
252
+ });
253
+
254
+ describe('haveMultiplications', () => {
255
+ it('should return true if dataList contains any duplicate entry based on the given key', () => {
256
+ const dataList = [
257
+ { _id: 1, name: 'John' },
258
+ { _id: 2, name: 'Jane' },
259
+ { _id: 3, name: 'Alice' },
260
+ { _id: 1, name: 'Bob' },
261
+ ];
262
+
263
+ const result = DyFM_Array.haveMultiplications(dataList, '_id');
264
+
265
+ expect(result).toBe(true);
266
+ });
267
+
268
+ it('should return false if dataList does not contain any duplicate entry based on the given key', () => {
269
+ const dataList = [
270
+ { _id: 1, name: 'John' },
271
+ { _id: 2, name: 'Jane' },
272
+ { _id: 3, name: 'Alice' },
273
+ { _id: 4, name: 'Bob' },
274
+ ];
275
+
276
+ const result = DyFM_Array.haveMultiplications(dataList, '_id');
277
+
278
+ expect(result).toBe(false);
279
+ });
280
+ });
281
+
282
+ describe('filterMultiplications', () => {
283
+ xit('should filter out duplicate items based on the specified key', () => {
284
+ const dataList = [
285
+ { _id: 1, name: 'Alice' },
286
+ { _id: 2, name: 'Bob' },
287
+ { _id: 1, name: 'Charlie' },
288
+ { _id: 3, name: 'David' },
289
+ { _id: 1, name: 'Eve' },
290
+ ];
291
+
292
+ const expectedFilteredData = [
293
+ { _id: 1, name: 'Alice' },
294
+ { _id: 2, name: 'Bob' },
295
+ { _id: 3, name: 'David' },
296
+ ];
297
+
298
+ const filteredData = DyFM_Array.filterMultiplications(dataList);
299
+
300
+ expect(filteredData).toEqual(expectedFilteredData);
301
+ });
302
+
303
+ it('should return an empty array if no duplicates are found', () => {
304
+ const dataList = [
305
+ { _id: 1, name: 'Alice' },
306
+ { _id: 2, name: 'Bob' },
307
+ { _id: 3, name: 'Charlie' },
308
+ ];
309
+
310
+ const filteredData = DyFM_Array.filterMultiplications(dataList);
311
+
312
+ expect(filteredData).toEqual([]);
313
+ });
314
+
315
+ it('should handle empty input list', () => {
316
+ const dataList: any[] = [];
317
+
318
+ const filteredData = DyFM_Array.filterMultiplications(dataList);
319
+
320
+ expect(filteredData).toEqual([]);
321
+ });
322
+ });
323
+
324
+ describe('gatherMultiplications', () => {
325
+ it('should gather multiplications based on the specified key', () => {
326
+ const dataList = [
327
+ { _id: 1, name: 'Alice' },
328
+ { _id: 2, name: 'Bob' },
329
+ { _id: 1, name: 'Charlie' },
330
+ { _id: 3, name: 'David' },
331
+ { _id: 2, name: 'Eve' },
332
+ { _id: 3, name: 'Frank' },
333
+ ];
334
+
335
+ const expectedMultiplications = [
336
+ [
337
+ { _id: 1, name: 'Alice' },
338
+ { _id: 1, name: 'Charlie' },
339
+ ],
340
+ [
341
+ { _id: 2, name: 'Bob' },
342
+ { _id: 2, name: 'Eve' },
343
+ ],
344
+ [
345
+ { _id: 3, name: 'David' },
346
+ { _id: 3, name: 'Frank' },
347
+ ],
348
+ ];
349
+
350
+ expect(DyFM_Array.gatherMultiplications(dataList)).toEqual(expectedMultiplications);
351
+ });
352
+ });
39
353
  });
@@ -89,10 +89,10 @@ export class DyFM_Array {
89
89
  let randomIndex: number;
90
90
 
91
91
  while (0 < currentIndex) {
92
- randomIndex = Math.floor(Math.random() * currentIndex);
93
92
  currentIndex--;
94
-
95
- [ array[currentIndex], array[randomIndex] ] = [ array[randomIndex], array[currentIndex] ];
93
+
94
+ randomIndex = Math.floor(Math.random() * (array.length - 1));
95
+ this.swap(array, currentIndex, randomIndex);
96
96
  }
97
97
 
98
98
  return array;
@@ -0,0 +1,79 @@
1
+
2
+ import { DyFM_BoxBounds } from './box-bounds.util';
3
+ import { DyFM_Vector2_Util } from './vector2.util';
4
+
5
+ xdescribe('DyFM_BoxBounds', () => {
6
+ let boxBounds: DyFM_BoxBounds;
7
+ const mockPosition = new DyFM_Vector2_Util({ x: 0, y: 0 });
8
+ const mockSize = new DyFM_Vector2_Util({ x: 10, y: 10 });
9
+
10
+ beforeEach(() => {
11
+ boxBounds = new DyFM_BoxBounds(mockPosition, mockSize);
12
+ });
13
+
14
+ it('should set position correctly ()', () => {
15
+ const newPosition = new DyFM_Vector2_Util({ x: 5, y: 5 });
16
+
17
+ boxBounds.pos = newPosition;
18
+ expect(boxBounds.pos).toEqual(newPosition);
19
+ });
20
+
21
+ it('should get position correctly', () => {
22
+ const expectedPosition = new DyFM_Vector2_Util({ x: 5, y: 5 });
23
+
24
+ expect(boxBounds.pos).toEqual(expectedPosition);
25
+ });
26
+
27
+ it('should set size correctly', () => {
28
+ const newSize = new DyFM_Vector2_Util({ x: 20, y: 20 });
29
+
30
+ boxBounds.size = newSize;
31
+ expect(boxBounds.size).toEqual(newSize);
32
+ });
33
+
34
+ it('should get size correctly', () => {
35
+ const expectedSize = new DyFM_Vector2_Util({ x: 20, y: 20 });
36
+
37
+ expect(boxBounds.size).toEqual(expectedSize);
38
+ });
39
+
40
+ it('should calculate center correctly', () => {
41
+ const expectedCenter = new DyFM_Vector2_Util({ x: 10, y: 10 });
42
+
43
+ boxBounds['calcCenter']();
44
+ expect(boxBounds.center).toEqual(expectedCenter);
45
+ });
46
+
47
+ it('should calculate center margin correctly', () => {
48
+ const expectedCenterMargin = new DyFM_Vector2_Util({ x: -5, y: -5 });
49
+
50
+ boxBounds['calcCenter']();
51
+ expect(boxBounds.centerMargin).toEqual(expectedCenterMargin);
52
+ });
53
+
54
+ it('should return true for constructed method', () => {
55
+ expect(boxBounds.constructed()).toBe(true);
56
+ });
57
+
58
+ it('should throw error when newValues has undefined position', () => {
59
+ expect(() => {
60
+ boxBounds.newValues(undefined, { x: 10, y: 10 });
61
+ }).toThrow(Error);
62
+ });
63
+
64
+ it('should throw error when newValues has undefined size', () => {
65
+ expect(() => {
66
+ boxBounds.newValues({ x: 0, y: 0 }, undefined);
67
+ }).toThrow(Error);
68
+ });
69
+
70
+ it('should clone and return a new instance', () => {
71
+ const clonedBoxBounds = boxBounds.clone();
72
+
73
+ expect(clonedBoxBounds).toBeInstanceOf(DyFM_BoxBounds);
74
+ expect(clonedBoxBounds).toEqual(boxBounds);
75
+ });
76
+
77
+ // Add more test cases as needed
78
+
79
+ });
@@ -10,7 +10,7 @@ import { DyFM_Vector2_Util } from './vector2.util';
10
10
  * (if this is not true, report it as a bug)
11
11
  */
12
12
  export class DyFM_BoxBounds {
13
- private _pos: DyFM_Vector2_Util;
13
+ private readonly _pos: DyFM_Vector2_Util;
14
14
  set pos(value: DyFM_Vector2) {
15
15
  this._pos.newValues(value);
16
16
 
@@ -20,7 +20,7 @@ export class DyFM_BoxBounds {
20
20
  return this._pos;
21
21
  }
22
22
 
23
- private _size: DyFM_Vector2_Util;
23
+ private readonly _size: DyFM_Vector2_Util;
24
24
  set size(value: DyFM_Vector2) {
25
25
  this._size.newValues(value);
26
26