Skip to content

Commit 49fd182

Browse files
Harrison IfeanyichukwuHarrison Ifeanyichukwu
authored andcommitted
feat: added install method
1 parent adb3208 commit 49fd182

File tree

3 files changed

+789
-708
lines changed

3 files changed

+789
-708
lines changed

src/main.js

Lines changed: 33 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,37 @@
11
import Serializer from './modules/Serializer.js';
22

3-
export default class XMLSerializer {
4-
/**
5-
*@param {boolean} [preserveWhiteSpace=true] - boolean value indicating if white spaces
6-
* should be preserved as it is in the source
7-
*/
8-
constructor(preserveWhiteSpace) {
9-
this.serializer = new Serializer(preserveWhiteSpace);
10-
}
3+
export class XMLSerializer {
4+
/**
5+
*@param {boolean} [preserveWhiteSpace=true] - boolean value indicating if white spaces
6+
* should be preserved as it is in the source
7+
*/
8+
constructor(preserveWhiteSpace) {
9+
this.serializer = new Serializer(preserveWhiteSpace);
10+
}
1111

12-
/**
13-
* return XMLSerializer as modules name
14-
*/
15-
get [Symbol.toStringTag]() {
16-
return 'XMLSerializer';
17-
}
12+
/**
13+
* return XMLSerializer as modules name
14+
*/
15+
get [Symbol.toStringTag]() {
16+
return 'XMLSerializer';
17+
}
1818

19-
/**
20-
* produces an XML serialization of root passing a value of false for the
21-
* require well-formed parameter, and return the result.
22-
*@param {Node} root - the root node
23-
*@param {boolean} [requireWellFormed=false] - boolean value indicating if it should require xml
24-
* well formedness
25-
*@returns {string}
26-
*/
27-
serializeToString(root, requireWellFormed) {
28-
return this.serializer.serializeToString(root, requireWellFormed);
29-
}
30-
}
19+
/**
20+
* produces an XML serialization of root passing a value of false for the
21+
* require well-formed parameter, and return the result.
22+
*@param {Node} root - the root node
23+
*@param {boolean} [requireWellFormed=false] - boolean value indicating if it should require xml
24+
* well formedness
25+
*@returns {string}
26+
*/
27+
serializeToString(root, requireWellFormed) {
28+
return this.serializer.serializeToString(root, requireWellFormed);
29+
}
30+
}
31+
32+
/**
33+
* installs the serialize to the given target object
34+
*/
35+
XMLSerializer.install = target => {
36+
target.XMLSerializer = XMLSerializer;
37+
};

0 commit comments

Comments
 (0)