mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-07-04 17:20:09 +00:00
[jsftp] Add types for jsftp
This commit is contained in:
committed by
Konrad Księski
parent
8f7b983d50
commit
7196075fbd
50
types/jsftp/index.d.ts
vendored
Normal file
50
types/jsftp/index.d.ts
vendored
Normal file
@@ -0,0 +1,50 @@
|
||||
// Type definitions for jsftp 2.1
|
||||
// Project: https://github.com/sergi/jsftp
|
||||
// Definitions by: Konrad Księski <https://github.com/xyleen>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/// <reference types="node" />
|
||||
|
||||
import { Socket } from 'net';
|
||||
import { EventEmitter } from 'events';
|
||||
|
||||
export interface JsftpOpts {
|
||||
host?: string;
|
||||
port?: number;
|
||||
user?: string;
|
||||
pass?: string;
|
||||
createSocket?: ({ port, host }: { port: number, host: string }, firstAction: () => {}) => Socket;
|
||||
useList?: boolean;
|
||||
}
|
||||
|
||||
export type ErrorCallback = (err: Error) => void;
|
||||
export type RawCallback = (err: Error, data: { code: number, text: string }) => void;
|
||||
export type ListCallback = (err: Error, dirContents: string) => void;
|
||||
export type GetCallback = (err: Error, socket: Socket) => void;
|
||||
export type LsCallback = (err: Error, res: [{ name: string }]) => void;
|
||||
|
||||
export default class Ftp extends EventEmitter {
|
||||
constructor(opts: JsftpOpts);
|
||||
|
||||
ls(filePath: string, callback: LsCallback): void;
|
||||
|
||||
list(filePath: string, callback: ListCallback): void;
|
||||
|
||||
get(remotePath: string, callback: GetCallback): void;
|
||||
get(remotePath: string, localPath: string, callback: ErrorCallback): void;
|
||||
|
||||
put(source: string | Buffer | NodeJS.ReadableStream, remotePath: string, callback: ErrorCallback): void;
|
||||
|
||||
rename(from: string, to: string, callback: ErrorCallback): void;
|
||||
|
||||
// Ftp.raw(command, params, callback)
|
||||
raw(command: string, callback: RawCallback): void;
|
||||
raw(command: string, arg1: any, callback: RawCallback): void;
|
||||
raw(command: string, arg1: any, arg2: any, callback: RawCallback): void;
|
||||
raw(command: string, arg1: any, arg2: any, arg3: any, callback: RawCallback): void;
|
||||
raw(command: string, arg1: any, arg2: any, arg3: any, arg4: any, callback: RawCallback): void;
|
||||
|
||||
keepAlive(timeInMs?: number): void;
|
||||
|
||||
destroy(): void;
|
||||
}
|
||||
25
types/jsftp/jsftp-tests.ts
Normal file
25
types/jsftp/jsftp-tests.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
import Ftp from 'jsftp';
|
||||
|
||||
const connectOpts = {
|
||||
host: 'localhost',
|
||||
port: 22222,
|
||||
};
|
||||
|
||||
const ftp = new Ftp(connectOpts); // $ExpectType Ftp
|
||||
|
||||
ftp.ls('foo', (err) => { }); // $ExpectType void
|
||||
|
||||
ftp.list('foo', (err) => { }); // $ExpectType void
|
||||
|
||||
ftp.get('foo', (err) => { }); // $ExpectType void
|
||||
ftp.get('foo', 'bar', (err) => { }); // $ExpectType void
|
||||
|
||||
ftp.put('foo', 'bar', (err) => { }); // $ExpectType void
|
||||
|
||||
ftp.rename('foo', 'bar', (err) => { }); // $ExpectType void
|
||||
|
||||
ftp.raw('foo', 'param', (err) => { }); // $ExpectType void
|
||||
|
||||
ftp.keepAlive(); // $ExpectType void
|
||||
|
||||
ftp.destroy(); // $ExpectType void
|
||||
23
types/jsftp/tsconfig.json
Normal file
23
types/jsftp/tsconfig.json
Normal file
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"jsftp-tests.ts"
|
||||
]
|
||||
}
|
||||
1
types/jsftp/tslint.json
Normal file
1
types/jsftp/tslint.json
Normal file
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Reference in New Issue
Block a user