Introducing Socket Firewall: Free, Proactive Protection for Your Software Supply Chain.Learn More
Socket
Book a DemoInstallSign in
Socket

promise-ext-delay

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

promise-ext-delay

Simple delay promise

latest
Source
npmnpm
Version
1.0.4
Version published
Weekly downloads
8
33.33%
Maintainers
1
Weekly downloads
 
Created
Source

Build Status

PromiseDelay

Simple delay promise.

Usage

require('promise-ext-delay')();

Promise.delay(1000).then(function(){...})

Description

This is realization of a small and simple delay promise, that supports CommonJS, AMD ang non-module definition.

The module is function, that extends any promise constructor and first of all, you'll need to call this function to extend promise constructor.

Injection for CommonJS:

require('promise-ext-delay')();

Injection for AMD:

require(['promiseDelay'], function(PromiseDelay){
    PromiseDelay();
});

Injection for non-module environment:

<script src="promiseDelay.min.js"></script>
<script>
    PromiseDelay(); //in non-module environment, global function PromiseDelay will be created
</script>

The function that injects delay promise have 2 parameters:

  • PromiseConstructor - just function-constructor, that will be extended. If nothing is passed, then default promise constructor will be used.
  • extName - name of the delay function/method. If nothing is passed, then delay will be used. Can be passed instead of the first parameter.

Some examples of injection:

PromiseDelay(); //or
PromiseDelay(YourCustomPromiseConstructor, 'methodName'); //or
PromiseDelay('methodName');

After injection, you'll may use delay promise:

As static function

Promise.delay(1000).then(function(){...})

Or as object method

var p = new Prmise(function(resolve){
    resolve('some value');
});

p.delay(5000).then(function(){...});

Notice that delay promise will pass promise value through itself, therefore you'll receive your value in promise chain after delay promise.

Keywords

promise

FAQs

Package last updated on 25 Jan 2016

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