antd-mini
Version:
antd-mini 是支付宝小程序 UI 组件库,遵循 Ant Design 规范。
19 lines (18 loc) • 654 B
JavaScript
export function flattenObject(obj, parentKey, result) {
if (parentKey === void 0) { parentKey = ''; }
if (result === void 0) { result = {}; }
for (var key in obj) {
if (Object.prototype.hasOwnProperty.call(obj, key)) {
var currentKey = parentKey ? "".concat(parentKey, ".").concat(key) : key;
var value = obj[key];
if (Object.prototype.toString.call(value) === '[object Object]') {
flattenObject(value, currentKey, result);
}
else {
result[currentKey] = value;
}
}
}
return result;
}
export default flattenObject;