UNPKG
imma
Version:
latest (0.0.1)
0.0.1
A collection of functions for dealing with native arrays and objects immutably
imma
/
lib
/
object
/
mapEntries.js
13 lines
(12 loc)
•
304 B
JavaScript
View Raw
1
2
3
4
5
6
7
8
9
10
11
12
13
'use strict'
const
mapEntries =
module
.
exports
=
(
object
, fn
) =>
{
const
result = {}
let
index =
0
for
(
let
key
in
object
) {
const
entry = [ key,
object
[key] ]
const
[ newKey, newValue ] =
fn
(entry, index,
object
) result[newKey] = newValue index++ }
return
result }