You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
21 lines
542 B
JavaScript
21 lines
542 B
JavaScript
'use strict';
|
|
|
|
const promiseTry = require("es6-promise-try");
|
|
const defaultValue = require("./");
|
|
|
|
function promiseThatReturns(value) {
|
|
return Promise.resolve(value);
|
|
}
|
|
|
|
console.log(defaultValue(null, () => 4));
|
|
console.log(defaultValue("foo", "bar"));
|
|
|
|
promiseTry(() => {
|
|
return Promise.all([
|
|
defaultValue.async(promiseThatReturns(undefined), promiseThatReturns(Infinity)),
|
|
defaultValue.async(() => promiseThatReturns("baz"), promiseThatReturns("qux"))
|
|
]);
|
|
}).then((results) => {
|
|
console.log(results[0]);
|
|
console.log(results[1]);
|
|
}) |