feat: mapObject

This commit is contained in:
cha0s 2020-05-21 08:56:10 -05:00
parent ada5754083
commit 8c876f7efb
2 changed files with 21 additions and 4 deletions

View File

@ -1,6 +1,14 @@
export {arrayUnique, flatten, fromObject as arrayFromObject} from './array';
export {
arrayUnique,
flatten,
fromObject as arrayFromObject,
shuffleInPlace
} from './array';
export {EventEmitterMixin as EventEmitter} from './event-emitter';
export {inflate, deflate} from './flate';
export {compose, fastApply} from './function';
export {invoke as invokeHook, invokeFlat as invokeHookFlat} from './hook/registry';
export {iterateForEach} from './iterator';
export {merge} from './merge';
export {
mergeDiff,
@ -8,9 +16,9 @@ export {
mergeDiffObject,
mergeDiffPrimitive,
} from './merge-diff';
export {inflate, deflate} from './flate';
export {compose, fastApply} from './function';
export {iterateForEach} from './iterator';
export {
map as mapObject,
} from './object';
export {PropertyMixin as Property} from './property';
export {TickingPromise} from './ticking-promise';
export {virtualize, virtualizeStatic} from './virtualize';

9
packages/core/object.js Normal file
View File

@ -0,0 +1,9 @@
export function map(O, fn) {
const keys = Object.keys(O);
const result = {};
for (let i = 0; i < keys.length; i++) {
const key = keys[i];
result[key] = fn(O[key]);
}
return result;
}