summaryrefslogtreecommitdiff
path: root/js/stat.ts
diff options
context:
space:
mode:
Diffstat (limited to 'js/stat.ts')
-rw-r--r--js/stat.ts42
1 files changed, 21 insertions, 21 deletions
diff --git a/js/stat.ts b/js/stat.ts
index 4d04ea221..9f99ab441 100644
--- a/js/stat.ts
+++ b/js/stat.ts
@@ -5,6 +5,27 @@ import * as dispatch from "./dispatch";
import { assert } from "./util";
import { FileInfo, FileInfoImpl } from "./file_info";
+function req(
+ filename: string,
+ lstat: boolean
+): [flatbuffers.Builder, msg.Any, flatbuffers.Offset] {
+ const builder = flatbuffers.createBuilder();
+ const filename_ = builder.createString(filename);
+ msg.Stat.startStat(builder);
+ msg.Stat.addFilename(builder, filename_);
+ msg.Stat.addLstat(builder, lstat);
+ const inner = msg.Stat.endStat(builder);
+ return [builder, msg.Any.Stat, inner];
+}
+
+function res(baseRes: null | msg.Base): FileInfo {
+ assert(baseRes != null);
+ assert(msg.Any.StatRes === baseRes!.innerType());
+ const res = new msg.StatRes();
+ assert(baseRes!.inner(res) != null);
+ return new FileInfoImpl(res);
+}
+
/** Queries the file system for information on the path provided. If the given
* path is a symlink information about the symlink will be returned.
*
@@ -45,24 +66,3 @@ export async function stat(filename: string): Promise<FileInfo> {
export function statSync(filename: string): FileInfo {
return res(dispatch.sendSync(...req(filename, false)));
}
-
-function req(
- filename: string,
- lstat: boolean
-): [flatbuffers.Builder, msg.Any, flatbuffers.Offset] {
- const builder = flatbuffers.createBuilder();
- const filename_ = builder.createString(filename);
- msg.Stat.startStat(builder);
- msg.Stat.addFilename(builder, filename_);
- msg.Stat.addLstat(builder, lstat);
- const inner = msg.Stat.endStat(builder);
- return [builder, msg.Any.Stat, inner];
-}
-
-function res(baseRes: null | msg.Base): FileInfo {
- assert(baseRes != null);
- assert(msg.Any.StatRes === baseRes!.innerType());
- const res = new msg.StatRes();
- assert(baseRes!.inner(res) != null);
- return new FileInfoImpl(res);
-}