New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

collapse-decorator

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

collapse-decorator

A decorator / annotation to collapse async promises, to have instead of hundred pending promises only one.

  • 1.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1
decreased by-50%
Maintainers
1
Weekly downloads
 
Created
Source

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.

Keywords

FAQs

Package last updated on 14 Feb 2017

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc