blob: 45db54841c21d5b4d6270e217971d47f1fd849b5 (
plain)
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
|
'use strict';
var utils = require('./utils');
/**
* An object to write any content to a string.
* @constructor
*/
var StringWriter = function() {
this.data = [];
};
StringWriter.prototype = {
/**
* Append any content to the current string.
* @param {Object} input the content to add.
*/
append: function(input) {
input = utils.transformTo("string", input);
this.data.push(input);
},
/**
* Finalize the construction an return the result.
* @return {string} the generated string.
*/
finalize: function() {
return this.data.join("");
}
};
module.exports = StringWriter;
|