Skip to content

Commit c84aa45

Browse files
committed
Refactor: bound functions to arrow functions
1 parent aa833bf commit c84aa45

1 file changed

Lines changed: 10 additions & 18 deletions

File tree

lib/node/NodeMainTemplatePlugin.js

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -71,15 +71,13 @@ module.exports = class NodeMainTemplatePlugin {
7171
"installedChunks[chunkId] = [resolve, reject];",
7272
"var filename = __dirname + " + this.applyPluginsWaterfall("asset-path", JSON.stringify("/" + chunkFilename), {
7373
hash: "\" + " + this.renderCurrentHashCode(hash) + " + \"",
74-
hashWithLength: function(length) {
75-
return "\" + " + this.renderCurrentHashCode(hash, length) + " + \"";
76-
}.bind(this),
74+
hashWithLength: (length) => "\" + " + this.renderCurrentHashCode(hash, length) + " + \"",
7775
chunk: {
7876
id: "\" + chunkId + \"",
7977
hash: "\" + " + JSON.stringify(chunkMaps.hash) + "[chunkId] + \"",
80-
hashWithLength: function(length) {
78+
hashWithLength: (length) => {
8179
const shortChunkHashMap = {};
82-
Object.keys(chunkMaps.hash).forEach(function(chunkId) {
80+
Object.keys(chunkMaps.hash).forEach((chunkId) => {
8381
if(typeof chunkMaps.hash[chunkId] === "string")
8482
shortChunkHashMap[chunkId] = chunkMaps.hash[chunkId].substr(0, length);
8583
});
@@ -116,15 +114,13 @@ module.exports = class NodeMainTemplatePlugin {
116114
} else {
117115
const request = this.applyPluginsWaterfall("asset-path", JSON.stringify("./" + chunkFilename), {
118116
hash: "\" + " + this.renderCurrentHashCode(hash) + " + \"",
119-
hashWithLength: function(length) {
120-
return "\" + " + this.renderCurrentHashCode(hash, length) + " + \"";
121-
}.bind(this),
117+
hashWithLength: (length) => "\" + " + this.renderCurrentHashCode(hash, length) + " + \"",
122118
chunk: {
123119
id: "\" + chunkId + \"",
124120
hash: "\" + " + JSON.stringify(chunkMaps.hash) + "[chunkId] + \"",
125-
hashWithLength: function(length) {
121+
hashWithLength: (length) => {
126122
const shortChunkHashMap = {};
127-
Object.keys(chunkMaps.hash).forEach(function(chunkId) {
123+
Object.keys(chunkMaps.hash).forEach((chunkId) => {
128124
if(typeof chunkMaps.hash[chunkId] === "string")
129125
shortChunkHashMap[chunkId] = chunkMaps.hash[chunkId].substr(0, length);
130126
});
@@ -153,15 +149,13 @@ module.exports = class NodeMainTemplatePlugin {
153149
const chunkMaps = chunk.getChunkMaps();
154150
const currentHotUpdateChunkFilename = this.applyPluginsWaterfall("asset-path", JSON.stringify(hotUpdateChunkFilename), {
155151
hash: "\" + " + this.renderCurrentHashCode(hash) + " + \"",
156-
hashWithLength: function(length) {
157-
return "\" + " + this.renderCurrentHashCode(hash, length) + " + \"";
158-
}.bind(this),
152+
hashWithLength: (length) => "\" + " + this.renderCurrentHashCode(hash, length) + " + \"",
159153
chunk: {
160154
id: "\" + chunkId + \"",
161155
hash: "\" + " + JSON.stringify(chunkMaps.hash) + "[chunkId] + \"",
162-
hashWithLength: function(length) {
156+
hashWithLength: (length) => {
163157
const shortChunkHashMap = {};
164-
Object.keys(chunkMaps.hash).forEach(function(chunkId) {
158+
Object.keys(chunkMaps.hash).forEach((chunkId) => {
165159
if(typeof chunkMaps.hash[chunkId] === "string")
166160
shortChunkHashMap[chunkId] = chunkMaps.hash[chunkId].substr(0, length);
167161
});
@@ -172,9 +166,7 @@ module.exports = class NodeMainTemplatePlugin {
172166
});
173167
const currentHotUpdateMainFilename = this.applyPluginsWaterfall("asset-path", JSON.stringify(hotUpdateMainFilename), {
174168
hash: "\" + " + this.renderCurrentHashCode(hash) + " + \"",
175-
hashWithLength: function(length) {
176-
return "\" + " + this.renderCurrentHashCode(hash, length) + " + \"";
177-
}.bind(this)
169+
hashWithLength: (length) => "\" + " + this.renderCurrentHashCode(hash, length) + " + \""
178170
});
179171
return Template.getFunctionContent(asyncChunkLoading ? require("./NodeMainTemplateAsync.runtime.js") : require("./NodeMainTemplate.runtime.js"))
180172
.replace(/\$require\$/g, this.requireFn)

0 commit comments

Comments
 (0)