forked from deoxxa/xml-c14n
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
36 lines (29 loc) · 1.12 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
var ExclusiveCanonicalisation = require("./lib/algorithm/exclusive-canonicalisation");
var builtIn = {
algorithms: {
"http://www.w3.org/2001/10/xml-exc-c14n#": function(options) {
return new ExclusiveCanonicalisation(options);
},
"http://www.w3.org/2001/10/xml-exc-c14n#WithComments": function(options) {
options = Object.create(options || null);
options.includeComments = true;
return new ExclusiveCanonicalisation(options);
},
},
};
var CanonicalisationFactory = module.exports = function CanonicalisationFactory() {
if (!(this instanceof CanonicalisationFactory)) {
return new CanonicalisationFactory();
}
this.algorithms = Object.create(builtIn.algorithms);
};
CanonicalisationFactory.prototype.registerAlgorithm = function registerAlgorithm(uri, implementation) {
this.algorithms[uri] = implementation;
return this;
};
CanonicalisationFactory.prototype.getAlgorithm = function getAlgorithm(uri) {
return this.algorithms[uri];
};
CanonicalisationFactory.prototype.createCanonicaliser = function createCanonicaliser(uri, options) {
return this.algorithms[uri](options);
};