mirror of
https://github.com/denoland/deno.git
synced 2025-09-26 20:29:11 +00:00
Revert json ops (#2814)
* Revert "port more ops to JSON (#2809)" This reverts commit137f33733d
. * Revert "port ops to JSON: compiler, errors, fetch, files (#2804)" This reverts commit79f82cf10e
. * Revert "Port rest of os ops to JSON (#2802)" This reverts commit5b2baa5c99
.
This commit is contained in:
parent
bdc0a13261
commit
2235dd795d
45 changed files with 1968 additions and 1045 deletions
|
@ -1,8 +1,15 @@
|
|||
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
|
||||
import * as dispatch from "./dispatch";
|
||||
import { sendSync } from "./dispatch_json";
|
||||
import { sendSync, msg, flatbuffers } from "./dispatch_flatbuffers";
|
||||
import { assert } from "./util";
|
||||
|
||||
function req(
|
||||
typedArray: ArrayBufferView
|
||||
): [flatbuffers.Builder, msg.Any, flatbuffers.Offset, ArrayBufferView] {
|
||||
const builder = flatbuffers.createBuilder();
|
||||
const inner = msg.GetRandomValues.createGetRandomValues(builder);
|
||||
return [builder, msg.Any.GetRandomValues, inner, typedArray];
|
||||
}
|
||||
|
||||
/** Synchronously collects cryptographically secure random values. The
|
||||
* underlying CSPRNG in use is Rust's `rand::rngs::ThreadRng`.
|
||||
*
|
||||
|
@ -21,11 +28,6 @@ export function getRandomValues<
|
|||
>(typedArray: T): T {
|
||||
assert(typedArray !== null, "Input must not be null");
|
||||
assert(typedArray.length <= 65536, "Input must not be longer than 65536");
|
||||
const ui8 = new Uint8Array(
|
||||
typedArray.buffer,
|
||||
typedArray.byteOffset,
|
||||
typedArray.byteLength
|
||||
);
|
||||
sendSync(dispatch.OP_GET_RANDOM_VALUES, {}, ui8);
|
||||
sendSync(...req(typedArray as ArrayBufferView));
|
||||
return typedArray;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue