toString([id])

Converts the tree into a string.

Parameters

  • id (string, optional) - string id of a node to be printed. Default is root.

Returns

  • (string) - string representation of the tree.

Examples

import Treeful from 'treeful';

console.log(Treeful.toString());
/*
root: null
*/

Treeful.add('n1')
       .add('n2', 'string')
           .add('n3', true, 'n2');

console.log(Treeful.toString());
/*
root: null
    n2: string
        n3: true
    n1: null
*/

console.log(Treeful.toString('n2'));
/*
n2: string
    n3: true
*/

results matching ""

    No results matching ""