UNPKG

node-noise

Version:
32 lines 1.18 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.allocUnsafe = exports.alloc = void 0; var as_uint8array_1 = require("./util/as-uint8array"); /** * Returns a `Uint8Array` of the requested size. Referenced memory will * be initialized to 0. */ function alloc(size) { var _a; if (size === void 0) { size = 0; } if (((_a = globalThis.Buffer) === null || _a === void 0 ? void 0 : _a.alloc) != null) { return (0, as_uint8array_1.asUint8Array)(globalThis.Buffer.alloc(size)); } return new Uint8Array(size); } exports.alloc = alloc; /** * Where possible returns a Uint8Array of the requested size that references * uninitialized memory. Only use if you are certain you will immediately * overwrite every value in the returned `Uint8Array`. */ function allocUnsafe(size) { var _a; if (size === void 0) { size = 0; } if (((_a = globalThis.Buffer) === null || _a === void 0 ? void 0 : _a.allocUnsafe) != null) { return (0, as_uint8array_1.asUint8Array)(globalThis.Buffer.allocUnsafe(size)); } return new Uint8Array(size); } exports.allocUnsafe = allocUnsafe; //# sourceMappingURL=alloc.js.map