Skip to content

Commit

Permalink
better mapDEcorate support promise and normal function properly
Browse files Browse the repository at this point in the history
  • Loading branch information
ildella committed Jan 17, 2024
1 parent d3ec032 commit 97736f1
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
11 changes: 9 additions & 2 deletions fusto/exstream-extras.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,16 @@ __.extend('decorate', function (key, value) {
})

__.extend('mapDecorate', function (f, key) {
const isPromise = f instanceof Promise
if (isPromise === true)
// eslint-disable-next-line fp/no-this
return this.map(async item => {
const value = await f(item)
return {[key]: value, ...item}
})
// eslint-disable-next-line fp/no-this
return this.map(async item => {
const value = await f(item)
return this.map(item => {
const value = f(item)
return {[key]: value, ...item}
})
})
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "moar-js",
"version": "1.14.1",
"version": "1.14.2",
"description": "Simple JavaScript files I use across projects",
"author": {
"name": "Daniele Dellafiore"
Expand Down

0 comments on commit 97736f1

Please sign in to comment.