tidy
This commit is contained in:
parent
ecd9964a94
commit
e6ffaf5f32
|
@ -8,17 +8,17 @@ let BUFFER = Symbol()
|
|||
let array
|
||||
|
||||
let recurse = obj => {
|
||||
let temp
|
||||
switch (typeof obj === 'object' && obj !== null && Object.getPrototypeOf(obj)) {
|
||||
case Array.prototype:
|
||||
array.push(ARRAY, obj.length)
|
||||
for (let i = 0; i < obj.length; i++) i in obj ? recurse(obj[i]) : array.push(HOLE)
|
||||
break
|
||||
case Object.prototype:
|
||||
temp = [...Object.getOwnPropertyNames(obj).sort(), ...Object.getOwnPropertySymbols(obj)]
|
||||
case Object.prototype: {
|
||||
let temp = [...Object.getOwnPropertyNames(obj).sort(), ...Object.getOwnPropertySymbols(obj)]
|
||||
array.push(OBJECT, temp.length, ...temp)
|
||||
temp.forEach(key => recurse(obj[key]))
|
||||
break
|
||||
}
|
||||
case RegExp.prototype:
|
||||
array.push(REGEXP, obj.toString())
|
||||
break
|
||||
|
|
Loading…
Reference in New Issue