flow like the river
This commit is contained in:
commit
013fe673f3
42435 changed files with 5764238 additions and 0 deletions
20
BACK_BACK/node_modules/graphql/jsutils/mapValue.js.flow
generated
vendored
Executable file
20
BACK_BACK/node_modules/graphql/jsutils/mapValue.js.flow
generated
vendored
Executable file
|
|
@ -0,0 +1,20 @@
|
|||
// @flow strict
|
||||
import objectEntries from '../polyfills/objectEntries';
|
||||
|
||||
import type { ObjMap } from './ObjMap';
|
||||
|
||||
/**
|
||||
* Creates an object map with the same keys as `map` and values generated by
|
||||
* running each value of `map` thru `fn`.
|
||||
*/
|
||||
export default function mapValue<T, V>(
|
||||
map: ObjMap<T>,
|
||||
fn: (value: T, key: string) => V,
|
||||
): ObjMap<V> {
|
||||
const result = Object.create(null);
|
||||
|
||||
for (const [key, value] of objectEntries(map)) {
|
||||
result[key] = fn(value, key);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue