From 7a338096583f581a4c2733802110f15e8a19e4a5 Mon Sep 17 00:00:00 2001 From: Brian Lee Date: Sat, 27 May 2017 17:35:56 -0700 Subject: [PATCH 1/5] Allow subclass gm function to accept source types other than path strings --- types/gm/gm-tests.ts | 10 ++++++++++ types/gm/index.d.ts | 3 +++ 2 files changed, 13 insertions(+) diff --git a/types/gm/gm-tests.ts b/types/gm/gm-tests.ts index e8bf5787cd..50c124ffc5 100644 --- a/types/gm/gm-tests.ts +++ b/types/gm/gm-tests.ts @@ -346,3 +346,13 @@ var imageMagick = gm.subClass({ imageMagick: true }); var readStream = imageMagick(src) .adjoin() .stream(); + +var passStream = imageMagick(readStream).stream(); + +var buffers: Buffer[] = []; +var buffer: Buffer; +passStream.on('data', (chunk) => buffers.push(chunk as Buffer)).on('close', () => { + buffer = Buffer.concat(buffers); + var readstream = imageMagick(buffer).stream(); +}) + diff --git a/types/gm/index.d.ts b/types/gm/index.d.ts index 7fd419ede3..a08086e58e 100644 --- a/types/gm/index.d.ts +++ b/types/gm/index.d.ts @@ -615,6 +615,9 @@ declare namespace m { export interface SubClass { (image: string): State; + (stream: NodeJS.ReadableStream, image?: string): State + (buffer: Buffer, image?: string): State + (width: number, height: number, color?: string): State } export function compare(filename1: string, filename2: string, callback: CompareCallback): void; From 803b84709699b305f8a84746c0c73bfb955725dc Mon Sep 17 00:00:00 2001 From: Brian Lee Date: Tue, 30 May 2017 13:19:08 -0700 Subject: [PATCH 2/5] Rewrite overloaded function --- types/gm/index.d.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/types/gm/index.d.ts b/types/gm/index.d.ts index a08086e58e..8da081ffd5 100644 --- a/types/gm/index.d.ts +++ b/types/gm/index.d.ts @@ -615,9 +615,9 @@ declare namespace m { export interface SubClass { (image: string): State; - (stream: NodeJS.ReadableStream, image?: string): State - (buffer: Buffer, image?: string): State - (width: number, height: number, color?: string): State + (stream: NodeJS.ReadableStream, image?: string): State; + (buffer: Buffer, image?: string): State; + (width: number, height: number, color?: string): State; } export function compare(filename1: string, filename2: string, callback: CompareCallback): void; From a70a977fe4acee57c5f5cf5a9e16575284cde81d Mon Sep 17 00:00:00 2001 From: Brian Lee Date: Tue, 27 Jun 2017 17:22:48 -0700 Subject: [PATCH 3/5] Add additional tests --- types/node/node-tests.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/types/node/node-tests.ts b/types/node/node-tests.ts index aeefc2bbdc..ea177760cb 100644 --- a/types/node/node-tests.ts +++ b/types/node/node-tests.ts @@ -544,6 +544,11 @@ namespace util_tests { maxArrayLength: null, breakLength: Infinity }) + assert(typeof util.inspect.custom === 'symbol') + // util.promisify + var readPromised = util.promisify(fs.readFile) + var sampleRead: Promise = readPromised(__filename).then((data: string): void => {}).catch((error: Error): void => {}) + assert(typeof util.promisify.custom === 'symbol') } } From 42af84cc3a5f629c4d49e896f4f80fdb16147213 Mon Sep 17 00:00:00 2001 From: Brian Lee Date: Tue, 27 Jun 2017 17:24:31 -0700 Subject: [PATCH 4/5] Add properties for util.inspect and util.promisify --- types/node/index.d.ts | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/types/node/index.d.ts b/types/node/index.d.ts index 21d48b504a..23aceac90c 100644 --- a/types/node/index.d.ts +++ b/types/node/index.d.ts @@ -3938,8 +3938,17 @@ declare module "util" { export function puts(...param: any[]): void; export function print(...param: any[]): void; export function log(string: string): void; - export function inspect(object: any, showHidden?: boolean, depth?: number | null, color?: boolean): string; - export function inspect(object: any, options: InspectOptions): string; + export var inspect: { + (object: any, showHidden?: boolean, depth?: number | null, color?: boolean): string; + (object: any, options: InspectOptions): string; + colors: { + [color: string]: [number, number] + } + styles: { + [style: string]: string + } + custom: symbol + } export function isArray(object: any): object is any[]; export function isRegExp(object: any): object is RegExp; export function isDate(object: any): object is Date; @@ -3958,7 +3967,10 @@ declare module "util" { export function isSymbol(object: any): object is symbol; export function isUndefined(object: any): object is undefined; export function deprecate(fn: Function, message: string): Function; - export function promisify(fn: Function): Function; + export var promisify: { + (fn: Function): Function; + custom: symbol + } } declare module "assert" { From f8156fb34adb09aa89acb1fe67644928d745f756 Mon Sep 17 00:00:00 2001 From: Brian Lee Date: Wed, 28 Jun 2017 00:48:12 -0700 Subject: [PATCH 5/5] Add util.inspect.defaultOptions property --- types/node/index.d.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/types/node/index.d.ts b/types/node/index.d.ts index 7bc703db58..b87382f103 100644 --- a/types/node/index.d.ts +++ b/types/node/index.d.ts @@ -3953,7 +3953,8 @@ declare module "util" { styles: { [style: string]: string } - custom: symbol + defaultOptions: InspectOptions; + custom: symbol; } export function isArray(object: any): object is any[]; export function isRegExp(object: any): object is RegExp;