🚀 Launch Week Day 2:Introducing Custom Tabs for Org Alerts.Learn More →
Socket
Book a DemoInstallSign in
Socket

fetch-files

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fetch-files

Download files using presets.

latest
Source
npmnpm
Version
0.1.0
Version published
Maintainers
1
Created
Source

fetch-files NPM version

Download files using presets.

Install

Install with npm

$ npm i fetch-files --save

Usage

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

API

FetchFiles

Create an instance of FetchFiles with the given options.

Params

  • options {Object}

.preset

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

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

.queue

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

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

.fetch

Fetch all files in the queue.

Params

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

Example

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

Complete example

Fetch three files from three different GitHub repos:

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)
  })
  • github-base: Base methods for creating node.js apps that work with the GitHub API.
  • gists: Methods for working with the GitHub Gist API. Node.js/JavaScript

Running tests

Install dev dependencies:

$ npm i -d && npm test

Contributing

Pull requests and stars are always welcome. For bugs and feature requests, please create an issue

Author

Jon Schlinkert

License

Copyright © 2015 Jon Schlinkert Released under the MIT license.

This file was generated by verb-cli on August 19, 2015.

FAQs

Package last updated on 19 Aug 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts