Skip to content

Commit 3208094

Browse files
timseTheLarkInn
authored andcommitted
refactor const dependency to es6 (webpack#3699)
1 parent 7f1c79b commit 3208094

1 file changed

Lines changed: 22 additions & 19 deletions

File tree

‎lib/dependencies/ConstDependency.js‎

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,28 +2,31 @@
22
MIT License http://www.opensource.org/licenses/mit-license.php
33
Author Tobias Koppers @sokra
44
*/
5-
var NullDependency = require("./NullDependency");
5+
"use strict";
6+
const NullDependency = require("./NullDependency");
67

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+
}
1314

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+
}
1620

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+
}
1827

19-
ConstDependency.Template.prototype.apply = function(dep, source) {
20-
if(typeof dep.range === "number")
21-
source.insert(dep.range, dep.expression);
22-
else
2328
source.replace(dep.range[0], dep.range[1] - 1, dep.expression);
24-
};
29+
}
30+
}
2531

26-
ConstDependency.prototype.updateHash = function(hash) {
27-
hash.update(this.range + "");
28-
hash.update(this.expression + "");
29-
};
32+
module.exports = ConstDependency;

0 commit comments

Comments
 (0)