Skip to content
This repository was archived by the owner on Nov 17, 2018. It is now read-only.

mxjp/node-delayed-promise

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

delayed-promise

Travis npm npm

Utility for delayed promise rejection handling


Installation

npm install delayed-promise

Usage

const wrap = require('delayed-promise');

async function example() {
	// Wrap a promise to retrieve it's state later:
	const unwrap = wrap(promise);

	// ...Other async code...

	// Unwrap the promise & retrieve it's state:
	await unwrap();
}

wrap(value)

Wraps a promise or a value to store it's state in the back.

  • value <any> - If a promise, it will be wrapped, if a value, the unwrap function will return a promise that resolves to this value.
  • returns <function> - The unwrapping function as described below.

unwrap()

Returns a promise that,

  • resolves when the wrapped promise resolves.
  • rejects when the wrapped promise rejects.
  • resolves to a value if the value passed to wrap(..) was not a promise.

Running tests

npm install
npm test

Releases

No releases published

Packages

 
 
 

Contributors