2020-01-02 15:13:47 -05:00
|
|
|
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
|
2019-09-02 17:07:11 -04:00
|
|
|
import { sendSync } from "./dispatch_json.ts";
|
2018-10-30 20:58:55 +01:00
|
|
|
|
2019-03-10 04:30:38 +11:00
|
|
|
export interface ResourceMap {
|
|
|
|
[rid: number]: string;
|
|
|
|
}
|
2018-11-09 15:07:48 +11:00
|
|
|
|
|
|
|
/** Returns a map of open _file like_ resource ids along with their string
|
|
|
|
* representation.
|
|
|
|
*/
|
|
|
|
export function resources(): ResourceMap {
|
2020-02-25 09:14:27 -05:00
|
|
|
const res = sendSync("op_resources") as Array<[number, string]>;
|
2019-03-10 04:30:38 +11:00
|
|
|
const resources: ResourceMap = {};
|
2019-08-26 14:50:21 +02:00
|
|
|
for (const resourceTuple of res) {
|
|
|
|
resources[resourceTuple[0]] = resourceTuple[1];
|
2018-10-30 20:58:55 +01:00
|
|
|
}
|
|
|
|
return resources;
|
|
|
|
}
|