Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

whoosh

Package Overview
Dependencies
Maintainers
3
Versions
23
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

whoosh - npm Package Compare versions

Comparing version 0.3.7 to 1.1.0

_config.yml

9

index.js

@@ -105,4 +105,3 @@ var Client = require('ssh2').Client

debug('Connection to %s:%s ended', config.hostname, config.port)
disconnected = true
disconnecting = false
disconnect()
})

@@ -112,5 +111,9 @@

debug('Connection to %s:%s closed', config.hostname, config.port)
disconnect()
})
function disconnect() {
disconnected = true
disconnecting = false
})
}
}

@@ -117,0 +120,0 @@ }

{
"name": "whoosh",
"version": "0.3.7",
"version": "1.1.0",
"description": "A streaming sftp client",
"main": "index.js",
"scripts": {
"test": "NODE_ENV=test mocha --recursive tests",
"lint": "node_modules/.bin/eslint .",
"test": "mocha",
"lint": "eslint .",
"istanbul": "istanbul cover --report html --report lcov _mocha",
"codeclimate": "codeclimate-test-reporter < coverage/lcov.info",
"precommit": "npm run lint",
"prepush": "npm test"
"prepush": "npm test",
"docker": "docker-compose up -d"
},

@@ -20,13 +23,16 @@ "keywords": [

"devDependencies": {
"async": "^1.2.1",
"eslint": "^0.23.0",
"eslint-config-imperative": "0.0.6",
"fs-extra": "^0.18.4",
"husky": "^0.8.1",
"mocha": "^2.2.5"
"async": "^2.1.4",
"chai": "^3.5.0",
"codeclimate-test-reporter": "^0.4.0",
"eslint": "^3.12.2",
"eslint-config-imperative": "^1.0.0",
"eslint-plugin-imperative": "^1.0.0",
"fs-extra": "^2.0.0",
"husky": "^0.13.1",
"mocha": "^3.2.0"
},
"dependencies": {
"debug": "^2.2.0",
"lodash": "^3.9.3",
"ssh2": "^0.4.8"
"debug": "^2.6.0",
"lodash": "^4.17.4",
"ssh2": "^0.5.4"
},

@@ -43,3 +49,3 @@ "directories": {

},
"homepage": "https://github.com/guidesmiths/whoosh"
"homepage": "https://guidesmiths.github.io/whoosh/"
}
# Whoosh
Whoosh is an ultra thin wrapper for [SFTPStream](https://github.com/mscdex/ssh2-streams/blob/master/SFTPStream.md), with the additional benefit of being able to easily stream in memory content to/from an SFTP server.
Whoosh is an ultra thin wrapper for [SFTPStream](https://github.com/mscdex/ssh2-streams/blob/master/SFTPStream.md). It's so thin that there's not much point using it unless you want to stream in memory content to/from an SFTP server.
[![NPM version](https://img.shields.io/npm/v/whoosh.svg?style=flat-square)](https://www.npmjs.com/package/whoosh)
[![NPM downloads](https://img.shields.io/npm/dm/whoosh.svg?style=flat-square)](https://www.npmjs.com/package/whoosh)
[![Build Status](https://img.shields.io/travis/guidesmiths/whoosh/master.svg)](https://travis-ci.org/guidesmiths/whoosh)
[![Code Climate](https://codeclimate.com/github/guidesmiths/whoosh/badges/gpa.svg)](https://codeclimate.com/github/guidesmiths/whoosh)
[![Test Coverage](https://codeclimate.com/github/guidesmiths/whoosh/badges/coverage.svg)](https://codeclimate.com/github/guidesmiths/whoosh/coverage)
[![Code Style](https://img.shields.io/badge/code%20style-imperative-brightgreen.svg)](https://github.com/guidesmiths/eslint-config-imperative)
[![Dependency Status](https://david-dm.org/guidesmiths/whoosh.svg)](https://david-dm.org/guidesmiths/whoosh)
[![devDependencies Status](https://david-dm.org/guidesmiths/whoosh/dev-status.svg)](https://david-dm.org/guidesmiths/whoosh?type=dev)
## Usage
## API
### Connecting
### connect(&lt;params;&gt;, &lt;cb&gt;)
Connect to an sftp server
```js

@@ -14,4 +23,4 @@ Whoosh.connect({

password: 'secret'
}, function(err, whoosh) {
// Do stuff with whoosh
}, (err, client) => {
// profit :)
})

@@ -21,38 +30,41 @@ ```

### What can I do with whoosh?
### disconnect(&lt;cb&gt;)
Disconnect from an sftp server
```
Whoosh.connect(config, (err, client) => {
client.disconnect(() => {
// Disconnected
})
})
```
#### isConnected (sync)
### isConnected()
Returns true when connected to the SFTP server. Useful for checking whether a previously established connection has dropped.
```js
Whoosh.connect(config, function(err, whoosh) {
if (err) return bail(err)
assert.ok(whoosh.isConnected())
whoosh.disconnect(function() {
assert.ok(!whoosh.isConnected())
)}
Whoosh.connect(config, (err, client) => {
if (err) throw err
client.isConnected() // returns true
})
```
#### isConnected (async)
### isConnected(&lt;cb&gt;)
Asynchronous version of isConnected
```js
Whoosh.connect(config, function(err, whoosh) {
if (err) return bail(err)
whoosh.isConnected(function(err, connected) {
assert.ok(connected)
whoosh.disconnect(function() {
whoosh.isConnected(function(err, connected) {
assert.ok(!connected)
})
})
Whoosh.connect(config, (err, client) => {
if (err) throw err
client.isConnected((err, connected) => {
// Check connected status here
)}
})
```
#### getContent
### getContent(&lt;path&gt;, [&lt;options&gt;], &lt;cb&gt;)
Streams the contents of a remote file to a variable
```js
Whoosh.connect(config, function(err, whoosh) {
if (err) return bail(err)
whoosh.getContent('some/remote/file', options, function(err, content, stats) {
whoosh.disconnect(function() {
if (err) return bail(err)
console.log('Downloaded ' + stats.bytes + ' bytes in ' + stats.duration + 'ms')
Whoosh.connect(config, (err, client) => {
if (err) throw err
client.getContent('some/remote/file', (err, content, stats) => {
client.disconnect(() => {
if (err) throw err
console.log(`Downloaded ${stats.bytes} bytes in ${stats.duration} ms`)
)}

@@ -64,12 +76,11 @@ })

#### putContent
### putContent(&lt;content;&gt;, &lt;path&gt;, [&lt;options&gt;], &lt;cb&gt;)
Streams the contents of a variable to a remote file
```js
var content = 'my content'
Whoosh.connect(config, function(err, whoosh) {
if (err) return bail(err)
whoosh.putContent('some/remote/file', content, options, function(err, stats) {
whoosh.disconnect(function() {
if (err) return bail(err)
console.log('Uploaded ' + stats.bytes + ' bytes in ' + stats.duration + 'ms')
Whoosh.connect(config, (err, client) => {
if (err) throw err
client.putContent('some conent', 'some/remote/file', (err, stats) => {
client.disconnect(() => {
if (err) throw err
console.log(`Uploaded ${stats.bytes} bytes in ${stats.duration} ms`)
})

@@ -81,10 +92,10 @@ })

#### exists
### exists
Reports on whether a remote file exists
```js
Whoosh.connect(config, function(err, whoosh) {
if (err) return bail(err)
whoosh.exists('some/remote/file', function(err, exists) {
whoosh.disconnect(function() {
if (err) return bail(err)
Whoosh.connect(config, function(err, client) {
if (err) throw err
client.exists('some/remote/file', (err, exists) => {
client.disconnect(() => {
if (err) throw err
console.log(exists ? 'File exists' : 'File does not exist')

@@ -95,11 +106,12 @@ )}

```
#### Everything else
The ```whoosh``` object is just a decorated instance of [SFTPStream](https://github.com/mscdex/ssh2-streams/blob/master/SFTPStream.md) so all the other SFTP methods are available. e.g.
## Everything else
The ```client``` object is just a decorated instance of [SFTPStream](https://github.com/mscdex/ssh2-streams/blob/master/SFTPStream.md) so all the other SFTP methods are available. e.g.
```js
Whoosh.connect(config, function(err, whoosh) {
if (err) return bail(err)
whoosh.unlink('some/remote/file', function(err) {
whoosh.disconnect(function() {
if (err) return bail(err)
Whoosh.connect(config, function(err, client) {
if (err) throw err
client.unlink('some/remote/file', function(err) {
client.disconnect(() => {
if (err) throw err
console.log('Deleted some/remote/file')

@@ -106,0 +118,0 @@ })

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc