From 732f67b1e58f25708e4f10a481ac81d6d6cfb5ae Mon Sep 17 00:00:00 2001 From: s0m3on3 Date: Sat, 17 Feb 2018 20:40:18 +0200 Subject: [PATCH 1/5] [adone] refactoring * [collection.Queue] add static "from" method * add pretty namespace * [text] move pretty.table, pretty.json to pretty * [util] move humanizeTime, humanizeSize to pretty --- types/adone/glosses/collections/queue.d.ts | 2 + types/adone/glosses/pretty/index.d.ts | 10 + types/adone/glosses/pretty/json.d.ts | 16 ++ types/adone/glosses/pretty/size.d.ts | 3 + types/adone/glosses/pretty/table.d.ts | 38 ++++ types/adone/glosses/pretty/time.d.ts | 11 + types/adone/glosses/text/index.d.ts | 1 - types/adone/glosses/text/pretties.d.ts | 55 ----- types/adone/glosses/utils.d.ts | 11 - types/adone/index.d.ts | 1 + types/adone/test/glosses/collections/queue.ts | 11 + types/adone/test/glosses/pretty/json.ts | 19 ++ types/adone/test/glosses/pretty/size.ts | 12 ++ types/adone/test/glosses/pretty/table.ts | 177 +++++++++++++++ types/adone/test/glosses/pretty/time.ts | 14 ++ types/adone/test/glosses/text/pretties.ts | 203 ------------------ types/adone/test/glosses/utils.ts | 14 -- types/adone/tsconfig.json | 13 +- 18 files changed, 324 insertions(+), 287 deletions(-) create mode 100644 types/adone/glosses/pretty/index.d.ts create mode 100644 types/adone/glosses/pretty/json.d.ts create mode 100644 types/adone/glosses/pretty/size.d.ts create mode 100644 types/adone/glosses/pretty/table.d.ts create mode 100644 types/adone/glosses/pretty/time.d.ts delete mode 100644 types/adone/glosses/text/pretties.d.ts create mode 100644 types/adone/test/glosses/pretty/json.ts create mode 100644 types/adone/test/glosses/pretty/size.ts create mode 100644 types/adone/test/glosses/pretty/table.ts create mode 100644 types/adone/test/glosses/pretty/time.ts delete mode 100644 types/adone/test/glosses/text/pretties.ts diff --git a/types/adone/glosses/collections/queue.d.ts b/types/adone/glosses/collections/queue.d.ts index e67eb8fda9..8a0832a7e6 100644 --- a/types/adone/glosses/collections/queue.d.ts +++ b/types/adone/glosses/collections/queue.d.ts @@ -27,5 +27,7 @@ declare namespace adone.collection { * Removes and returns an element from the beginning */ pop(): T | undefined; + + static from(iterable: Iterable, length?: number): Queue; } } diff --git a/types/adone/glosses/pretty/index.d.ts b/types/adone/glosses/pretty/index.d.ts new file mode 100644 index 0000000000..ca2bc125f6 --- /dev/null +++ b/types/adone/glosses/pretty/index.d.ts @@ -0,0 +1,10 @@ +/// +/// +/// +/// + +declare namespace adone { + namespace pretty { + // + } +} diff --git a/types/adone/glosses/pretty/json.d.ts b/types/adone/glosses/pretty/json.d.ts new file mode 100644 index 0000000000..0c86d4fa49 --- /dev/null +++ b/types/adone/glosses/pretty/json.d.ts @@ -0,0 +1,16 @@ +declare namespace adone.pretty { + namespace I { + interface JSONOptions { + emptyArrayMsg?: string; + keysColor?: string; + dashColor?: string; + numberColor?: string; + stringColor?: string; + defaultIndentation?: number; + noColor?: boolean; + noAlign?: boolean; + } + } + + function json(data: any, options?: I.JSONOptions, indentation?: number): string; +} diff --git a/types/adone/glosses/pretty/size.d.ts b/types/adone/glosses/pretty/size.d.ts new file mode 100644 index 0000000000..2ff1c1c4b5 --- /dev/null +++ b/types/adone/glosses/pretty/size.d.ts @@ -0,0 +1,3 @@ +declare namespace adone.pretty { + function size(num: number, space?: string): string; +} diff --git a/types/adone/glosses/pretty/table.d.ts b/types/adone/glosses/pretty/table.d.ts new file mode 100644 index 0000000000..b71ce18d2c --- /dev/null +++ b/types/adone/glosses/pretty/table.d.ts @@ -0,0 +1,38 @@ +declare namespace adone.pretty { + namespace I { + interface TableColumn { + id: string; + header?: string; + align?: "right" | "center" | "left"; + width?: string | number; + maxWidth?: number | string; + wordwrap?: "soft" | "hard" | adone.text.I.WordWrapOptions; + handle?: (item: object) => string; + format?: string | ((val: any, item: object) => string); + style?: string | ((val: any, str: string) => string); + } + + type TableModel = TableColumn[]; + + interface TableStyle { + "padding-left"?: number; + "padding-right"?: number; + head?: string[]; + broder?: string[]; + compact?: boolean; + } + + interface TableOptions { + model: TableModel; + noHeader?: boolean; + borderless?: boolean; + style?: TableStyle; + width?: number | string; + countAnsiEscapeCodes?: boolean; + } + + type TableData = Array<{ [id: string]: any }>; + } + + function table(data: I.TableData, options: I.TableOptions): string; +} diff --git a/types/adone/glosses/pretty/time.d.ts b/types/adone/glosses/pretty/time.d.ts new file mode 100644 index 0000000000..3732c16640 --- /dev/null +++ b/types/adone/glosses/pretty/time.d.ts @@ -0,0 +1,11 @@ +declare namespace adone.pretty { + namespace I { + interface TimeOptions { + msDecimalDigits?: number; + secDecimalDigits?: number; + verbose?: boolean; + compact?: boolean; + } + } + function time(ms: number, options?: I.TimeOptions): string; +} diff --git a/types/adone/glosses/text/index.d.ts b/types/adone/glosses/text/index.d.ts index a640789765..57b0fb1867 100644 --- a/types/adone/glosses/text/index.d.ts +++ b/types/adone/glosses/text/index.d.ts @@ -1,4 +1,3 @@ -/// /// /// /// diff --git a/types/adone/glosses/text/pretties.d.ts b/types/adone/glosses/text/pretties.d.ts deleted file mode 100644 index 886901b268..0000000000 --- a/types/adone/glosses/text/pretties.d.ts +++ /dev/null @@ -1,55 +0,0 @@ -declare namespace adone.text { - namespace pretty { - namespace I { - interface JSONOptions { - emptyArrayMsg?: string; - keysColor?: string; - dashColor?: string; - numberColor?: string; - stringColor?: string; - defaultIndentation?: number; - noColor?: boolean; - noAlign?: boolean; - } - } - - function json(data: any, options?: I.JSONOptions, indentation?: number): string; - - namespace I { - interface TableColumn { - id: string; - header?: string; - align?: "right" | "center" | "left"; - width?: string | number; - maxWidth?: number | string; - wordwrap?: "soft" | "hard" | adone.text.I.WordWrapOptions; - handle?: (item: object) => string; - format?: string | ((val: any, item: object) => string); - style?: string | ((val: any, str: string) => string); - } - - type TableModel = TableColumn[]; - - interface TableStyle { - "padding-left"?: number; - "padding-right"?: number; - head?: string[]; - broder?: string[]; - compact?: boolean; - } - - interface TableOptions { - model: TableModel; - noHeader?: boolean; - borderless?: boolean; - style?: TableStyle; - width?: number | string; - countAnsiEscapeCodes?: boolean; - } - - type TableData = Array<{ [id: string]: any }>; - } - - function table(data: I.TableData, options: I.TableOptions): string; - } -} diff --git a/types/adone/glosses/utils.d.ts b/types/adone/glosses/utils.d.ts index d84dce79c9..d1a0aa49bc 100644 --- a/types/adone/glosses/utils.d.ts +++ b/types/adone/glosses/utils.d.ts @@ -86,17 +86,6 @@ declare namespace adone { function invertObject(source: object, options?: I.KeysOptions): object; - namespace I { - interface HumanizeTimeOptions { - msDecimalDigits?: number; - secDecimalDigits?: number; - verbose?: boolean; - compact?: boolean; - } - } - function humanizeTime(ms: number, options?: I.HumanizeTimeOptions): string; - function humanizeSize(num: number, space?: string): string; - function parseSize(str: string | number): number | null; namespace I { diff --git a/types/adone/index.d.ts b/types/adone/index.d.ts index abcf5165c2..ea3b208438 100644 --- a/types/adone/index.d.ts +++ b/types/adone/index.d.ts @@ -22,6 +22,7 @@ /// /// /// +/// /// /// /// diff --git a/types/adone/test/glosses/collections/queue.ts b/types/adone/test/glosses/collections/queue.ts index fd6df7f39b..2aefee9716 100644 --- a/types/adone/test/glosses/collections/queue.ts +++ b/types/adone/test/glosses/collections/queue.ts @@ -14,4 +14,15 @@ namespace adoneTests.collection.Queue { { const a: boolean = new Queue().full; } { const a: number = new Queue().length; } { const a: boolean = new Queue().empty; } + + { + const q = Queue.from([1, 2, 3]); + const a: number | undefined = q.pop(); + } + { + const q = Queue.from((function*() { + yield 42; + })()); + const a: number | undefined = q.pop(); + } } diff --git a/types/adone/test/glosses/pretty/json.ts b/types/adone/test/glosses/pretty/json.ts new file mode 100644 index 0000000000..730447baba --- /dev/null +++ b/types/adone/test/glosses/pretty/json.ts @@ -0,0 +1,19 @@ +namespace adoneTests.pretty.json { + const { + json + } = adone.pretty; + + let str: string; + + str = json({}); + str = json({}, {}); + str = json({}, {}, 1); + str = json({}, { dashColor: "green" }); + str = json({}, { defaultIndentation: 10 }); + str = json({}, { emptyArrayMsg: "asdas" }); + str = json({}, { keysColor: "green" }); + str = json({}, { noAlign: true }); + str = json({}, { noColor: true }); + str = json({}, { numberColor: "green" }); + str = json({}, { stringColor: "green" }); +} diff --git a/types/adone/test/glosses/pretty/size.ts b/types/adone/test/glosses/pretty/size.ts new file mode 100644 index 0000000000..1ed5e904fe --- /dev/null +++ b/types/adone/test/glosses/pretty/size.ts @@ -0,0 +1,12 @@ +namespace adoneTests.pretty.size { + const { + pretty: { + size + } + } = adone; + + let str: string; + + str = size(12345); + str = size(12345, ""); +} diff --git a/types/adone/test/glosses/pretty/table.ts b/types/adone/test/glosses/pretty/table.ts new file mode 100644 index 0000000000..0ed4099bbc --- /dev/null +++ b/types/adone/test/glosses/pretty/table.ts @@ -0,0 +1,177 @@ +namespace adoneTests.pretty.table { + const { + table + } = adone.pretty; + + let str: string; + + str = table([], { + model: [] + }); + str = table([], { + borderless: true, + model: [] + }); + str = table([], { + countAnsiEscapeCodes: true, + model: [] + }); + str = table([], { + noHeader: true, + model: [] + }); + str = table([], { + style: { + "padding-left": 1 + }, + model: [] + }); + str = table([], { + style: { + "padding-right": 1 + }, + model: [] + }); + str = table([], { + style: { + broder: ["a"] + }, + model: [] + }); + str = table([], { + style: { + compact: true + }, + model: [] + }); + str = table([], { + style: { + head: ["a"] + }, + model: [] + }); + str = table([], { + width: 100, + model: [] + }); + str = table([], { + width: "100%", + model: [] + }); + str = table([], { + model: [{ + id: "ads", + align: "center" + }] + }); + str = table([], { + model: [{ + id: "ads", + format: "%s" + }] + }); + str = table([], { + model: [{ + id: "ads", + format(val: any, item: object) { + return "2"; + } + }] + }); + str = table([], { + model: [{ + id: "ads", + handle(item: object) { + return "a"; + } + }] + }); + str = table([], { + model: [{ + id: "ads", + header: "he" + }] + }); + str = table([], { + model: [{ + id: "ads", + maxWidth: "100%" + }] + }); + str = table([], { + model: [{ + id: "ads", + maxWidth: 100 + }] + }); + str = table([], { + model: [{ + id: "ads", + style: "asd" + }] + }); + str = table([], { + model: [{ + id: "ads", + style(val: any, str: string) { + return "1"; + } + }] + }); + str = table([], { + model: [{ + id: "ads", + width: 100 + }] + }); + str = table([], { + model: [{ + id: "ads", + width: "100%" + }] + }); + str = table([], { + model: [{ + id: "ads", + wordwrap: "soft" + }] + }); + str = table([], { + model: [{ + id: "ads", + wordwrap: "hard" + }] + }); + str = table([], { + model: [{ + id: "ads", + wordwrap: { + countAnsiEscapeCodes: true + } + }] + }); + str = table([], { + model: [{ + id: "ads", + wordwrap: { + join: true + } + }] + }); + str = table([], { + model: [{ + id: "ads", + wordwrap: { + mode: "soft" + } + }] + }); + str = table([], { + model: [{ + id: "ads", + wordwrap: { + mode: "hard" + } + }] + }); +} diff --git a/types/adone/test/glosses/pretty/time.ts b/types/adone/test/glosses/pretty/time.ts new file mode 100644 index 0000000000..79d1e6325f --- /dev/null +++ b/types/adone/test/glosses/pretty/time.ts @@ -0,0 +1,14 @@ +namespace adoneTests.pretty.time { + const { + time + } = adone.pretty; + + let str: string; + + str = time(12345); + str = time(12345, {}); + str = time(12345, { compact: true }); + str = time(12345, { msDecimalDigits: 2 }); + str = time(12345, { secDecimalDigits: 2 }); + str = time(12345, { verbose: true }); +} diff --git a/types/adone/test/glosses/text/pretties.ts b/types/adone/test/glosses/text/pretties.ts deleted file mode 100644 index 3061275cdd..0000000000 --- a/types/adone/test/glosses/text/pretties.ts +++ /dev/null @@ -1,203 +0,0 @@ -namespace adoneTests.text.pretty { - const { - text: { - pretty - } - } = adone; - - let str: string; - - namespace json { - const { - json - } = pretty; - - str = json({}); - str = json({}, {}); - str = json({}, {}, 1); - str = json({}, { dashColor: "green" }); - str = json({}, { defaultIndentation: 10 }); - str = json({}, { emptyArrayMsg: "asdas" }); - str = json({}, { keysColor: "green" }); - str = json({}, { noAlign: true }); - str = json({}, { noColor: true }); - str = json({}, { numberColor: "green" }); - str = json({}, { stringColor: "green" }); - } - - namespace table { - const { - table - } = pretty; - - str = table([], { - model: [] - }); - str = table([], { - borderless: true, - model: [] - }); - str = table([], { - countAnsiEscapeCodes: true, - model: [] - }); - str = table([], { - noHeader: true, - model: [] - }); - str = table([], { - style: { - "padding-left": 1 - }, - model: [] - }); - str = table([], { - style: { - "padding-right": 1 - }, - model: [] - }); - str = table([], { - style: { - broder: ["a"] - }, - model: [] - }); - str = table([], { - style: { - compact: true - }, - model: [] - }); - str = table([], { - style: { - head: ["a"] - }, - model: [] - }); - str = table([], { - width: 100, - model: [] - }); - str = table([], { - width: "100%", - model: [] - }); - str = table([], { - model: [{ - id: "ads", - align: "center" - }] - }); - str = table([], { - model: [{ - id: "ads", - format: "%s" - }] - }); - str = table([], { - model: [{ - id: "ads", - format(val: any, item: object) { - return "2"; - } - }] - }); - str = table([], { - model: [{ - id: "ads", - handle(item: object) { - return "a"; - } - }] - }); - str = table([], { - model: [{ - id: "ads", - header: "he" - }] - }); - str = table([], { - model: [{ - id: "ads", - maxWidth: "100%" - }] - }); - str = table([], { - model: [{ - id: "ads", - maxWidth: 100 - }] - }); - str = table([], { - model: [{ - id: "ads", - style: "asd" - }] - }); - str = table([], { - model: [{ - id: "ads", - style(val: any, str: string) { - return "1"; - } - }] - }); - str = table([], { - model: [{ - id: "ads", - width: 100 - }] - }); - str = table([], { - model: [{ - id: "ads", - width: "100%" - }] - }); - str = table([], { - model: [{ - id: "ads", - wordwrap: "soft" - }] - }); - str = table([], { - model: [{ - id: "ads", - wordwrap: "hard" - }] - }); - str = table([], { - model: [{ - id: "ads", - wordwrap: { - countAnsiEscapeCodes: true - } - }] - }); - str = table([], { - model: [{ - id: "ads", - wordwrap: { - join: true - } - }] - }); - str = table([], { - model: [{ - id: "ads", - wordwrap: { - mode: "soft" - } - }] - }); - str = table([], { - model: [{ - id: "ads", - wordwrap: { - mode: "hard" - } - }] - }); - } -} diff --git a/types/adone/test/glosses/utils.ts b/types/adone/test/glosses/utils.ts index 656e000f8b..f0b789c78b 100644 --- a/types/adone/test/glosses/utils.ts +++ b/types/adone/test/glosses/utils.ts @@ -195,20 +195,6 @@ namespace utilTests { const e: object = util.invertObject({}, { onlyEnumerable: true }); } - namespace humanizeTime { - const a: string = util.humanizeTime(12345); - const b: string = util.humanizeTime(12345, {}); - const c: string = util.humanizeTime(12345, { compact: true }); - const d: string = util.humanizeTime(12345, { msDecimalDigits: 2 }); - const e: string = util.humanizeTime(12345, { secDecimalDigits: 2 }); - const f: string = util.humanizeTime(12345, { verbose: true }); - } - - namespace humanizeSize { - const a: string = util.humanizeSize(12345); - const b: string = util.humanizeSize(12345, ""); - } - namespace parseSize { const a: number | null = util.parseSize(123); const b: number | null = util.parseSize("123Kb"); diff --git a/types/adone/tsconfig.json b/types/adone/tsconfig.json index 66671bc175..18f90a5ae9 100644 --- a/types/adone/tsconfig.json +++ b/types/adone/tsconfig.json @@ -16,7 +16,8 @@ "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true, - "experimentalDecorators": true + "experimentalDecorators": true, + "esModuleInterop": true }, "files": [ "adone-tests.ts", @@ -63,6 +64,10 @@ "glosses/net/http/client.d.ts", "glosses/net/http/index.d.ts", "glosses/net/index.d.ts", + "glosses/pretty/json.d.ts", + "glosses/pretty/size.d.ts", + "glosses/pretty/table.d.ts", + "glosses/pretty/time.d.ts", "glosses/promise.d.ts", "glosses/regex.d.ts", "glosses/semver.d.ts", @@ -78,7 +83,6 @@ "glosses/templating/index.d.ts", "glosses/templating/nunjucks.d.ts", "glosses/text/index.d.ts", - "glosses/text/pretties.d.ts", "glosses/text/spinners.d.ts", "glosses/text/table.d.ts", "glosses/text/unicode.d.ts", @@ -123,6 +127,10 @@ "test/glosses/math/simd.ts", "test/glosses/meta.ts", "test/glosses/net/http/client.ts", + "test/glosses/pretty/json.ts", + "test/glosses/pretty/size.ts", + "test/glosses/pretty/table.ts", + "test/glosses/pretty/time.ts", "test/glosses/promise.ts", "test/glosses/regex.ts", "test/glosses/semver.ts", @@ -136,7 +144,6 @@ "test/glosses/templating/dot.ts", "test/glosses/templating/nunjucks.ts", "test/glosses/text/index.ts", - "test/glosses/text/pretties.ts", "test/glosses/text/spinners.ts", "test/glosses/text/table.ts", "test/glosses/text/unicode.ts", From f9314de6349e5d42470355495557f0eb02781be0 Mon Sep 17 00:00:00 2001 From: s0m3on3 Date: Wed, 21 Feb 2018 01:00:35 +0200 Subject: [PATCH 2/5] [adone] refactoring * adone.exception -> adone.error * adone.fatal -> adone.logFatal * adone.error -> adone.logError * adone.warn -> adone.logWarn * adone.info -> adone.logInfo * adone.debug -> adone.logDebug * adone.trace -> adone.logTrace --- types/adone/adone.d.ts | 12 +++---- types/adone/glosses/assertion.d.ts | 2 +- types/adone/glosses/data.d.ts | 2 +- .../glosses/{exceptions.d.ts => errors.d.ts} | 2 +- types/adone/index.d.ts | 2 +- types/adone/test/glosses/assertion.ts | 6 ++-- types/adone/test/glosses/errors.ts | 36 +++++++++++++++++++ types/adone/test/glosses/exceptions.ts | 36 ------------------- types/adone/test/index.ts | 12 +++---- types/adone/tsconfig.json | 4 +-- 10 files changed, 57 insertions(+), 57 deletions(-) rename types/adone/glosses/{exceptions.d.ts => errors.d.ts} (98%) create mode 100644 types/adone/test/glosses/errors.ts delete mode 100644 types/adone/test/glosses/exceptions.ts diff --git a/types/adone/adone.d.ts b/types/adone/adone.d.ts index 0d6e3255ee..f1f5cbf694 100644 --- a/types/adone/adone.d.ts +++ b/types/adone/adone.d.ts @@ -11,12 +11,12 @@ declare namespace adone { export const bad: "BAD"; export const exts: [".js", ".tjs", ".ajs"]; export function log(...args: any[]): void; - export function fatal(...args: any[]): void; - export function error(...args: any[]): void; - export function warn(...args: any[]): void; - export function info(...args: any[]): void; - export function debug(...args: any[]): void; - export function trace(...args: any[]): void; + export function logFatal(...args: any[]): void; + export function logError(...args: any[]): void; + export function logWarn(...args: any[]): void; + export function logInfo(...args: any[]): void; + export function logDebug(...args: any[]): void; + export function logTrace(...args: any[]): void; export function o(...props: any[]): object; export const Date: typeof global.Date; export const hrtime: typeof global.process.hrtime; diff --git a/types/adone/glosses/assertion.d.ts b/types/adone/glosses/assertion.d.ts index ca0d75bdf5..f0cf377a21 100644 --- a/types/adone/glosses/assertion.d.ts +++ b/types/adone/glosses/assertion.d.ts @@ -1019,7 +1019,7 @@ declare namespace adone { } } - class AssertionError extends exception.Exception { + class AssertionError extends error.Exception { constructor(message?: string, props?: object, ssf?: object) } diff --git a/types/adone/glosses/data.d.ts b/types/adone/glosses/data.d.ts index 4d3dae7b2b..3a979cae98 100644 --- a/types/adone/glosses/data.d.ts +++ b/types/adone/glosses/data.d.ts @@ -582,7 +582,7 @@ declare namespace adone { /** * Represents a YAML exception */ - class Exception extends adone.exception.Exception { + class Exception extends adone.error.Exception { reason: string; mark: Mark; diff --git a/types/adone/glosses/exceptions.d.ts b/types/adone/glosses/errors.d.ts similarity index 98% rename from types/adone/glosses/exceptions.d.ts rename to types/adone/glosses/errors.d.ts index 1b1981f80e..c3d9e1f632 100644 --- a/types/adone/glosses/exceptions.d.ts +++ b/types/adone/glosses/errors.d.ts @@ -1,5 +1,5 @@ declare namespace adone { - namespace exception { + namespace error { class Exception extends Error { constructor(message?: string | Error, captureStackTrace?: boolean); } diff --git a/types/adone/index.d.ts b/types/adone/index.d.ts index ea3b208438..e0ddfec26b 100644 --- a/types/adone/index.d.ts +++ b/types/adone/index.d.ts @@ -14,7 +14,7 @@ /// /// /// -/// +/// /// /// /// diff --git a/types/adone/test/glosses/assertion.ts b/types/adone/test/glosses/assertion.ts index 3e457dc876..292cfa190c 100644 --- a/types/adone/test/glosses/assertion.ts +++ b/types/adone/test/glosses/assertion.ts @@ -3,9 +3,9 @@ namespace assertionTests { namespace assertionInterface { namespace exception { - const a: adone.exception.Exception = new assertion.AssertionError(); - const b: adone.exception.Exception = new assertion.AssertionError("hello"); - const c: adone.exception.Exception = new assertion.AssertionError("hello", { actual: 2, expected: 3 }, () => {}); + const a: adone.error.Exception = new assertion.AssertionError(); + const b: adone.error.Exception = new assertion.AssertionError("hello"); + const c: adone.error.Exception = new assertion.AssertionError("hello", { actual: 2, expected: 3 }, () => {}); } namespace config { diff --git a/types/adone/test/glosses/errors.ts b/types/adone/test/glosses/errors.ts new file mode 100644 index 0000000000..d84a267b07 --- /dev/null +++ b/types/adone/test/glosses/errors.ts @@ -0,0 +1,36 @@ +namespace ErrorsTests { + { const a: Error = new adone.error.Exception(); } + { const a: Error = new adone.error.Exception("message"); } + { const a: Error = new adone.error.Exception(new Error()); } + { const a: Error = new adone.error.Exception(new Error(), true); } + { const a: adone.error.Exception = new adone.error.Runtime(); } + { const a: adone.error.Exception = new adone.error.IncompleteBufferError(); } + { const a: adone.error.Exception = new adone.error.NotImplemented(); } + { const a: adone.error.Exception = new adone.error.IllegalState(); } + { const a: adone.error.Exception = new adone.error.NotValid(); } + { const a: adone.error.Exception = new adone.error.Unknown(); } + { const a: adone.error.Exception = new adone.error.NotExists(); } + { const a: adone.error.Exception = new adone.error.Exists(); } + { const a: adone.error.Exception = new adone.error.Empty(); } + { const a: adone.error.Exception = new adone.error.InvalidAccess(); } + { const a: adone.error.Exception = new adone.error.NotSupported(); } + { const a: adone.error.Exception = new adone.error.InvalidArgument(); } + { const a: adone.error.Exception = new adone.error.InvalidNumberOfArguments(); } + { const a: adone.error.Exception = new adone.error.NotFound(); } + { const a: adone.error.Exception = new adone.error.Timeout(); } + { const a: adone.error.Exception = new adone.error.Incorrect(); } + { const a: adone.error.Exception = new adone.error.NotAllowed(); } + { const a: adone.error.Exception = new adone.error.LimitExceeded(); } + { const a: adone.error.Exception = new adone.error.Encoding(); } + { const a: adone.error.Exception = new adone.error.Network(); } + { const a: adone.error.Exception = new adone.error.Bind(); } + { const a: adone.error.Exception = new adone.error.Connect(); } + { const a: adone.error.Exception = new adone.error.Database(); } + { const a: adone.error.Exception = new adone.error.DatabaseInitialization(); } + { const a: adone.error.Exception = new adone.error.DatabaseOpen(); } + { const a: adone.error.Exception = new adone.error.DatabaseRead(); } + { const a: adone.error.Exception = new adone.error.DatabaseWrite(); } + { const a: adone.error.Exception = new adone.error.NetronIllegalState(); } + { const a: adone.error.Exception = new adone.error.NetronPeerDisconnected(); } + { const a: adone.error.Exception = new adone.error.NetronTimeout(); } +} diff --git a/types/adone/test/glosses/exceptions.ts b/types/adone/test/glosses/exceptions.ts deleted file mode 100644 index d9694990d0..0000000000 --- a/types/adone/test/glosses/exceptions.ts +++ /dev/null @@ -1,36 +0,0 @@ -namespace ExcetpionsTests { - { const a: Error = new adone.exception.Exception(); } - { const a: Error = new adone.exception.Exception("message"); } - { const a: Error = new adone.exception.Exception(new Error()); } - { const a: Error = new adone.exception.Exception(new Error(), true); } - { const a: adone.exception.Exception = new adone.exception.Runtime(); } - { const a: adone.exception.Exception = new adone.exception.IncompleteBufferError(); } - { const a: adone.exception.Exception = new adone.exception.NotImplemented(); } - { const a: adone.exception.Exception = new adone.exception.IllegalState(); } - { const a: adone.exception.Exception = new adone.exception.NotValid(); } - { const a: adone.exception.Exception = new adone.exception.Unknown(); } - { const a: adone.exception.Exception = new adone.exception.NotExists(); } - { const a: adone.exception.Exception = new adone.exception.Exists(); } - { const a: adone.exception.Exception = new adone.exception.Empty(); } - { const a: adone.exception.Exception = new adone.exception.InvalidAccess(); } - { const a: adone.exception.Exception = new adone.exception.NotSupported(); } - { const a: adone.exception.Exception = new adone.exception.InvalidArgument(); } - { const a: adone.exception.Exception = new adone.exception.InvalidNumberOfArguments(); } - { const a: adone.exception.Exception = new adone.exception.NotFound(); } - { const a: adone.exception.Exception = new adone.exception.Timeout(); } - { const a: adone.exception.Exception = new adone.exception.Incorrect(); } - { const a: adone.exception.Exception = new adone.exception.NotAllowed(); } - { const a: adone.exception.Exception = new adone.exception.LimitExceeded(); } - { const a: adone.exception.Exception = new adone.exception.Encoding(); } - { const a: adone.exception.Exception = new adone.exception.Network(); } - { const a: adone.exception.Exception = new adone.exception.Bind(); } - { const a: adone.exception.Exception = new adone.exception.Connect(); } - { const a: adone.exception.Exception = new adone.exception.Database(); } - { const a: adone.exception.Exception = new adone.exception.DatabaseInitialization(); } - { const a: adone.exception.Exception = new adone.exception.DatabaseOpen(); } - { const a: adone.exception.Exception = new adone.exception.DatabaseRead(); } - { const a: adone.exception.Exception = new adone.exception.DatabaseWrite(); } - { const a: adone.exception.Exception = new adone.exception.NetronIllegalState(); } - { const a: adone.exception.Exception = new adone.exception.NetronPeerDisconnected(); } - { const a: adone.exception.Exception = new adone.exception.NetronTimeout(); } -} diff --git a/types/adone/test/index.ts b/types/adone/test/index.ts index a9de1ab34b..efb8fc8fd7 100644 --- a/types/adone/test/index.ts +++ b/types/adone/test/index.ts @@ -10,12 +10,12 @@ namespace AdoneRootTests { { const a: string = adone.bad; } { const a: string[] = adone.exts; } adone.log(); - adone.fatal(); - adone.error(); - adone.warn(); - adone.info(); - adone.debug(); - adone.trace(); + adone.logFatal(); + adone.logError(); + adone.logWarn(); + adone.logInfo(); + adone.logDebug(); + adone.logTrace(); { const a: object = adone.o(); } { const a: object = adone.o({}); } { const a: typeof Date = adone.Date; } diff --git a/types/adone/tsconfig.json b/types/adone/tsconfig.json index 18f90a5ae9..729fb82734 100644 --- a/types/adone/tsconfig.json +++ b/types/adone/tsconfig.json @@ -52,7 +52,7 @@ "glosses/data.d.ts", "glosses/datetime.d.ts", "glosses/events.d.ts", - "glosses/exceptions.d.ts", + "glosses/errors.d.ts", "glosses/fake.d.ts", "glosses/fast.d.ts", "glosses/fs.d.ts", @@ -117,7 +117,7 @@ "test/glosses/data.ts", "test/glosses/datetime.ts", "test/glosses/events.ts", - "test/glosses/exceptions.ts", + "test/glosses/errors.ts", "test/glosses/fake.ts", "test/glosses/fast.ts", "test/glosses/fs.ts", From 746a790616ca4c7afb64137f0736cac995fa93f9 Mon Sep 17 00:00:00 2001 From: s0m3on3 Date: Sat, 24 Feb 2018 23:25:13 +0200 Subject: [PATCH 3/5] [adone] main namespace fixes --- types/adone/adone.d.ts | 40 ++++------------------- types/adone/test/index.ts | 67 +++++++++++++++------------------------ 2 files changed, 32 insertions(+), 75 deletions(-) diff --git a/types/adone/adone.d.ts b/types/adone/adone.d.ts index f1f5cbf694..91ebc4db7c 100644 --- a/types/adone/adone.d.ts +++ b/types/adone/adone.d.ts @@ -7,9 +7,8 @@ declare namespace adone { export function identity(x: T): T; export function truly(): true; export function falsely(): false; - export const ok: "OK"; - export const bad: "BAD"; - export const exts: [".js", ".tjs", ".ajs"]; + export const ok: "ok"; + export const bad: "bad"; export function log(...args: any[]): void; export function logFatal(...args: any[]): void; export function logError(...args: any[]): void; @@ -76,35 +75,9 @@ declare namespace adone { set(Class: object, tag: string): void; has(obj: object, tag: string): boolean; define(tag: string, predicate?: string): void; - SUBSYSTEM: symbol; - APPLICATION: symbol; - TRANSFORM: symbol; - CORE_STREAM: symbol; - LOGGER: symbol; - LONG: symbol; - BIGNUMBER: symbol; - EXBUFFER: symbol; - EXDATE: symbol; - CONFIGURATION: symbol; - GENESIS_NETRON: symbol; - GENESIS_PEER: symbol; - NETRON: symbol; - NETRON_PEER: symbol; - NETRON_ADAPTER: symbol; - NETRON_DEFINITION: symbol; - NETRON_DEFINITIONS: symbol; - NETRON_REFERENCE: symbol; - NETRON_INTERFACE: symbol; - NETRON_STUB: symbol; - NETRON_REMOTESTUB: symbol; - NETRON_STREAM: symbol; - FAST_STREAM: symbol; - FAST_FS_STREAM: symbol; - FAST_FS_MAP_STREAM: symbol; } } export const tag: I.Tag; - export function bind(libName: string): object; export function getAssetAbsolutePath(relPath: string): string; export function loadAsset(relPath: string): string | Buffer; export function require(path: string): object; @@ -122,11 +95,10 @@ declare namespace adone { export const runtime: I.Runtime; - export const homePath: string; - export const rootPath: string; - export const etcPath: string; - export const config: object; - export const emptyBuffer: Buffer; + export const ROOT_PATH: string; + export const ETC_PATH: string; + export const configuration: object; + export const EMPTY_BUFFER: Buffer; export const assert: assertion.I.AssertFunction; export const expect: assertion.I.ExpectFunction; diff --git a/types/adone/test/index.ts b/types/adone/test/index.ts index efb8fc8fd7..ac012b9535 100644 --- a/types/adone/test/index.ts +++ b/types/adone/test/index.ts @@ -1,14 +1,23 @@ namespace AdoneRootTests { - { const a: symbol = adone.null; } + let num: number; + let sym: symbol; + let str: string; + let numarr: number[]; + let obj: object; + let bool: boolean; + + sym = adone.null; adone.noop(); - { const a: number = adone.identity(2); } - { const a: string = adone.identity("2"); } - { const a: number[] = adone.identity([1, 2]); } - { adone.truly() === true; } - { adone.falsely() === false; } - { const a: string = adone.ok; } - { const a: string = adone.bad; } - { const a: string[] = adone.exts; } + + num = adone.identity(2); + str = adone.identity("3"); + numarr = adone.identity([1, 2]); + + adone.truly() === true; + adone.falsely() === false; + + str = adone.ok; + str = adone.bad; adone.log(); adone.logFatal(); adone.logError(); @@ -16,8 +25,8 @@ namespace AdoneRootTests { adone.logInfo(); adone.logDebug(); adone.logTrace(); - { const a: object = adone.o(); } - { const a: object = adone.o({}); } + obj = adone.o(); + obj = adone.o({}); { const a: typeof Date = adone.Date; } { const a: typeof process.hrtime = adone.hrtime; } { const a: typeof global.setTimeout = adone.setTimeout; } @@ -26,6 +35,7 @@ namespace AdoneRootTests { { const a: typeof clearInterval = adone.clearInterval; } { const a: typeof global.setImmediate = adone.setImmediate; } { const a: typeof clearImmediate = adone.clearImmediate; } + adone.lazify({}); adone.lazify({}, {}); adone.lazify({}, {}, () => { }); @@ -33,40 +43,15 @@ namespace AdoneRootTests { adone.lazify({}, {}, () => { }, { configurable: true }); adone.lazify({}, {}, () => { }, { writable: false }); adone.lazify({}, {}, () => { }, { mapper: (key: string, obj: any) => null }); + adone.tag.set({}, "123"); - { const a: boolean = adone.tag.has({}, "123"); } + bool = adone.tag.has({}, "123"); adone.tag.define("12"); adone.tag.define("123", "456"); - { const a: symbol = adone.tag.SUBSYSTEM; } - { const a: symbol = adone.tag.APPLICATION; } - { const a: symbol = adone.tag.TRANSFORM; } - { const a: symbol = adone.tag.CORE_STREAM; } - { const a: symbol = adone.tag.LOGGER; } - { const a: symbol = adone.tag.LONG; } - { const a: symbol = adone.tag.BIGNUMBER; } - { const a: symbol = adone.tag.EXBUFFER; } - { const a: symbol = adone.tag.EXDATE; } - { const a: symbol = adone.tag.CONFIGURATION; } - { const a: symbol = adone.tag.GENESIS_NETRON; } - { const a: symbol = adone.tag.GENESIS_PEER; } - { const a: symbol = adone.tag.NETRON; } - { const a: symbol = adone.tag.NETRON_PEER; } - { const a: symbol = adone.tag.NETRON_ADAPTER; } - { const a: symbol = adone.tag.NETRON_DEFINITION; } - { const a: symbol = adone.tag.NETRON_DEFINITIONS; } - { const a: symbol = adone.tag.NETRON_REFERENCE; } - { const a: symbol = adone.tag.NETRON_INTERFACE; } - { const a: symbol = adone.tag.NETRON_STUB; } - { const a: symbol = adone.tag.NETRON_REMOTESTUB; } - { const a: symbol = adone.tag.NETRON_STREAM; } - { const a: symbol = adone.tag.FAST_STREAM; } - { const a: symbol = adone.tag.FAST_FS_STREAM; } - { const a: symbol = adone.tag.FAST_FS_MAP_STREAM; } - { const a: object = adone.bind("library"); } // hmm - { const a: string = adone.getAssetAbsolutePath("asset"); } + str = adone.getAssetAbsolutePath("asset"); { const a: Buffer | string = adone.loadAsset("asset"); } - { const a: object = adone.require("path"); } - { const a: object = adone.package; } + obj = adone.require("path"); + obj = adone.package; { const a: typeof adone.assertion.assert = adone.assert; } { const a: typeof adone.assertion.expect = adone.expect; } } From a62421c6e1a2c613cb6b616946e1f4d65c95a95c Mon Sep 17 00:00:00 2001 From: s0m3on3 Date: Tue, 27 Feb 2018 00:27:15 +0200 Subject: [PATCH 4/5] [adone] add vault --- types/adone/glosses/vault.d.ts | 204 ++++++++++++++++++++++++++++++ types/adone/index.d.ts | 1 + types/adone/test/glosses/vault.ts | 203 +++++++++++++++++++++++++++++ types/adone/tsconfig.json | 2 + 4 files changed, 410 insertions(+) create mode 100644 types/adone/glosses/vault.d.ts create mode 100644 types/adone/test/glosses/vault.ts diff --git a/types/adone/glosses/vault.d.ts b/types/adone/glosses/vault.d.ts new file mode 100644 index 0000000000..2fc39c0c3b --- /dev/null +++ b/types/adone/glosses/vault.d.ts @@ -0,0 +1,204 @@ +declare namespace adone { + namespace vault { + namespace I { + interface VaultConstructorOptions { + // TODO: leveldb options + location: string; + ValuableClass?: object; + } + + interface VaultClearOptions { + hosts?: boolean; + tags?: boolean; + } + + interface VaultToJSONOptions { + valuable?: ValuableToJSONOptions; + includeStats?: boolean; + } + + interface ValuableToJSONOptions { + includeId?: boolean; + includeEntryId?: boolean; + entriesAsArray?: boolean; + tags?: "normal" | "onlyName" | "onlyId" | "none"; + } + + interface VaultJSONStats { + location: string; + created: number; + updated: number; + } + } + + class Vault { + constructor(options: I.VaultConstructorOptions); + + open(): Promise; + + close(): Promise; + + location(): string; + + create(name: string, tags?: string[]): Promise; + + get(name: string): Promise; + + release(name: string): void; + + delete(name: string): Promise; + + clear(options?: I.VaultClearOptions): Promise; + + has(name: string): boolean; + + keys(): string[]; + + values(): Promise; + + entries(): Promise<{ [key: string]: any }>; + + toJSON(options: I.VaultToJSONOptions & { valuable: object, includeStats: true }): Promise<{ + valuables: object[], + stats: I.VaultJSONStats + }>; + toJSON(options: I.VaultToJSONOptions & { valuable: object }): Promise<{ + valuables: object[] + }>; + toJSON(options: I.VaultToJSONOptions & { includeStats: true }): Promise<{ + stats: I.VaultJSONStats + }>; + toJSON(): {}; + + addTag(tag: string, vid?: number): Promise; + + deleteTag(tag: string): Promise; + + tags(ids?: number[], opts?: { privateProps?: boolean }): object[]; + + tagNames(ids?: number[]): string[]; + + getNotes(): string; + + setNotes(notes: string): Promise; + } + + namespace I { + interface ValueableEntriesOptions { + entriesAsArray?: boolean; + includeEntryId?: boolean; + } + + interface ValuableEntry { + name: string; + value: any; + type: string; + } + + interface ValuableClearOptions { + includeNotes?: boolean; + includeTags?: boolean; + } + + interface ValuableJSON { + name: string; + notes: string; + entries: I.ValuableEntry[]; + } + } + + class Valuable { + constructor(vaule: Vault, id: number, metaData: object, tags: object[]); + + name(): string; + + internalId(): number; + + getNotes(): string; + + setNotes(notes: string): Promise; + + set(name: string, value: any, type?: string): Promise; + + setMulti(entries: object): Promise; + + get(name: string): Promise; + + type(name: string): any; + + has(name: string): boolean; + + keys(): string[]; + + entries(opts: I.ValueableEntriesOptions & { entriesAsArray: true }): Promise; + entries(opts: I.ValueableEntriesOptions & { entriesAsArray: true, includeEntryId: true }): Promise>; + entries(opts?: I.ValueableEntriesOptions): Promise; + + delete(name: string): Promise; + + clear(opts?: I.ValuableClearOptions): Promise; + + toJSON(opts?: I.ValuableToJSONOptions): object; // TODO + + fromJSON(json: object): Promise; + + addTag(tag: string): Promise; + + hasTag(tag: string): boolean; + + deleteTag(tag: string): Promise; + + deleteAllTags(): Promise; + + tags(): object[]; + } + + function open(options?: I.VaultConstructorOptions): Promise; + + namespace I { + interface SlicedValuable { + name(): string; + + internalId(): number; + + getNotes(): string; + + setNotes(notes: string): Promise; + + set(name: string, value: any, type?: string): Promise; + + setMulti(entries: object): Promise; + + get(name: string): Promise; + + type(name: string): any; + + has(name: string): boolean; + + keys(): string[]; + + entries(opts: I.ValueableEntriesOptions & { entriesAsArray: true }): Promise; + entries(opts: I.ValueableEntriesOptions & { entriesAsArray: true, includeEntryId: true }): Promise>; + entries(opts?: I.ValueableEntriesOptions): Promise; + + delete(name: string): Promise; + + toJSON(opts?: I.ValuableToJSONOptions): object; + + fromJSON(json: object): Promise; + + addTag(tag: string): Promise; + + hasTag(tag: string): boolean; + + deleteTag(tag: string): Promise; + + deleteAllTags(): Promise; + + tags(): object[]; + } + } + + function slice(valuable: Valuable, prefix: string | string[], separator?: string): I.SlicedValuable; + } +} diff --git a/types/adone/index.d.ts b/types/adone/index.d.ts index e0ddfec26b..a74641c4df 100644 --- a/types/adone/index.d.ts +++ b/types/adone/index.d.ts @@ -34,6 +34,7 @@ /// /// /// +/// declare const _adone: typeof adone; diff --git a/types/adone/test/glosses/vault.ts b/types/adone/test/glosses/vault.ts new file mode 100644 index 0000000000..1423a46715 --- /dev/null +++ b/types/adone/test/glosses/vault.ts @@ -0,0 +1,203 @@ +namespace adoneTests.vault { + const { + is, + vault + } = adone; + + let num: number; + let bool: boolean; + let obj: object; + let str: string; + + namespace Vault { + const { + Vault + } = vault; + + new Vault({ + location: "a" + }); + new Vault({ + location: "a", + ValuableClass: vault.Valuable + }); + + const v = new Vault({ + location: "a" + }); + + v.addTag("hello").then((x) => { + if (!is.null(x)) { + num = x; + } + }); + v.clear().then((x) => { + num = x; + }); + v.close().then(); + v.create("hello").then((x) => { + x.set("a", "b"); + }); + v.create("hello", ["a", "b"]).then((x) => { + x.set("a", "b"); + }); + v.delete("a").then(); + v.deleteTag("a").then((x) => { + bool = x; + }); + v.entries().then((x) => { + obj = x; + }); + v.get("a").then((x) => { + x.set("a", "b"); + }); + str = v.getNotes(); + bool = v.has("a"); + str = v.keys()[0]; + str = v.location(); + v.open().then(() => {}); + v.release("name"); + v.setNotes("asd").then(); + str = v.tagNames()[0]; + str = v.tagNames([1])[0]; + obj = v.tags()[0]; + obj = v.toJSON(); + v.toJSON({ valuable: { includeId: true } }).then((x) => { + obj = x.valuables[0]; + }); + v.toJSON({ includeStats: true }).then((x) => { + num = x.stats.created; + num = x.stats.updated; + str = x.stats.location; + }); + v.values().then((x) => { + x[0]; + }); + } + + namespace Valuable { + new vault.Vault({ location: "a" }).get("a").then((v) => { + v.addTag("a").then(); + v.clear().then((x) => { + num = x; + }); + v.clear({ includeNotes: true }).then((x) => { + num = x; + }); + v.clear({ includeTags: true }).then((x) => { + num = x; + }); + v.delete("a").then((x) => { + num = x; + }); + v.deleteAllTags(); + v.entries().then((x) => { + obj = x; + }); + v.entries({ entriesAsArray: true }).then((x) => { + obj = x; + }); + v.entries({ includeEntryId: true }).then((x) => { + obj = x; + }); + v.fromJSON({}).then((x) => { + num = x; + }); + v.get("a").then(); + str = v.getNotes(); + bool = v.has("a"); + bool = v.hasTag("a"); + num = v.internalId(); + str = v.keys()[0]; + str = v.name(); + v.set("a", "b").then((x) => { + num = x; + }); + v.set("a", "b", "wtf").then((x) => { + num = x; + }); + v.setMulti({ a: "1", b: "2" }).then(); + v.setNotes("a").then(); + obj = v.tags(); + obj = v.toJSON(); + obj = v.toJSON({ entriesAsArray: true }); + obj = v.toJSON({ includeEntryId: true }); + obj = v.toJSON({ includeId: false }); + obj = v.toJSON({ tags: "normal" }); + obj = v.toJSON({ tags: "none" }); + obj = v.toJSON({ tags: "onlyId" }); + obj = v.toJSON({ tags: "onlyName" }); + v.type("a"); + }); + } + + namespace slice { + new vault.Vault({ location: "a" }).get("a").then((valuable) => { + vault.slice(valuable, "s"); + vault.slice(valuable, ["s"]); + vault.slice(valuable, ["s"], "a"); + vault.slice(valuable, ["s"], "a"); + const v = vault.slice(valuable, "s"); + v.addTag("a").then(); + v.delete("a").then((x) => { + num = x; + }); + v.deleteAllTags().then(); + v.deleteTag("a").then((x) => { + bool = x; + }); + v.entries().then((x) => { + obj = x; + }); + v.entries({}).then((x) => { + obj = x; + }); + v.entries({ entriesAsArray: true }).then((x) => { + obj = x; + }); + v.entries({ includeEntryId: true }).then((x) => { + obj = x; + }); + v.fromJSON({}).then((x) => { + num = x; + }); + v.get("a").then(); + str = v.getNotes(); + bool = v.has("a"); + bool = v.hasTag("a"); + num = v.internalId(); + str = v.keys()[0]; + str = v.name(); + v.set("a", "b").then((x) => { + num = x; + }); + v.set("a", "b", "wtf").then((x) => { + num = x; + }); + v.setMulti({}).then(); + v.setNotes("a").then((x) => { + num = x; + }); + obj = v.tags()[0]; + obj = v.toJSON(); + obj = v.toJSON({}); + obj = v.toJSON({ entriesAsArray: true }); + obj = v.toJSON({ includeEntryId: true }); + obj = v.toJSON({ includeId: true }); + obj = v.toJSON({ tags: "none" }); + obj = v.toJSON({ tags: "normal" }); + obj = v.toJSON({ tags: "onlyId" }); + obj = v.toJSON({ tags: "onlyName" }); + v.type("a"); + }); + } + + namespace open { + vault.open({ location: "a" }).then((x) => { + x.get("a").then((x) => x.setMulti({})); + }); + vault.open({ location: "a", ValuableClass: vault.Valuable }).then((x) => { + x.get("a").then((x) => x.setMulti({})); + }); + } +} diff --git a/types/adone/tsconfig.json b/types/adone/tsconfig.json index 729fb82734..6e6b3fe1c3 100644 --- a/types/adone/tsconfig.json +++ b/types/adone/tsconfig.json @@ -87,6 +87,7 @@ "glosses/text/table.d.ts", "glosses/text/unicode.d.ts", "glosses/utils.d.ts", + "glosses/vault.d.ts", "index.d.ts", "test/glosses/application.ts", "test/glosses/archives.ts", @@ -148,6 +149,7 @@ "test/glosses/text/table.ts", "test/glosses/text/unicode.ts", "test/glosses/utils.ts", + "test/glosses/vault.ts", "test/index-import.ts", "test/index.ts" ] From 6ba4e9c43a7d11fb0a0553a14e0d469f9687a418 Mon Sep 17 00:00:00 2001 From: s0m3on3 Date: Wed, 28 Feb 2018 14:27:20 +0200 Subject: [PATCH 5/5] [adone] fix util.throttle options --- types/adone/glosses/utils.d.ts | 2 +- types/adone/test/glosses/utils.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/types/adone/glosses/utils.d.ts b/types/adone/glosses/utils.d.ts index d1a0aa49bc..5d2eb5f198 100644 --- a/types/adone/glosses/utils.d.ts +++ b/types/adone/glosses/utils.d.ts @@ -536,7 +536,7 @@ declare namespace adone { namespace throttle { namespace I { interface Options { - max?: number; + concurrency?: number; interval?: number; ordered?: boolean; waitForReturn?: boolean; diff --git a/types/adone/test/glosses/utils.ts b/types/adone/test/glosses/utils.ts index f0b789c78b..a01d010608 100644 --- a/types/adone/test/glosses/utils.ts +++ b/types/adone/test/glosses/utils.ts @@ -472,7 +472,7 @@ namespace utilTests { const c: (a: number, b: string) => Promise = util.throttle.create((a: number, b: string) => String(a) + b); const d = util.throttle.create(() => { }, {}); const e = util.throttle.create(() => { }, { interval: 1000 }); - const f = util.throttle.create(() => { }, { max: 10 }); + const f = util.throttle.create(() => { }, { concurrency: 10 }); const g = util.throttle.create(() => { }, { ordered: true }); const h = util.throttle.create(() => { }, { waitForReturn: true }); const i = util.throttle.create(() => { }, { onDone() {} });