promise-data

0.1.5 • Public • Published

PromiseData

Build Coverage Status Dependencies

Executes a list of promises and stores the the results in a data object

Installation

This is a Node.js module available through the npm registry.

Before installing, download and install Node.js.

Installation is done using the npm install command:

$ npm install promise-data

Usage

Import

import PromiseData from 'promise-data';

Runs Promises Synchronously

PromiseData.sync([
  {prop: 'prop0', promise: () => myPromise('param')},
  {prop: 'prop1', promise: mySecondPromise}
]).then(function(data) {
  console.log(data.prop0); // the result from myPromise('param')
  console.log(data.prop1); // the result from mySecondPromise()
});

Runs Promises Asynchronously

PromiseData.async([
  {prop: 'prop0', promise: () => myPromise('param');},
  {prop: 'prop1', promise: mySecondPromise}
]).then(function(data) {
  console.log(data.prop0); // the result from myPromise('param')
  console.log(data.prop1); // the result from mySecondPromise()
});

Simplified Data Format

PromiseData.async({
  prop0: () => myPromise('param'),
  prop1: mySecondPromise
}).then(function(data) {
  console.log(data.prop0); // the result from myPromise('param')
  console.log(data.prop1); // the result from mySecondPromise()
});

Credits

License

The MIT License

Copyright (c) 2018 Thomas Boles [https://github.com/tcboles]

Readme

Keywords

none

Package Sidebar

Install

npm i promise-data

Weekly Downloads

1

Version

0.1.5

License

MIT

Unpacked Size

18.9 kB

Total Files

12

Last publish

Collaborators

  • tcboles