tuchk4 / apop

2 stars 1 forks source link

v2.2.1 #26

Closed marvelsrp closed 7 years ago

marvelsrp commented 7 years ago

2.2.1 (May 18, 2017)

tuchk4 commented 7 years ago

@marvelsrp please add short examaple how to use eachKeys in PR descr.

marvelsrp commented 7 years ago

@tuchk4 Example

import rmk from 'rmk';

let formula = rmk(rmk.each((key, value) => {
 return {key: key + '_', value: value * 2}
})
let data = {a:1, b: 2, c: 3, d: 4}
formula(data)
// or
rmk.clear()(data)
// => {a_: 2, b_: 4, c_: 6, d_: 8}

I thought to use {[key]: value}. But it is slower:

let key = Object(t).keys[0];
result[key] = t[key];

than

result[t.key] = t.value;