t-comm
Version:
专业、稳定、纯粹的工具库
27 lines (24 loc) • 597 B
JavaScript
import _typeof from '@babel/runtime/helpers/typeof';
function updateChildId(data) {
if (data === null || data === void 0 ? void 0 : data.child_id_new) {
data.child_id = data.child_id_new;
}
}
function traverseResp(data, cb) {
if (cb === void 0) {
cb = updateChildId;
}
if (_typeof(data) === 'object') {
cb(data);
if (Array.isArray(data)) {
data.forEach(function (item) {
return traverseResp(item);
});
} else {
Object.values(data).forEach(function (item) {
return traverseResp(item);
});
}
}
}
export { traverseResp };