From 5e48bc7dcd71a91a94be913280efe4b00828e673 Mon Sep 17 00:00:00 2001 From: Bleser Date: Tue, 20 Mar 2018 16:04:55 +0500 Subject: [PATCH] Added type definition for function "pdf()" with buffer in callback. --- types/nightmare/index.d.ts | 1 + types/nightmare/nightmare-tests.ts | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/types/nightmare/index.d.ts b/types/nightmare/index.d.ts index 7be47c2d30..f3895b90c0 100644 --- a/types/nightmare/index.d.ts +++ b/types/nightmare/index.d.ts @@ -107,6 +107,7 @@ declare class Nightmare { html(path: string, saveType: 'MHTML'): Nightmare; pdf(path: string): Nightmare; pdf(path: string, options: Object): Nightmare; + pdf(cd:(err:Error, data:Buffer)=>void): Nightmare; title(): string; title(cb: (title: string) => void): Nightmare; url(cb: (url: string) => void): Nightmare; diff --git a/types/nightmare/nightmare-tests.ts b/types/nightmare/nightmare-tests.ts index 1dfe655c94..65391e8ef9 100644 --- a/types/nightmare/nightmare-tests.ts +++ b/types/nightmare/nightmare-tests.ts @@ -189,6 +189,14 @@ new Nightmare() .pdf('test/test.pdf') .run(done); +new Nightmare() + .goto("http://yahoo.com") + .pdf((err,data)=>{ + console.log(Buffer.isBuffer(data)) + }) + .run(done) + + new Nightmare() .goto('http://www.google.com/') .wait('input')