1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-11-22 15:06:54 -05:00
denoland-deno/util.ts

23 lines
570 B
TypeScript
Raw Normal View History

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) {
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;
}