POJOs: use symbol properties as well, just not in a normalized order

master
Conduitry 5 years ago
parent 92ce930651
commit 5d0b1fceb1

@ -14,7 +14,7 @@ let recurse = obj => {
obj.forEach(recurse)
break
case Object.prototype:
temp = Object.getOwnPropertyNames(obj).sort()
temp = [...Object.getOwnPropertyNames(obj).sort(), ...Object.getOwnPropertySymbols(obj)]
array.push(OBJECT, temp.length, ...temp)
temp.forEach(key => recurse(obj[key]))
break

@ -33,6 +33,13 @@ assert.notEqual(call([[0, 0], [0]]), call([[0], [0, 0]]))
assert.equal(call({ a: 0, b: 1 }), call({ b: 1, a: 0 }))
{
let s = Symbol()
assert.notEqual(call({ a: 0, b: 1 }), call({ [s]: 2, b: 1, a: 0 }))
assert.equal(call({ a: 0, b: 1, [s]: 2 }), call({ [s]: 2, b: 1, a: 0 }))
assert.notEqual(call({ a: 0, b: 1, [s]: 2 }), call({ [s]: 3, b: 1, a: 0 }))
}
assert.equal(call(new Date(2000, 0, 1)), call(new Date(2000, 0, 1, 0, 0, 0)))
assert.equal(call([new Date(2000, 0, 1)]), call([new Date(2000, 0, 1, 0, 0, 0)]))

Loading…
Cancel
Save