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

Function toIntArray

packages/effect/src/Random.ts:558–572  ·  view source on GitHub ↗

* Convert a string to UTF-8 encoded 32-bit integers (little-endian).

(seed: string)

Source from the content-addressed store, hash-verified

556 * Convert a string to UTF-8 encoded 32-bit integers (little-endian).
557 */
558function toIntArray(seed: string): Array<number> {
559 const bytes = seedEncoder.encode(seed)
560 const result: Array<number> = []
561
562 for (let index = 0; index < bytes.length; index += 4) {
563 result.push(
564 ((bytes[index] ?? 0) << 0) |
565 ((bytes[index + 1] ?? 0) << 8) |
566 ((bytes[index + 2] ?? 0) << 16) |
567 ((bytes[index + 3] ?? 0) << 24)
568 )
569 }
570
571 return result
572}

Callers 1

seedFunction · 0.85

Calls 1

pushMethod · 0.80

Tested by

no test coverage detected