0
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2025-03-03 17:34:47 -05:00

Cleanups for runtime lib declarations.

This commit is contained in:
Kitson Kelly 2018-11-09 15:07:48 +11:00 committed by Ryan Dahl
parent 1f2c92c7c8
commit 172f5a5133
3 changed files with 12 additions and 7 deletions

View file

@ -116,12 +116,11 @@ export async function copy(dst: Writer, src: Reader): Promise<number> {
return n; return n;
} }
/** /** Turns `r` into async iterator.
* Turns `r` into async iterator.
* *
* for await (const chunk of readerIterator(reader)) { * for await (const chunk of readerIterator(reader)) {
* console.log(chunk) * console.log(chunk)
* } * }
*/ */
export function toAsyncIterator(r: Reader): AsyncIterableIterator<Uint8Array> { export function toAsyncIterator(r: Reader): AsyncIterableIterator<Uint8Array> {
const b = new Uint8Array(1024); const b = new Uint8Array(1024);

View file

@ -45,4 +45,5 @@ interface Libdeno {
} }
const window = globalEval("this"); const window = globalEval("this");
// @internal
export const libdeno = window.libdeno as Libdeno; export const libdeno = window.libdeno as Libdeno;

View file

@ -4,7 +4,12 @@ import * as flatbuffers from "./flatbuffers";
import { assert } from "./util"; import { assert } from "./util";
import * as dispatch from "./dispatch"; import * as dispatch from "./dispatch";
export function resources(): { [key: number]: string } { export type ResourceMap = { [rid: number]: string };
/** Returns a map of open _file like_ resource ids along with their string
* representation.
*/
export function resources(): ResourceMap {
const builder = flatbuffers.createBuilder(); const builder = flatbuffers.createBuilder();
msg.Resources.startResources(builder); msg.Resources.startResources(builder);
const inner = msg.Resource.endResource(builder); const inner = msg.Resource.endResource(builder);
@ -14,7 +19,7 @@ export function resources(): { [key: number]: string } {
const res = new msg.ResourcesRes(); const res = new msg.ResourcesRes();
assert(baseRes!.inner(res) !== null); assert(baseRes!.inner(res) !== null);
const resources: { [key: number]: string } = {}; const resources = {} as ResourceMap;
for (let i = 0; i < res.resourcesLength(); i++) { for (let i = 0; i < res.resourcesLength(); i++) {
const item = res.resources(i)!; const item = res.resources(i)!;