2018-05-19 05:38:51 -04:00
|
|
|
import { debug } from "./main";
|
2018-05-21 18:53:53 -04:00
|
|
|
import { TypedArray } from "./types";
|
2018-05-14 18:22:39 -04:00
|
|
|
|
|
|
|
// Internal logging for deno. Use the "debug" variable above to control
|
|
|
|
// output.
|
|
|
|
// tslint:disable-next-line:no-any
|
|
|
|
export function log(...args: any[]): void {
|
|
|
|
if (debug) {
|
|
|
|
console.log(...args);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-05-14 13:02:47 -04:00
|
|
|
export function assert(cond: boolean, msg = "") {
|
|
|
|
if (!cond) {
|
2018-05-15 04:39:03 -04:00
|
|
|
throw Error("Assert fail. " + msg);
|
2018-05-14 13:02:47 -04:00
|
|
|
}
|
|
|
|
}
|
2018-05-21 18:53:53 -04:00
|
|
|
|
|
|
|
export function typedArrayToArrayBuffer(ta: TypedArray): ArrayBuffer {
|
|
|
|
const ab = ta.buffer.slice(ta.byteOffset, ta.byteOffset + ta.byteLength);
|
|
|
|
return ab as ArrayBuffer;
|
|
|
|
}
|