Skip to content

feathers-studio/Promise.object

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

📤 Promise.object

Promise.object is Promise.all for objects, and it traverses deeply! It's also fully typed.

Installation

npm install --save @codefeathers/promise.object

Usage

import promiseObject from "@codefeathers/promise.object";

const resolved = await promiseObject({
	foo: Promise.resolve(5),
	bar: {
		baz: Promise.resolve([ 1, 2, 3 ])
	}
});

console.log(resolved);
//-> { foo: 5, bar: { baz: [ 1, 2, 3 ] } }

We need to go deeper!

import promiseObject from "@codefeathers/promise.object";

const resolved = await promiseObject(
	Promise.resolve({
		foo: Promise.resolve({
			bar: Promise.resolve(5)
		})
	})
);

console.log(resolved);
//-> { foo: { bar: 5 } }

Deno

import promiseObject from "https://deno.land/x/promise_object@v0.10.0";

Credits

The original idea and challenge was from @TRGWII.