From 2f44db6756f974ad3e258e4a777db2519f1b9091 Mon Sep 17 00:00:00 2001 From: Ryan Dahl Date: Wed, 3 Oct 2018 21:41:59 -0400 Subject: Use underscores in filenames. --- js/compiler.ts | 2 +- js/deno.ts | 2 +- js/file_info.ts | 108 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ js/fileinfo.ts | 108 ------------------------------------------------------ js/global-eval.ts | 10 ----- js/global_eval.ts | 10 +++++ js/globals.ts | 2 +- js/libdeno.ts | 2 +- js/net.ts | 48 ++++++++++++------------ js/read_dir.ts | 2 +- js/stat.ts | 2 +- 11 files changed, 148 insertions(+), 148 deletions(-) create mode 100644 js/file_info.ts delete mode 100644 js/fileinfo.ts delete mode 100644 js/global-eval.ts create mode 100644 js/global_eval.ts (limited to 'js') diff --git a/js/compiler.ts b/js/compiler.ts index 9496610da..7eba87549 100644 --- a/js/compiler.ts +++ b/js/compiler.ts @@ -3,7 +3,7 @@ import * as ts from "typescript"; import { assetSourceCode } from "./assets"; import * as deno from "./deno"; -import { globalEval } from "./global-eval"; +import { globalEval } from "./global_eval"; import { libdeno } from "./libdeno"; import { window } from "./globals"; import * as os from "./os"; diff --git a/js/deno.ts b/js/deno.ts index c12df1236..53ca4c009 100644 --- a/js/deno.ts +++ b/js/deno.ts @@ -20,6 +20,6 @@ export { libdeno } from "./libdeno"; export { platform } from "./platform"; export { trace } from "./trace"; export { truncateSync, truncate } from "./truncate"; -export { FileInfo } from "./fileinfo"; +export { FileInfo } from "./file_info"; export { connect, dial, listen, Listener, Conn } from "./net"; export const args: string[] = []; diff --git a/js/file_info.ts b/js/file_info.ts new file mode 100644 index 000000000..00e68ac91 --- /dev/null +++ b/js/file_info.ts @@ -0,0 +1,108 @@ +// Copyright 2018 the Deno authors. All rights reserved. MIT license. +import * as msg from "gen/msg_generated"; + +/** + * A FileInfo describes a file and is returned by `stat`, `lstat`, + * `statSync`, `lstatSync`. + */ +export interface FileInfo { + readonly _isFile: boolean; + readonly _isSymlink: boolean; + /** The size of the file, in bytes. */ + len: number; + /** + * The last modification time of the file. This corresponds to the `mtime` + * field from `stat` on Unix and `ftLastWriteTime` on Windows. This may not + * be available on all platforms. + */ + modified: number | null; + /** + * The last access time of the file. This corresponds to the `atime` + * field from `stat` on Unix and `ftLastAccessTime` on Windows. This may not + * be available on all platforms. + */ + accessed: number | null; + /** + * The last access time of the file. This corresponds to the `birthtime` + * field from `stat` on Unix and `ftCreationTime` on Windows. This may not + * be available on all platforms. + */ + created: number | null; + /** + * The underlying raw st_mode bits that contain the standard Unix permissions + * for this file/directory. TODO Match behavior with Go on windows for mode. + */ + mode: number | null; + + /** + * Returns the file or directory name. + */ + name: string | null; + + /** Returns the file or directory path. */ + path: string | null; + + /** + * Returns whether this is info for a regular file. This result is mutually + * exclusive to `FileInfo.isDirectory` and `FileInfo.isSymlink`. + */ + isFile(): boolean; + + /** + * Returns whether this is info for a regular directory. This result is + * mutually exclusive to `FileInfo.isFile` and `FileInfo.isSymlink`. + */ + isDirectory(): boolean; + + /** + * Returns whether this is info for a symlink. This result is + * mutually exclusive to `FileInfo.isFile` and `FileInfo.isDirectory`. + */ + isSymlink(): boolean; +} + +export class FileInfoImpl implements FileInfo { + readonly _isFile: boolean; + readonly _isSymlink: boolean; + len: number; + modified: number | null; + accessed: number | null; + created: number | null; + mode: number | null; + name: string | null; + path: string | null; + + /* @internal */ + constructor(private _inner: msg.StatRes) { + const modified = this._inner.modified().toFloat64(); + const accessed = this._inner.accessed().toFloat64(); + const created = this._inner.created().toFloat64(); + const hasMode = this._inner.hasMode(); + const mode = this._inner.mode(); // negative for invalid mode (Windows) + const name = this._inner.name(); + const path = this._inner.path(); + + this._isFile = this._inner.isFile(); + this._isSymlink = this._inner.isSymlink(); + this.len = this._inner.len().toFloat64(); + this.modified = modified ? modified : null; + this.accessed = accessed ? accessed : null; + this.created = created ? created : null; + // null on Windows + this.mode = hasMode ? mode : null; + this.name = name ? name : null; + this.path = path ? path : null; + } + + isFile() { + return this._isFile; + } + + isDirectory() { + return !this._isFile && !this._isSymlink; + } + + isSymlink() { + return this._isSymlink; + } +} diff --git a/js/fileinfo.ts b/js/fileinfo.ts deleted file mode 100644 index 00e68ac91..000000000 --- a/js/fileinfo.ts +++ /dev/null @@ -1,108 +0,0 @@ -// Copyright 2018 the Deno authors. All rights reserved. MIT license. -import * as msg from "gen/msg_generated"; - -/** - * A FileInfo describes a file and is returned by `stat`, `lstat`, - * `statSync`, `lstatSync`. - */ -export interface FileInfo { - readonly _isFile: boolean; - readonly _isSymlink: boolean; - /** The size of the file, in bytes. */ - len: number; - /** - * The last modification time of the file. This corresponds to the `mtime` - * field from `stat` on Unix and `ftLastWriteTime` on Windows. This may not - * be available on all platforms. - */ - modified: number | null; - /** - * The last access time of the file. This corresponds to the `atime` - * field from `stat` on Unix and `ftLastAccessTime` on Windows. This may not - * be available on all platforms. - */ - accessed: number | null; - /** - * The last access time of the file. This corresponds to the `birthtime` - * field from `stat` on Unix and `ftCreationTime` on Windows. This may not - * be available on all platforms. - */ - created: number | null; - /** - * The underlying raw st_mode bits that contain the standard Unix permissions - * for this file/directory. TODO Match behavior with Go on windows for mode. - */ - mode: number | null; - - /** - * Returns the file or directory name. - */ - name: string | null; - - /** Returns the file or directory path. */ - path: string | null; - - /** - * Returns whether this is info for a regular file. This result is mutually - * exclusive to `FileInfo.isDirectory` and `FileInfo.isSymlink`. - */ - isFile(): boolean; - - /** - * Returns whether this is info for a regular directory. This result is - * mutually exclusive to `FileInfo.isFile` and `FileInfo.isSymlink`. - */ - isDirectory(): boolean; - - /** - * Returns whether this is info for a symlink. This result is - * mutually exclusive to `FileInfo.isFile` and `FileInfo.isDirectory`. - */ - isSymlink(): boolean; -} - -export class FileInfoImpl implements FileInfo { - readonly _isFile: boolean; - readonly _isSymlink: boolean; - len: number; - modified: number | null; - accessed: number | null; - created: number | null; - mode: number | null; - name: string | null; - path: string | null; - - /* @internal */ - constructor(private _inner: msg.StatRes) { - const modified = this._inner.modified().toFloat64(); - const accessed = this._inner.accessed().toFloat64(); - const created = this._inner.created().toFloat64(); - const hasMode = this._inner.hasMode(); - const mode = this._inner.mode(); // negative for invalid mode (Windows) - const name = this._inner.name(); - const path = this._inner.path(); - - this._isFile = this._inner.isFile(); - this._isSymlink = this._inner.isSymlink(); - this.len = this._inner.len().toFloat64(); - this.modified = modified ? modified : null; - this.accessed = accessed ? accessed : null; - this.created = created ? created : null; - // null on Windows - this.mode = hasMode ? mode : null; - this.name = name ? name : null; - this.path = path ? path : null; - } - - isFile() { - return this._isFile; - } - - isDirectory() { - return !this._isFile && !this._isSymlink; - } - - isSymlink() { - return this._isSymlink; - } -} diff --git a/js/global-eval.ts b/js/global-eval.ts deleted file mode 100644 index 1f77c4952..000000000 --- a/js/global-eval.ts +++ /dev/null @@ -1,10 +0,0 @@ -/** - * If you use the eval function indirectly, by invoking it via a reference - * other than eval, as of ECMAScript 5 it works in the global scope rather than - * the local scope. This means, for instance, that function declarations create - * global functions, and that the code being evaluated doesn't have access to - * local variables within the scope where it's being called. - * - * @internal - */ -export const globalEval = eval; diff --git a/js/global_eval.ts b/js/global_eval.ts new file mode 100644 index 000000000..1f77c4952 --- /dev/null +++ b/js/global_eval.ts @@ -0,0 +1,10 @@ +/** + * If you use the eval function indirectly, by invoking it via a reference + * other than eval, as of ECMAScript 5 it works in the global scope rather than + * the local scope. This means, for instance, that function declarations create + * global functions, and that the code being evaluated doesn't have access to + * local variables within the scope where it's being called. + * + * @internal + */ +export const globalEval = eval; diff --git a/js/globals.ts b/js/globals.ts index d88e1b28d..2e6b24305 100644 --- a/js/globals.ts +++ b/js/globals.ts @@ -5,7 +5,7 @@ import * as timers from "./timers"; import * as textEncoding from "./text_encoding"; import * as fetch_ from "./fetch"; import { libdeno } from "./libdeno"; -import { globalEval } from "./global-eval"; +import { globalEval } from "./global_eval"; import { DenoHeaders } from "./fetch"; import { DenoBlob } from "./blob"; diff --git a/js/libdeno.ts b/js/libdeno.ts index afd6f1aec..97269c36c 100644 --- a/js/libdeno.ts +++ b/js/libdeno.ts @@ -1,5 +1,5 @@ import { RawSourceMap } from "./types"; -import { globalEval } from "./global-eval"; +import { globalEval } from "./global_eval"; // The libdeno functions are moved so that users can't access them. type MessageCallback = (msg: Uint8Array) => void; diff --git a/js/net.ts b/js/net.ts index a0307bfe9..ccbd331dd 100644 --- a/js/net.ts +++ b/js/net.ts @@ -1,7 +1,7 @@ // Copyright 2018 the Deno authors. All rights reserved. MIT license. import { ReadResult, Reader, Writer, Closer } from "./io"; -import * as fbs from "gen/msg_generated"; +import * as msg from "gen/msg_generated"; import { assert, notImplemented } from "./util"; import * as dispatch from "./dispatch"; import { flatbuffers } from "flatbuffers"; @@ -32,14 +32,14 @@ class ListenerImpl implements Listener { async accept(): Promise { const builder = new flatbuffers.Builder(); - fbs.Accept.startAccept(builder); - fbs.Accept.addRid(builder, this.fd); - const msg = fbs.Accept.endAccept(builder); - const baseRes = await dispatch.sendAsync(builder, fbs.Any.Accept, msg); + msg.Accept.startAccept(builder); + msg.Accept.addRid(builder, this.fd); + const inner = msg.Accept.endAccept(builder); + const baseRes = await dispatch.sendAsync(builder, msg.Any.Accept, inner); assert(baseRes != null); - assert(fbs.Any.NewConn === baseRes!.msgType()); - const res = new fbs.NewConn(); - assert(baseRes!.msg(res) != null); + assert(msg.Any.NewConn === baseRes!.innerType()); + const res = new msg.NewConn(); + assert(baseRes!.inner(res) != null); return new ConnImpl(res.rid(), res.remoteAddr()!, res.localAddr()!); } @@ -112,15 +112,15 @@ export function listen(network: Network, address: string): Listener { const builder = new flatbuffers.Builder(); const network_ = builder.createString(network); const address_ = builder.createString(address); - fbs.Listen.startListen(builder); - fbs.Listen.addNetwork(builder, network_); - fbs.Listen.addAddress(builder, address_); - const msg = fbs.Listen.endListen(builder); - const baseRes = dispatch.sendSync(builder, fbs.Any.Listen, msg); + msg.Listen.startListen(builder); + msg.Listen.addNetwork(builder, network_); + msg.Listen.addAddress(builder, address_); + const inner = msg.Listen.endListen(builder); + const baseRes = dispatch.sendSync(builder, msg.Any.Listen, inner); assert(baseRes != null); - assert(fbs.Any.ListenRes === baseRes!.msgType()); - const res = new fbs.ListenRes(); - assert(baseRes!.msg(res) != null); + assert(msg.Any.ListenRes === baseRes!.innerType()); + const res = new msg.ListenRes(); + assert(baseRes!.inner(res) != null); return new ListenerImpl(res.rid()); } @@ -154,15 +154,15 @@ export async function dial(network: Network, address: string): Promise { const builder = new flatbuffers.Builder(); const network_ = builder.createString(network); const address_ = builder.createString(address); - fbs.Dial.startDial(builder); - fbs.Dial.addNetwork(builder, network_); - fbs.Dial.addAddress(builder, address_); - const msg = fbs.Dial.endDial(builder); - const baseRes = await dispatch.sendAsync(builder, fbs.Any.Dial, msg); + msg.Dial.startDial(builder); + msg.Dial.addNetwork(builder, network_); + msg.Dial.addAddress(builder, address_); + const inner = msg.Dial.endDial(builder); + const baseRes = await dispatch.sendAsync(builder, msg.Any.Dial, inner); assert(baseRes != null); - assert(fbs.Any.NewConn === baseRes!.msgType()); - const res = new fbs.NewConn(); - assert(baseRes!.msg(res) != null); + assert(msg.Any.NewConn === baseRes!.innerType()); + const res = new msg.NewConn(); + assert(baseRes!.inner(res) != null); return new ConnImpl(res.rid(), res.remoteAddr()!, res.localAddr()!); } diff --git a/js/read_dir.ts b/js/read_dir.ts index b1977549d..d99b085ec 100644 --- a/js/read_dir.ts +++ b/js/read_dir.ts @@ -2,7 +2,7 @@ import * as msg from "gen/msg_generated"; import { flatbuffers } from "flatbuffers"; import * as dispatch from "./dispatch"; -import { FileInfo, FileInfoImpl } from "./fileinfo"; +import { FileInfo, FileInfoImpl } from "./file_info"; import { assert } from "./util"; /** diff --git a/js/stat.ts b/js/stat.ts index 21d80dab3..4cfc4290f 100644 --- a/js/stat.ts +++ b/js/stat.ts @@ -3,7 +3,7 @@ import * as msg from "gen/msg_generated"; import { flatbuffers } from "flatbuffers"; import * as dispatch from "./dispatch"; import { assert } from "./util"; -import { FileInfo, FileInfoImpl } from "./fileinfo"; +import { FileInfo, FileInfoImpl } from "./file_info"; /** * Queries the file system for information on the path provided. -- cgit v1.2.3