* Convert a string to UTF-8 encoded 32-bit integers (little-endian).
(seed: string)
| 556 | * Convert a string to UTF-8 encoded 32-bit integers (little-endian). |
| 557 | */ |
| 558 | function 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 | } |