@@ -16,14 +16,24 @@ function AsciiTree(lines, leadingCharCode, enc) {
16
16
this . topLine = null ;
17
17
this . enc = enc ;
18
18
}
19
+ /**
20
+ * @function toBufferLines
21
+ * @return {Buffer[] } - converted Buffers.
22
+ */
23
+ AsciiTree . prototype . toBufferArray = function ( ) {
24
+ var enc = this . enc ;
25
+ return this . toBytesLineArray ( ) . map ( function ( it ) {
26
+ return it . toBuffer ( ) ;
27
+ } ) ;
28
+ } ;
19
29
/**
20
30
* @function toStringLines
21
31
* @return {string[] } - converted lines.
22
32
*/
23
- AsciiTree . prototype . toStringLines = function ( ) {
33
+ AsciiTree . prototype . toStringArray = function ( ) {
24
34
var enc = this . enc ;
25
- return this . toBytesLines ( ) . map ( function ( it ) {
26
- return enc ? it . toBuffer ( ) . toString ( enc ) : it . toBuffer ( ) . toString ( ) ;
35
+ return this . toBufferArray ( ) . map ( function ( it ) {
36
+ return enc ? it . toString ( enc ) : it . toString ( ) ;
27
37
} ) ;
28
38
} ;
29
39
@@ -32,22 +42,16 @@ AsciiTree.prototype.toStringLines = function() {
32
42
* @return {string } - converted string.
33
43
*/
34
44
AsciiTree . prototype . toString = function ( ) {
35
- var enc = this . enc ,
36
- bytesArray ,
37
- buf ;
38
-
39
- bytesArray = this . toBytesLines ( ) . reduce ( function ( val , it ) {
40
- return val . concat ( it . content , it . separator ) ;
41
- } , [ ] ) ;
42
- buf = new Buffer ( bytesArray ) ;
43
- return enc ? buf . toString ( enc ) : buf . toString ( ) ;
45
+ return this . toStringArray ( ) . reduce ( function ( val , it ) {
46
+ return val + it ;
47
+ } , "" ) ;
44
48
} ;
45
49
46
50
/**
47
- * @function toBytesLines
51
+ * @function toBytesLineArray
48
52
* @return {BytesLine[] } - return array of BytesLine.
49
53
*/
50
- AsciiTree . prototype . toBytesLines = function ( ) {
54
+ AsciiTree . prototype . toBytesLineArray = function ( ) {
51
55
return this . topLine . toLines ( ) ;
52
56
} ;
53
57
0 commit comments