This commit is contained in:
Conduitry 2018-03-18 04:03:24 -04:00
parent ecd9964a94
commit e6ffaf5f32
1 changed files with 3 additions and 3 deletions

View File

@ -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