How to use treeify - 10 common examples

To help you get started, we’ve selected a few treeify examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github DefinitelyTyped / DefinitelyTyped / types / treeify / treeify-tests.ts View on Github external
import * as treeify from 'treeify';

function log(s: string): void {}

treeify.asTree(
    {
        apples: 'gala', //      ├─ apples: gala
        oranges: 'mandarin' //  └─ oranges: mandarin
    },
    true,
    true
);

treeify.asLines(
    {
        apples: 'gala', //                       ├─ apples: gala
        oranges: 'mandarin', //                  ├─ oranges: mandarin
        grapes: {  //                            └─ grapes
            seedless: 'Thompson, Selma Pete', //     ├─ seedless: Thompson, Selma Pete
            seeded: 'concord' //                     └─ seeded: Concord
        }
    },
    true,
    log
);

treeify.asLines(
    {
        apples: 'gala', //      ├─ apples: gala
        oranges: 'mandarin' //  └─ oranges: mandarin
github node-opcua / node-opcua / packages / node-opcua-samples / bin / simple_client.js View on Github external
crawler.read(nodeId, function (err, obj) {
                console.log(" Time         = ", (new Date()).getTime() - t);
                console.log(" read        = ", crawler.readCounter);
                console.log(" browse      = ", crawler.browseCounter);
                console.log(" transaction = ", crawler.transactionCounter);
                if (!err) {

                    if (false) {
                        // todo : treeify.asTree performance is *very* slow on large object, replace with better implementation
                        //xx console.log(treeify.asTree(obj, true));
                        treeify.asLines(obj, true, true, function (line) {
                            console.log(line);
                        });
                    } else {
                        process.exit(1);
                    }
                }
                client.removeListener("receive_response", print_stat);
                callback(err);
            });
github node-opcua / node-opcua / packages / node-opcua-samples / bin / simple_client.js View on Github external
crawler.read(nodeId, function (err, obj) {
                console.log(" Time         = ", (new Date()).getTime() - t);
                console.log(" read        = ", crawler.readCounter);
                console.log(" browse      = ", crawler.browseCounter);
                console.log(" transaction = ", crawler.transactionCounter);
                if (!err) {

                    if (false) {
                        // todo : treeify.asTree performance is *very* slow on large object, replace with better implementation
                        //xx console.log(treeify.asTree(obj, true));
                        treeify.asLines(obj, true, true, function (line) {
                            console.log(line);
                        });
                    } else {
                      //  process.exit(1);
                    }
                }
                client.removeListener("receive_response", print_stat);
                crawler.dispose();
                callback(err);
            });
github tes / bosco / src / RunListHelper.js View on Github external
resolveDependencies(filteredRepos, [], function (err, repoList) {
    var runList = _.chain(repoList)
      .filter(boscoOptionFilter('deps-only', notCurrentService))
      .filter(boscoOptionFilter('docker-only', isType('remote')))
      .map(getConfig)
      .filter(isInfraOnly)
      .filter(exclude)
      .sortBy(getOrder)
      .value();

    if (displayOnly) {
      _.chain(repos)
        .map(_.curry(createTree)(tree, []))
        .value();
      /* eslint-disable no-console */
      console.log(treeify.asTree(tree));
      /* eslint-enable no-console */
      next();
    } else {
      next(null, runList);
    }
  });
}
github node-opcua / node-opcua / packages / node-opcua-samples / bin / simple_client_ts.ts View on Github external
const dataValue = await the_session.readVariableValue(server_NamespaceArray_Id);

    console.log(" --- NAMESPACE ARRAY ---");
    const namespaceArray = dataValue.value.value;
    for (const namespace of namespaceArray) {
        console.log(" Namespace ", namespace.index, "  : ", namespace);
    }
    console.log(" -----------------------");

    // -----------------------------------------------------------------------------------------------------------
    //   enumerate all EVENT TYPES
    // -----------------------------------------------------------------------------------------------------------
    const result = getAllEventTypes(the_session);
    console.log(chalk.cyan("---------------------------------------------------- All Event Types "));
    console.log(treeify.asTree(result, true));
    console.log(" -----------------------");

    // -----------------------------------------------------------------------------------------------------------
    //   Node Crawling
    // -----------------------------------------------------------------------------------------------------------
    let t1: number;
    let t2: number;

    function print_stat() {
        t2 = Date.now();
        const str = util.format("R= %d W= %d T=%d t= %d",
            client.bytesRead, client.bytesWritten, client.transactionsPerformed, (t2 - t1));
        console.log(chalk.yellow.bold(str));
    }

    if (doCrawling) {
github node-opcua / node-opcua / packages / node-opcua-samples / bin / simple_client_ts.ts View on Github external
// xx     console.log("->",(new Date()).getTime()-t,element.browseName.name,element.nodeId.toString());
        // xx });

        const nodeId = "ObjectsFolder";
        console.log("now crawling object folder ...please wait...");

        const obj = await crawler.read(nodeId);
        console.log(" Time        = ", (new Date()).getTime() - t5);
        console.log(" read        = ", crawler.readCounter);
        console.log(" browse      = ", crawler.browseCounter);
        console.log(" browseNext  = ", crawler.browseNextCounter);
        console.log(" transaction = ", crawler.transactionCounter);
        if (false) {
            // todo : treeify.asTree performance is *very* slow on large object, replace with better implementation
            // xx console.log(treeify.asTree(obj, true));
            treeify.asLines(obj, true, true, (line: string) => {
                console.log(line);
            });
        }
        crawler.dispose();
    }
    client.removeListener("receive_response", print_stat);

    // -----------------------------------------------------------------------------------------------------------------
    // enumerate all Condition Types exposed by the server
    // -----------------------------------------------------------------------------------------------------------------

    console.log("--------------------------------------------------------------- Enumerate all Condition Types exposed by the server");
    const conditionTree = await enumerateAllConditionTypes(the_session);
    console.log(treeify.asTree(conditionTree));
    console.log(" -----------------------------------------------------------------------------------------------------------------");
github ConsenSys / surya / src / ftrace.js View on Github external
if(functionCallObject.contract.substring(0,8) !== '#address') {
            constructCallTree(functionCallObject.contract, functionCallName, parentObject[keyString])
          }
        } else {
          parentObject[keyString] = Object.keys(functionCallsTree[functionCallObject.contract][functionCallName]).length === 0 ?
                                    {} :
                                    '..[Repeated Ref]..'.red
        }
      }
    })
  }

  // Call with seed
  constructCallTree(contractToTraverse, functionToTraverse, callTree[seedKeyString])

  return treeify.asTree(callTree, true)
}
github node-opcua / node-opcua / test / end_to_end / u_test_e2e_client_node_crawler.js View on Github external
crawler.read(nodeId, function (err, obj) {
                        if (!err) {
                            treeify.asLines(obj, true, true, function (line) {
                                console.log(line);
                            });
                        }
                        callback(err);
                    });
