Skip to content

Commit

Permalink
Switch to Typescript
Browse files Browse the repository at this point in the history
  • Loading branch information
patrickjuchli committed Feb 15, 2019
1 parent b063caf commit 08b17d8
Show file tree
Hide file tree
Showing 36 changed files with 1,226 additions and 2,041 deletions.
24 changes: 0 additions & 24 deletions .eslintrc.json

This file was deleted.

1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
node_modules
temp
dist
.vscode
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## 3.2.0

- Changed: Source is now written in Typescript, fixes #49.

## 3.1.1

- Fixed: Switch seamlessly between control and data connection for tracking timeout.
Expand Down
6 changes: 0 additions & 6 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,3 @@
Contributions are welcome!

This library has specific goals. FTP is an old protocol, there are many features, quirks and server implementations. It's not a goal to support all of them. It should provide a foundation that covers the basic needs.

## Testing

- `npm test` runs unit tests.
- `npm run tdd` runs unit tests automatically every time a file changed.
- `npm run lint` runs the linter.
2 changes: 1 addition & 1 deletion LICENSE.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright (c) 2018 Patrick Juchli
Copyright (c) 2019 Patrick Juchli

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
20 changes: 10 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ This is an FTP client for Node.js. It supports explicit FTPS over TLS, Passive M

## Advisory

Prefer alternative transfer protocols like HTTP or SFTP (SSH) if you can. Use this library when you have no choice and need to use FTP. Try to use FTPS whenever possible, FTP alone does not encrypt your data.
Prefer alternative transfer protocols like HTTPS or SFTP (SSH). Use this library when you have no choice and need to use FTP. Try to use FTPS whenever possible, FTP alone does not provide any security.

## Dependencies

Expand Down Expand Up @@ -70,7 +70,7 @@ Close the client and all open socket connections. The client can’t be used any

True if the client has been closed, either by the user or by an error.

`access(options): Promise<Response>`
`access(options): Promise<FTPResponse>`

Get access to an FTP server. This method will connect to a server, optionally secure the connection with TLS, login a user and apply some default settings (TYPE I, STRU F, PBSZ 0, PROT P). It returns the response of the initial connect command. The available options are:

Expand All @@ -87,11 +87,11 @@ Get access to an FTP server. This method will connect to a server, optionally se

Get a description of supported features. This will return a Map where keys correspond to FTP commands and values contain further details.

`send(command, ignoreErrorCodes = false): Promise<Response>`
`send(command, ignoreErrorCodes = false): Promise<FTPResponse>`

Send an FTP command. You can choose to ignore error return codes. Other errors originating from the socket connections including timeouts will still reject the Promise returned.

`cd(remotePath): Promise<Response>`
`cd(remotePath): Promise<FTPResponse>`

Change the working directory.

Expand All @@ -111,19 +111,19 @@ Get the last modification time of a file in the working directory. This command

Get the size of a file in the working directory.

`rename(path, newPath): Promise<Response>`
`rename(path, newPath): Promise<FTPResponse>`

Rename a file. Depending on the server you may also use this to move a file to another directory by providing full paths.

`remove(filename, ignoreErrorCodes = false): Promise<Response>`
`remove(filename, ignoreErrorCodes = false): Promise<FTPResponse>`

Remove a file from the working directory.

`upload(readableStream, remoteFilename): Promise<Response>`
`upload(readableStream, remoteFilename): Promise<FTPResponse>`

Upload data from a readable stream and store it as a file with a given filename in the current working directory.

`download(writableStream, remoteFilename, startAt = 0): Promise<Response>`
`download(writableStream, remoteFilename, startAt = 0): Promise<FTPResponse>`

Download a file with a given filename from the current working directory and pipe its data to a writable stream. You may optionally start at a specific offset, for example to resume a cancelled transfer.

Expand Down Expand Up @@ -200,7 +200,7 @@ myClient.ftp.log = myLogger.debug

## Static Types

In addition to unit tests and linting, the source code is fully [type-checked](tsconfig.json) using Typescript. Type declarations are written in JSDoc and are complete enough to satisfy the most rigorous [compiler settings](https://www.typescriptlang.org/docs/handbook/compiler-options.html) such as `strict` or `noImplicitAny`.
In addition to unit tests and linting, the source code is written in Typescript using rigorous [compiler settings](tsconfig.json) like `strict` and `noImplicitAny`. When building the project, the source is transpiled to Javascript and type declaration files. This makes the library useable for both Javascript and Typescript projects.

## Extending the library

Expand Down Expand Up @@ -238,7 +238,7 @@ Set the socket for the control connection. When setting a new socket the current

Set the socket for the data connection. When setting a new socket the current one will be closed and all listeners will be removed.

`handle(command, handler): Promise<Response>`
`handle(command, handler): Promise<FTPResponse>`

Send an FTP command and register a handler function to handle all subsequent responses and socket events until the task is rejected or resolved. `command` may be undefined. This returns a promise that is resolved/rejected when the task given to the handler is resolved/rejected. This is the central method of this library, see the example below for a more detailed explanation.

Expand Down
55 changes: 0 additions & 55 deletions lib/FileInfo.js

This file was deleted.

Loading

0 comments on commit 08b17d8

Please sign in to comment.