1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-12-11 18:17:48 -05:00
denoland-deno/cli/js/ops/resources.ts

19 lines
516 B
TypeScript
Raw Normal View History

2020-01-02 15:13:47 -05:00
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
2020-07-06 21:45:39 -04:00
import { sendSync } from "./dispatch_json.ts";
2018-10-30 15:58:55 -04:00
2020-07-06 21:45:39 -04:00
export type ResourceMap = Record<number, string>;
2018-11-08 23:07:48 -05:00
export function resources(): ResourceMap {
2020-02-25 09:14:27 -05:00
const res = sendSync("op_resources") as Array<[number, string]>;
const resources: ResourceMap = {};
2019-08-26 08:50:21 -04:00
for (const resourceTuple of res) {
resources[resourceTuple[0]] = resourceTuple[1];
2018-10-30 15:58:55 -04:00
}
return resources;
}
export function close(rid: number): void {
sendSync("op_close", { rid });
}