2020-04-30 11:23:40 -04:00
|
|
|
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
|
|
|
|
|
|
|
|
/// <reference no-default-lib="true" />
|
|
|
|
/// <reference lib="deno.ns" />
|
|
|
|
|
|
|
|
declare namespace Deno {
|
|
|
|
/**
|
|
|
|
* **UNSTABLE**: New API, yet to be vetted. This API is under consideration to
|
|
|
|
* determine if permissions are required to call it.
|
|
|
|
*
|
|
|
|
* Retrieve the process umask. If `mask` is provided, sets the process umask.
|
|
|
|
* This call always returns what the umask was before the call.
|
|
|
|
*
|
2020-05-16 15:23:48 -04:00
|
|
|
* ```ts
|
|
|
|
* console.log(Deno.umask()); // e.g. 18 (0o022)
|
|
|
|
* const prevUmaskValue = Deno.umask(0o077); // e.g. 18 (0o022)
|
|
|
|
* console.log(Deno.umask()); // e.g. 63 (0o077)
|
|
|
|
* ```
|
2020-04-30 11:23:40 -04:00
|
|
|
*
|
|
|
|
* NOTE: This API is not implemented on Windows
|
|
|
|
*/
|
|
|
|
export function umask(mask?: number): number;
|
|
|
|
|
2020-06-03 13:46:09 -04:00
|
|
|
/** **UNSTABLE**: This API needs a security review.
|
|
|
|
*
|
|
|
|
* Synchronously creates `newpath` as a hard link to `oldpath`.
|
2020-04-30 11:23:40 -04:00
|
|
|
*
|
2020-05-16 15:23:48 -04:00
|
|
|
* ```ts
|
|
|
|
* Deno.linkSync("old/name", "new/name");
|
|
|
|
* ```
|
2020-04-30 11:23:40 -04:00
|
|
|
*
|
|
|
|
* Requires `allow-read` and `allow-write` permissions. */
|
|
|
|
export function linkSync(oldpath: string, newpath: string): void;
|
|
|
|
|
2020-06-03 13:46:09 -04:00
|
|
|
/** **UNSTABLE**: This API needs a security review.
|
2020-04-30 11:23:40 -04:00
|
|
|
*
|
2020-06-03 13:46:09 -04:00
|
|
|
* Creates `newpath` as a hard link to `oldpath`.
|
2020-04-30 11:23:40 -04:00
|
|
|
*
|
2020-05-16 15:23:48 -04:00
|
|
|
* ```ts
|
|
|
|
* await Deno.link("old/name", "new/name");
|
|
|
|
* ```
|
2020-04-30 11:23:40 -04:00
|
|
|
*
|
|
|
|
* Requires `allow-read` and `allow-write` permissions. */
|
|
|
|
export function link(oldpath: string, newpath: string): Promise<void>;
|
|
|
|
|
2020-07-10 10:07:12 -04:00
|
|
|
/** **UNSTABLE**: New API, yet to be vetted.
|
|
|
|
*
|
|
|
|
* Gets the size of the console as columns/rows.
|
|
|
|
*
|
|
|
|
* ```ts
|
2020-08-10 23:22:10 -04:00
|
|
|
* const { columns, rows } = Deno.consoleSize(Deno.stdout.rid);
|
2020-07-10 10:07:12 -04:00
|
|
|
* ```
|
|
|
|
*/
|
|
|
|
export function consoleSize(
|
2020-07-14 15:24:17 -04:00
|
|
|
rid: number,
|
2020-07-10 10:07:12 -04:00
|
|
|
): {
|
|
|
|
columns: number;
|
|
|
|
rows: number;
|
|
|
|
};
|
|
|
|
|
2020-05-18 18:46:02 -04:00
|
|
|
export type SymlinkOptions = {
|
|
|
|
type: "file" | "dir";
|
|
|
|
};
|
|
|
|
|
2020-06-03 13:46:09 -04:00
|
|
|
/** **UNSTABLE**: This API needs a security review.
|
2020-04-30 11:23:40 -04:00
|
|
|
*
|
|
|
|
* Creates `newpath` as a symbolic link to `oldpath`.
|
|
|
|
*
|
2020-05-18 18:46:02 -04:00
|
|
|
* The options.type parameter can be set to `file` or `dir`. This argument is only
|
2020-04-30 11:23:40 -04:00
|
|
|
* available on Windows and ignored on other platforms.
|
|
|
|
*
|
2020-05-16 15:23:48 -04:00
|
|
|
* ```ts
|
|
|
|
* Deno.symlinkSync("old/name", "new/name");
|
|
|
|
* ```
|
2020-04-30 11:23:40 -04:00
|
|
|
*
|
2020-05-18 18:46:02 -04:00
|
|
|
* Requires `allow-write` permission. */
|
2020-04-30 11:23:40 -04:00
|
|
|
export function symlinkSync(
|
|
|
|
oldpath: string,
|
|
|
|
newpath: string,
|
2020-07-14 15:24:17 -04:00
|
|
|
options?: SymlinkOptions,
|
2020-04-30 11:23:40 -04:00
|
|
|
): void;
|
|
|
|
|
2020-06-03 13:46:09 -04:00
|
|
|
/** **UNSTABLE**: This API needs a security review.
|
2020-04-30 11:23:40 -04:00
|
|
|
*
|
|
|
|
* Creates `newpath` as a symbolic link to `oldpath`.
|
|
|
|
*
|
2020-05-18 18:46:02 -04:00
|
|
|
* The options.type parameter can be set to `file` or `dir`. This argument is only
|
2020-04-30 11:23:40 -04:00
|
|
|
* available on Windows and ignored on other platforms.
|
|
|
|
*
|
2020-05-16 15:23:48 -04:00
|
|
|
* ```ts
|
|
|
|
* await Deno.symlink("old/name", "new/name");
|
|
|
|
* ```
|
2020-04-30 11:23:40 -04:00
|
|
|
*
|
2020-05-18 18:46:02 -04:00
|
|
|
* Requires `allow-write` permission. */
|
2020-04-30 11:23:40 -04:00
|
|
|
export function symlink(
|
|
|
|
oldpath: string,
|
|
|
|
newpath: string,
|
2020-07-14 15:24:17 -04:00
|
|
|
options?: SymlinkOptions,
|
2020-04-30 11:23:40 -04:00
|
|
|
): Promise<void>;
|
|
|
|
|
2020-06-03 13:46:09 -04:00
|
|
|
/** **Unstable** There are questions around which permission this needs. And
|
|
|
|
* maybe should be renamed (loadAverage?)
|
|
|
|
*
|
|
|
|
* Returns an array containing the 1, 5, and 15 minute load averages. The
|
2020-04-30 11:23:40 -04:00
|
|
|
* load average is a measure of CPU and IO utilization of the last one, five,
|
|
|
|
* and 15 minute periods expressed as a fractional number. Zero means there
|
|
|
|
* is no load. On Windows, the three values are always the same and represent
|
|
|
|
* the current load, not the 1, 5 and 15 minute load averages.
|
|
|
|
*
|
2020-05-16 15:23:48 -04:00
|
|
|
* ```ts
|
|
|
|
* console.log(Deno.loadavg()); // e.g. [ 0.71, 0.44, 0.44 ]
|
|
|
|
* ```
|
2020-04-30 11:23:40 -04:00
|
|
|
*
|
|
|
|
* Requires `allow-env` permission.
|
|
|
|
*/
|
|
|
|
export function loadavg(): number[];
|
|
|
|
|
2020-06-03 13:46:09 -04:00
|
|
|
/** **Unstable** new API. yet to be vetted. Under consideration to possibly move to
|
|
|
|
* Deno.build or Deno.versions and if it should depend sys-info, which may not
|
|
|
|
* be desireable.
|
|
|
|
*
|
|
|
|
* Returns the release version of the Operating System.
|
2020-04-30 11:23:40 -04:00
|
|
|
*
|
2020-05-16 15:23:48 -04:00
|
|
|
* ```ts
|
|
|
|
* console.log(Deno.osRelease());
|
|
|
|
* ```
|
2020-04-30 11:23:40 -04:00
|
|
|
*
|
|
|
|
* Requires `allow-env` permission.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
export function osRelease(): string;
|
|
|
|
|
2020-09-19 17:30:59 -04:00
|
|
|
/** **Unstable** new API. yet to be vetted.
|
2020-09-10 04:38:17 -04:00
|
|
|
*
|
|
|
|
* Displays the total amount of free and used physical and swap memory in the
|
|
|
|
* system, as well as the buffers and caches used by the kernel.
|
2020-09-19 17:30:59 -04:00
|
|
|
*
|
2020-09-10 04:38:17 -04:00
|
|
|
* This is similar to the `free` command in Linux
|
|
|
|
*
|
|
|
|
* ```ts
|
|
|
|
* console.log(Deno.systemMemoryInfo());
|
|
|
|
* ```
|
|
|
|
*
|
|
|
|
* Requires `allow-env` permission.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
export function systemMemoryInfo(): SystemMemoryInfo;
|
|
|
|
|
|
|
|
export interface SystemMemoryInfo {
|
|
|
|
/** Total installed memory */
|
|
|
|
total: number;
|
|
|
|
/** Unused memory */
|
|
|
|
free: number;
|
|
|
|
/** Estimation of how much memory is available for starting new
|
|
|
|
* applications, without swapping. Unlike the data provided by the cache or
|
|
|
|
* free fields, this field takes into account page cache and also that not
|
|
|
|
* all reclaimable memory slabs will be reclaimed due to items being in use
|
|
|
|
*/
|
|
|
|
available: number;
|
|
|
|
/** Memory used by kernel buffers */
|
|
|
|
buffers: number;
|
|
|
|
/** Memory used by the page cache and slabs */
|
|
|
|
cached: number;
|
|
|
|
/** Total swap memory */
|
|
|
|
swapTotal: number;
|
|
|
|
/** Unused swap memory */
|
|
|
|
swapFree: number;
|
|
|
|
}
|
|
|
|
|
2020-10-26 10:54:27 -04:00
|
|
|
/** **Unstable** new API. yet to be vetted.
|
|
|
|
*
|
|
|
|
* Returns the total number of logical cpus in the system along with
|
|
|
|
* the speed measured in MHz. If either the syscall to get the core
|
|
|
|
* count or speed of the cpu is unsuccessful the value of the it
|
|
|
|
* is undefined.
|
|
|
|
*
|
|
|
|
* ```ts
|
|
|
|
* console.log(Deno.systemCpuInfo());
|
|
|
|
* ```
|
|
|
|
*
|
|
|
|
* Requires `allow-env` permission.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
export function systemCpuInfo(): SystemCpuInfo;
|
|
|
|
|
|
|
|
export interface SystemCpuInfo {
|
|
|
|
/** Total number of logical cpus in the system */
|
|
|
|
cores: number | undefined;
|
|
|
|
/** The speed of the cpu measured in MHz */
|
|
|
|
speed: number | undefined;
|
|
|
|
}
|
|
|
|
|
2020-04-30 11:23:40 -04:00
|
|
|
/** **UNSTABLE**: new API, yet to be vetted.
|
|
|
|
*
|
2020-05-14 02:58:48 -04:00
|
|
|
* Open and initialize a plugin.
|
2020-04-30 11:23:40 -04:00
|
|
|
*
|
2020-05-16 15:23:48 -04:00
|
|
|
* ```ts
|
|
|
|
* const rid = Deno.openPlugin("./path/to/some/plugin.so");
|
|
|
|
* const opId = Deno.core.ops()["some_op"];
|
|
|
|
* const response = Deno.core.dispatch(opId, new Uint8Array([1,2,3,4]));
|
|
|
|
* console.log(`Response from plugin ${response}`);
|
|
|
|
* ```
|
2020-04-30 11:23:40 -04:00
|
|
|
*
|
|
|
|
* Requires `allow-plugin` permission.
|
|
|
|
*
|
|
|
|
* The plugin system is not stable and will change in the future, hence the
|
|
|
|
* lack of docs. For now take a look at the example
|
|
|
|
* https://github.com/denoland/deno/tree/master/test_plugin
|
|
|
|
*/
|
|
|
|
export function openPlugin(filename: string): number;
|
|
|
|
|
|
|
|
/** The log category for a diagnostic message. */
|
|
|
|
export enum DiagnosticCategory {
|
2020-09-12 05:53:57 -04:00
|
|
|
Warning = 0,
|
|
|
|
Error = 1,
|
|
|
|
Suggestion = 2,
|
|
|
|
Message = 3,
|
2020-04-30 11:23:40 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
export interface DiagnosticMessageChain {
|
|
|
|
message: string;
|
|
|
|
category: DiagnosticCategory;
|
|
|
|
code: number;
|
|
|
|
next?: DiagnosticMessageChain[];
|
|
|
|
}
|
|
|
|
|
2020-09-12 05:53:57 -04:00
|
|
|
export interface Diagnostic {
|
2020-04-30 11:23:40 -04:00
|
|
|
/** A string message summarizing the diagnostic. */
|
2020-09-12 05:53:57 -04:00
|
|
|
messageText?: string;
|
2020-04-30 11:23:40 -04:00
|
|
|
/** An ordered array of further diagnostics. */
|
|
|
|
messageChain?: DiagnosticMessageChain;
|
|
|
|
/** Information related to the diagnostic. This is present when there is a
|
|
|
|
* suggestion or other additional diagnostic information */
|
2020-09-12 05:53:57 -04:00
|
|
|
relatedInformation?: Diagnostic[];
|
2020-04-30 11:23:40 -04:00
|
|
|
/** The text of the source line related to the diagnostic. */
|
|
|
|
sourceLine?: string;
|
2020-09-12 05:53:57 -04:00
|
|
|
source?: string;
|
|
|
|
/** The start position of the error. Zero based index. */
|
|
|
|
start?: {
|
|
|
|
line: number;
|
|
|
|
character: number;
|
|
|
|
};
|
|
|
|
/** The end position of the error. Zero based index. */
|
|
|
|
end?: {
|
|
|
|
line: number;
|
|
|
|
character: number;
|
|
|
|
};
|
|
|
|
/** The filename of the resource related to the diagnostic message. */
|
|
|
|
fileName?: string;
|
2020-04-30 11:23:40 -04:00
|
|
|
/** The category of the diagnostic. */
|
|
|
|
category: DiagnosticCategory;
|
|
|
|
/** A number identifier. */
|
|
|
|
code: number;
|
|
|
|
}
|
|
|
|
|
|
|
|
/** **UNSTABLE**: new API, yet to be vetted.
|
|
|
|
*
|
|
|
|
* Format an array of diagnostic items and return them as a single string in a
|
|
|
|
* user friendly format.
|
|
|
|
*
|
2020-05-16 15:23:48 -04:00
|
|
|
* ```ts
|
|
|
|
* const [diagnostics, result] = Deno.compile("file_with_compile_issues.ts");
|
|
|
|
* console.table(diagnostics); // Prints raw diagnostic data
|
|
|
|
* console.log(Deno.formatDiagnostics(diagnostics)); // User friendly output of diagnostics
|
|
|
|
* ```
|
2020-04-30 11:23:40 -04:00
|
|
|
*
|
2020-09-12 05:53:57 -04:00
|
|
|
* @param diagnostics An array of diagnostic items to format
|
2020-04-30 11:23:40 -04:00
|
|
|
*/
|
2020-09-12 05:53:57 -04:00
|
|
|
export function formatDiagnostics(diagnostics: Diagnostic[]): string;
|
2020-04-30 11:23:40 -04:00
|
|
|
|
|
|
|
/** **UNSTABLE**: new API, yet to be vetted.
|
|
|
|
*
|
|
|
|
* A specific subset TypeScript compiler options that can be supported by the
|
|
|
|
* Deno TypeScript compiler. */
|
|
|
|
export interface CompilerOptions {
|
|
|
|
/** Allow JavaScript files to be compiled. Defaults to `true`. */
|
|
|
|
allowJs?: boolean;
|
|
|
|
/** Allow default imports from modules with no default export. This does not
|
|
|
|
* affect code emit, just typechecking. Defaults to `false`. */
|
|
|
|
allowSyntheticDefaultImports?: boolean;
|
|
|
|
/** Allow accessing UMD globals from modules. Defaults to `false`. */
|
|
|
|
allowUmdGlobalAccess?: boolean;
|
|
|
|
/** Do not report errors on unreachable code. Defaults to `false`. */
|
|
|
|
allowUnreachableCode?: boolean;
|
|
|
|
/** Do not report errors on unused labels. Defaults to `false` */
|
|
|
|
allowUnusedLabels?: boolean;
|
|
|
|
/** Parse in strict mode and emit `"use strict"` for each source file.
|
|
|
|
* Defaults to `true`. */
|
|
|
|
alwaysStrict?: boolean;
|
|
|
|
/** Base directory to resolve non-relative module names. Defaults to
|
|
|
|
* `undefined`. */
|
|
|
|
baseUrl?: string;
|
|
|
|
/** Report errors in `.js` files. Use in conjunction with `allowJs`. Defaults
|
|
|
|
* to `false`. */
|
|
|
|
checkJs?: boolean;
|
|
|
|
/** Generates corresponding `.d.ts` file. Defaults to `false`. */
|
|
|
|
declaration?: boolean;
|
|
|
|
/** Output directory for generated declaration files. */
|
|
|
|
declarationDir?: string;
|
|
|
|
/** Generates a source map for each corresponding `.d.ts` file. Defaults to
|
|
|
|
* `false`. */
|
|
|
|
declarationMap?: boolean;
|
|
|
|
/** Provide full support for iterables in `for..of`, spread and
|
|
|
|
* destructuring when targeting ES5 or ES3. Defaults to `false`. */
|
|
|
|
downlevelIteration?: boolean;
|
|
|
|
/** Only emit `.d.ts` declaration files. Defaults to `false`. */
|
|
|
|
emitDeclarationOnly?: boolean;
|
|
|
|
/** Emit design-type metadata for decorated declarations in source. See issue
|
|
|
|
* [microsoft/TypeScript#2577](https://github.com/Microsoft/TypeScript/issues/2577)
|
|
|
|
* for details. Defaults to `false`. */
|
|
|
|
emitDecoratorMetadata?: boolean;
|
|
|
|
/** Emit `__importStar` and `__importDefault` helpers for runtime babel
|
|
|
|
* ecosystem compatibility and enable `allowSyntheticDefaultImports` for type
|
|
|
|
* system compatibility. Defaults to `true`. */
|
|
|
|
esModuleInterop?: boolean;
|
2020-11-01 21:51:56 -05:00
|
|
|
/** Enables experimental support for ES decorators. Defaults to `true`. */
|
2020-04-30 11:23:40 -04:00
|
|
|
experimentalDecorators?: boolean;
|
2020-11-01 21:51:56 -05:00
|
|
|
/** Import emit helpers (e.g. `__extends`, `__rest`, etc..) from
|
|
|
|
* [tslib](https://www.npmjs.com/package/tslib). */
|
|
|
|
importHelpers?: boolean;
|
2020-11-09 14:50:33 -05:00
|
|
|
/** This flag controls how `import` works, there are 3 different options:
|
2020-12-28 18:05:29 -05:00
|
|
|
*
|
2020-11-09 14:50:33 -05:00
|
|
|
* - `remove`: The default behavior of dropping import statements which only
|
|
|
|
* reference types.
|
|
|
|
* - `preserve`: Preserves all `import` statements whose values or types are
|
|
|
|
* never used. This can cause imports/side-effects to be preserved.
|
|
|
|
* - `error`: This preserves all imports (the same as the preserve option),
|
|
|
|
* but will error when a value import is only used as a type. This might
|
|
|
|
* be useful if you want to ensure no values are being accidentally
|
|
|
|
* imported, but still make side-effect imports explicit.
|
2020-12-28 18:05:29 -05:00
|
|
|
*
|
2020-11-09 14:50:33 -05:00
|
|
|
* This flag works because you can use `import type` to explicitly create an
|
|
|
|
* `import` statement which should never be emitted into JavaScript. */
|
|
|
|
importsNotUsedAsValues?: "remove" | "preserve" | "error";
|
2020-04-30 11:23:40 -04:00
|
|
|
/** Emit a single file with source maps instead of having a separate file.
|
|
|
|
* Defaults to `false`. */
|
|
|
|
inlineSourceMap?: boolean;
|
|
|
|
/** Emit the source alongside the source maps within a single file; requires
|
|
|
|
* `inlineSourceMap` or `sourceMap` to be set. Defaults to `false`. */
|
|
|
|
inlineSources?: boolean;
|
|
|
|
/** Perform additional checks to ensure that transpile only would be safe.
|
2020-11-01 21:51:56 -05:00
|
|
|
* Defaults to `true`. */
|
2020-04-30 11:23:40 -04:00
|
|
|
isolatedModules?: boolean;
|
|
|
|
/** Support JSX in `.tsx` files: `"react"`, `"preserve"`, `"react-native"`.
|
|
|
|
* Defaults to `"react"`. */
|
|
|
|
jsx?: "react" | "preserve" | "react-native";
|
|
|
|
/** Specify the JSX factory function to use when targeting react JSX emit,
|
|
|
|
* e.g. `React.createElement` or `h`. Defaults to `React.createElement`. */
|
|
|
|
jsxFactory?: string;
|
2020-11-01 21:51:56 -05:00
|
|
|
/** Specify the JSX fragment factory function to use when targeting react
|
|
|
|
* JSX emit, e.g. `Fragment`. Defaults to `React.Fragment`. */
|
|
|
|
jsxFragmentFactory?: string;
|
2020-04-30 11:23:40 -04:00
|
|
|
/** Resolve keyof to string valued property names only (no numbers or
|
|
|
|
* symbols). Defaults to `false`. */
|
|
|
|
keyofStringsOnly?: string;
|
|
|
|
/** List of library files to be included in the compilation. If omitted,
|
|
|
|
* then the Deno main runtime libs are used. */
|
|
|
|
lib?: string[];
|
|
|
|
/** The locale to use to show error messages. */
|
|
|
|
locale?: string;
|
|
|
|
/** Specifies the location where debugger should locate map files instead of
|
|
|
|
* generated locations. Use this flag if the `.map` files will be located at
|
|
|
|
* run-time in a different location than the `.js` files. The location
|
|
|
|
* specified will be embedded in the source map to direct the debugger where
|
|
|
|
* the map files will be located. Defaults to `undefined`. */
|
|
|
|
mapRoot?: string;
|
|
|
|
/** Specify the module format for the emitted code. Defaults to
|
|
|
|
* `"esnext"`. */
|
|
|
|
module?:
|
|
|
|
| "none"
|
|
|
|
| "commonjs"
|
|
|
|
| "amd"
|
|
|
|
| "system"
|
|
|
|
| "umd"
|
|
|
|
| "es6"
|
|
|
|
| "es2015"
|
|
|
|
| "esnext";
|
|
|
|
/** Do not generate custom helper functions like `__extends` in compiled
|
|
|
|
* output. Defaults to `false`. */
|
|
|
|
noEmitHelpers?: boolean;
|
|
|
|
/** Report errors for fallthrough cases in switch statement. Defaults to
|
|
|
|
* `false`. */
|
|
|
|
noFallthroughCasesInSwitch?: boolean;
|
|
|
|
/** Raise error on expressions and declarations with an implied any type.
|
|
|
|
* Defaults to `true`. */
|
|
|
|
noImplicitAny?: boolean;
|
|
|
|
/** Report an error when not all code paths in function return a value.
|
|
|
|
* Defaults to `false`. */
|
|
|
|
noImplicitReturns?: boolean;
|
|
|
|
/** Raise error on `this` expressions with an implied `any` type. Defaults to
|
|
|
|
* `true`. */
|
|
|
|
noImplicitThis?: boolean;
|
|
|
|
/** Do not emit `"use strict"` directives in module output. Defaults to
|
|
|
|
* `false`. */
|
|
|
|
noImplicitUseStrict?: boolean;
|
|
|
|
/** Do not add triple-slash references or module import targets to the list of
|
|
|
|
* compiled files. Defaults to `false`. */
|
|
|
|
noResolve?: boolean;
|
|
|
|
/** Disable strict checking of generic signatures in function types. Defaults
|
|
|
|
* to `false`. */
|
|
|
|
noStrictGenericChecks?: boolean;
|
|
|
|
/** Report errors on unused locals. Defaults to `false`. */
|
|
|
|
noUnusedLocals?: boolean;
|
|
|
|
/** Report errors on unused parameters. Defaults to `false`. */
|
|
|
|
noUnusedParameters?: boolean;
|
|
|
|
/** List of path mapping entries for module names to locations relative to the
|
|
|
|
* `baseUrl`. Defaults to `undefined`. */
|
|
|
|
paths?: Record<string, string[]>;
|
|
|
|
/** Do not erase const enum declarations in generated code. Defaults to
|
|
|
|
* `false`. */
|
|
|
|
preserveConstEnums?: boolean;
|
|
|
|
/** Remove all comments except copy-right header comments beginning with
|
|
|
|
* `/*!`. Defaults to `true`. */
|
|
|
|
removeComments?: boolean;
|
|
|
|
/** Specifies the root directory of input files. Only use to control the
|
|
|
|
* output directory structure with `outDir`. Defaults to `undefined`. */
|
|
|
|
rootDir?: string;
|
|
|
|
/** List of _root_ folders whose combined content represent the structure of
|
|
|
|
* the project at runtime. Defaults to `undefined`. */
|
|
|
|
rootDirs?: string[];
|
|
|
|
/** Generates corresponding `.map` file. Defaults to `false`. */
|
|
|
|
sourceMap?: boolean;
|
|
|
|
/** Specifies the location where debugger should locate TypeScript files
|
|
|
|
* instead of source locations. Use this flag if the sources will be located
|
|
|
|
* at run-time in a different location than that at design-time. The location
|
|
|
|
* specified will be embedded in the sourceMap to direct the debugger where
|
|
|
|
* the source files will be located. Defaults to `undefined`. */
|
|
|
|
sourceRoot?: string;
|
2020-11-01 21:51:56 -05:00
|
|
|
/** Skip type checking of all declaration files (`*.d.ts`). */
|
|
|
|
skipLibCheck?: boolean;
|
2020-04-30 11:23:40 -04:00
|
|
|
/** Enable all strict type checking options. Enabling `strict` enables
|
|
|
|
* `noImplicitAny`, `noImplicitThis`, `alwaysStrict`, `strictBindCallApply`,
|
|
|
|
* `strictNullChecks`, `strictFunctionTypes` and
|
|
|
|
* `strictPropertyInitialization`. Defaults to `true`. */
|
|
|
|
strict?: boolean;
|
|
|
|
/** Enable stricter checking of the `bind`, `call`, and `apply` methods on
|
|
|
|
* functions. Defaults to `true`. */
|
|
|
|
strictBindCallApply?: boolean;
|
|
|
|
/** Disable bivariant parameter checking for function types. Defaults to
|
|
|
|
* `true`. */
|
|
|
|
strictFunctionTypes?: boolean;
|
|
|
|
/** Ensure non-undefined class properties are initialized in the constructor.
|
|
|
|
* This option requires `strictNullChecks` be enabled in order to take effect.
|
|
|
|
* Defaults to `true`. */
|
|
|
|
strictPropertyInitialization?: boolean;
|
|
|
|
/** In strict null checking mode, the `null` and `undefined` values are not in
|
|
|
|
* the domain of every type and are only assignable to themselves and `any`
|
|
|
|
* (the one exception being that `undefined` is also assignable to `void`). */
|
|
|
|
strictNullChecks?: boolean;
|
|
|
|
/** Suppress excess property checks for object literals. Defaults to
|
|
|
|
* `false`. */
|
|
|
|
suppressExcessPropertyErrors?: boolean;
|
|
|
|
/** Suppress `noImplicitAny` errors for indexing objects lacking index
|
|
|
|
* signatures. */
|
|
|
|
suppressImplicitAnyIndexErrors?: boolean;
|
|
|
|
/** Specify ECMAScript target version. Defaults to `esnext`. */
|
|
|
|
target?:
|
|
|
|
| "es3"
|
|
|
|
| "es5"
|
|
|
|
| "es6"
|
|
|
|
| "es2015"
|
|
|
|
| "es2016"
|
|
|
|
| "es2017"
|
|
|
|
| "es2018"
|
|
|
|
| "es2019"
|
|
|
|
| "es2020"
|
|
|
|
| "esnext";
|
|
|
|
/** List of names of type definitions to include. Defaults to `undefined`.
|
|
|
|
*
|
|
|
|
* The type definitions are resolved according to the normal Deno resolution
|
|
|
|
* irrespective of if sources are provided on the call. Like other Deno
|
|
|
|
* modules, there is no "magical" resolution. For example:
|
|
|
|
*
|
2020-05-16 15:23:48 -04:00
|
|
|
* ```ts
|
|
|
|
* Deno.compile(
|
|
|
|
* "./foo.js",
|
|
|
|
* undefined,
|
|
|
|
* {
|
|
|
|
* types: [ "./foo.d.ts", "https://deno.land/x/example/types.d.ts" ]
|
|
|
|
* }
|
|
|
|
* );
|
|
|
|
* ```
|
2020-04-30 11:23:40 -04:00
|
|
|
*/
|
|
|
|
types?: string[];
|
2020-11-01 21:51:56 -05:00
|
|
|
/** Emit class fields with ECMAScript-standard semantics. Defaults to
|
|
|
|
* `false`. */
|
|
|
|
useDefineForClassFields?: boolean;
|
2020-04-30 11:23:40 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
/** **UNSTABLE**: new API, yet to be vetted.
|
|
|
|
*
|
|
|
|
* The results of a transpile only command, where the `source` contains the
|
|
|
|
* emitted source, and `map` optionally contains the source map. */
|
|
|
|
export interface TranspileOnlyResult {
|
|
|
|
source: string;
|
|
|
|
map?: string;
|
|
|
|
}
|
|
|
|
|
|
|
|
/** **UNSTABLE**: new API, yet to be vetted.
|
|
|
|
*
|
|
|
|
* Takes a set of TypeScript sources and resolves to a map where the key was
|
|
|
|
* the original file name provided in sources and the result contains the
|
|
|
|
* `source` and optionally the `map` from the transpile operation. This does no
|
|
|
|
* type checking and validation, it effectively "strips" the types from the
|
|
|
|
* file.
|
|
|
|
*
|
2020-05-16 15:23:48 -04:00
|
|
|
* ```ts
|
|
|
|
* const results = await Deno.transpileOnly({
|
|
|
|
* "foo.ts": `const foo: string = "foo";`
|
|
|
|
* });
|
|
|
|
* ```
|
2020-04-30 11:23:40 -04:00
|
|
|
*
|
|
|
|
* @param sources A map where the key is the filename and the value is the text
|
|
|
|
* to transpile. The filename is only used in the transpile and
|
|
|
|
* not resolved, for example to fill in the source name in the
|
|
|
|
* source map.
|
|
|
|
* @param options An option object of options to send to the compiler. This is
|
|
|
|
* a subset of ts.CompilerOptions which can be supported by Deno.
|
2020-10-26 09:03:03 -04:00
|
|
|
* If unsupported option is passed then the API will throw an error.
|
2020-04-30 11:23:40 -04:00
|
|
|
*/
|
|
|
|
export function transpileOnly(
|
|
|
|
sources: Record<string, string>,
|
2020-07-14 15:24:17 -04:00
|
|
|
options?: CompilerOptions,
|
2020-04-30 11:23:40 -04:00
|
|
|
): Promise<Record<string, TranspileOnlyResult>>;
|
|
|
|
|
|
|
|
/** **UNSTABLE**: new API, yet to be vetted.
|
|
|
|
*
|
|
|
|
* Takes a root module name, and optionally a record set of sources. Resolves
|
|
|
|
* with a compiled set of modules and possibly diagnostics if the compiler
|
|
|
|
* encountered any issues. If just a root name is provided, the modules
|
|
|
|
* will be resolved as if the root module had been passed on the command line.
|
|
|
|
*
|
|
|
|
* If sources are passed, all modules will be resolved out of this object, where
|
|
|
|
* the key is the module name and the value is the content. The extension of
|
|
|
|
* the module name will be used to determine the media type of the module.
|
|
|
|
*
|
2020-05-16 15:23:48 -04:00
|
|
|
* ```ts
|
|
|
|
* const [ maybeDiagnostics1, output1 ] = await Deno.compile("foo.ts");
|
2020-04-30 11:23:40 -04:00
|
|
|
*
|
2020-05-16 15:23:48 -04:00
|
|
|
* const [ maybeDiagnostics2, output2 ] = await Deno.compile("/foo.ts", {
|
|
|
|
* "/foo.ts": `export * from "./bar.ts";`,
|
|
|
|
* "/bar.ts": `export const bar = "bar";`
|
|
|
|
* });
|
|
|
|
* ```
|
2020-04-30 11:23:40 -04:00
|
|
|
*
|
|
|
|
* @param rootName The root name of the module which will be used as the
|
|
|
|
* "starting point". If no `sources` is specified, Deno will
|
|
|
|
* resolve the module externally as if the `rootName` had been
|
|
|
|
* specified on the command line.
|
|
|
|
* @param sources An optional key/value map of sources to be used when resolving
|
|
|
|
* modules, where the key is the module name, and the value is
|
|
|
|
* the source content. The extension of the key will determine
|
|
|
|
* the media type of the file when processing. If supplied,
|
|
|
|
* Deno will not attempt to resolve any modules externally.
|
|
|
|
* @param options An optional object of options to send to the compiler. This is
|
|
|
|
* a subset of ts.CompilerOptions which can be supported by Deno.
|
|
|
|
*/
|
|
|
|
export function compile(
|
|
|
|
rootName: string,
|
|
|
|
sources?: Record<string, string>,
|
2020-07-14 15:24:17 -04:00
|
|
|
options?: CompilerOptions,
|
2020-09-12 05:53:57 -04:00
|
|
|
): Promise<[Diagnostic[] | undefined, Record<string, string>]>;
|
2020-04-30 11:23:40 -04:00
|
|
|
|
|
|
|
/** **UNSTABLE**: new API, yet to be vetted.
|
|
|
|
*
|
|
|
|
* `bundle()` is part the compiler API. A full description of this functionality
|
2020-05-17 13:24:39 -04:00
|
|
|
* can be found in the [manual](https://deno.land/manual/runtime/compiler_apis#denobundle).
|
2020-04-30 11:23:40 -04:00
|
|
|
*
|
|
|
|
* Takes a root module name, and optionally a record set of sources. Resolves
|
|
|
|
* with a single JavaScript string (and bundle diagnostics if issues arise with
|
|
|
|
* the bundling) that is like the output of a `deno bundle` command. If just
|
|
|
|
* a root name is provided, the modules will be resolved as if the root module
|
|
|
|
* had been passed on the command line.
|
|
|
|
*
|
|
|
|
* If sources are passed, all modules will be resolved out of this object, where
|
|
|
|
* the key is the module name and the value is the content. The extension of the
|
|
|
|
* module name will be used to determine the media type of the module.
|
|
|
|
*
|
2020-05-16 15:23:48 -04:00
|
|
|
* ```ts
|
|
|
|
* // equivalent to "deno bundle foo.ts" from the command line
|
|
|
|
* const [ maybeDiagnostics1, output1 ] = await Deno.bundle("foo.ts");
|
2020-04-30 11:23:40 -04:00
|
|
|
*
|
2020-05-16 15:23:48 -04:00
|
|
|
* const [ maybeDiagnostics2, output2 ] = await Deno.bundle("/foo.ts", {
|
|
|
|
* "/foo.ts": `export * from "./bar.ts";`,
|
|
|
|
* "/bar.ts": `export const bar = "bar";`
|
|
|
|
* });
|
|
|
|
* ```
|
2020-04-30 11:23:40 -04:00
|
|
|
*
|
|
|
|
* @param rootName The root name of the module which will be used as the
|
|
|
|
* "starting point". If no `sources` is specified, Deno will
|
|
|
|
* resolve the module externally as if the `rootName` had been
|
|
|
|
* specified on the command line.
|
|
|
|
* @param sources An optional key/value map of sources to be used when resolving
|
|
|
|
* modules, where the key is the module name, and the value is
|
|
|
|
* the source content. The extension of the key will determine
|
|
|
|
* the media type of the file when processing. If supplied,
|
|
|
|
* Deno will not attempt to resolve any modules externally.
|
|
|
|
* @param options An optional object of options to send to the compiler. This is
|
|
|
|
* a subset of ts.CompilerOptions which can be supported by Deno.
|
|
|
|
*/
|
|
|
|
export function bundle(
|
|
|
|
rootName: string,
|
|
|
|
sources?: Record<string, string>,
|
2020-07-14 15:24:17 -04:00
|
|
|
options?: CompilerOptions,
|
2020-09-12 05:53:57 -04:00
|
|
|
): Promise<[Diagnostic[] | undefined, string]>;
|
2020-04-30 11:23:40 -04:00
|
|
|
|
|
|
|
/** **UNSTABLE**: Should not have same name as `window.location` type. */
|
|
|
|
interface Location {
|
|
|
|
/** The full url for the module, e.g. `file://some/file.ts` or
|
|
|
|
* `https://some/file.ts`. */
|
|
|
|
fileName: string;
|
|
|
|
/** The line number in the file. It is assumed to be 1-indexed. */
|
|
|
|
lineNumber: number;
|
|
|
|
/** The column number in the file. It is assumed to be 1-indexed. */
|
|
|
|
columnNumber: number;
|
|
|
|
}
|
|
|
|
|
2020-06-03 13:46:09 -04:00
|
|
|
/** **UNSTABLE**: new API, yet to be vetted.
|
2020-04-30 11:23:40 -04:00
|
|
|
*
|
|
|
|
* Given a current location in a module, lookup the source location and return
|
|
|
|
* it.
|
|
|
|
*
|
|
|
|
* When Deno transpiles code, it keep source maps of the transpiled code. This
|
|
|
|
* function can be used to lookup the original location. This is
|
|
|
|
* automatically done when accessing the `.stack` of an error, or when an
|
|
|
|
* uncaught error is logged. This function can be used to perform the lookup
|
|
|
|
* for creating better error handling.
|
|
|
|
*
|
|
|
|
* **Note:** `line` and `column` are 1 indexed, which matches display
|
|
|
|
* expectations, but is not typical of most index numbers in Deno.
|
|
|
|
*
|
|
|
|
* An example:
|
|
|
|
*
|
2020-05-16 15:23:48 -04:00
|
|
|
* ```ts
|
|
|
|
* const orig = Deno.applySourceMap({
|
|
|
|
* fileName: "file://my/module.ts",
|
|
|
|
* lineNumber: 5,
|
|
|
|
* columnNumber: 15
|
|
|
|
* });
|
|
|
|
* console.log(`${orig.filename}:${orig.line}:${orig.column}`);
|
|
|
|
* ```
|
2020-04-30 11:23:40 -04:00
|
|
|
*/
|
|
|
|
export function applySourceMap(location: Location): Location;
|
|
|
|
|
|
|
|
enum LinuxSignal {
|
|
|
|
SIGHUP = 1,
|
|
|
|
SIGINT = 2,
|
|
|
|
SIGQUIT = 3,
|
|
|
|
SIGILL = 4,
|
|
|
|
SIGTRAP = 5,
|
|
|
|
SIGABRT = 6,
|
|
|
|
SIGBUS = 7,
|
|
|
|
SIGFPE = 8,
|
|
|
|
SIGKILL = 9,
|
|
|
|
SIGUSR1 = 10,
|
|
|
|
SIGSEGV = 11,
|
|
|
|
SIGUSR2 = 12,
|
|
|
|
SIGPIPE = 13,
|
|
|
|
SIGALRM = 14,
|
|
|
|
SIGTERM = 15,
|
|
|
|
SIGSTKFLT = 16,
|
|
|
|
SIGCHLD = 17,
|
|
|
|
SIGCONT = 18,
|
|
|
|
SIGSTOP = 19,
|
|
|
|
SIGTSTP = 20,
|
|
|
|
SIGTTIN = 21,
|
|
|
|
SIGTTOU = 22,
|
|
|
|
SIGURG = 23,
|
|
|
|
SIGXCPU = 24,
|
|
|
|
SIGXFSZ = 25,
|
|
|
|
SIGVTALRM = 26,
|
|
|
|
SIGPROF = 27,
|
|
|
|
SIGWINCH = 28,
|
|
|
|
SIGIO = 29,
|
|
|
|
SIGPWR = 30,
|
|
|
|
SIGSYS = 31,
|
|
|
|
}
|
|
|
|
enum MacOSSignal {
|
|
|
|
SIGHUP = 1,
|
|
|
|
SIGINT = 2,
|
|
|
|
SIGQUIT = 3,
|
|
|
|
SIGILL = 4,
|
|
|
|
SIGTRAP = 5,
|
|
|
|
SIGABRT = 6,
|
|
|
|
SIGEMT = 7,
|
|
|
|
SIGFPE = 8,
|
|
|
|
SIGKILL = 9,
|
|
|
|
SIGBUS = 10,
|
|
|
|
SIGSEGV = 11,
|
|
|
|
SIGSYS = 12,
|
|
|
|
SIGPIPE = 13,
|
|
|
|
SIGALRM = 14,
|
|
|
|
SIGTERM = 15,
|
|
|
|
SIGURG = 16,
|
|
|
|
SIGSTOP = 17,
|
|
|
|
SIGTSTP = 18,
|
|
|
|
SIGCONT = 19,
|
|
|
|
SIGCHLD = 20,
|
|
|
|
SIGTTIN = 21,
|
|
|
|
SIGTTOU = 22,
|
|
|
|
SIGIO = 23,
|
|
|
|
SIGXCPU = 24,
|
|
|
|
SIGXFSZ = 25,
|
|
|
|
SIGVTALRM = 26,
|
|
|
|
SIGPROF = 27,
|
|
|
|
SIGWINCH = 28,
|
|
|
|
SIGINFO = 29,
|
|
|
|
SIGUSR1 = 30,
|
|
|
|
SIGUSR2 = 31,
|
|
|
|
}
|
|
|
|
|
2020-06-03 13:46:09 -04:00
|
|
|
/** **UNSTABLE**: Further changes required to make platform independent.
|
2020-04-30 11:23:40 -04:00
|
|
|
*
|
|
|
|
* Signals numbers. This is platform dependent. */
|
|
|
|
export const Signal: typeof MacOSSignal | typeof LinuxSignal;
|
|
|
|
|
|
|
|
/** **UNSTABLE**: new API, yet to be vetted.
|
|
|
|
*
|
|
|
|
* Represents the stream of signals, implements both `AsyncIterator` and
|
|
|
|
* `PromiseLike`. */
|
|
|
|
export class SignalStream
|
|
|
|
implements AsyncIterableIterator<void>, PromiseLike<void> {
|
|
|
|
constructor(signal: typeof Deno.Signal);
|
|
|
|
then<T, S>(
|
|
|
|
f: (v: void) => T | Promise<T>,
|
2020-07-14 15:24:17 -04:00
|
|
|
g?: (v: void) => S | Promise<S>,
|
2020-04-30 11:23:40 -04:00
|
|
|
): Promise<T | S>;
|
|
|
|
next(): Promise<IteratorResult<void>>;
|
|
|
|
[Symbol.asyncIterator](): AsyncIterableIterator<void>;
|
|
|
|
dispose(): void;
|
|
|
|
}
|
|
|
|
|
|
|
|
/** **UNSTABLE**: new API, yet to be vetted.
|
|
|
|
*
|
|
|
|
* Returns the stream of the given signal number. You can use it as an async
|
|
|
|
* iterator.
|
|
|
|
*
|
2020-05-16 15:23:48 -04:00
|
|
|
* ```ts
|
|
|
|
* for await (const _ of Deno.signal(Deno.Signal.SIGTERM)) {
|
|
|
|
* console.log("got SIGTERM!");
|
|
|
|
* }
|
|
|
|
* ```
|
2020-04-30 11:23:40 -04:00
|
|
|
*
|
|
|
|
* You can also use it as a promise. In this case you can only receive the
|
|
|
|
* first one.
|
|
|
|
*
|
2020-05-16 15:23:48 -04:00
|
|
|
* ```ts
|
|
|
|
* await Deno.signal(Deno.Signal.SIGTERM);
|
|
|
|
* console.log("SIGTERM received!")
|
|
|
|
* ```
|
2020-04-30 11:23:40 -04:00
|
|
|
*
|
|
|
|
* If you want to stop receiving the signals, you can use `.dispose()` method
|
|
|
|
* of the signal stream object.
|
|
|
|
*
|
2020-05-16 15:23:48 -04:00
|
|
|
* ```ts
|
|
|
|
* const sig = Deno.signal(Deno.Signal.SIGTERM);
|
|
|
|
* setTimeout(() => { sig.dispose(); }, 5000);
|
|
|
|
* for await (const _ of sig) {
|
|
|
|
* console.log("SIGTERM!")
|
|
|
|
* }
|
|
|
|
* ```
|
2020-04-30 11:23:40 -04:00
|
|
|
*
|
|
|
|
* The above for-await loop exits after 5 seconds when `sig.dispose()` is
|
|
|
|
* called.
|
|
|
|
*
|
|
|
|
* NOTE: This functionality is not yet implemented on Windows.
|
|
|
|
*/
|
|
|
|
export function signal(signo: number): SignalStream;
|
|
|
|
|
|
|
|
/** **UNSTABLE**: new API, yet to be vetted. */
|
|
|
|
export const signals: {
|
|
|
|
/** Returns the stream of SIGALRM signals.
|
|
|
|
*
|
|
|
|
* This method is the shorthand for `Deno.signal(Deno.Signal.SIGALRM)`. */
|
|
|
|
alarm: () => SignalStream;
|
|
|
|
/** Returns the stream of SIGCHLD signals.
|
|
|
|
*
|
|
|
|
* This method is the shorthand for `Deno.signal(Deno.Signal.SIGCHLD)`. */
|
|
|
|
child: () => SignalStream;
|
|
|
|
/** Returns the stream of SIGHUP signals.
|
|
|
|
*
|
|
|
|
* This method is the shorthand for `Deno.signal(Deno.Signal.SIGHUP)`. */
|
|
|
|
hungup: () => SignalStream;
|
|
|
|
/** Returns the stream of SIGINT signals.
|
|
|
|
*
|
|
|
|
* This method is the shorthand for `Deno.signal(Deno.Signal.SIGINT)`. */
|
|
|
|
interrupt: () => SignalStream;
|
|
|
|
/** Returns the stream of SIGIO signals.
|
|
|
|
*
|
|
|
|
* This method is the shorthand for `Deno.signal(Deno.Signal.SIGIO)`. */
|
|
|
|
io: () => SignalStream;
|
|
|
|
/** Returns the stream of SIGPIPE signals.
|
|
|
|
*
|
|
|
|
* This method is the shorthand for `Deno.signal(Deno.Signal.SIGPIPE)`. */
|
|
|
|
pipe: () => SignalStream;
|
|
|
|
/** Returns the stream of SIGQUIT signals.
|
|
|
|
*
|
|
|
|
* This method is the shorthand for `Deno.signal(Deno.Signal.SIGQUIT)`. */
|
|
|
|
quit: () => SignalStream;
|
|
|
|
/** Returns the stream of SIGTERM signals.
|
|
|
|
*
|
|
|
|
* This method is the shorthand for `Deno.signal(Deno.Signal.SIGTERM)`. */
|
|
|
|
terminate: () => SignalStream;
|
|
|
|
/** Returns the stream of SIGUSR1 signals.
|
|
|
|
*
|
|
|
|
* This method is the shorthand for `Deno.signal(Deno.Signal.SIGUSR1)`. */
|
|
|
|
userDefined1: () => SignalStream;
|
|
|
|
/** Returns the stream of SIGUSR2 signals.
|
|
|
|
*
|
|
|
|
* This method is the shorthand for `Deno.signal(Deno.Signal.SIGUSR2)`. */
|
|
|
|
userDefined2: () => SignalStream;
|
|
|
|
/** Returns the stream of SIGWINCH signals.
|
|
|
|
*
|
|
|
|
* This method is the shorthand for `Deno.signal(Deno.Signal.SIGWINCH)`. */
|
|
|
|
windowChange: () => SignalStream;
|
|
|
|
};
|
|
|
|
|
2020-11-30 11:08:03 -05:00
|
|
|
export type SetRawOptions = {
|
|
|
|
cbreak: boolean;
|
|
|
|
};
|
|
|
|
|
2020-04-30 11:23:40 -04:00
|
|
|
/** **UNSTABLE**: new API, yet to be vetted
|
|
|
|
*
|
|
|
|
* Set TTY to be under raw mode or not. In raw mode, characters are read and
|
|
|
|
* returned as is, without being processed. All special processing of
|
|
|
|
* characters by the terminal is disabled, including echoing input characters.
|
|
|
|
* Reading from a TTY device in raw mode is faster than reading from a TTY
|
|
|
|
* device in canonical mode.
|
|
|
|
*
|
2020-11-30 11:08:03 -05:00
|
|
|
* The `cbreak` option can be used to indicate that characters that correspond
|
|
|
|
* to a signal should still be generated. When disabling raw mode, this option
|
|
|
|
* is ignored. This functionality currently only works on Linux and Mac OS.
|
|
|
|
*
|
2020-05-16 15:23:48 -04:00
|
|
|
* ```ts
|
2020-11-30 11:08:03 -05:00
|
|
|
* Deno.setRaw(myTTY.rid, true, { cbreak: true });
|
2020-05-16 15:23:48 -04:00
|
|
|
* ```
|
2020-04-30 11:23:40 -04:00
|
|
|
*/
|
2020-11-30 11:08:03 -05:00
|
|
|
export function setRaw(
|
|
|
|
rid: number,
|
|
|
|
mode: boolean,
|
|
|
|
options?: SetRawOptions,
|
|
|
|
): void;
|
2020-04-30 11:23:40 -04:00
|
|
|
|
|
|
|
/** **UNSTABLE**: needs investigation into high precision time.
|
|
|
|
*
|
|
|
|
* Synchronously changes the access (`atime`) and modification (`mtime`) times
|
|
|
|
* of a file system object referenced by `path`. Given times are either in
|
|
|
|
* seconds (UNIX epoch time) or as `Date` objects.
|
|
|
|
*
|
2020-05-16 15:23:48 -04:00
|
|
|
* ```ts
|
|
|
|
* Deno.utimeSync("myfile.txt", 1556495550, new Date());
|
|
|
|
* ```
|
2020-04-30 11:23:40 -04:00
|
|
|
*
|
|
|
|
* Requires `allow-write` permission. */
|
|
|
|
export function utimeSync(
|
|
|
|
path: string,
|
|
|
|
atime: number | Date,
|
2020-07-14 15:24:17 -04:00
|
|
|
mtime: number | Date,
|
2020-04-30 11:23:40 -04:00
|
|
|
): void;
|
|
|
|
|
|
|
|
/** **UNSTABLE**: needs investigation into high precision time.
|
|
|
|
*
|
|
|
|
* Changes the access (`atime`) and modification (`mtime`) times of a file
|
|
|
|
* system object referenced by `path`. Given times are either in seconds
|
|
|
|
* (UNIX epoch time) or as `Date` objects.
|
|
|
|
*
|
2020-05-16 15:23:48 -04:00
|
|
|
* ```ts
|
|
|
|
* await Deno.utime("myfile.txt", 1556495550, new Date());
|
|
|
|
* ```
|
2020-04-30 11:23:40 -04:00
|
|
|
*
|
|
|
|
* Requires `allow-write` permission. */
|
|
|
|
export function utime(
|
|
|
|
path: string,
|
|
|
|
atime: number | Date,
|
2020-07-14 15:24:17 -04:00
|
|
|
mtime: number | Date,
|
2020-04-30 11:23:40 -04:00
|
|
|
): Promise<void>;
|
|
|
|
|
2020-06-03 13:46:09 -04:00
|
|
|
/** **UNSTABLE**: Under consideration to remove `ShutdownMode` entirely.
|
2020-04-30 11:23:40 -04:00
|
|
|
*
|
|
|
|
* Corresponds to `SHUT_RD`, `SHUT_WR`, `SHUT_RDWR` on POSIX-like systems.
|
|
|
|
*
|
|
|
|
* See: http://man7.org/linux/man-pages/man2/shutdown.2.html */
|
|
|
|
export enum ShutdownMode {
|
|
|
|
Read = 0,
|
|
|
|
Write,
|
|
|
|
ReadWrite, // TODO(ry) panics on ReadWrite.
|
|
|
|
}
|
|
|
|
|
|
|
|
/** **UNSTABLE**: Both the `how` parameter and `ShutdownMode` enum are under
|
|
|
|
* consideration for removal.
|
|
|
|
*
|
|
|
|
* Shutdown socket send and receive operations.
|
|
|
|
*
|
|
|
|
* Matches behavior of POSIX shutdown(3).
|
|
|
|
*
|
2020-05-16 15:23:48 -04:00
|
|
|
* ```ts
|
|
|
|
* const listener = Deno.listen({ port: 80 });
|
|
|
|
* const conn = await listener.accept();
|
|
|
|
* Deno.shutdown(conn.rid, Deno.ShutdownMode.Write);
|
|
|
|
* ```
|
2020-04-30 11:23:40 -04:00
|
|
|
*/
|
|
|
|
export function shutdown(rid: number, how: ShutdownMode): Promise<void>;
|
|
|
|
|
2020-06-03 13:46:09 -04:00
|
|
|
/** **UNSTABLE**: new API, yet to be vetted.
|
2020-04-30 11:23:40 -04:00
|
|
|
*
|
|
|
|
* A generic transport listener for message-oriented protocols. */
|
|
|
|
export interface DatagramConn extends AsyncIterable<[Uint8Array, Addr]> {
|
|
|
|
/** **UNSTABLE**: new API, yet to be vetted.
|
|
|
|
*
|
|
|
|
* Waits for and resolves to the next message to the `UDPConn`. */
|
|
|
|
receive(p?: Uint8Array): Promise<[Uint8Array, Addr]>;
|
|
|
|
/** UNSTABLE: new API, yet to be vetted.
|
|
|
|
*
|
|
|
|
* Sends a message to the target. */
|
2020-06-13 10:14:31 -04:00
|
|
|
send(p: Uint8Array, addr: Addr): Promise<number>;
|
2020-04-30 11:23:40 -04:00
|
|
|
/** UNSTABLE: new API, yet to be vetted.
|
|
|
|
*
|
|
|
|
* Close closes the socket. Any pending message promises will be rejected
|
|
|
|
* with errors. */
|
|
|
|
close(): void;
|
|
|
|
/** Return the address of the `UDPConn`. */
|
|
|
|
readonly addr: Addr;
|
|
|
|
[Symbol.asyncIterator](): AsyncIterableIterator<[Uint8Array, Addr]>;
|
|
|
|
}
|
|
|
|
|
|
|
|
export interface UnixListenOptions {
|
|
|
|
/** A Path to the Unix Socket. */
|
|
|
|
path: string;
|
|
|
|
}
|
|
|
|
|
|
|
|
/** **UNSTABLE**: new API, yet to be vetted.
|
|
|
|
*
|
|
|
|
* Listen announces on the local transport address.
|
|
|
|
*
|
2020-05-16 15:23:48 -04:00
|
|
|
* ```ts
|
|
|
|
* const listener = Deno.listen({ path: "/foo/bar.sock", transport: "unix" })
|
|
|
|
* ```
|
2020-04-30 11:23:40 -04:00
|
|
|
*
|
|
|
|
* Requires `allow-read` and `allow-write` permission. */
|
|
|
|
export function listen(
|
2020-07-14 15:24:17 -04:00
|
|
|
options: UnixListenOptions & { transport: "unix" },
|
2020-04-30 11:23:40 -04:00
|
|
|
): Listener;
|
|
|
|
|
2020-06-03 13:46:09 -04:00
|
|
|
/** **UNSTABLE**: new API, yet to be vetted
|
2020-04-30 11:23:40 -04:00
|
|
|
*
|
|
|
|
* Listen announces on the local transport address.
|
|
|
|
*
|
2020-05-16 15:23:48 -04:00
|
|
|
* ```ts
|
|
|
|
* const listener1 = Deno.listenDatagram({
|
|
|
|
* port: 80,
|
|
|
|
* transport: "udp"
|
|
|
|
* });
|
|
|
|
* const listener2 = Deno.listenDatagram({
|
|
|
|
* hostname: "golang.org",
|
|
|
|
* port: 80,
|
|
|
|
* transport: "udp"
|
|
|
|
* });
|
|
|
|
* ```
|
2020-04-30 11:23:40 -04:00
|
|
|
*
|
|
|
|
* Requires `allow-net` permission. */
|
|
|
|
export function listenDatagram(
|
2020-07-14 15:24:17 -04:00
|
|
|
options: ListenOptions & { transport: "udp" },
|
2020-04-30 11:23:40 -04:00
|
|
|
): DatagramConn;
|
|
|
|
|
2020-06-03 13:46:09 -04:00
|
|
|
/** **UNSTABLE**: new API, yet to be vetted
|
2020-04-30 11:23:40 -04:00
|
|
|
*
|
|
|
|
* Listen announces on the local transport address.
|
|
|
|
*
|
2020-05-16 15:23:48 -04:00
|
|
|
* ```ts
|
|
|
|
* const listener = Deno.listenDatagram({
|
|
|
|
* address: "/foo/bar.sock",
|
|
|
|
* transport: "unixpacket"
|
|
|
|
* });
|
|
|
|
* ```
|
2020-04-30 11:23:40 -04:00
|
|
|
*
|
|
|
|
* Requires `allow-read` and `allow-write` permission. */
|
|
|
|
export function listenDatagram(
|
2020-07-14 15:24:17 -04:00
|
|
|
options: UnixListenOptions & { transport: "unixpacket" },
|
2020-04-30 11:23:40 -04:00
|
|
|
): DatagramConn;
|
|
|
|
|
|
|
|
export interface UnixConnectOptions {
|
|
|
|
transport: "unix";
|
|
|
|
path: string;
|
|
|
|
}
|
|
|
|
|
2020-06-03 13:46:09 -04:00
|
|
|
/** **UNSTABLE**: The unix socket transport is unstable as a new API yet to
|
|
|
|
* be vetted. The TCP transport is considered stable.
|
|
|
|
*
|
2020-04-30 11:23:40 -04:00
|
|
|
* Connects to the hostname (default is "127.0.0.1") and port on the named
|
|
|
|
* transport (default is "tcp"), and resolves to the connection (`Conn`).
|
|
|
|
*
|
2020-05-16 15:23:48 -04:00
|
|
|
* ```ts
|
|
|
|
* const conn1 = await Deno.connect({ port: 80 });
|
|
|
|
* const conn2 = await Deno.connect({ hostname: "192.0.2.1", port: 80 });
|
|
|
|
* const conn3 = await Deno.connect({ hostname: "[2001:db8::1]", port: 80 });
|
|
|
|
* const conn4 = await Deno.connect({ hostname: "golang.org", port: 80, transport: "tcp" });
|
|
|
|
* const conn5 = await Deno.connect({ path: "/foo/bar.sock", transport: "unix" });
|
|
|
|
* ```
|
2020-04-30 11:23:40 -04:00
|
|
|
*
|
2020-05-24 09:43:40 -04:00
|
|
|
* Requires `allow-net` permission for "tcp" and `allow-read` for "unix". */
|
2020-04-30 11:23:40 -04:00
|
|
|
export function connect(
|
2020-07-14 15:24:17 -04:00
|
|
|
options: ConnectOptions | UnixConnectOptions,
|
2020-04-30 11:23:40 -04:00
|
|
|
): Promise<Conn>;
|
|
|
|
|
|
|
|
export interface StartTlsOptions {
|
|
|
|
/** A literal IP address or host name that can be resolved to an IP address.
|
|
|
|
* If not specified, defaults to `127.0.0.1`. */
|
|
|
|
hostname?: string;
|
|
|
|
/** Server certificate file. */
|
|
|
|
certFile?: string;
|
|
|
|
}
|
|
|
|
|
|
|
|
/** **UNSTABLE**: new API, yet to be vetted.
|
|
|
|
*
|
|
|
|
* Start TLS handshake from an existing connection using
|
|
|
|
* an optional cert file, hostname (default is "127.0.0.1"). The
|
|
|
|
* cert file is optional and if not included Mozilla's root certificates will
|
|
|
|
* be used (see also https://github.com/ctz/webpki-roots for specifics)
|
|
|
|
* Using this function requires that the other end of the connection is
|
|
|
|
* prepared for TLS handshake.
|
|
|
|
*
|
2020-05-16 15:23:48 -04:00
|
|
|
* ```ts
|
|
|
|
* const conn = await Deno.connect({ port: 80, hostname: "127.0.0.1" });
|
|
|
|
* const tlsConn = await Deno.startTls(conn, { certFile: "./certs/my_custom_root_CA.pem", hostname: "127.0.0.1", port: 80 });
|
|
|
|
* ```
|
2020-04-30 11:23:40 -04:00
|
|
|
*
|
|
|
|
* Requires `allow-net` permission.
|
|
|
|
*/
|
|
|
|
export function startTls(
|
|
|
|
conn: Conn,
|
2020-07-14 15:24:17 -04:00
|
|
|
options?: StartTlsOptions,
|
2020-04-30 11:23:40 -04:00
|
|
|
): Promise<Conn>;
|
|
|
|
|
|
|
|
/** **UNSTABLE**: The `signo` argument may change to require the Deno.Signal
|
|
|
|
* enum.
|
|
|
|
*
|
|
|
|
* Send a signal to process under given `pid`. This functionality currently
|
|
|
|
* only works on Linux and Mac OS.
|
|
|
|
*
|
|
|
|
* If `pid` is negative, the signal will be sent to the process group
|
|
|
|
* identified by `pid`.
|
|
|
|
*
|
|
|
|
* const p = Deno.run({
|
2020-12-28 18:05:29 -05:00
|
|
|
* cmd: ["sleep", "10000"]
|
2020-04-30 11:23:40 -04:00
|
|
|
* });
|
|
|
|
*
|
|
|
|
* Deno.kill(p.pid, Deno.Signal.SIGINT);
|
|
|
|
*
|
|
|
|
* Requires `allow-run` permission. */
|
|
|
|
export function kill(pid: number, signo: number): void;
|
|
|
|
|
2020-07-13 12:23:24 -04:00
|
|
|
/** The name of a "powerful feature" which needs permission.
|
|
|
|
*
|
|
|
|
* See: https://w3c.github.io/permissions/#permission-registry
|
|
|
|
*
|
|
|
|
* Note that the definition of `PermissionName` in the above spec is swapped
|
|
|
|
* out for a set of Deno permissions which are not web-compatible. */
|
|
|
|
export type PermissionName =
|
|
|
|
| "run"
|
|
|
|
| "read"
|
|
|
|
| "write"
|
|
|
|
| "net"
|
|
|
|
| "env"
|
|
|
|
| "plugin"
|
|
|
|
| "hrtime";
|
|
|
|
|
|
|
|
/** The current status of the permission.
|
|
|
|
*
|
|
|
|
* See: https://w3c.github.io/permissions/#status-of-a-permission */
|
|
|
|
export type PermissionState = "granted" | "denied" | "prompt";
|
|
|
|
|
|
|
|
export interface RunPermissionDescriptor {
|
|
|
|
name: "run";
|
|
|
|
}
|
|
|
|
|
|
|
|
export interface ReadPermissionDescriptor {
|
|
|
|
name: "read";
|
|
|
|
path?: string;
|
|
|
|
}
|
|
|
|
|
|
|
|
export interface WritePermissionDescriptor {
|
|
|
|
name: "write";
|
|
|
|
path?: string;
|
|
|
|
}
|
|
|
|
|
|
|
|
export interface NetPermissionDescriptor {
|
|
|
|
name: "net";
|
2020-12-30 17:35:28 -05:00
|
|
|
/** Optional host string of the form `"<hostname>[:<port>]"`. Examples:
|
2020-07-13 12:23:24 -04:00
|
|
|
*
|
2020-12-30 17:35:28 -05:00
|
|
|
* "github.com"
|
|
|
|
* "deno.land:8080"
|
|
|
|
*/
|
|
|
|
host?: string;
|
2020-07-13 12:23:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
export interface EnvPermissionDescriptor {
|
|
|
|
name: "env";
|
|
|
|
}
|
|
|
|
|
|
|
|
export interface PluginPermissionDescriptor {
|
|
|
|
name: "plugin";
|
|
|
|
}
|
|
|
|
|
|
|
|
export interface HrtimePermissionDescriptor {
|
|
|
|
name: "hrtime";
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Permission descriptors which define a permission and can be queried,
|
|
|
|
* requested, or revoked.
|
|
|
|
*
|
|
|
|
* See: https://w3c.github.io/permissions/#permission-descriptor */
|
|
|
|
export type PermissionDescriptor =
|
|
|
|
| RunPermissionDescriptor
|
|
|
|
| ReadPermissionDescriptor
|
|
|
|
| WritePermissionDescriptor
|
|
|
|
| NetPermissionDescriptor
|
|
|
|
| EnvPermissionDescriptor
|
|
|
|
| PluginPermissionDescriptor
|
|
|
|
| HrtimePermissionDescriptor;
|
|
|
|
|
|
|
|
export class Permissions {
|
|
|
|
/** Resolves to the current status of a permission.
|
|
|
|
*
|
|
|
|
* ```ts
|
|
|
|
* const status = await Deno.permissions.query({ name: "read", path: "/etc" });
|
|
|
|
* if (status.state === "granted") {
|
|
|
|
* data = await Deno.readFile("/etc/passwd");
|
|
|
|
* }
|
|
|
|
* ```
|
|
|
|
*/
|
|
|
|
query(desc: PermissionDescriptor): Promise<PermissionStatus>;
|
|
|
|
|
|
|
|
/** Revokes a permission, and resolves to the state of the permission.
|
|
|
|
*
|
|
|
|
* const status = await Deno.permissions.revoke({ name: "run" });
|
|
|
|
* assert(status.state !== "granted")
|
|
|
|
*/
|
|
|
|
revoke(desc: PermissionDescriptor): Promise<PermissionStatus>;
|
|
|
|
|
|
|
|
/** Requests the permission, and resolves to the state of the permission.
|
|
|
|
*
|
|
|
|
* ```ts
|
|
|
|
* const status = await Deno.permissions.request({ name: "env" });
|
|
|
|
* if (status.state === "granted") {
|
2020-12-12 07:15:50 -05:00
|
|
|
* console.log("'env' permission is granted.");
|
2020-07-13 12:23:24 -04:00
|
|
|
* } else {
|
|
|
|
* console.log("'env' permission is denied.");
|
|
|
|
* }
|
|
|
|
* ```
|
|
|
|
*/
|
|
|
|
request(desc: PermissionDescriptor): Promise<PermissionStatus>;
|
|
|
|
}
|
|
|
|
|
|
|
|
/** **UNSTABLE**: Under consideration to move to `navigator.permissions` to
|
|
|
|
* match web API. It could look like `navigator.permissions.query({ name: Deno.symbols.read })`.
|
|
|
|
*/
|
|
|
|
export const permissions: Permissions;
|
|
|
|
|
|
|
|
/** see: https://w3c.github.io/permissions/#permissionstatus */
|
|
|
|
export class PermissionStatus {
|
|
|
|
state: PermissionState;
|
2020-09-19 17:30:59 -04:00
|
|
|
constructor();
|
2020-07-13 12:23:24 -04:00
|
|
|
}
|
|
|
|
|
2020-06-03 13:46:09 -04:00
|
|
|
/** **UNSTABLE**: New API, yet to be vetted. Additional consideration is still
|
|
|
|
* necessary around the permissions required.
|
|
|
|
*
|
|
|
|
* Get the `hostname` of the machine the Deno process is running on.
|
2020-05-09 12:44:35 -04:00
|
|
|
*
|
2020-05-16 15:23:48 -04:00
|
|
|
* ```ts
|
|
|
|
* console.log(Deno.hostname());
|
|
|
|
* ```
|
2020-05-09 12:44:35 -04:00
|
|
|
*
|
|
|
|
* Requires `allow-env` permission.
|
|
|
|
*/
|
|
|
|
export function hostname(): string;
|
2020-06-10 23:00:29 -04:00
|
|
|
|
2020-07-02 09:34:19 -04:00
|
|
|
/** **UNSTABLE**: new API, yet to be vetted.
|
|
|
|
* Synchronously truncates or extends the specified file stream, to reach the
|
2020-06-20 09:46:10 -04:00
|
|
|
* specified `len`. If `len` is not specified then the entire file contents
|
|
|
|
* are truncated.
|
|
|
|
*
|
|
|
|
* ```ts
|
|
|
|
* // truncate the entire file
|
|
|
|
* const file = Deno.open("my_file.txt", { read: true, write: true, truncate: true, create: true });
|
|
|
|
* Deno.ftruncateSync(file.rid);
|
|
|
|
*
|
|
|
|
* // truncate part of the file
|
|
|
|
* const file = Deno.open("my_file.txt", { read: true, write: true, create: true });
|
|
|
|
* Deno.write(file.rid, new TextEncoder().encode("Hello World"));
|
|
|
|
* Deno.ftruncateSync(file.rid, 7);
|
|
|
|
* const data = new Uint8Array(32);
|
|
|
|
* Deno.readSync(file.rid, data);
|
|
|
|
* console.log(new TextDecoder().decode(data)); // Hello W
|
|
|
|
* ```
|
|
|
|
*/
|
|
|
|
export function ftruncateSync(rid: number, len?: number): void;
|
|
|
|
|
2020-07-02 09:34:19 -04:00
|
|
|
/** **UNSTABLE**: new API, yet to be vetted.
|
|
|
|
* Truncates or extends the specified file stream, to reach the specified `len`. If
|
2020-06-20 09:46:10 -04:00
|
|
|
* `len` is not specified then the entire file contents are truncated.
|
|
|
|
*
|
|
|
|
* ```ts
|
|
|
|
* // truncate the entire file
|
|
|
|
* const file = Deno.open("my_file.txt", { read: true, write: true, create: true });
|
|
|
|
* await Deno.ftruncate(file.rid);
|
|
|
|
*
|
|
|
|
* // truncate part of the file
|
|
|
|
* const file = Deno.open("my_file.txt", { read: true, write: true, create: true });
|
|
|
|
* await Deno.write(file.rid, new TextEncoder().encode("Hello World"));
|
|
|
|
* await Deno.ftruncate(file.rid, 7);
|
|
|
|
* const data = new Uint8Array(32);
|
|
|
|
* await Deno.read(file.rid, data);
|
|
|
|
* console.log(new TextDecoder().decode(data)); // Hello W
|
|
|
|
* ```
|
|
|
|
*/
|
|
|
|
export function ftruncate(rid: number, len?: number): Promise<void>;
|
2020-06-21 09:29:44 -04:00
|
|
|
|
2020-06-22 08:58:52 -04:00
|
|
|
/** **UNSTABLE**: New API, yet to be vetted.
|
|
|
|
* Synchronously returns a `Deno.FileInfo` for the given file stream.
|
|
|
|
*
|
|
|
|
* ```ts
|
|
|
|
* const file = Deno.openSync("file.txt", { read: true });
|
|
|
|
* const fileInfo = Deno.fstatSync(file.rid);
|
|
|
|
* assert(fileInfo.isFile);
|
|
|
|
* ```
|
|
|
|
*/
|
|
|
|
export function fstatSync(rid: number): FileInfo;
|
|
|
|
|
|
|
|
/** **UNSTABLE**: New API, yet to be vetted.
|
|
|
|
* Returns a `Deno.FileInfo` for the given file stream.
|
|
|
|
*
|
|
|
|
* ```ts
|
|
|
|
* const file = await Deno.open("file.txt", { read: true });
|
|
|
|
* const fileInfo = await Deno.fstat(file.rid);
|
|
|
|
* assert(fileInfo.isFile);
|
|
|
|
* ```
|
|
|
|
*/
|
|
|
|
export function fstat(rid: number): Promise<FileInfo>;
|
2020-07-08 10:35:45 -04:00
|
|
|
|
|
|
|
/** **UNSTABLE**: New API, yet to be vetted.
|
|
|
|
* The pid of the current process's parent.
|
|
|
|
*/
|
|
|
|
export const ppid: number;
|
2020-08-05 14:44:03 -04:00
|
|
|
|
|
|
|
/** **UNSTABLE**: New API, yet to be vetted.
|
|
|
|
* A custom HttpClient for use with `fetch`.
|
2020-08-10 16:41:51 -04:00
|
|
|
*
|
2020-08-05 14:44:03 -04:00
|
|
|
* ```ts
|
|
|
|
* const client = new Deno.createHttpClient({ caFile: "./ca.pem" });
|
|
|
|
* const req = await fetch("https://myserver.com", { client });
|
|
|
|
* ```
|
|
|
|
*/
|
|
|
|
export class HttpClient {
|
|
|
|
rid: number;
|
|
|
|
close(): void;
|
|
|
|
}
|
|
|
|
|
|
|
|
/** **UNSTABLE**: New API, yet to be vetted.
|
|
|
|
* The options used when creating a [HttpClient].
|
|
|
|
*/
|
|
|
|
interface CreateHttpClientOptions {
|
|
|
|
/** A certificate authority to use when validating TLS certificates.
|
2020-08-10 16:41:51 -04:00
|
|
|
*
|
2020-08-05 14:44:03 -04:00
|
|
|
* Requires `allow-read` permission.
|
|
|
|
*/
|
|
|
|
caFile?: string;
|
2020-12-19 17:13:48 -05:00
|
|
|
|
|
|
|
/** A certificate authority to use when validating TLS certificates. Certificate data must be PEM encoded.
|
|
|
|
*/
|
|
|
|
caData?: string;
|
2020-08-05 14:44:03 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
/** **UNSTABLE**: New API, yet to be vetted.
|
|
|
|
* Create a custom HttpClient for to use with `fetch`.
|
2020-08-10 16:41:51 -04:00
|
|
|
*
|
2020-08-05 14:44:03 -04:00
|
|
|
* ```ts
|
|
|
|
* const client = new Deno.createHttpClient({ caFile: "./ca.pem" });
|
|
|
|
* const req = await fetch("https://myserver.com", { client });
|
|
|
|
* ```
|
|
|
|
*/
|
|
|
|
export function createHttpClient(
|
|
|
|
options: CreateHttpClientOptions,
|
|
|
|
): HttpClient;
|
2020-08-31 14:29:43 -04:00
|
|
|
|
|
|
|
/** **UNSTABLE**: needs investigation into high precision time.
|
|
|
|
*
|
|
|
|
* Synchronously changes the access (`atime`) and modification (`mtime`) times
|
|
|
|
* of a file stream resource referenced by `rid`. Given times are either in
|
|
|
|
* seconds (UNIX epoch time) or as `Date` objects.
|
|
|
|
*
|
|
|
|
* ```ts
|
|
|
|
* const file = Deno.openSync("file.txt", { create: true });
|
|
|
|
* Deno.futimeSync(file.rid, 1556495550, new Date());
|
|
|
|
* ```
|
|
|
|
*/
|
|
|
|
export function futimeSync(
|
|
|
|
rid: number,
|
|
|
|
atime: number | Date,
|
|
|
|
mtime: number | Date,
|
|
|
|
): void;
|
|
|
|
|
|
|
|
/** **UNSTABLE**: needs investigation into high precision time.
|
|
|
|
*
|
|
|
|
* Changes the access (`atime`) and modification (`mtime`) times of a file
|
|
|
|
* stream resource referenced by `rid`. Given times are either in seconds
|
|
|
|
* (UNIX epoch time) or as `Date` objects.
|
|
|
|
*
|
|
|
|
* ```ts
|
|
|
|
* const file = await Deno.open("file.txt", { create: true });
|
|
|
|
* await Deno.futime(file.rid, 1556495550, new Date());
|
|
|
|
* ```
|
|
|
|
*/
|
|
|
|
export function futime(
|
|
|
|
rid: number,
|
|
|
|
atime: number | Date,
|
|
|
|
mtime: number | Date,
|
|
|
|
): Promise<void>;
|
2020-10-15 21:06:31 -04:00
|
|
|
|
|
|
|
/** *UNSTABLE**: new API, yet to be vetted.
|
|
|
|
*
|
|
|
|
* SleepSync puts the main thread to sleep synchronously for a given amount of
|
|
|
|
* time in milliseconds.
|
|
|
|
*
|
|
|
|
* ```ts
|
|
|
|
* Deno.sleepSync(10);
|
|
|
|
* ```
|
|
|
|
*/
|
|
|
|
export function sleepSync(millis: number): Promise<void>;
|
2020-04-30 11:23:40 -04:00
|
|
|
}
|
2020-08-05 14:44:03 -04:00
|
|
|
|
|
|
|
declare function fetch(
|
|
|
|
input: Request | URL | string,
|
|
|
|
init?: RequestInit & { client: Deno.HttpClient },
|
|
|
|
): Promise<Response>;
|