|
2 | 2 | MIT License http://www.opensource.org/licenses/mit-license.php |
3 | 3 | Author Tobias Koppers @sokra |
4 | 4 | */ |
5 | | -var NullDependency = require("./NullDependency"); |
| 5 | +"use strict"; |
| 6 | +const NullDependency = require("./NullDependency"); |
6 | 7 |
|
7 | | -function ConstDependency(expression, range) { |
8 | | - NullDependency.call(this); |
9 | | - this.expression = expression; |
10 | | - this.range = range; |
11 | | -} |
12 | | -module.exports = ConstDependency; |
| 8 | +class ConstDependency extends NullDependency { |
| 9 | + constructor(expression, range) { |
| 10 | + super(); |
| 11 | + this.expression = expression; |
| 12 | + this.range = range; |
| 13 | + } |
13 | 14 |
|
14 | | -ConstDependency.prototype = Object.create(NullDependency.prototype); |
15 | | -ConstDependency.prototype.constructor = ConstDependency; |
| 15 | + updateHash(hash) { |
| 16 | + hash.update(this.range + ""); |
| 17 | + hash.update(this.expression + ""); |
| 18 | + } |
| 19 | +} |
16 | 20 |
|
17 | | -ConstDependency.Template = function ConstDependencyTemplate() {}; |
| 21 | +ConstDependency.Template = class ConstDependencyTemplate { |
| 22 | + apply(dep, source) { |
| 23 | + if(typeof dep.range === "number") { |
| 24 | + source.insert(dep.range, dep.expression); |
| 25 | + return; |
| 26 | + } |
18 | 27 |
|
19 | | -ConstDependency.Template.prototype.apply = function(dep, source) { |
20 | | - if(typeof dep.range === "number") |
21 | | - source.insert(dep.range, dep.expression); |
22 | | - else |
23 | 28 | source.replace(dep.range[0], dep.range[1] - 1, dep.expression); |
24 | | -}; |
| 29 | + } |
| 30 | +} |
25 | 31 |
|
26 | | -ConstDependency.prototype.updateHash = function(hash) { |
27 | | - hash.update(this.range + ""); |
28 | | - hash.update(this.expression + ""); |
29 | | -}; |
| 32 | +module.exports = ConstDependency; |
0 commit comments