import { Map } from "immutable"; import { compose } from "@typed/compose"; import { CallStatus, ValueType } from "./enums"; import CreateImmutable from "./util/CreateImmutable"; import Those from "./util/Those"; import Exclude from "./util/Exclude"; import ValueMap, { KeyMap } from "./types/ValueMap"; const ExcludeReservedWords = Those(Exclude, ["get", "set"]); /** * @method ValueMap Preps all static and network keys with their default values for the Context store * @param {KeyMap} storeValues static values * @param {string[]} staticKeys values (undefined or with default value) that will be filled with an API call * @return {ValueMap} squashed together ValueMap */ export default ( storeValues: KeyMap, // mutable values staticKeys: string[] // immutable values ): ValueMap => { const newMap: ValueMap = {}; if (!!storeValues) { compose( ExcludeReservedWords, Object.keys )(storeValues).forEach((key: string) => { newMap[key] = CreateImmutable(storeValues[key]); }); } if (!!staticKeys) { ExcludeReservedWords(staticKeys).forEach((key: string) => { newMap[key] = CreateImmutable(storeValues[key], true); }); } return newMap; };