mirror of
https://github.com/denoland/deno.git
synced 2024-10-29 08:58:01 -04:00
Minor code refactoring
This commit is contained in:
parent
2eb80f3617
commit
bbc4e55bda
6 changed files with 37 additions and 32 deletions
|
@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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() {
|
||||
|
|
49
js/fetch_types.d.ts
vendored
49
js/fetch_types.d.ts
vendored
|
@ -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;
|
||||
/**
|
||||
|
|
7
js/os.ts
7
js/os.ts
|
@ -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;
|
||||
/**
|
||||
|
|
|
@ -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:
|
||||
|
|
Loading…
Reference in a new issue