map-transform
Version:
Map and transform objects with mapping definitions
14 lines • 570 B
JavaScript
import { pathGetter } from '../operations/getSet.js';
const extractPath = (path) => typeof path === 'string' ? path : path.path;
const transformer = function get(props) {
return () => {
const path = extractPath(props) || '.';
if (typeof path !== 'string' && path !== undefined) {
throw new TypeError("The 'get' transformer does not allow `path` to be a pipeline");
}
const mapper = pathGetter(path);
return (data, state) => mapper(data, state);
};
};
export default transformer;
//# sourceMappingURL=get.js.map