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 {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 {invoke as invokeHook, invokeFlat as invokeHookFlat} from './hook/registry';
export {iterateForEach} from './iterator';
export {merge} from './merge'; export {merge} from './merge';
export { export {
mergeDiff, mergeDiff,
@ -8,9 +16,9 @@ export {
mergeDiffObject, mergeDiffObject,
mergeDiffPrimitive, mergeDiffPrimitive,
} from './merge-diff'; } from './merge-diff';
export {inflate, deflate} from './flate'; export {
export {compose, fastApply} from './function'; map as mapObject,
export {iterateForEach} from './iterator'; } from './object';
export {PropertyMixin as Property} from './property'; export {PropertyMixin as Property} from './property';
export {TickingPromise} from './ticking-promise'; export {TickingPromise} from './ticking-promise';
export {virtualize, virtualizeStatic} from './virtualize'; 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;
}