2
0
mirror of https://github.com/tenrok/vue-meta.git synced 2026-06-25 05:20:34 +03:00

refactor method

This commit is contained in:
pimlie
2019-02-23 12:33:30 +01:00
parent 4968ee10b9
commit f25415b621
+4 -5
View File
@@ -2,15 +2,14 @@ import isArray from './isArray'
import { isObject } from './typeof' import { isObject } from './typeof'
export function ensureIsArray(arg, key) { export function ensureIsArray(arg, key) {
if (isObject(arg) && key) { if (!key || !isObject(arg)) {
return isArray(arg) ? arg : []
}
if (!isArray(arg[key])) { if (!isArray(arg[key])) {
arg[key] = [] arg[key] = []
} }
return arg return arg
}
return isArray(arg) ? arg : []
} }
export function ensuredPush(object, key, el) { export function ensuredPush(object, key, el) {