@fatcherjs/middleware-progress
TypeScript icon, indicating that this package has built-in type declarations

2.0.0 • Public • Published

@fatcherjs/middleware-progress

A Middleware for getting progress

Install

NPM

>$ npm install @fatcherjs/middleware-progress

CDN

<script src="https://cdn.jsdelivr.net/npm/@fatcherjs/middleware-progress/dist/progress.min.js"></script>

Usage

import { progress } from '@fatcherjs/middleware-progress';
import { fatcher } from 'fatcher';

fatcher({
    url: '/bar/foo',
    middlewares: [
        progress({
            onDownloadProgress: (current, total) => {
                console.log(current / total);
            },
        }),
    ],
    payload: {
        bar: 'foo',
    },
})
    .then(res => {
        console.log(res);
    })
    .catch(err => {
        console.error(error);
    });

Options

Name Description Type DefaultValue
onDownloadProgress Callback with read stream chunks ((current: number, total: number) => void) | null null
lengthName Custom name in headers with content-length` string 'content-length'

License

MIT

Readme

Keywords

none

Package Sidebar

Install

npm i @fatcherjs/middleware-progress

Weekly Downloads

8

Version

2.0.0

License

MIT

Unpacked Size

6.67 kB

Total Files

7

Last publish

Collaborators

  • fanhaoyuan