collapse-decorator

1.0.0 • Public • Published

Collapse Decorator Build Status Coverage Status

A decorator to collapse promises into a single pending promise to be used with async api calls.

Install

npm install collapse-decorator

Usage

import { Collapse } from 'collapse-decorator';
 
 
class Example {
    @Collapse(1000)
    callApi(param) {
        return new Promise((resolve, reject) => {
            // do something
        });
    }
}

Custom Hash-Builder

Sometimes it is necessary to use a custom hash builder function, especially if objects are passed as parameters.

import { Collapse } from 'collapse-decorator';
 
 
class Example {
    @Collapse(1000, options => `${options.secure}/${options.path}`)
    callApi(options) {
        return new Promise((resolve, reject) => {
            // do something
        });
    }
}

This will create a hash string for an object, this is not supported by the default hash function.

Dependencies (0)

    Dev Dependencies (21)

    Package Sidebar

    Install

    npm i collapse-decorator

    Weekly Downloads

    1

    Version

    1.0.0

    License

    none

    Last publish

    Collaborators

    • mgeppert