Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/philipjscott/partial-load

Download part of a file :floppy_disk:
https://github.com/philipjscott/partial-load

Last synced: about 1 month ago
JSON representation

Download part of a file :floppy_disk:

Awesome Lists containing this project

README

        

# partial-load

Download part of a file.

## Installation

```bash
$ yarn add partial-load

# Or,

$ npm install partial-load --save
```

## Usage

```js
const partialDownload = require('partial-load')

const url = 'https://www.w3schools.com/html/mov_bbb.webm'
const megabyte = 1024 * 1024

// stop loading once 1MB has been exceeded
partialDownload(url, './output/file.webm', megabyte)
.then((bytes) => console.log('Downloaded ', bytes, ' bytes!'))
```

## API

#### partialLoad(url, output, byteLimit)

Returns of a `Promise` which resolves to the number of loaded bytes.

#### url

Type: `String`

The url of the file.

#### output

Type: `String`

The file path of the output, assumes directory exists.

#### byteLimit

Type: `Number`

The byte limit threshold; the load will stop once the byte limit has been exceeded.