(input)
| 1 | function PrepareObject(input) { |
| 2 | if (!input) return {}; |
| 3 | |
| 4 | let output = {}; |
| 5 | |
| 6 | if (Array.isArray(input)) { |
| 7 | input.forEach((item, index) => { |
| 8 | output[index] = item; |
| 9 | }); |
| 10 | } else if (typeof input === "object") { |
| 11 | if (input._id) { |
| 12 | output = { |
| 13 | ...input, |
| 14 | _id: mongodb.ObjectID(input._id) |
| 15 | }; |
| 16 | } else { |
| 17 | output = { ...input }; |
| 18 | } |
| 19 | } |
| 20 | |
| 21 | return output; |
| 22 | } |
| 23 | |
| 24 | module.exports = { PrepareObject } |
no outgoing calls
no test coverage detected