| 2 | |
| 3 | const stringify = obj => JSON.stringify(obj, null, 2) |
| 4 | const parse = str => |
| 5 | JSON.parse(str, (_, v) => { |
| 6 | if ( |
| 7 | v !== null && |
| 8 | typeof v === 'object' && |
| 9 | 'type' in v && |
| 10 | v.type === 'Buffer' && |
| 11 | 'data' in v && |
| 12 | Array.isArray(v.data) |
| 13 | ) { |
| 14 | return Buffer.from(v.data) |
| 15 | } |
| 16 | return v |
| 17 | }) |
| 18 | class CloudDBAdapter { |
| 19 | constructor(url, { serialize = stringify, deserialize = parse, fetchOptions = {} } = {}) { |
| 20 | this.url = url |
nothing calls this directly
no outgoing calls
no test coverage detected