1 | // Copyright (c) Jupyter Development Team.
|
2 | // Distributed under the terms of the Modified BSD License.
|
3 | /*-----------------------------------------------------------------------------
|
4 | | Copyright (c) 2014-2017, PhosphorJS Contributors
|
5 | |
|
6 | | Distributed under the terms of the BSD 3-Clause License.
|
7 | |
|
8 | | The full license is in the file LICENSE, distributed with this software.
|
9 | |----------------------------------------------------------------------------*/
|
10 |
|
11 | // Fallback
|
12 | export function fallbackRandomValues(buffer: Uint8Array): void {
|
13 | let value = 0;
|
14 | for (let i = 0, n = buffer.length; i < n; ++i) {
|
15 | if (i % 4 === 0) {
|
16 | value = (Math.random() * 0xffffffff) >>> 0;
|
17 | }
|
18 | buffer[i] = value & 0xff;
|
19 | value >>>= 8;
|
20 | }
|
21 | }
|