Skip to content

Commit

Permalink
feat: added install method
Browse files Browse the repository at this point in the history
  • Loading branch information
teclone committed Mar 2, 2020
1 parent adb3208 commit 49fd182
Show file tree
Hide file tree
Showing 3 changed files with 789 additions and 708 deletions.
59 changes: 33 additions & 26 deletions src/main.js
Original file line number Diff line number Diff line change
@@ -1,30 +1,37 @@
import Serializer from './modules/Serializer.js';

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

/**
* return XMLSerializer as modules name
*/
get [Symbol.toStringTag]() {
return 'XMLSerializer';
}
/**
* return XMLSerializer as modules name
*/
get [Symbol.toStringTag]() {
return 'XMLSerializer';
}

/**
* produces an XML serialization of root passing a value of false for the
* require well-formed parameter, and return the result.
*@param {Node} root - the root node
*@param {boolean} [requireWellFormed=false] - boolean value indicating if it should require xml
* well formedness
*@returns {string}
*/
serializeToString(root, requireWellFormed) {
return this.serializer.serializeToString(root, requireWellFormed);
}
}
/**
* produces an XML serialization of root passing a value of false for the
* require well-formed parameter, and return the result.
*@param {Node} root - the root node
*@param {boolean} [requireWellFormed=false] - boolean value indicating if it should require xml
* well formedness
*@returns {string}
*/
serializeToString(root, requireWellFormed) {
return this.serializer.serializeToString(root, requireWellFormed);
}
}

/**
* installs the serialize to the given target object
*/
XMLSerializer.install = target => {
target.XMLSerializer = XMLSerializer;
};
Loading

0 comments on commit 49fd182

Please sign in to comment.