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
This commit is contained in:
Kartik Malik
2018-08-02 22:19:02 +05:30
committed by Sheetal Nandi
parent c0912e8b26
commit 6f8d56fbbf
2 changed files with 9 additions and 3 deletions

View File

@@ -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 <https://github.com/igrayson>, Ascari Andrea <https://github.com/ascariandrea>
// Definitions by: igrayson <https://github.com/igrayson>, Ascari Andrea <https://github.com/ascariandrea>, Kartik Malik <https://github.com/kartik2406>
// 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<void>;
list(remoteFilePath: string): Promise<sftp.FileInfo[]>;
get(remoteFilePath: string, useCompression?: boolean, encoding?: string | null): Promise<NodeJS.ReadableStream>;
fastGet(remoteFilePath: string, localPath: string, options?: ssh2Stream.TransferOptions): Promise<string>;
put(input: string | Buffer | NodeJS.ReadableStream, remoteFilePath: string, useCompression?: boolean, encoding?: string): Promise<void>;
fastPut(localPath: string, emoteFilePath: string, options?: ssh2Stream.TransferOptions): Promise<string>;
mkdir(remoteFilePath: string, recursive?: boolean): Promise<void>;
rmdir(remoteFilePath: string, recursive?: boolean): Promise<void>;
delete(remoteFilePath: string): Promise<void>;

View File

@@ -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);