All Projects → marcelowa → promise-all-properties

marcelowa / promise-all-properties

Licence: Unlicense license
A helper function that recevies an object with a promise in each property and returns a promise that resolves to an object with the same properties and the resolved values of the promises

Programming Languages

typescript
32286 projects

Labels

Projects that are alternatives of or similar to promise-all-properties

Promise Queue
Promise-based queue
Stars: ✭ 210 (+707.69%)
Mutual labels:  promise
Massive Js
A data mapper for Node.js and PostgreSQL.
Stars: ✭ 2,521 (+9596.15%)
Mutual labels:  promise
Escape From Callback Mountain
Example Project & Guide for mastering Promises in Node/JavaScript. Feat. proposed 'Functional River' pattern
Stars: ✭ 249 (+857.69%)
Mutual labels:  promise
Tickedoff
Tiny library (<200B gzip) for deferring something by a "tick"
Stars: ✭ 213 (+719.23%)
Mutual labels:  promise
Core Js
Standard Library
Stars: ✭ 15,854 (+60876.92%)
Mutual labels:  promise
Popsicle
Simple HTTP requests for node and the browser
Stars: ✭ 238 (+815.38%)
Mutual labels:  promise
Penpal
A promise-based library for securely communicating with iframes via postMessage.
Stars: ✭ 197 (+657.69%)
Mutual labels:  promise
fetchye
✨ If you know how to use Fetch, you know how to use Fetchye [fetch-yae]. Simple React Hooks, Centralized Cache, Infinitely Extensible.
Stars: ✭ 36 (+38.46%)
Mutual labels:  promise
Radwimps
君の then-then-then 世は Promise で Future
Stars: ✭ 229 (+780.77%)
Mutual labels:  promise
Task Easy
A simple, customizable, and lightweight priority queue for promises.
Stars: ✭ 244 (+838.46%)
Mutual labels:  promise
React Organism
Dead simple React state management to bring pure components alive
Stars: ✭ 219 (+742.31%)
Mutual labels:  promise
Wx Promise Request
解决微信小程序 wx.request 请求的并发数限制、不支持异步问题
Stars: ✭ 226 (+769.23%)
Mutual labels:  promise
Await Of
await wrapper for easier errors handling without try-catch
Stars: ✭ 240 (+823.08%)
Mutual labels:  promise
Promisejs.org
a promise website to document and promote
Stars: ✭ 210 (+707.69%)
Mutual labels:  promise
When
⏰ A lightweight implementation of Promises in Swift
Stars: ✭ 250 (+861.54%)
Mutual labels:  promise
Limitrr
Light NodeJS rate limiting and response delaying using Redis - including Express middleware.
Stars: ✭ 203 (+680.77%)
Mutual labels:  promise
Api
Promise and RxJS APIs around Polkadot and any Substrate-based chain RPC calls. It is dynamically generated based on what the Substrate runtime provides in terms of metadata. Full documentation & examples available
Stars: ✭ 232 (+792.31%)
Mutual labels:  promise
promise4j
Fluent promise framework for Java
Stars: ✭ 20 (-23.08%)
Mutual labels:  promise
Axios
Promise based HTTP client for the browser and node.js
Stars: ✭ 89,857 (+345503.85%)
Mutual labels:  promise
Spirit
Modern modular library for building web applications
Stars: ✭ 241 (+826.92%)
Mutual labels:  promise

Promise all properties

tests

A helper function that receives an object with a promise in each property and returns a promise that resolves to an object with the same properties and the resolved values of the promises.

The returned promise is rejected in the following cases:

  1. The input argument is not an "object"
  2. at least one of the promises is rejected

Requirements

  • ES6 Promise supporting javascript engine (browser or Node.js), or at least an ES6 Promise polyfill
  • yarn installed

Usage example (ES6/Typescript):

import promiseAllProperties from 'promise-all-properties';

const promisesObject = {
  someProperty: Promise.resolve('resolve value'),
  anotherProperty: Promise.resolve('another resolved value'),
};

const promise = promiseAllProperties(promisesObject);

promise.then((resolvedObject) => {
  console.log(resolvedObject);
  // {
  //   someProperty: 'resolve value',
  //   anotherProperty: 'another resolved value'
  // }
});

Breaking changes

v3.0.0

  • Passing an Array of values causes the promise to be rejected as invalid
  • Stricter TypeScript signature now errors on non-object arguments.

Developers

Run tests:

npm test

Build:

npm run build

Contributions:

PR's are welcome just make sure the the PR is squashed (one commit) and the commit messages starts with one of the following prefixes:

[INITIAL]: The initial commit
[FEAT]: Only changes that creating new features or modofying existing features, that are not bug fixes
[FIX]: Only bug fixes
[DOCS]: Only Documentation changes
[STYLE]: Only changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc)
[REFACTOR]: Only code changes that are neither fixes or features
[TEST]: Only changes that are adding new tests or modifying existing tests
[TOOLS]: Only changes that affect external processeses like build tools, dev tools, auxiliary tools and libraries such as documentation generation
[CLEANUP]: Only code removal: code lines, comment lines or files without affecting the project whatsoever

License

Public domain Unlicense

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].