UNPKG

ramda-extension

Version:

Helpful functions built on top of the mighty Ramda

32 lines (31 loc) 821 B
import { o, fromPairs, map } from 'ramda'; import duplicate from './duplicate'; /** * Creates object mirror from list of keys. * * @func * @category Object * * * @param {Array} keyList List of values representing the keys and values of resulting object. * * @return {Object} Object, where keys and appropriate values equals to value in `keyList`. * * @example * * const actionTypes = R_.valueMirror([ * 'ITEM_REQUEST', * 'ITEM_SUCCESS', * 'ITEM_ERROR', * ]); * * const action = { type: actionTypes.ITEM_REQUEST }; * * action.type === actionTypes.ITEM_REQUEST // true * actionTypes.ITEM_SUCCESS // "ITEM_SUCCESS" * * @sig [String] -> Object * */ var valueMirror = /*#__PURE__*/o(fromPairs, /*#__PURE__*/map(duplicate)); export default valueMirror;