Skip to content

Commit 307566a

Browse files
committed
Feature: Add an option to provide output.hashFunction as a function
1 parent 5edc7ef commit 307566a

20 files changed

+41
-2
lines changed

lib/util/createHash.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ class BulkUpdateDecorator {
3838
}
3939

4040
module.exports = algorithm => {
41+
if(typeof algorithm === "function") {
42+
return new BulkUpdateDecorator(new algorithm());
43+
}
4144
switch(algorithm) {
4245
// TODO add non-cryptographic algorithm here
4346
default: return new BulkUpdateDecorator(require("crypto").createHash(algorithm));

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
"less": "^2.5.1",
5050
"less-loader": "^4.0.3",
5151
"lodash": "^4.17.4",
52+
"metrohash": "^2.3.0",
5253
"mocha": "^3.2.0",
5354
"mocha-lcov-reporter": "^1.0.0",
5455
"nsp": "^2.6.1",

schemas/WebpackOptions.json

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -403,8 +403,15 @@
403403
},
404404
"hashFunction": {
405405
"description": "Algorithm used for generation the hash (see node.js crypto package)",
406-
"minLength": 1,
407-
"type": "string"
406+
"anyOf": [
407+
{
408+
"type": "string",
409+
"minLength": 1
410+
},
411+
{
412+
"instanceof": "Function"
413+
}
414+
]
408415
},
409416
"hashSalt": {
410417
"description": "Any string which is added to the hash to salt it",
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
module.exports = module.id;
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
module.exports = module.id;
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
module.exports = module.id;
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
module.exports = module.id;
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
module.exports = module.id;
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
module.exports = module.id;
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
module.exports = module.id;
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
module.exports = module.id;
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
module.exports = module.id;
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
module.exports = module.id;
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
module.exports = module.id;
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
module.exports = module.id;
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
module.exports = module.id;
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
module.exports = module.id;
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
module.exports = module.id;
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
it("should have unique ids", function () {
2+
var ids = [];
3+
for(var i = 1; i <= 15; i++) {
4+
var id = require("./files/file" + i + ".js");
5+
ids.indexOf(id).should.be.eql(-1);
6+
ids.push(id);
7+
}
8+
});
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
module.exports = [{
2+
output: {
3+
hashFunction: require("metrohash").MetroHash64
4+
}
5+
}];

0 commit comments

Comments
 (0)