0.0.5 • Published 6 years ago

npm-promise-one v0.0.5

Weekly downloads
1
License
ISC
Repository
-
Last release
6 years ago

Introduction

Currently there is Promise.all to resolve an array of promises concurrently. Sometime there is a need to resolve these promises one at a time.

Input an array and a callback that will use the array element to generate a promise. The second callback is to handle the data. It will then return an array of the concatenated outputs.

Example

"use strict";

const axios = require('axios');
const p = require('npm-promise-one');

const array = [1, 3, 7, 11, 51];
const url = 'https://jsonplaceholder.typicode.com/posts/';

function getPost(i) {
  return axios.get(url + i);
}

function process(response) {
  return response.data;
}

p.one(array, getPost, process).then(function(result) {
  console.log(result);
});
0.0.5

6 years ago

0.0.4

6 years ago

0.0.3

6 years ago

0.0.2

6 years ago

0.0.1

6 years ago