fix(Util): support empty array for flatten (#4590)

This commit is contained in:
Souji 2020-08-11 21:01:29 +02:00 committed by GitHub
parent fab3153de6
commit 317f24076e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -24,12 +24,11 @@ class Util {
static flatten(obj, ...props) {
if (!isObject(obj)) return obj;
props = Object.assign(
...Object.keys(obj)
.filter(k => !k.startsWith('_'))
.map(k => ({ [k]: true })),
...props,
);
const objProps = Object.keys(obj)
.filter(k => !k.startsWith('_'))
.map(k => ({ [k]: true }));
props = objProps.length ? Object.assign(...objProps, ...props) : Object.assign({}, ...props);
const out = {};