UNPKG

@helpscout/helix

Version:

A Faker-powered fixture generator for Javascript

42 lines (35 loc) 1.08 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = void 0; var _lodash = require("lodash"); /** * Function remap the Faker class/object, to replace methods with functions * that don't automatically execute. This function works recursively to walk * down the entire Faker API tree. * * @param object $object Faker object/nested Faker object * * @returns object */ var remapFakerObject = function remapFakerObject(object) { return (0, _lodash.mapValues)(object, function (value, key) { if ((0, _lodash.isObject)(value) && !(0, _lodash.isFunction)(value)) { return remapFakerObject(value); } if ((0, _lodash.isFunction)(value)) { return function () { for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { args[_key] = arguments[_key]; } return function () { return value.apply(void 0, args); }; }; } return value; }); }; var _default = remapFakerObject; exports.default = _default;