MCPcopy Create free account
hub / github.com/Effect-TS/effect / shuffle

Function shuffle

packages/effect/test/Hash.test.ts:187–194  ·  view source on GitHub ↗
(values: ReadonlyArray<A>)

Source from the content-addressed store, hash-verified

185 }
186 const randomKey = (): unknown => [random(60), `k${random(60)}`, [random(4), random(4)]][random(3)]
187 const shuffle = <A>(values: ReadonlyArray<A>): Array<A> => {
188 const output = [...values]
189 for (let i = output.length - 1; i > 0; i--) {
190 const j = random(i + 1)
191 ;[output[i], output[j]] = [output[j], output[i]]
192 }
193 return output
194 }
195
196 it("hashes HashMaps and HashSets independently of insertion order", () => {
197 for (let run = 0; run < 200; run++) {

Callers 1

Hash.test.tsFile · 0.70

Calls 1

randomFunction · 0.70

Tested by

no test coverage detected