From 6f8d56fbbf92e1b1b434ee95f0ae7b08ab429da9 Mon Sep 17 00:00:00 2001 From: Kartik Malik Date: Thu, 2 Aug 2018 22:19:02 +0530 Subject: [PATCH] Adding definitions for fastGet, fastPut in ssh2-sftp-client (#27638) * Adding definations for fastGet, fastPut in ssh2-sftp-client * Adding proper ssh2-streams typing for ssh2-sftp-client functions fastGet and fastPut * Adding type for return value of fastGet and fastPut --- types/ssh2-sftp-client/index.d.ts | 8 +++++--- types/ssh2-sftp-client/ssh2-sftp-client-tests.ts | 4 ++++ 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/types/ssh2-sftp-client/index.d.ts b/types/ssh2-sftp-client/index.d.ts index a0133961d8..0e1555abaf 100644 --- a/types/ssh2-sftp-client/index.d.ts +++ b/types/ssh2-sftp-client/index.d.ts @@ -1,17 +1,19 @@ -// Type definitions for ssh2-sftp-client 2.0 +// Type definitions for ssh2-sftp-client 2.3 // Project: https://www.npmjs.com/package/ssh2-sftp-client -// Definitions by: igrayson , Ascari Andrea +// Definitions by: igrayson , Ascari Andrea , Kartik Malik // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped import * as ssh2 from 'ssh2'; - +import * as ssh2Stream from 'ssh2-streams'; export = sftp; declare class sftp { connect(options: ssh2.ConnectConfig): Promise; list(remoteFilePath: string): Promise; get(remoteFilePath: string, useCompression?: boolean, encoding?: string | null): Promise; + fastGet(remoteFilePath: string, localPath: string, options?: ssh2Stream.TransferOptions): Promise; put(input: string | Buffer | NodeJS.ReadableStream, remoteFilePath: string, useCompression?: boolean, encoding?: string): Promise; + fastPut(localPath: string, emoteFilePath: string, options?: ssh2Stream.TransferOptions): Promise; mkdir(remoteFilePath: string, recursive?: boolean): Promise; rmdir(remoteFilePath: string, recursive?: boolean): Promise; delete(remoteFilePath: string): Promise; diff --git a/types/ssh2-sftp-client/ssh2-sftp-client-tests.ts b/types/ssh2-sftp-client/ssh2-sftp-client-tests.ts index 67d2d35826..0b9c1a940c 100644 --- a/types/ssh2-sftp-client/ssh2-sftp-client-tests.ts +++ b/types/ssh2-sftp-client/ssh2-sftp-client-tests.ts @@ -15,10 +15,14 @@ client.get('/remote/path').then(stream => stream.read(0)); client.get('/remote/path', true, 'utf8').then(stream => stream.read(0)); client.get('/remote/path', true, null).then(stream => stream.read(0)); +client.fastGet('/remote/path', 'local/path').then(() => null); + client.put('/local/path', '/remote/path').then(() => null); client.put(new Buffer('content'), '/remote/path').then(() => null); client.put(fs.createReadStream('Hello World'), '/remote/path').then(() => null); +client.fastPut('/remote/path', 'local/path').then(() => null); + client.mkdir('/remote/path/dir', true).then(() => null); client.rmdir('/remote/path/dir', true).then(() => null);