diff options
author | David Sherret <dsherret@users.noreply.github.com> | 2023-09-07 08:09:16 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-09-07 09:09:16 -0400 |
commit | 3fc19dab47492e06043fc7add28e64693a4eb775 (patch) | |
tree | 855e952933662aef37bd20c084901ae0e488b2db /ext/node/polyfills/internal/crypto/random.ts | |
parent | 01a761f1d4f7ff4943fbf80464a276b434d8a8f7 (diff) |
feat: support import attributes (#20342)
Diffstat (limited to 'ext/node/polyfills/internal/crypto/random.ts')
-rw-r--r-- | ext/node/polyfills/internal/crypto/random.ts | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/ext/node/polyfills/internal/crypto/random.ts b/ext/node/polyfills/internal/crypto/random.ts index 62e564801..a02d232e8 100644 --- a/ext/node/polyfills/internal/crypto/random.ts +++ b/ext/node/polyfills/internal/crypto/random.ts @@ -2,7 +2,7 @@ // Copyright Joyent, Inc. and Node.js contributors. All rights reserved. MIT license. // TODO(petamoriken): enable prefer-primordials for node polyfills -// deno-lint-ignore-file camelcase prefer-primordials +// deno-lint-ignore-file prefer-primordials import { notImplemented } from "ext:deno_node/_utils.ts"; import randomBytes from "ext:deno_node/internal/crypto/_randomBytes.ts"; @@ -32,6 +32,9 @@ export { } from "ext:deno_node/internal/crypto/_randomFill.ts"; export { default as randomInt } from "ext:deno_node/internal/crypto/_randomInt.ts"; +const primordials = globalThis.__bootstrap.primordials; +const { StringPrototypePadStart, StringPrototypeToString } = primordials; + const { core } = globalThis.__bootstrap; const { ops } = core; const { @@ -286,8 +289,8 @@ function unsignedBigIntToBuffer(bigint: bigint, name: string) { throw new ERR_OUT_OF_RANGE(name, ">= 0", bigint); } - const hex = bigint.toString(16); - const padded = hex.padStart(hex.length + (hex.length % 2), 0); + const hex = StringPrototypeToString(bigint, 16); + const padded = StringPrototypePadStart(hex, hex.length + (hex.length % 2), 0); return Buffer.from(padded, "hex"); } |