Collapse Decorator

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) => {
});
}
}
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) => {
});
}
}
This will create a hash string for an object, this is not supported by the default hash function.