zent
Version:
一套前端设计语言和基于React的实现
23 lines (22 loc) • 691 B
JavaScript
import isObject from '../../../utils/isObject';
var flattenNames = function (things) {
if (things === void 0) { things = []; }
var names = [];
things.forEach(function (thing) {
if (Array.isArray(thing)) {
names = names.concat(flattenNames(thing));
}
else if (isObject(thing)) {
Object.keys(thing).forEach(function (key) {
var value = thing[key];
value === true && names.push(key);
names.push(key + "-" + value);
});
}
else if (typeof thing === 'string') {
names.push(thing);
}
});
return names;
};
export default flattenNames;