Remove dispatch.ts and move assignCmdId to util.ts

This commit is contained in:
Ryan Dahl 2018-08-01 12:36:17 -04:00
parent df8208557d
commit 421358e7a9
4 changed files with 9 additions and 39 deletions

View file

@ -20,6 +20,14 @@ export function assert(cond: boolean, msg = "assert") {
}
}
let cmdIdCounter = 0;
export function assignCmdId(): number {
// TODO(piscisaureus) Safely re-use so they don't overflow.
const cmdId = ++cmdIdCounter;
assert(cmdId < 2 ** 32, "cmdId overflow");
return cmdId;
}
export function typedArrayToArrayBuffer(ta: TypedArray): ArrayBuffer {
const ab = ta.buffer.slice(ta.byteOffset, ta.byteOffset + ta.byteLength);
return ab as ArrayBuffer;