Last change
on this file since 59329aa was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago |
initial commit
|
-
Property mode
set to
100644
|
File size:
549 bytes
|
Rev | Line | |
---|
[6a3a178] | 1 | "use strict";
|
---|
| 2 |
|
---|
| 3 | Object.defineProperty(exports, "__esModule", {
|
---|
| 4 | value: true
|
---|
| 5 | });
|
---|
| 6 | exports.default = rng;
|
---|
| 7 |
|
---|
| 8 | var _crypto = _interopRequireDefault(require("crypto"));
|
---|
| 9 |
|
---|
| 10 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
---|
| 11 |
|
---|
| 12 | const rnds8Pool = new Uint8Array(256); // # of random values to pre-allocate
|
---|
| 13 |
|
---|
| 14 | let poolPtr = rnds8Pool.length;
|
---|
| 15 |
|
---|
| 16 | function rng() {
|
---|
| 17 | if (poolPtr > rnds8Pool.length - 16) {
|
---|
| 18 | _crypto.default.randomFillSync(rnds8Pool);
|
---|
| 19 |
|
---|
| 20 | poolPtr = 0;
|
---|
| 21 | }
|
---|
| 22 |
|
---|
| 23 | return rnds8Pool.slice(poolPtr, poolPtr += 16);
|
---|
| 24 | } |
---|
Note:
See
TracBrowser
for help on using the repository browser.