Skip to content

Commit

Permalink
fix example
Browse files Browse the repository at this point in the history
  • Loading branch information
richytong committed Dec 15, 2024
1 parent 2042ad3 commit 4fdfa54
Showing 1 changed file with 7 additions and 24 deletions.
31 changes: 7 additions & 24 deletions all.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,12 +113,15 @@ const _allValues = function (values) {
* getAndLogUserById('1') // Got user {"_id":1,"name":"George"} by id 1
* ```
*
* Values passed in resolver position are set on the result object or array directly. If any of these values are promises, they are resolved for their values before being set on the result object or array.
* Values may be provided along with functions, in which case they are set on the result object or array directly. If any of these values are promises, they are resolved for their values before being set on the result object or array.
*
* ```javascript [playground]
* all({}, [
* Promise.resolve(1),
* ])
* all({}, {
* a: Promise.resolve(1),
* b: 2,
* c: () => 3,
* d: async () => 4,
* }).then(console.log) // { a: 1, b: 2, c: 3, d: 4 }
* ```
*
* Any promises passed in argument position are resolved for their values before further execution. This only applies to the eager version of the API.
Expand Down Expand Up @@ -161,26 +164,6 @@ const all = function (...args) {
return isArray(resolversOrValues)
? functionArrayAll(resolversOrValues, argValues)
: functionObjectAll(resolversOrValues, argValues)

/*
////////////////////////////////////////////////////////////////
const funcs = args.pop()
if (args.length == 0) {
return isArray(funcs)
? curryArgs2(functionArrayAll, funcs, __)
: curryArgs2(functionObjectAll, funcs, __)
}
if (areAnyValuesPromises(args)) {
return isArray(funcs)
? promiseAll(args).then(curry2(functionArrayAll, funcs, __))
: promiseAll(args).then(curry2(functionObjectAll, funcs, __))
}
return isArray(funcs)
? functionArrayAll(funcs, args)
: functionObjectAll(funcs, args)
*/
}

/**
Expand Down

0 comments on commit 4fdfa54

Please sign in to comment.