diff options
author | ShinDarth <borzifrancesco@gmail.com> | 2018-09-02 00:49:47 +0200 |
---|---|---|
committer | Ryan Dahl <ry@tinyclouds.org> | 2018-09-01 21:59:52 -0400 |
commit | bbc4e55bdae2d37fee92e778f4a13eaf1d4fb4e1 (patch) | |
tree | 4b02289cd48406709fc2445152ebc4904c609f9a /js | |
parent | 2eb80f3617e44f9be2bd8ac15762824924bdfa08 (diff) |
Minor code refactoring
Diffstat (limited to 'js')
-rw-r--r-- | js/compiler.ts | 6 | ||||
-rw-r--r-- | js/console_test.ts | 2 | ||||
-rw-r--r-- | js/fetch_test.ts | 2 | ||||
-rw-r--r-- | js/fetch_types.d.ts | 49 | ||||
-rw-r--r-- | js/os.ts | 7 | ||||
-rw-r--r-- | js/v8_source_maps.ts | 3 |
6 files changed, 37 insertions, 32 deletions
diff --git a/js/compiler.ts b/js/compiler.ts index e75bc48d8..883feb2f9 100644 --- a/js/compiler.ts +++ b/js/compiler.ts @@ -283,7 +283,7 @@ export class DenoCompiler implements ts.LanguageServiceHost { * emit of a dynamic ES `import()` from TypeScript. */ private _makeLocalRequire(moduleMetaData: ModuleMetaData): AMDRequire { - const localRequire = ( + return ( deps: ModuleSpecifier[], callback: AmdCallback, errback: AmdErrback @@ -304,7 +304,6 @@ export class DenoCompiler implements ts.LanguageServiceHost { errback(e); } }; - return localRequire; } /** @@ -431,7 +430,7 @@ export class DenoCompiler implements ts.LanguageServiceHost { */ makeDefine(moduleMetaData: ModuleMetaData): AmdDefine { // TODO should this really be part of the public API of the compiler? - const localDefine: AmdDefine = ( + return ( deps: ModuleSpecifier[], factory: AmdFactory ): void => { @@ -457,7 +456,6 @@ export class DenoCompiler implements ts.LanguageServiceHost { this._runQueue.push(moduleMetaData); } }; - return localDefine; } /** diff --git a/js/console_test.ts b/js/console_test.ts index 01345825d..caa9bf1f4 100644 --- a/js/console_test.ts +++ b/js/console_test.ts @@ -1,6 +1,6 @@ // Copyright 2018 the Deno authors. All rights reserved. MIT license. -import { test, assert, assertEqual } from "./test_util.ts"; +import { test, assertEqual } from "./test_util.ts"; import { stringifyArgs } from "./console.ts"; // tslint:disable-next-line:no-any diff --git a/js/fetch_test.ts b/js/fetch_test.ts index 61221b2c4..873f2fbde 100644 --- a/js/fetch_test.ts +++ b/js/fetch_test.ts @@ -1,5 +1,5 @@ // Copyright 2018 the Deno authors. All rights reserved. MIT license. -import { test, testPerm, assert, assertEqual } from "./test_util.ts"; +import { testPerm, assertEqual } from "./test_util.ts"; import * as deno from "deno"; testPerm({ net: true }, async function fetchJsonSuccess() { diff --git a/js/fetch_types.d.ts b/js/fetch_types.d.ts index 4f77b5bd1..f00bdd3c5 100644 --- a/js/fetch_types.d.ts +++ b/js/fetch_types.d.ts @@ -77,7 +77,8 @@ interface URLSearchParams { */ append(name: string, value: string): void; /** - * Deletes the given search parameter, and its associated value, from the list of all search parameters. + * Deletes the given search parameter, and its associated value, + * from the list of all search parameters. */ delete(name: string): void; /** @@ -93,7 +94,8 @@ interface URLSearchParams { */ has(name: string): boolean; /** - * Sets the value associated to a given search parameter to the given value. If there were several values, delete the others. + * Sets the value associated to a given search parameter to the given value. + * If there were several values, delete the others. */ set(name: string, value: string): void; sort(): void; @@ -349,14 +351,15 @@ export interface ResponseInit { export interface Request extends Body { /** - * Returns the cache mode associated with request, which is a string indicating - * how the the request will interact with the browser's cache when fetching. + * Returns the cache mode associated with request, + * which is a string indicating how the the request will interact + * with the browser's cache when fetching. */ readonly cache: RequestCache; /** * Returns the credentials mode associated with request, which is a string - * indicating whether credentials will be sent with the request always, never, or only when sent to a - * same-origin URL. + * indicating whether credentials will be sent with the request always, never, + * or only when sent to a same-origin URL. */ readonly credentials: RequestCredentials; /** @@ -366,13 +369,14 @@ export interface Request extends Body { readonly destination: RequestDestination; /** * Returns a Headers object consisting of the headers associated with request. - * Note that headers added in the network layer by the user agent will not be accounted for in this - * object, e.g., the "Host" header. + * Note that headers added in the network layer by the user agent + * will not be accounted for in this object, e.g., the "Host" header. */ readonly headers: Headers; /** - * Returns request's subresource integrity metadata, which is a cryptographic hash of - * the resource being fetched. Its value consists of multiple hashes separated by whitespace. [SRI] + * Returns request's subresource integrity metadata, + * which is a cryptographic hash of the resource being fetched. + * Its value consists of multiple hashes separated by whitespace. [SRI] */ readonly integrity: string; /** @@ -381,12 +385,13 @@ export interface Request extends Body { */ readonly isHistoryNavigation: boolean; /** - * Returns a boolean indicating whether or not request is for a reload navigation. + * Returns a boolean indicating whether or not requestis for a + * reload navigation. */ readonly isReloadNavigation: boolean; /** - * Returns a boolean indicating whether or not request can outlive the global in which - * it was created. + * Returns a boolean indicating whether or not request can outlive + * the global in which it was created. */ readonly keepalive: boolean; /** @@ -394,20 +399,23 @@ export interface Request extends Body { */ readonly method: string; /** - * Returns the mode associated with request, which is a string indicating - * whether the request will use CORS, or will be restricted to same-origin URLs. + * Returns the mode associated with request, which is a string + * indicating whether the request will use CORS, or will be + * restricted to same-origin URLs. */ readonly mode: RequestMode; /** * Returns the redirect mode associated with request, which is a string - * indicating how redirects for the request will be handled during fetching. A request will follow redirects by default. + * indicating how redirects for the request will be handled during fetching. + * A request will follow redirects by default. */ readonly redirect: RequestRedirect; /** * Returns the referrer of request. Its value can be a same-origin URL if * explicitly set in init, the empty string to indicate no referrer, and - * "about:client" when defaulting to the global's default. This is used during - * fetching to determine the value of the `Referer` header of the request being made. + * "about:client" when defaulting to the global's default. + * This is used during fetching to determine the value of the `Referer` + * header of the request being made. */ readonly referrer: string; /** @@ -416,8 +424,9 @@ export interface Request extends Body { */ readonly referrerPolicy: ReferrerPolicy; /** - * Returns the signal associated with request, which is an AbortSignal object indicating whether or not request has been aborted, and its abort - * event handler. + * Returns the signal associated with request, which is an AbortSignal + * object indicating whether or not request has been aborted, + * and its abort event handler. */ readonly signal: AbortSignal; /** @@ -33,13 +33,12 @@ export function codeFetch( assert(fbs.Any.CodeFetchRes === baseRes!.msgType()); const codeFetchRes = new fbs.CodeFetchRes(); assert(baseRes!.msg(codeFetchRes) != null); - const r = { + return { moduleName: codeFetchRes.moduleName(), filename: codeFetchRes.filename(), sourceCode: codeFetchRes.sourceCode(), outputCode: codeFetchRes.outputCode() }; - return r; } export function codeCache( @@ -191,8 +190,8 @@ export function env(): { [index: string]: string } { * `statSync`, `lstatSync`. */ export class FileInfo { - private _isFile: boolean; - private _isSymlink: boolean; + private readonly _isFile: boolean; + private readonly _isSymlink: boolean; /** The size of the file, in bytes. */ len: number; /** diff --git a/js/v8_source_maps.ts b/js/v8_source_maps.ts index 8961a0626..94c437f6d 100644 --- a/js/v8_source_maps.ts +++ b/js/v8_source_maps.ts @@ -242,8 +242,7 @@ function mapSourcePosition(position: Position): MappedPosition { if (consumer == null) { return position; } - const mapped = consumer.originalPositionFor(position); - return mapped; + return consumer.originalPositionFor(position); } // Parses code generated by FormatEvalOrigin(), a function inside V8: |