UNPKG

util-helpers

Version:

一个基于业务场景的工具方法库

25 lines (22 loc) 846 B
import { isPlainObject, forEach, isArray } from 'ut2'; var transformObjectValue = function (data, fn, deep) { if (deep === void 0) { deep = true; } if (isPlainObject(data)) { var result_1 = {}; forEach(data, function (value, key) { var newValue = deep && (isPlainObject(value) || isArray(value)) ? transformObjectValue(value, fn) : fn(value, key); result_1[key] = newValue; }); return result_1; } else if (isArray(data)) { var result_2 = []; forEach(data, function (value, index) { var newValue = deep && (isPlainObject(value) || isArray(value)) ? transformObjectValue(value, fn) : fn(value, index); result_2.push(newValue); }); return result_2; } return data; }; export { transformObjectValue as default };