promise

promise

Source:

Example

import promise from '@fantaptik/core';

promise.reject( 1000, "error" ).catch( e => console.log( e ) ); // "error" after 1s
promise.resolve( 500, ["a", "b"] ).then( data => console.log( data ) ); // ["a", "b"] after .5s

Methods

(static) reject(timeout, result) → {Promise}

Source:

reject returns a promise that will reject after the specified timeout with result.

Parameters:
Name Type Description
timeout number

Timeout in ms.

result *

The result to reject.

Returns:
Type
Promise

(static) reject(timeout, result) → {Promise}

Source:

resolve returns a promise that will resolve after the specified timeout with result.

Parameters:
Name Type Description
timeout number

Timeout in ms.

result *

The result to resolve.

Returns:
Type
Promise