(obj)
| 160 | } |
| 161 | |
| 162 | read(obj) { |
| 163 | if (obj === undefined) { |
| 164 | return undefined; |
| 165 | } |
| 166 | if (obj === null) { |
| 167 | return null; |
| 168 | } |
| 169 | if (Array.isArray(obj)) { |
| 170 | return obj.map(item => this.read(item)); |
| 171 | } |
| 172 | const type = obj[typeSerializers.typeKey]; |
| 173 | if (type) { |
| 174 | const d = this._deserializers[type]; |
| 175 | if (d) { |
| 176 | // Use type serializer |
| 177 | return d.deserialize(obj); |
| 178 | } |
| 179 | return obj[typeSerializers.valueKey]; |
| 180 | } |
| 181 | if (obj && typeof obj === 'object' && obj.constructor === Object) { |
| 182 | return this._deserializeObject(obj); |
| 183 | } |
| 184 | // Default (for boolean, number and other scalars) |
| 185 | return obj; |
| 186 | } |
| 187 | |
| 188 | _deserializeObject(obj) { |
| 189 | const keys = Object.keys(obj); |
no test coverage detected