# nightmare-inline-download

> Add inline download management to NightmareJS

Latest version **0.2.2** (published 2016-07-08) · MIT license · 0 weekly downloads

## Install

```sh
npm install nightmare-inline-download
pnpm add nightmare-inline-download
yarn add nightmare-inline-download
bun add nightmare-inline-download
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.2.2 |
| Published | 2016-07-08 |
| First published | 2016-04-02 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 36 |
| Author | Ross Hinkley |
| Maintainers | rosshinkley |
| Keywords | nightmare, phantomjs, download, downloads |

## Links

- npm: https://www.npmjs.com/package/nightmare-inline-download
- Repository: https://github.com/rosshinkley/nightmare-inline-download
- Homepage: https://github.com/rosshinkley/nightmare-inline-download#readme
- Issues: https://github.com/rosshinkley/nightmare-inline-download/issues
- npm.io page: https://npm.io/package/nightmare-inline-download

## Dependencies (2)

- [debug](https://npm.io/package/debug.md) ^2.2.0
- [sliced](https://npm.io/package/sliced.md) ^1.0.1

## Recent versions

- 0.2.2 (latest) — 2016-07-08
- 0.2.1 — 2016-06-21
- 0.2.0 — 2016-05-22
- 0.1.1 — 2016-04-08
- 0.1.0 — 2016-04-02

## README

nightmare-inline-download
======================

Add inline download management to your [Nightmare](http://github.com/segmentio/nightmare) scripts.

# Important Note
If you need to manage multiple downloads at the same time or want downloads to be processed in the background, check out the [Nightmare download manager](https://github.com/rosshinkley/nightmare-download-manager).

## Usage
Require the library: and pass the Nightmare library as a reference to attach the plugin actions:

```js
var Nightmare = require('nightmare');
require('nightmare-inline-download')(Nightmare);
```

... and that's it.  You should now be able to handle downloads.

### .download([path|action])

Allows for downloads to be saved to a custom location or cancelled.  The possible values for `action` are `'cancel'`, `'continue'` for default behavior, or a file path (file name and extension inclusive) to save the download to an alternative location.  If yielded upon, `.download()` returns a hash of download information:

* **filename**:  the filename the server sent.
* **mimetype**: the mimetype of the download.
* **receivedBytes**: the number of bytes received for a download.
* **totalBytes**: the number of bytes to expect if `Content-length` is set as a header.
* **url**: the address of where the download is being sent from.
* **path**: specifies the save path for the download.
* **state**: the state of the download.  At yield, `state` can be `'cancelled'`, `'interrupted'`, or `'completed'`.

## Additional Nightmare Options

### ignoreDownloads
Defines whether or not all downloads should be ignored.

### maxDownloadRequestWait
Sets the maximum time for the client to anticipate a `.download()` call.  If the call is not made, the download is automatically cancelled.

### paths.downloads
Sets the Electron path for where downloads are saved.

## Example

```javascript
var Nightmare = require('nightmare');
require('nightmare-inline-download')(Nightmare);
var nightmare = Nightmare();
var downloadInfo = nightmare
  .goto('https://github.com/segmentio/nightmare')
  .click('a[href="/segmentio/nightmare/archive/master.zip"]')
  .download('/some/other/path/master.zip');

// ... do something with downloadInfo, in an evaluate for example ...

  .end()
  .then(()=>console.log('done'));
```

---
_Source: https://npm.io/package/nightmare-inline-download · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
