Skip to content

Commit

Permalink
chore: format
Browse files Browse the repository at this point in the history
  • Loading branch information
aleclarson committed Jul 5, 2024
1 parent 3b8da79 commit df9e121
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 6 deletions.
6 changes: 1 addition & 5 deletions src/random/shuffle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,7 @@ export function shuffle<T>(
random: (min: number, max: number) => number = _.random,
): T[] {
const newArray = array.slice()
for (
let idx = 0, randomIdx: number, item: T;
idx < array.length;
idx++
) {
for (let idx = 0, randomIdx: number, item: T; idx < array.length; idx++) {
randomIdx = random(0, array.length - 1)
item = newArray[randomIdx]
newArray[randomIdx] = newArray[idx]
Expand Down
2 changes: 1 addition & 1 deletion tests/random/shuffle.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ describe('shuffle', () => {
const list = [1, 2, 3, 4, 5]
const mockRandom = vi.fn(() => 1)
const result = _.shuffle(list, mockRandom)

expect(mockRandom).toHaveBeenCalled()
expect(result).not.toEqual(list)
expect(result.length).toBe(list.length)
Expand Down

0 comments on commit df9e121

Please sign in to comment.