.gitignore added
[dotfiles/.git] / .config / coc / extensions / node_modules / coc-prettier / node_modules / unherit / index.js
1 'use strict'
2
3 var xtend = require('xtend')
4 var inherits = require('inherits')
5
6 module.exports = unherit
7
8 // Create a custom constructor which can be modified without affecting the
9 // original class.
10 function unherit(Super) {
11   var result
12   var key
13   var value
14
15   inherits(Of, Super)
16   inherits(From, Of)
17
18   // Clone values.
19   result = Of.prototype
20
21   for (key in result) {
22     value = result[key]
23
24     if (value && typeof value === 'object') {
25       result[key] = 'concat' in value ? value.concat() : xtend(value)
26     }
27   }
28
29   return Of
30
31   // Constructor accepting a single argument, which itself is an `arguments`
32   // object.
33   function From(parameters) {
34     return Super.apply(this, parameters)
35   }
36
37   // Constructor accepting variadic arguments.
38   function Of() {
39     if (!(this instanceof Of)) {
40       return new From(arguments)
41     }
42
43     return Super.apply(this, arguments)
44   }
45 }