@bitbybit-dev/base 0.19.8 → 0.20.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (65) hide show
  1. package/babel.config.cjs +1 -0
  2. package/babel.config.d.cts +5 -0
  3. package/index.d.ts +1 -0
  4. package/{index.ts → index.js} +1 -2
  5. package/lib/api/index.js +1 -0
  6. package/lib/api/inputs/base-inputs.d.ts +35 -0
  7. package/lib/api/inputs/base-inputs.js +1 -0
  8. package/lib/api/inputs/{color-inputs.ts → color-inputs.d.ts} +26 -48
  9. package/lib/api/inputs/color-inputs.js +164 -0
  10. package/lib/api/inputs/dates-inputs.d.ts +216 -0
  11. package/lib/api/inputs/dates-inputs.js +271 -0
  12. package/lib/api/inputs/{index.ts → index.d.ts} +1 -0
  13. package/lib/api/inputs/index.js +10 -0
  14. package/lib/api/inputs/{inputs.ts → inputs.d.ts} +1 -0
  15. package/lib/api/inputs/inputs.js +10 -0
  16. package/lib/api/inputs/{lists-inputs.ts → lists-inputs.d.ts} +91 -190
  17. package/lib/api/inputs/lists-inputs.js +576 -0
  18. package/lib/api/inputs/{logic-inputs.ts → logic-inputs.d.ts} +24 -46
  19. package/lib/api/inputs/logic-inputs.js +111 -0
  20. package/lib/api/inputs/{math-inputs.ts → math-inputs.d.ts} +53 -97
  21. package/lib/api/inputs/math-inputs.js +391 -0
  22. package/lib/api/inputs/{point-inputs.ts → point-inputs.d.ts} +77 -168
  23. package/lib/api/inputs/point-inputs.js +521 -0
  24. package/lib/api/inputs/text-inputs.d.ts +83 -0
  25. package/lib/api/inputs/text-inputs.js +120 -0
  26. package/lib/api/inputs/{transforms-inputs.ts → transforms-inputs.d.ts} +35 -64
  27. package/lib/api/inputs/transforms-inputs.js +200 -0
  28. package/lib/api/inputs/{vector-inputs.ts → vector-inputs.d.ts} +48 -104
  29. package/lib/api/inputs/vector-inputs.js +304 -0
  30. package/lib/api/services/color.d.ts +114 -0
  31. package/lib/api/services/{color.ts → color.js} +15 -34
  32. package/lib/api/services/dates.d.ts +367 -0
  33. package/lib/api/services/dates.js +450 -0
  34. package/lib/api/services/geometry-helper.d.ts +15 -0
  35. package/lib/api/services/{geometry-helper.ts → geometry-helper.js} +31 -43
  36. package/lib/api/services/{index.ts → index.d.ts} +2 -1
  37. package/lib/api/services/index.js +10 -0
  38. package/lib/api/services/lists.d.ts +287 -0
  39. package/lib/api/services/{lists.ts → lists.js} +59 -83
  40. package/lib/api/services/logic.d.ts +99 -0
  41. package/lib/api/services/{logic.ts → logic.js} +24 -32
  42. package/lib/api/services/math.d.ts +349 -0
  43. package/lib/api/services/{math.ts → math.js} +71 -136
  44. package/lib/api/services/point.d.ts +222 -0
  45. package/lib/api/services/{point.ts → point.js} +32 -67
  46. package/lib/api/services/text.d.ts +69 -0
  47. package/lib/api/services/{text.ts → text.js} +7 -17
  48. package/lib/api/services/transforms.d.ts +122 -0
  49. package/lib/api/services/{transforms.ts → transforms.js} +37 -83
  50. package/lib/api/services/vector.d.ts +320 -0
  51. package/lib/api/services/{vector.ts → vector.js} +42 -80
  52. package/lib/{index.ts → index.d.ts} +0 -1
  53. package/lib/index.js +1 -0
  54. package/package.json +1 -1
  55. package/lib/api/inputs/base-inputs.ts +0 -18
  56. package/lib/api/inputs/text-inputs.ts +0 -108
  57. package/lib/api/services/color.test.ts +0 -86
  58. package/lib/api/services/lists.test.ts +0 -612
  59. package/lib/api/services/logic.test.ts +0 -187
  60. package/lib/api/services/math.test.ts +0 -622
  61. package/lib/api/services/text.test.ts +0 -55
  62. package/lib/api/services/vector.test.ts +0 -360
  63. package/tsconfig.bitbybit.json +0 -26
  64. package/tsconfig.json +0 -24
  65. /package/lib/api/{index.ts → index.d.ts} +0 -0
