# fetch-files

> Download files using presets.

Latest version **0.1.0** (published 2015-08-19) · MIT license · 0 weekly downloads

## Install

```sh
npm install fetch-files
pnpm add fetch-files
yarn add fetch-files
bun add fetch-files
```

## 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.1.0 |
| Published | 2015-08-19 |
| First published | 2015-08-19 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=0.10.0 |
| Dependencies | 6 |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 3 |
| Author | Jon Schlinkert |
| Maintainers | jonschlinkert |

## Links

- npm: https://www.npmjs.com/package/fetch-files
- Repository: https://github.com/jonschlinkert/fetch-files
- Issues: https://github.com/jonschlinkert/fetch-files/issues
- npm.io page: https://npm.io/package/fetch-files

## Dependencies (6)

- [write](https://npm.io/package/write.md) ^0.2.1
- [request](https://npm.io/package/request.md) ^2.60.0
- [async-each](https://npm.io/package/async-each.md) ^0.1.6
- [lazy-cache](https://npm.io/package/lazy-cache.md) ^0.2.1
- [object.omit](https://npm.io/package/object.omit.md) ^2.0.0
- [extend-shallow](https://npm.io/package/extend-shallow.md) ^2.0.1

## Recent versions

- 0.1.0 (latest) — 2015-08-19

## README

# fetch-files [![NPM version](https://badge.fury.io/js/fetch-files.svg)](http://badge.fury.io/js/fetch-files)

> Download files using presets.

## Install

Install with [npm](https://www.npmjs.com/)

```sh
$ npm i fetch-files --save
```

## Usage

```js
var FetchFiles = require('fetch-files');
var downloader = new FetchFiles({destBase: 'foo/bar'});
```

## API

### [FetchFiles](index.js#L25)

Create an instance of `FetchFiles` with the given `options`.

**Params**

* `options` **{Object}**

### [.preset](index.js#L53)

Store a preset with the given configuration values.

**Params**

* `name` **{String}**: Preset name, e.g. `github`
* `config` **{Object}**
* `returns` **{Object}**: Returns `FetchFiles` for chaining

**Example**

```js
downloader.preset('github', {
  url: 'https://raw.githubusercontent.com',
  fn: function (preset, config) {
    config.pathname = config.url.split('/').slice(-3).join('_');
    return preset.url;
  }
});
```

### [.queue](index.js#L74)

Add a URL to the download queue.

**Params**

* `url` **{String}**
* `config` **{Object}**: The configuration to use for the URL.
* `returns` **{Object}**: Returns `FetchFiles` for chaining

**Example**

```js
downloader.queue('/assemble/assemble/v0.6.0/.verb.md', {preset: 'github'});
```

### [.fetch](index.js#L119)

Fetch all files in the queue.

**Params**

* `cb` **{Function}**: callback
* `returns` **{Object}**: Returns `FetchFiles` for chaining

**Example**

```js
downloader.fetch(function (err, res) {
  console.log(res);
});
```

## Complete example

Fetch three files from three different GitHub repos:

```js
var FetchFiles = require('fetch-files');
var downloader = new FetchFiles({destBase: 'foo/bar'});

downloader.preset('github', {
    url: 'https://raw.githubusercontent.com',
    fn: function (preset, config) {
      config.pathname = config.url.split('/').slice(-3).join('_');
      return preset.url;
    }
  })
  .queue('/assemble/assemble/v0.6.0/.verb.md', {preset: 'github'})
  .queue('/jonschlinkert/template/master/.verb.md', {preset: 'github'})
  .queue('/verbose/verb/master/.verb.md', {preset: 'github'})
  .fetch(function (err, res) {
    if (err) console.error(err);
    console.log(res)
  })
```

## Related projects

* [github-base](https://github.com/jonschlinkert/github-base): Base methods for creating node.js apps that work with the GitHub API.
* [gists](https://github.com/jonschlinkert/gists): Methods for working with the GitHub Gist API. Node.js/JavaScript

## Running tests

Install dev dependencies:

```sh
$ npm i -d && npm test
```

## Contributing

Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](https://github.com/jonschlinkert/fetch-files/issues/new)

## Author

**Jon Schlinkert**

+ [github/jonschlinkert](https://github.com/jonschlinkert)
+ [twitter/jonschlinkert](http://twitter.com/jonschlinkert)

## License

Copyright © 2015 Jon Schlinkert
Released under the MIT license.

***

_This file was generated by [verb-cli](https://github.com/assemble/verb-cli) on August 19, 2015._

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