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

refactor method

This commit is contained in:
pimlie
2019-02-23 12:33:30 +01:00
parent 4968ee10b9
commit f25415b621
+6 -7
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)) {
if (!isArray(arg[key])) { return isArray(arg) ? arg : []
arg[key] = []
}
return arg
} }
return isArray(arg) ? arg : [] if (!isArray(arg[key])) {
arg[key] = []
}
return arg
} }
export function ensuredPush(object, key, el) { export function ensuredPush(object, key, el) {