(obj, config)
| 30 | } |
| 31 | |
| 32 | function parseObject(obj, config) { |
| 33 | if (Array.isArray(obj)) { |
| 34 | return obj.map(item => { |
| 35 | return parseObject(item, config); |
| 36 | }); |
| 37 | } else if (obj && obj.__type == 'Date') { |
| 38 | return Object.assign(new Date(obj.iso), obj); |
| 39 | } else if (obj && obj.__type == 'File') { |
| 40 | if (obj.url) { |
| 41 | const { validateFileUrl } = require('../FileUrlValidator'); |
| 42 | validateFileUrl(obj.url, config); |
| 43 | } |
| 44 | return Parse.File.fromJSON(obj); |
| 45 | } else if (obj && obj.__type == 'Pointer') { |
| 46 | return Parse.Object.fromJSON({ |
| 47 | __type: 'Pointer', |
| 48 | className: obj.className, |
| 49 | objectId: obj.objectId, |
| 50 | }); |
| 51 | } else if (Buffer.isBuffer(obj)) { |
| 52 | return obj; |
| 53 | } else if (obj && typeof obj === 'object') { |
| 54 | return parseParams(obj, config); |
| 55 | } else { |
| 56 | return obj; |
| 57 | } |
| 58 | } |
| 59 | |
| 60 | function parseParams(params, config) { |
| 61 | return _.mapValues(params, item => parseObject(item, config)); |
no test coverage detected