1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2025-01-16 10:54:14 -05:00
denoland-deno/js/resources.ts

20 lines
592 B
TypeScript
Raw Normal View History

2019-01-22 04:03:30 +09:00
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
import * as dispatch from "./dispatch.ts";
import { sendSync } from "./dispatch_json.ts";
2018-10-30 20:58:55 +01: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 {
2019-08-26 14:50:21 +02:00
const res = sendSync(dispatch.OP_RESOURCES) as Array<[number, string]>;
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;
}