* Recursively clone objects
(obj, parent)
| 6 | * Recursively clone objects |
| 7 | */ |
| 8 | function clone(obj, parent) { |
| 9 | let cloned = new obj.constructor() |
| 10 | |
| 11 | for (let i of Object.keys(obj || {})) { |
| 12 | let value = obj[i] |
| 13 | if (i === 'parent' && typeof value === 'object') { |
| 14 | if (parent) { |
| 15 | cloned[i] = parent |
| 16 | } |
| 17 | } else if (i === 'source' || i === null) { |
| 18 | cloned[i] = value |
| 19 | } else if (Array.isArray(value)) { |
| 20 | cloned[i] = value.map(x => clone(x, cloned)) |
| 21 | } else if ( |
| 22 | i !== '_autoprefixerPrefix' && |
| 23 | i !== '_autoprefixerValues' && |
| 24 | i !== 'proxyCache' |
| 25 | ) { |
| 26 | if (typeof value === 'object' && value !== null) { |
| 27 | value = clone(value, cloned) |
| 28 | } |
| 29 | cloned[i] = value |
| 30 | } |
| 31 | } |
| 32 | |
| 33 | return cloned |
| 34 | } |
| 35 | |
| 36 | class Prefixer { |
| 37 | constructor(name, prefixes, all) { |
no outgoing calls
no test coverage detected
searching dependent graphs…