Software zum Installieren eines Smart-Mirror Frameworks , zum Nutzen von hochschulrelevanten Informationen, auf einem Raspberry-Pi.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

index.js 1.1KB

1234567891011121314151617181920212223242526272829303132333435
  1. module.exports = function archy (obj, prefix, opts) {
  2. if (prefix === undefined) prefix = '';
  3. if (!opts) opts = {};
  4. var chr = function (s) {
  5. var chars = {
  6. '│' : '|',
  7. '└' : '`',
  8. '├' : '+',
  9. '─' : '-',
  10. '┬' : '-'
  11. };
  12. return opts.unicode === false ? chars[s] : s;
  13. };
  14. if (typeof obj === 'string') obj = { label : obj };
  15. var nodes = obj.nodes || [];
  16. var lines = (obj.label || '').split('\n');
  17. var splitter = '\n' + prefix + (nodes.length ? chr('│') : ' ') + ' ';
  18. return prefix
  19. + lines.join(splitter) + '\n'
  20. + nodes.map(function (node, ix) {
  21. var last = ix === nodes.length - 1;
  22. var more = node.nodes && node.nodes.length;
  23. var prefix_ = prefix + (last ? ' ' : chr('│')) + ' ';
  24. return prefix
  25. + (last ? chr('└') : chr('├')) + chr('─')
  26. + (more ? chr('┬') : chr('─')) + ' '
  27. + archy(node, prefix_, opts).slice(prefix.length + 2)
  28. ;
  29. }).join('')
  30. ;
  31. };