github ORESoftware / npm-link-up / lib / commands / ls / index.ts View on Github external
searchDir(searchRoot, treeObj[key], err => {

  if (err) {
    throw err;
  }

  cleanTree(treeObj);

  const treeString = treeify.asTree(treeObj, true);
  const formattedStr = String(treeString).split('\n').map(function (line) {
    return '\t' + line;
  });

  console.log(chalk.white(formattedStr.join('\n')));
  process.exit(0);

});
github node-opcua / node-opcua / packages / node-opcua-samples / bin / simple_client_ts.ts View on Github external
console.log(" connecting to ", chalk.cyan.bold(endpointUrl));
    console.log("    strategy", client.connectionStrategy);

    try {
        await client.connect(endpointUrl);
    } catch (err) {
        console.log(chalk.red(" Cannot connect to ") + endpointUrl);
        console.log(" Error = ", err.message);
        return;
    }

    const endpoints = await client.getEndpoints();

    if (argv.debug) {
        fs.writeFileSync("tmp/endpoints.log", JSON.stringify(endpoints, null, " "));
        console.log(treeify.asTree(endpoints, true));
    }

    const table = new Table();

    let serverCertificate: Certificate | undefined;

    let i = 0;
    for (const endpoint of endpoints) {
        table.cell("endpoint", endpoint.endpointUrl + "");
        table.cell("Application URI", endpoint.server.applicationUri);
        table.cell("Product URI", endpoint.server.productUri);
        table.cell("Application Name", endpoint.server.applicationName.text);
        table.cell("Security Mode", MessageSecurityMode[endpoint.securityMode].toString());
        table.cell("securityPolicyUri", endpoint.securityPolicyUri);
        table.cell("Type", ApplicationType[endpoint.server.applicationType]);
        table.cell("certificate", "..." /*endpoint.serverCertificate*/);

treeify

converts a JS object into a nice and readable tree structure for the console

MIT
Latest version published 7 years ago

Package Health Score

73 / 100
Full package analysis

Popular treeify functions