MCPcopy
hub / github.com/postcss/autoprefixer / clone

Function clone

lib/prefixer.js:8–34  ·  view source on GitHub ↗

* Recursively clone objects

(obj, parent)

Source from the content-addressed store, hash-verified

6 * Recursively clone objects
7 */
8function 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
36class Prefixer {
37 constructor(name, prefixes, all) {

Callers 1

cloneMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…