@reldens/utils 0.55.0 → 0.57.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.
package/CLAUDE.md CHANGED
@@ -1,7 +1,3 @@
1
- # CLAUDE.md
2
-
3
- This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4
-
5
1
  ## Package Overview
6
2
 
7
3
  **@reldens/utils** is a core utility package used throughout the Reldens ecosystem. It provides essential utilities for:
package/lib/shortcuts.js CHANGED
@@ -404,6 +404,19 @@ class Shortcuts
404
404
  return array[Math.floor(Math.random() * array.length)];
405
405
  }
406
406
 
407
+ shuffleArray(array)
408
+ {
409
+ if(!this.isArray(array)){
410
+ return [];
411
+ }
412
+ let newArray = [...array];
413
+ for(let i = newArray.length - 1; i > 0; i--){
414
+ let swapIndex = Math.floor(Math.random() * (i + 1));
415
+ [newArray[i], newArray[swapIndex]] = [newArray[swapIndex], newArray[i]];
416
+ }
417
+ return newArray;
418
+ }
419
+
407
420
  randomInteger(min, max)
408
421
  {
409
422
  return Math.floor(Math.random() * (max - min + 1)) + min;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@reldens/utils",
3
3
  "scope": "@reldens",
4
- "version": "0.55.0",
4
+ "version": "0.57.0",
5
5
  "description": "Reldens - Utils",
6
6
  "author": "Damian A. Pastorini",
7
7
  "license": "MIT",
@@ -673,6 +673,24 @@ class TestShortcuts
673
673
  });
674
674
  }
675
675
 
676
+ testShuffleArray()
677
+ {
678
+ this.test('returns an array with the same elements', () => {
679
+ let values = [1, 2, 3, 4, 5];
680
+ let result = sc.shuffleArray(values);
681
+ this.assert(5 === result.length);
682
+ this.assert(values.every(value => sc.inArray(value, result)));
683
+ });
684
+ this.test('does not mutate the input array', () => {
685
+ let values = [1, 2, 3];
686
+ sc.shuffleArray(values);
687
+ this.assert(3 === values.length && 1 === values[0] && 2 === values[1] && 3 === values[2]);
688
+ });
689
+ this.test('returns empty array for non-array', () => {
690
+ this.assert(0 === sc.shuffleArray(null).length);
691
+ });
692
+ }
693
+
676
694
  testRandomInteger()
677
695
  {
678
696
  this.test('returns integer within range', () => {