(s)
| 26103 | const a = i(85105) |
| 26104 | s.exports = class JSON06Serialiser extends a { |
| 26105 | serialise(s) { |
| 26106 | if (!(s instanceof this.namespace.elements.Element)) |
| 26107 | throw new TypeError(`Given element \`${s}\` is not an Element instance`) |
| 26108 | let o |
| 26109 | s._attributes && s.attributes.get('variable') && (o = s.attributes.get('variable')) |
| 26110 | const i = { element: s.element } |
| 26111 | s._meta && s._meta.length > 0 && (i.meta = this.serialiseObject(s.meta)) |
| 26112 | const a = 'enum' === s.element || -1 !== s.attributes.keys().indexOf('enumerations') |
| 26113 | if (a) { |
| 26114 | const o = this.enumSerialiseAttributes(s) |
| 26115 | o && (i.attributes = o) |
| 26116 | } else if (s._attributes && s._attributes.length > 0) { |
| 26117 | let { attributes: a } = s |
| 26118 | ;(a.get('metadata') && |
| 26119 | ((a = a.clone()), a.set('meta', a.get('metadata')), a.remove('metadata')), |
| 26120 | 'member' === s.element && o && ((a = a.clone()), a.remove('variable')), |
| 26121 | a.length > 0 && (i.attributes = this.serialiseObject(a))) |
| 26122 | } |
| 26123 | if (a) i.content = this.enumSerialiseContent(s, i) |
| 26124 | else if (this[`${s.element}SerialiseContent`]) |
| 26125 | i.content = this[`${s.element}SerialiseContent`](s, i) |
| 26126 | else if (void 0 !== s.content) { |
| 26127 | let a |
| 26128 | ;(o && s.content.key |
| 26129 | ? ((a = s.content.clone()), |
| 26130 | a.key.attributes.set('variable', o), |
| 26131 | (a = this.serialiseContent(a))) |
| 26132 | : (a = this.serialiseContent(s.content)), |
| 26133 | this.shouldSerialiseContent(s, a) && (i.content = a)) |
| 26134 | } else |
| 26135 | this.shouldSerialiseContent(s, s.content) && |
| 26136 | s instanceof this.namespace.elements.Array && |
| 26137 | (i.content = []) |
| 26138 | return i |
| 26139 | } |
| 26140 | shouldSerialiseContent(s, o) { |
| 26141 | return ( |
| 26142 | 'parseResult' === s.element || |
no test coverage detected