Simple entities serialization fixed

This commit is contained in:
barsdeveloper
2024-06-04 14:40:47 +02:00
parent c05e6d3cc9
commit e16822760f
11 changed files with 266 additions and 128 deletions

View File

@@ -243,12 +243,20 @@ export default class IEntity {
}
const thisKeys = Object.keys(this)
const otherKeys = Object.keys(other)
if (thisKeys.length != otherKeys.length || !(this instanceof other.constructor) && !(other instanceof this.constructor)) {
if (
thisKeys.length !== otherKeys.length
|| this.lookbehind != other.lookbehind
|| !(this instanceof other.constructor) && !(other instanceof this.constructor)
) {
return false
}
for (let i = 0; i < thisKeys.length; ++i) {
const a = this[thisKeys[i]]
const b = other[otherKeys[i]]
const k = thisKeys[i]
if (!otherKeys.includes(k)) {
return false
}
const a = this[k]
const b = other[k]
if (a instanceof IEntity) {
if (!a.equals(b)) {
return false
@@ -298,7 +306,7 @@ export default class IEntity {
}
result += serialization
}
if (Self.trailing && result.length) {
if (this.trailing && result.length) {
result += Self.attributeSeparator
}
return Self.wrap(this, result)