-
-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b8ae27b
commit 41c2559
Showing
7 changed files
with
81 additions
and
92 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,9 @@ | ||
'use strict'; | ||
const pMap = require('p-map'); | ||
import pMap from 'p-map'; | ||
|
||
const pProps = async (input, mapper = (value => value), options = undefined) => { | ||
export default async function pProps(input, mapper = (value => value), options = undefined) { | ||
const isMap = input instanceof Map; | ||
const entries = isMap ? [...input.entries()] : Object.entries(input); | ||
const values = await pMap(entries, async ([key, value]) => mapper(await value, key), options); | ||
const mappedEntries = entries.map(([key], index) => [key, values[index]]); | ||
return isMap ? new Map(mappedEntries) : Object.fromEntries(mappedEntries); | ||
}; | ||
|
||
module.exports = pProps; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters