vue-json-compare
Advanced tools
Comparing version
{ | ||
"name": "vue-json-compare", | ||
"version": "2.0.4", | ||
"version": "2.0.5", | ||
"description": "A vue(2.x) components for compare JSON data", | ||
@@ -5,0 +5,0 @@ "main": "./index.js", |
@@ -51,2 +51,4 @@ # vue-json-compare | ||
注意:左边是使用了[vue-json](https://github.com/5SSS/vue-json)这个包,纯展示使用的。右边的才是vue-json-compare展示的结果。 | ||
 | ||
@@ -53,0 +55,0 @@ |
@@ -1,2 +0,2 @@ | ||
import { isObject, isArray, isString, type } from './typeof.js' | ||
import check from './typeof.js' | ||
@@ -8,5 +8,5 @@ let _line = 1 | ||
let newData = [] | ||
if (isObject(source)) { | ||
if (check.isObject(source)) { | ||
newData = parseObject(source) | ||
} else if (isArray(source)) { | ||
} else if (check.isArray(source)) { | ||
newData = parseArray(source) | ||
@@ -23,10 +23,10 @@ } else { | ||
let newObj = Object.create(null) | ||
newObj.type = type(obj[key]) | ||
newObj.type = check.type(obj[key]) | ||
newObj.line = _line++ | ||
newObj.key = key | ||
if (isObject(obj[key])) { | ||
if (check.isObject(obj[key])) { | ||
newObj.value = parseObject(obj[key], _line) | ||
newObj.lastLine = _line++ | ||
newObj.show = true | ||
} else if (isArray(obj[key])) { | ||
} else if (check.isArray(obj[key])) { | ||
newObj.value = parseArray(obj[key], _line) | ||
@@ -41,3 +41,3 @@ newObj.lastLine = _line++ | ||
} else { | ||
if (isString(obj[key])) { | ||
if (check.isString(obj[key])) { | ||
newObj.value = '"' + obj[key] + '"' | ||
@@ -58,10 +58,10 @@ } else { | ||
let newObj = Object.create(null) | ||
newObj.type = type(arr[i]) | ||
newObj.type = check.type(arr[i]) | ||
newObj.key = i | ||
newObj.line = _line++ | ||
if (isObject(arr[i])) { | ||
if (check.isObject(arr[i])) { | ||
newObj.value = parseObject(arr[i], _line) | ||
newObj.lastLine = _line++ | ||
newObj.show = true | ||
} else if (isArray(arr[i])) { | ||
} else if (check.isArray(arr[i])) { | ||
newObj.value = parseArray(arr[i], _line) | ||
@@ -76,3 +76,3 @@ newObj.lastLine = _line++ | ||
} else { | ||
if (isString(arr[i])) { | ||
if (check.isString(arr[i])) { | ||
newObj.value = '"' + arr[i] + '"' | ||
@@ -79,0 +79,0 @@ } else { |
@@ -1,34 +0,29 @@ | ||
export const isArray = (item) => { | ||
return Object.prototype.toString.call(item) === '[object Array]' | ||
export default { | ||
isArray (item) { | ||
return Object.prototype.toString.call(item) === '[object Array]' | ||
}, | ||
isObject (item) { | ||
return Object.prototype.toString.call(item) === '[object Object]' | ||
}, | ||
isNull (item) { | ||
return Object.prototype.toString.call(item) === '[object Null]' | ||
}, | ||
isNumber (item) { | ||
return typeof item === 'number' | ||
}, | ||
isString (item) { | ||
return typeof item === 'string' | ||
}, | ||
isBoolean (item) { | ||
return typeof item === 'boolean' | ||
}, | ||
isUndefined (item) { | ||
return typeof item === 'undefined' | ||
}, | ||
type (item) { | ||
let t = Object.prototype.toString.call(item) | ||
let match = /(?!\[).+(?=\])/g | ||
t = t.match(match)[0].split(' ')[1] | ||
return t | ||
} | ||
} | ||
export const isObject = (item) => { | ||
return Object.prototype.toString.call(item) === '[object Object]' | ||
} | ||
export const isNull = (item) => { | ||
return Object.prototype.toString.call(item) === '[object Null]' | ||
} | ||
export const isNumber = (item) => { | ||
return typeof item === 'number' | ||
} | ||
export const isString = (item) => { | ||
return typeof item === 'string' | ||
} | ||
export const isBoolean = (item) => { | ||
return typeof item === 'boolean' | ||
} | ||
export const isUndefined = (item) => { | ||
return typeof item === 'undefined' | ||
} | ||
export const type = (item) => { | ||
let type = Object.prototype.toString.call(item) | ||
let match = /(?!\[).+(?=\])/g | ||
type = type.match(match)[0].split(' ')[1] | ||
return type | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
79918
0.2%110
1.85%72
2.86%