
Product
Introducing Custom Tabs for Org Alerts
Create and share saved alert views with custom tabs on the org alerts page, making it easier for teams to return to consistent, named filter sets.
resolve-value
Advanced tools
Deeply resolve all promises in a value.
Please consider following this project's author, Jon Schlinkert, and consider starring the project to show your :heart: and support.
Install with npm (requires Node.js >=10):
$ npm install --save resolve-value
const resolve = require('resolve-value');
assert.equal(await resolveValue(10), 10); //=> 10
assert.equal(await resolveValue(Promise.resolve(10)), 10); //=> 10
Functions
By default all functions are called.
assert.equal(await resolveValue(() => Promise.resolve(10)), 10); //=> 10
assert.equal(await resolveValue(async () => Promise.resolve(10)), 10); //=> 10
Pass a custom replacer function as the second argument to override this behavior.
const obj = { fn: () => 'do nothing', num: Promise.resolve(10) };
const result = await resolveValue(obj, (value, parent) => {
if (parent && parent.someKey === true) {
return value;
}
return value();
});
console.log(result.fn); //=> [Function: fn]
Objects
Resolves all property values, including functions.
const obj = { foo: async () => delay('bar', 10), num: Promise.resolve(10) };
const actual = await resolve(obj);
//=> { foo: 'bar', num: 10 }
Deeply nested
const obj = { foo: async () => delay('bar', 10), num: Promise.resolve(10) };
const arr = [obj, Promise.resolve(1), Promise.resolve(() => 2)];
const actual = await resolve(arr);
//=> [ { foo: 'bar', num: 10 }, 1, 2 ]
Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.
Please read the contributing guide for advice on opening issues, pull requests, and coding standards.
Running and reviewing unit tests is a great way to get familiarized with a library and its API. You can install dependencies and run tests with the following command:
$ npm install && npm test
(This project's readme.md is generated by verb, please don't edit the readme directly. Any changes to the readme must be made in the .verb.md readme template.)
To generate the readme, run the following command:
$ npm install -g verbose/verb#dev verb-generate-readme && verb
Jon Schlinkert
Copyright © 2021, Jon Schlinkert. Released under the MIT License.
This file was generated by verb-generate-readme, v0.8.0, on April 19, 2021.
FAQs
Deeply resolve all promises in a value.
The npm package resolve-value receives a total of 16 weekly downloads. As such, resolve-value popularity was classified as not popular.
We found that resolve-value demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Product
Create and share saved alert views with custom tabs on the org alerts page, making it easier for teams to return to consistent, named filter sets.

Product
Socket’s Rust and Cargo support is now generally available, providing dependency analysis and supply chain visibility for Rust projects.

Security News
Chrome 144 introduces the Temporal API, a modern approach to date and time handling designed to fix long-standing issues with JavaScript’s Date object.