How to use the ramda-extension.mapKeys function in ramda-extension

To help you get started, we’ve selected a few ramda-extension examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github lundegaard / redux-tools / packages / reducers / src / reducers.js View on Github external
always(alwaysEmptyObject),
	o(combineReducers, map(when(isPlainObject, object => recurseCombineReducers(object))))
);

const removeSuffix = o(head, split('@'));

/**
 * Attempts to recursively remove suffixes from all keys of an object.
 * If no suffix is present, the key will be skipped.
 *
 * @param {Object} object object to remove the suffixes from
 * @returns {Object} object with suffixes removed
 */
export const removeSuffixFromKeys = o(
	map(when(isPlainObject, object => removeSuffixFromKeys(object))),
	mapKeys(removeSuffix)
);

/**
 * Combines the reducers to create a new reducer. Uses `combineReducers` under the hood
 * and removes all suffixes.
 *
 * @param {Object} injectedReducers recursively nested object with reducers as values
 * @returns {Function} root reducer
 */
export const makeRootReducer = o(recurseCombineReducers, removeSuffixFromKeys);

/**
 * Returns Redux state by namespace. Returns undefined if namespace is undefined.
 *
 * @param {?string} namespace optional namespace
 * @param {Object} state Redux state
github lundegaard / redux-tools / packages / injectors-react / src / withSuffixing.js View on Github external
export default function withSuffixing(NextComponent) {
	class WithSuffixing extends Component {
		static propTypes = {
			namespace: PropTypes.string,
		};

		static displayName = `WithSuffixing(${getDisplayName(NextComponent)})`;

		id = counter++;

		suffixKeys = o(
			map(when(isPlainObject, object => this.suffixKeys(object))),
			mapKeys(suffix(this.id))
		);

		render() {
			return ;
		}
	}

	return WithSuffixing;
}