diff --git a/types/adone/adone.d.ts b/types/adone/adone.d.ts index 91ebc4db7c..d4e8b67b7b 100644 --- a/types/adone/adone.d.ts +++ b/types/adone/adone.d.ts @@ -1,4 +1,6 @@ /// +/// +/// declare namespace adone { const _null: symbol; @@ -104,4 +106,8 @@ declare namespace adone { export const expect: assertion.I.ExpectFunction; export const std: typeof nodestd; + + export const lodash: _.LoDashStatic; + + export const benchmark: typeof tbenchmark; } diff --git a/types/adone/benchmark.d.ts b/types/adone/benchmark.d.ts new file mode 100644 index 0000000000..042e1ae62c --- /dev/null +++ b/types/adone/benchmark.d.ts @@ -0,0 +1,5 @@ +import Benchmark = require("benchmark"); + +export { Benchmark }; + +export as namespace tbenchmark; diff --git a/types/adone/glosses/fs.d.ts b/types/adone/glosses/fs.d.ts index 7517764faf..2afc6ec8f7 100644 --- a/types/adone/glosses/fs.d.ts +++ b/types/adone/glosses/fs.d.ts @@ -1158,37 +1158,35 @@ declare namespace adone { */ function watch(paths: string | string[], options?: I.Watcher.ConstructorOptions): Watcher; - namespace is { - /** - * Returns true if the given path refers to a file - */ - function file(path: string): Promise; + /** + * Returns true if the given path refers to a file + */ + function isFile(path: string): Promise; - /** - * Returns true if the given path refers to a file - */ - function fileSync(path: string): boolean; + /** + * Returns true if the given path refers to a file + */ + function isFileSync(path: string): boolean; - /** - * Returns true if the given path refers to a direcotry - */ - function directory(path: string): Promise; + /** + * Returns true if the given path refers to a direcotry + */ + function isDirectory(path: string): Promise; - /** - * Returns true if the given path refers to a direcotry - */ - function directorySync(path: string): boolean; + /** + * Returns true if the given path refers to a direcotry + */ + function isDirectorySync(path: string): boolean; - /** - * Returns true if the given path refers to an executable file - */ - function executable(path: string): Promise; + /** + * Returns true if the given path refers to an executable file + */ + function isExecutable(path: string): Promise; - /** - * Returns true if the given path refers to an executable file - */ - function executableSync(path: string): boolean; - } + /** + * Returns true if the given path refers to an executable file + */ + function isExecutableSync(path: string): boolean; namespace I.Which { interface Options { @@ -1920,5 +1918,19 @@ declare namespace adone { * Creates a new TailWatcher instance with the given arguments */ function watchTail(filename: string, options?: I.TailWatcher.ConstructorOptions): TailWatcher; + + namespace I { + interface WriteFileAtomicOptions { + chown?: { + gid?: number; + uid?: number; + }; + encoding?: string | null; + fsync?: boolean; + mode?: number; + } + } + + function writeFileAtomic(filename: string, data: Buffer | string | Uint8Array, options?: I.WriteFileAtomicOptions): Promise; } } diff --git a/types/adone/glosses/is.d.ts b/types/adone/glosses/is.d.ts index 20d898ca7b..d112d3f109 100644 --- a/types/adone/glosses/is.d.ts +++ b/types/adone/glosses/is.d.ts @@ -676,5 +676,9 @@ declare namespace adone { export function emitter(obj: any): obj is event.Emitter; export function asyncEmitter(obj: any): obj is event.AsyncEmitter; + + export const openbsd: boolean; + + export const aix: boolean; } } diff --git a/types/adone/test/glosses/fs.ts b/types/adone/test/glosses/fs.ts index e7c5333624..86236038a0 100644 --- a/types/adone/test/glosses/fs.ts +++ b/types/adone/test/glosses/fs.ts @@ -602,13 +602,12 @@ namespace fsTests { } namespace isTests { - const { is } = fs; - is.file("hello").then((x: boolean) => {}); - { const a: boolean = is.fileSync("hello"); } - is.directory("hello").then((x: boolean) => {}); - { const a: boolean = is.directorySync("hello"); } - is.executable("hello").then((x: boolean) => {}); - { const a: boolean = is.executableSync("hello"); } + fs.isFile("hello").then((x: boolean) => {}); + { const a: boolean = fs.isFileSync("hello"); } + fs.isDirectory("hello").then((x: boolean) => {}); + { const a: boolean = fs.isDirectorySync("hello"); } + fs.isExecutable("hello").then((x: boolean) => {}); + { const a: boolean = fs.isExecutableSync("hello"); } } namespace whichTests { @@ -944,4 +943,17 @@ namespace fsTests { fs.watchTail("file", { separator: /\n/ }); fs.watchTail("file", { useWatchFile: true }); } + + namespace writeFileAtomicTests { + fs.writeFileAtomic("a", "b").then(() => {}); + fs.writeFileAtomic("a", Buffer.from("b")).then(() => {}); + fs.writeFileAtomic("a", new Uint8Array(10)).then(() => {}); + fs.writeFileAtomic("a", "a", {}).then(() => {}); + fs.writeFileAtomic("a", "a", { chown: {} }).then(() => {}); + fs.writeFileAtomic("a", "a", { chown: { gid: 0 } }).then(() => {}); + fs.writeFileAtomic("a", "a", { chown: { uid: 0 } }).then(() => {}); + fs.writeFileAtomic("a", "a", { encoding: "utf8" }).then(() => {}); + fs.writeFileAtomic("a", "a", { fsync: false }).then(() => {}); + fs.writeFileAtomic("a", "a", { mode: 0o666 }).then(() => {}); + } } diff --git a/types/adone/test/glosses/is.ts b/types/adone/test/glosses/is.ts index 045818f0ec..455dd745da 100644 --- a/types/adone/test/glosses/is.ts +++ b/types/adone/test/glosses/is.ts @@ -336,6 +336,8 @@ namespace isTests { { const a: boolean = is.freebsd; } { const a: boolean = is.darwin; } { const a: boolean = is.sunos; } + { const a: boolean = is.openbsd; } + { const a: boolean = is.aix; } { const a: boolean = is.uppercase("abc"); } { const a: boolean = is.lowercase("abc"); } { const a: boolean = is.digits("012"); } diff --git a/types/adone/test/index.ts b/types/adone/test/index.ts index ac012b9535..aec454539b 100644 --- a/types/adone/test/index.ts +++ b/types/adone/test/index.ts @@ -54,4 +54,15 @@ namespace AdoneRootTests { obj = adone.package; { const a: typeof adone.assertion.assert = adone.assert; } { const a: typeof adone.assertion.expect = adone.expect; } + + namespace lodashTests { + adone.lodash.get({}, "a"); + adone.lodash.defaults({}, {}); + adone.lodash.zip([]); + } + + namespace benchmarkTests { + const b = new adone.benchmark.Benchmark.Suite(); + b.add(() => {}).add("", () => {}).run(); + } } diff --git a/types/adone/tsconfig.json b/types/adone/tsconfig.json index 6e6b3fe1c3..6a1af264a3 100644 --- a/types/adone/tsconfig.json +++ b/types/adone/tsconfig.json @@ -22,6 +22,7 @@ "files": [ "adone-tests.ts", "adone.d.ts", + "benchmark.d.ts", "glosses/archives.d.ts", "glosses/assertion.d.ts", "glosses/collections/array_set.d.ts",