@@ -1,5 +1,4 @@
1
1
  import * as Inputs from "../inputs";
2
-
3
2
  /**
4
3
  * Contains various list methods.
5
4
  * <div>
@@ -15,20 +14,19 @@ export class Lists {
15
14
  * @shortname item by index
16
15
  * @drawable false
17
16
  */
18
- getItem<T>(inputs: Inputs.Lists.ListItemDto<T>): T {
17
+ getItem(inputs) {
19
18
  if (inputs.index < 0 || inputs.index >= inputs.list.length) {
20
19
  throw new Error("Index out of bounds");
21
20
  }
22
21
  let result;
23
22
  if (inputs.clone) {
24
23
  result = structuredClone(inputs.list[inputs.index]);
25
- } else {
24
+ }
25
+ else {
26
26
  result = inputs.list[inputs.index];
27
27
  }
28
28
  return result;
29
29
  }
30
-
31
-
32
30
  /**
33
31
  * Gets items randomly by using a threshold
34
32
  * @param inputs a list and a threshold for randomization of items to remove
@@ -37,7 +35,7 @@ export class Lists {
37
35
  * @shortname random get threshold
38
36
  * @drawable false
39
37
  */
40
- randomGetThreshold<T>(inputs: Inputs.Lists.RandomThresholdDto<T>): T[] {
38
+ randomGetThreshold(inputs) {
41
39
  let res = inputs.list;
42
40
  if (inputs.clone) {
43
41
  res = structuredClone(inputs.list);
@@ -50,7 +48,6 @@ export class Lists {
50
48
  }
51
49
  return newList;
52
50
  }
53
-
54
51
  /**
55
52
  * Gets a sub list between start and end indexes
56
53
  * @param inputs a list and start and end indexes
@@ -59,16 +56,16 @@ export class Lists {
59
56
  * @shortname sublist
60
57
  * @drawable false
61
58
  */
62
- getSubList<T>(inputs: Inputs.Lists.SubListDto<T>): T[] {
59
+ getSubList(inputs) {
63
60
  let result;
64
61
  if (inputs.clone) {
65
62
  result = structuredClone(inputs.list.slice(inputs.indexStart, inputs.indexEnd));
66
- } else {
63
+ }
64
+ else {
67
65
  result = inputs.list.slice(inputs.indexStart, inputs.indexEnd);
68
66
  }
69
67
  return result;
70
68
  }
71
-
72
69
  /**
73
70
  * Gets nth item in the list
74
71
  * @param inputs a list and index
@@ -77,7 +74,7 @@ export class Lists {
77
74
  * @shortname every n-th
78
75
  * @drawable false
79
76
  */
80
- getNthItem<T>(inputs: Inputs.Lists.GetNthItemDto<T>): T[] {
77
+ getNthItem(inputs) {
81
78
  let cloned = inputs.list;
82
79
  if (inputs.clone) {
83
80
  cloned = structuredClone(inputs.list);
@@ -98,7 +95,7 @@ export class Lists {
98
95
  * @shortname by pattern
99
96
  * @drawable false
100
97
  */
101
- getByPattern<T>(inputs: Inputs.Lists.GetByPatternDto<T>): T[] {
98
+ getByPattern(inputs) {
102
99
  const { list, pattern } = inputs;
103
100
  if (!pattern || pattern.length === 0) {
104
101
  throw new Error("Pattern is empty or does not exist");
@@ -127,7 +124,6 @@ export class Lists {
127
124
  }
128
125
  return result;
129
126
  }
130
-
131
127
  /**
132
128
  * Merge elements of lists on a given level and flatten output if needed
133
129
  * @param inputs lists, level and flatten data
@@ -136,10 +132,9 @@ export class Lists {
136
132
  * @shortname merge levels
137
133
  * @drawable false
138
134
  */
139
- mergeElementsOfLists<T>(inputs: Inputs.Lists.MergeElementsOfLists<T[]>): T[] {
135
+ mergeElementsOfLists(inputs) {
140
136
  const lists = inputs.lists;
141
137
  const level = inputs.level;
142
-
143
138
  const elToMerge = [];
144
139
  const result = [];
145
140
  lists.forEach(list => {
@@ -147,7 +142,6 @@ export class Lists {
147
142
  const elementsToMerge = list.flat(level);
148
143
  elToMerge.push(elementsToMerge);
149
144
  });
150
-
151
145
  const lengthMerge = this.getLongestListLength({ lists: elToMerge });
152
146
  for (let i = 0; i < lengthMerge; i++) {
153
147
  const temp = [];
@@ -161,24 +155,25 @@ export class Lists {
161
155
  result.push(temp);
162
156
  }
163
157
  }
164
-
165
158
  let final = [];
166
159
  if (level > 0) {
167
160
  for (let i = 0; i < level; i++) {
168
161
  if (i === level - 1 && i !== 0) {
169
162
  final[i - 1].push(result);
170
- } else if (i === level - 1) {
163
+ }
164
+ else if (i === level - 1) {
171
165
  final.push(result);
172
- } else {
166
+ }
167
+ else {
173
168
  final.push([]);
174
169
  }
175
170
  }
176
- } else {
171
+ }
172
+ else {
177
173
  final = result;
178
174
  }
179
175
  return final;
180
176
  }
181
-
182
177
  /**
183
178
  * Gets the longest list length from the list of lists
184
179
  * @param inputs a list of lists
@@ -187,21 +182,20 @@ export class Lists {
187
182
  * @shortname longest list length
188
183
  * @drawable false
189
184
  */
190
- getLongestListLength<T>(inputs: Inputs.Lists.GetLongestListLength<T[]>): number {
185
+ getLongestListLength(inputs) {
191
186
  let longestSoFar = 0;
192
187
  if (inputs.lists) {
193
-
194
188
  inputs.lists.forEach(l => {
195
189
  if (l.length > longestSoFar) {
196
190
  longestSoFar = l.length;
197
191
  }
198
192
  });
199
193
  return longestSoFar;
200
- } else {
194
+ }
195
+ else {
201
196
  return undefined;
202
197
  }
203
198
  }
204
-
205
199
  /**
206
200
  * Reverse the list
207
201
  * @param inputs a list and an index
@@ -210,14 +204,13 @@ export class Lists {
210
204
  * @shortname reverse
211
205
  * @drawable false
212
206
  */
213
- reverse<T>(inputs: Inputs.Lists.ListCloneDto<T>): T[] {
207
+ reverse(inputs) {
214
208
  let res = inputs.list;
215
209
  if (inputs.clone) {
216
210
  res = structuredClone(inputs.list);
217
211
  }
218
212
  return res.reverse();
219
213
  }
220
-
221
214
  /**
222
215
  * Flip 2d lists - every nth element of each list will form a separate list
223
216
  * @param inputs a list of lists to flip
@@ -226,7 +219,7 @@ export class Lists {
226
219
  * @shortname flip lists
227
220
  * @drawable false
228
221
  */
229
- flipLists<T>(inputs: Inputs.Lists.ListCloneDto<T[]>): T[][] {
222
+ flipLists(inputs) {
230
223
  if (inputs.list.length > 0) {
231
224
  const lengthOfFirstList = inputs.list[0].length;
232
225
  let allListsSameLength = true;
@@ -245,14 +238,15 @@ export class Lists {
245
238
  result.push(newList);
246
239
  }
247
240
  return result;
248
- } else {
241
+ }
242
+ else {
249
243
  throw new Error("Lists are not of the same length");
250
244
  }
251
- } else {
245
+ }
246
+ else {
252
247
  throw new Error("List is empty");
253
248
  }
254
249
  }
255
-
256
250
  /**
257
251
  * Group in lists of n elements
258
252
  * @param inputs a list
@@ -261,8 +255,8 @@ export class Lists {
261
255
  * @shortname group elements
262
256
  * @drawable false
263
257
  */
264
- groupNth<T>(inputs: Inputs.Lists.GroupListDto<T>): T[] {
265
- const groupElements = (inputs: Inputs.Lists.GroupListDto<T>) => {
258
+ groupNth(inputs) {
259
+ const groupElements = (inputs) => {
266
260
  const { nrElements, list, keepRemainder } = inputs;
267
261
  const nrElementsInGroup = nrElements;
268
262
  const result = [];
@@ -282,7 +276,6 @@ export class Lists {
282
276
  // TODO make this work on any level
283
277
  return groupElements(inputs);
284
278
  }
285
-
286
279
  /**
287
280
  * Get the depth of the list
288
281
  * @param inputs a list
@@ -291,7 +284,7 @@ export class Lists {
291
284
  * @shortname max list depth
292
285
  * @drawable false
293
286
  */
294
- getListDepth(inputs: Inputs.Lists.ListCloneDto<[]>): number {
287
+ getListDepth(inputs) {
295
288
  let levels = 0;
296
289
  let deeperLevelsExist = true;
297
290
  let flatRes = inputs.list;
@@ -305,14 +298,14 @@ export class Lists {
305
298
  flatRes = flatRes.flat();
306
299
  if (foundArray) {
307
300
  levels++;
308
- } else {
301
+ }
302
+ else {
309
303
  levels++;
310
304
  deeperLevelsExist = false;
311
305
  }
312
306
  }
313
307
  return levels;
314
308
  }
315
-
316
309
  /**
317
310
  * Gets the length of the list
318
311
  * @param inputs a length list
@@ -321,10 +314,9 @@ export class Lists {
321
314
  * @shortname list length
322
315
  * @drawable false
323
316
  */
324
- listLength<T>(inputs: Inputs.Lists.ListCloneDto<T>): number {
317
+ listLength(inputs) {
325
318
  return inputs.list.length;
326
319
  }
327
-
328
320
  /**
329
321
  * Add item to the list
330
322
  * @param inputs a list, item and an index
@@ -333,7 +325,7 @@ export class Lists {
333
325
  * @shortname add item
334
326
  * @drawable false
335
327
  */
336
- addItemAtIndex<T>(inputs: Inputs.Lists.AddItemAtIndexDto<T>): T[] {
328
+ addItemAtIndex(inputs) {
337
329
  let res = inputs.list;
338
330
  if (inputs.clone) {
339
331
  res = structuredClone(inputs.list);
@@ -343,7 +335,6 @@ export class Lists {
343
335
  }
344
336
  return res;
345
337
  }
346
-
347
338
  /**
348
339
  * Adds item to the list of provided indexes
349
340
  * @param inputs a list, item and an indexes
@@ -352,7 +343,7 @@ export class Lists {
352
343
  * @shortname add item at indexes
353
344
  * @drawable false
354
345
  */
355
- addItemAtIndexes<T>(inputs: Inputs.Lists.AddItemAtIndexesDto<T>): T[] {
346
+ addItemAtIndexes(inputs) {
356
347
  let cloned = inputs.list;
357
348
  if (inputs.clone) {
358
349
  cloned = structuredClone(inputs.list);
@@ -364,11 +355,9 @@ export class Lists {
364
355
  if (index >= 0 && index + i <= cloned.length) {
365
356
  cloned.splice(index + i, 0, inputs.item);
366
357
  }
367
- }
368
- );
358
+ });
369
359
  return cloned;
370
360
  }
371
-
372
361
  /**
373
362
  * Adds items to the list of provided indexes matching 1:1, first item will go to first index provided, etc.
374
363
  * @param inputs a list, items and an indexes
@@ -377,7 +366,7 @@ export class Lists {
377
366
  * @shortname add items
378
367
  * @drawable false
379
368
  */
380
- addItemsAtIndexes<T>(inputs: Inputs.Lists.AddItemsAtIndexesDto<T>): T[] {
369
+ addItemsAtIndexes(inputs) {
381
370
  if (inputs.items.length !== inputs.indexes.length) {
382
371
  throw new Error("Items and indexes must have the same length");
383
372
  }
@@ -401,7 +390,6 @@ export class Lists {
401
390
  });
402
391
  return cloned;
403
392
  }
404
-
405
393
  /**
406
394
  * Remove item from the list
407
395
  * @param inputs a list and index
@@ -410,7 +398,7 @@ export class Lists {
410
398
  * @shortname remove item
411
399
  * @drawable false
412
400
  */
413
- removeItemAtIndex<T>(inputs: Inputs.Lists.RemoveItemAtIndexDto<T>): T[] {
401
+ removeItemAtIndex(inputs) {
414
402
  let res = inputs.list;
415
403
  if (inputs.clone) {
416
404
  res = structuredClone(inputs.list);
@@ -420,7 +408,6 @@ export class Lists {
420
408
  }
421
409
  return res;
422
410
  }
423
-
424
411
  /**
425
412
  * Remove items from the list of provided indexes
426
413
  * @param inputs a list and indexes
@@ -429,7 +416,7 @@ export class Lists {
429
416
  * @shortname remove items
430
417
  * @drawable false
431
418
  */
432
- removeItemsAtIndexes<T>(inputs: Inputs.Lists.RemoveItemsAtIndexesDto<T>): T[] {
419
+ removeItemsAtIndexes(inputs) {
433
420
  let res = inputs.list;
434
421
  if (inputs.clone) {
435
422
  res = structuredClone(inputs.list);
@@ -443,7 +430,6 @@ export class Lists {
443
430
  });
444
431
  return res;
445
432
  }
446
-
447
433
  /**
448
434
  * Remove all items from the list
449
435
  * @param inputs a list
@@ -452,11 +438,10 @@ export class Lists {
452
438
  * @shortname remove all items
453
439
  * @drawable false
454
440
  */
455
- removeAllItems<T>(inputs: Inputs.Lists.ListDto<T>): T[] {
441
+ removeAllItems(inputs) {
456
442
  inputs.list.length = 0;
457
443
  return inputs.list;
458
444
  }
459
-
460
445
  /**
461
446
  * Remove item from the list
462
447
  * @param inputs a list and index
@@ -465,7 +450,7 @@ export class Lists {
465
450
  * @shortname every n-th
466
451
  * @drawable false
467
452
  */
468
- removeNthItem<T>(inputs: Inputs.Lists.RemoveNthItemDto<T>): T[] {
453
+ removeNthItem(inputs) {
469
454
  let res = inputs.list;
470
455
  if (inputs.clone) {
471
456
  res = structuredClone(inputs.list);
@@ -478,7 +463,6 @@ export class Lists {
478
463
  }
479
464
  return result;
480
465
  }
481
-
482
466
  /**
483
467
  * Removes items randomly by using a threshold
484
468
  * @param inputs a list and a threshold for randomization of items to remove
@@ -487,7 +471,7 @@ export class Lists {
487
471
  * @shortname random remove threshold
488
472
  * @drawable false
489
473
  */
490
- randomRemoveThreshold<T>(inputs: Inputs.Lists.RandomThresholdDto<T>): T[] {
474
+ randomRemoveThreshold(inputs) {
491
475
  let res = inputs.list;
492
476
  if (inputs.clone) {
493
477
  res = structuredClone(inputs.list);
@@ -500,7 +484,6 @@ export class Lists {
500
484
  }
501
485
  return newList;
502
486
  }
503
-
504
487
  /**
505
488
  * remove duplicate numbers from the list
506
489
  * @param inputs a list of numbers
@@ -509,14 +492,13 @@ export class Lists {
509
492
  * @shortname remove duplicates
510
493
  * @drawable false
511
494
  */
512
- removeDuplicateNumbers(inputs: Inputs.Lists.RemoveDuplicatesDto<number>): number[] {
495
+ removeDuplicateNumbers(inputs) {
513
496
  let res = inputs.list;
514
497
  if (inputs.clone) {
515
498
  res = structuredClone(inputs.list);
516
499
  }
517
500
  return res.filter((value, index, self) => self.indexOf(value) === index);
518
501
  }
519
-
520
502
  /**
521
503
  * remove duplicate numbers from the list with tolerance
522
504
  * @param inputs a list of numbers and the tolerance
@@ -525,14 +507,13 @@ export class Lists {
525
507
  * @shortname remove duplicates tol
526
508
  * @drawable false
527
509
  */
528
- removeDuplicateNumbersTolerance(inputs: Inputs.Lists.RemoveDuplicatesToleranceDto<number>): number[] {
510
+ removeDuplicateNumbersTolerance(inputs) {
529
511
  let res = inputs.list;
530
512
  if (inputs.clone) {
531
513
  res = structuredClone(inputs.list);
532
514
  }
533
515
  return res.filter((value, index, self) => self.findIndex(s => Math.abs(s - value) < inputs.tolerance) === index);
534
516
  }
535
-
536
517
  /**
537
518
  * Add item to the end of the list
538
519
  * @param inputs a list and an item
@@ -541,7 +522,7 @@ export class Lists {
541
522
  * @shortname add item to list
542
523
  * @drawable false
543
524
  */
544
- addItem<T>(inputs: Inputs.Lists.AddItemDto<T>): T[] {
525
+ addItem(inputs) {
545
526
  let res = inputs.list;
546
527
  if (inputs.clone) {
547
528
  res = structuredClone(inputs.list);
@@ -549,7 +530,6 @@ export class Lists {
549
530
  res.push(inputs.item);
550
531
  return res;
551
532
  }
552
-
553
533
  /**
554
534
  * Add item to the beginning of the list
555
535
  * @param inputs a list and an item
@@ -558,7 +538,7 @@ export class Lists {
558
538
  * @shortname prepend item to list
559
539
  * @drawable false
560
540
  */
561
- prependItem<T>(inputs: Inputs.Lists.AddItemDto<T>): T[] {
541
+ prependItem(inputs) {
562
542
  let res = inputs.list;
563
543
  if (inputs.clone) {
564
544
  res = structuredClone(inputs.list);
@@ -566,7 +546,6 @@ export class Lists {
566
546
  res.unshift(inputs.item);
567
547
  return res;
568
548
  }
569
-
570
549
  /**
571
550
  * Add item to the beginning or the end of the list
572
551
  * @param inputs a list, item and an option for first or last position
@@ -575,19 +554,19 @@ export class Lists {
575
554
  * @shortname item at first or last
576
555
  * @drawable false
577
556
  */
578
- addItemFirstLast<T>(inputs: Inputs.Lists.AddItemFirstLastDto<T>): T[] {
557
+ addItemFirstLast(inputs) {
579
558
  let res = inputs.list;
580
559
  if (inputs.clone) {
581
560
  res = structuredClone(inputs.list);
582
561
  }
583
562
  if (inputs.position === Inputs.Lists.firstLastEnum.first) {
584
563
  res.unshift(inputs.item);
585
- } else {
564
+ }
565
+ else {
586
566
  res.push(inputs.item);
587
567
  }
588
568
  return res;
589
569
  }
590
-
591
570
  /**
592
571
  * Creates an empty list
593
572
  * @returns an empty array list
@@ -595,10 +574,9 @@ export class Lists {
595
574
  * @shortname empty list
596
575
  * @drawable false
597
576
  */
598
- createEmptyList(): [] {
577
+ createEmptyList() {
599
578
  return [];
600
579
  }
601
-
602
580
  /**
603
581
  * Repeat the item and add it in the new list
604
582
  * @param inputs an item to multiply
@@ -607,14 +585,13 @@ export class Lists {
607
585
  * @shortname repeat
608
586
  * @drawable false
609
587
  */
610
- repeat<T>(inputs: Inputs.Lists.MultiplyItemDto<T>): T[] {
588
+ repeat(inputs) {
611
589
  const result = [];
612
590
  for (let i = 0; i < inputs.times; i++) {
613
591
  result.push(inputs.item);
614
592
  }
615
593
  return result;
616
594
  }
617
-
618
595
  /**
619
596
  * Repeat the list items by adding them in the new list till the certain length of the list is reached
620
597
  * @param inputs a list to multiply and a length limit
@@ -623,7 +600,7 @@ export class Lists {
623
600
  * @shortname repeat in pattern
624
601
  * @drawable false
625
602
  */
626
- repeatInPattern<T>(inputs: Inputs.Lists.RepeatInPatternDto<T>): T[] {
603
+ repeatInPattern(inputs) {
627
604
  // will repeat the items provided in the patten till the certain length of the list is reached
628
605
  let inpList = inputs.list;
629
606
  if (inputs.clone) {
@@ -642,7 +619,6 @@ export class Lists {
642
619
  }
643
620
  return res;
644
621
  }
645
-
646
622
  /**
647
623
  * Sort the list of numbers in ascending or descending order
648
624
  * @param inputs a list of numbers to sort and an option for ascending or descending order
@@ -651,18 +627,18 @@ export class Lists {
651
627
  * @shortname sort numbers
652
628
  * @drawable false
653
629
  */
654
- sortNumber(inputs: Inputs.Lists.SortDto<number>): number[] {
630
+ sortNumber(inputs) {
655
631
  let res = inputs.list;
656
632
  if (inputs.clone) {
657
633
  res = structuredClone(inputs.list);
658
634
  }
659
635
  if (inputs.orderAsc) {
660
636
  return res.sort((a, b) => a - b);
661
- } else {
637
+ }
638
+ else {
662
639
  return res.sort((a, b) => b - a);
663
640
  }
664
641
  }
665
-
666
642
  /**
667
643
  * Sort the list of texts in ascending or descending order alphabetically
668
644
  * @param inputs a list of texts to sort and an option for ascending or descending order
@@ -671,18 +647,18 @@ export class Lists {
671
647
  * @shortname sort texts
672
648
  * @drawable false
673
649
  */
674
- sortTexts(inputs: Inputs.Lists.SortDto<string>): string[] {
650
+ sortTexts(inputs) {
675
651
  let res = inputs.list;
676
652
  if (inputs.clone) {
677
653
  res = structuredClone(inputs.list);
678
654
  }
679
655
  if (inputs.orderAsc) {
680
656
  return res.sort();
681
- } else {
657
+ }
658
+ else {
682
659
  return res.sort().reverse();
683
660
  }
684
661
  }
685
-
686
662
  /**
687
663
  * Sort by numeric JSON property value
688
664
  * @param inputs a list to sort, a property to sort by and an option for ascending or descending order
@@ -691,16 +667,16 @@ export class Lists {
691
667
  * @shortname sort json objects
692
668
  * @drawable false
693
669
  */
694
- sortByPropValue(inputs: Inputs.Lists.SortJsonDto<any>): any[] {
670
+ sortByPropValue(inputs) {
695
671
  let res = inputs.list;
696
672
  if (inputs.clone) {
697
673
  res = structuredClone(inputs.list);
698
674
  }
699
675
  if (inputs.orderAsc) {
700
676
  return res.sort((a, b) => a[inputs.property] - b[inputs.property]);
701
- } else {
677
+ }
678
+ else {
702
679
  return res.sort((a, b) => b[inputs.property] - a[inputs.property]);
703
680
  }
704
681
  }
705
-
706
682
  }
@@ -0,0 +1,99 @@
1
+ import * as Inputs from "../inputs";
2
+ /**
3
+ * Contains various logic methods.
4
+ */
5
+ export declare class Logic {
6
+ /**
7
+ * Creates a boolean value - true or false
8
+ * @param inputs a true or false boolean
9
+ * @returns boolean
10
+ * @group create
11
+ * @shortname boolean
12
+ * @drawable false
13
+ */
14
+ boolean(inputs: Inputs.Logic.BooleanDto): boolean;
15
+ /**
16
+ * Creates a random boolean list of predefined length
17
+ * @param inputs a length and a threshold for randomization of true values
18
+ * @returns booleans
19
+ * @group create
20
+ * @shortname random booleans
21
+ * @drawable false
22
+ */
23
+ randomBooleans(inputs: Inputs.Logic.RandomBooleansDto): boolean[];
24
+ /**
25
+ * Creates a random boolean list of true and false values based on a list of numbers.
26
+ * All values between true threshold will be true, all values above false threshold will be false,
27
+ * and the rest will be distributed between true and false based on the number of levels in a gradient pattern.
28
+ * That means that the closer the number gets to the false threshold the bigger the chance will be to get random false value.
29
+ * @param inputs a length and a threshold for randomization of true values
30
+ * @returns booleans
31
+ * @group create
32
+ * @shortname 2 threshold random gradient
33
+ * @drawable false
34
+ */
35
+ twoThresholdRandomGradient(inputs: Inputs.Logic.TwoThresholdRandomGradientDto): boolean[];
36
+ /**
37
+ * Creates a boolean list based on a list of numbers and a threshold.
38
+ * @param inputs a length and a threshold for randomization of true values
39
+ * @returns booleans
40
+ * @group create
41
+ * @shortname threshold boolean list
42
+ * @drawable false
43
+ */
44
+ thresholdBooleanList(inputs: Inputs.Logic.ThresholdBooleanListDto): boolean[];
45
+ /**
46
+ * Creates a boolean list based on a list of numbers and a gap thresholds. Gap thresholds are pairs of numbers that define a range of numbers that will be true.
47
+ * @param inputs a length and a threshold for randomization of true values
48
+ * @returns booleans
49
+ * @group create
50
+ * @shortname threshold gaps boolean list
51
+ * @drawable false
52
+ */
53
+ thresholdGapsBooleanList(inputs: Inputs.Logic.ThresholdGapsBooleanListDto): boolean[];
54
+ /**
55
+ * Apply not operator on the boolean
56
+ * @param inputs a true or false boolean
57
+ * @returns boolean
58
+ * @group edit
59
+ * @shortname not
60
+ * @drawable false
61
+ */
62
+ not(inputs: Inputs.Logic.BooleanDto): boolean;
63
+ /**
64
+ * Apply not operator on a list of booleans
65
+ * @param inputs a list of true or false booleans
66
+ * @returns booleans
67
+ * @group edit
68
+ * @shortname not list
69
+ * @drawable false
70
+ */
71
+ notList(inputs: Inputs.Logic.BooleanListDto): boolean[];
72
+ /**
73
+ * Does comparison between first and second values
74
+ * @param inputs two values to be compared
75
+ * @returns Result of the comparison
76
+ * @group operations
77
+ * @shortname compare
78
+ * @drawable false
79
+ */
80
+ compare<T>(inputs: Inputs.Logic.ComparisonDto<T>): boolean;
81
+ /**
82
+ * Transmits a value if boolean provided is true and undefined if boolean provided is false
83
+ * @param inputs a value and a boolean value
84
+ * @returns value or undefined
85
+ * @group operations
86
+ * @shortname value gate
87
+ * @drawable false
88
+ */
89
+ valueGate<T>(inputs: Inputs.Logic.ValueGateDto<T>): T | undefined;
90
+ /**
91
+ * Returns first defined value out of two
92
+ * @param inputs two values
93
+ * @returns value or undefined
94
+ * @group operations
95
+ * @shortname first defined value gate
96
+ * @drawable false
97
+ */
98
+ firstDefinedValueGate<T, U>(inputs: Inputs.Logic.TwoValueGateDto<T, U>): T | U | undefined;
99
+ }