{"_id":"easy-table","_rev":"1137636","name":"easy-table","description":"Nice text table for the CLI","dist-tags":{"latest":"1.2.0"},"maintainers":[{"name":"eldar","email":"eldargab@gmail.com"}],"time":{"modified":"2021-10-06T20:20:57.000Z","created":"2012-03-13T12:54:44.459Z","1.2.0":"2021-10-06T20:20:14.876Z","1.1.1":"2018-01-08T10:18:41.866Z","1.1.0":"2017-04-06T09:23:21.062Z","1.0.0":"2015-05-26T13:02:58.953Z","0.3.0":"2014-02-02T08:34:58.573Z","0.2.0":"2012-07-31T09:36:18.664Z","0.0.3":"2012-04-17T04:43:01.959Z","0.0.2":"2012-03-20T15:11:35.616Z","0.0.1":"2012-03-13T12:54:44.459Z"},"users":{"thejh":true,"fgribreau":true,"jaredvogt":true,"gayan":true,"tunnckocore":true,"nukisman":true,"semencov":true,"knksmith57":true,"curioussavage":true,"emyann":true,"ndaidong":true,"rocket0191":true,"joaquin.briceno":true,"drdoof":true,"dm7":true,"coreyro":true,"modood":true,"stone_breaker":true,"vghhkjh":true},"author":{"name":"Eldar Gabdullin","email":"eldargab@gmail.com"},"repository":{"type":"git","url":"git+https://github.com/eldargab/easy-table.git"},"versions":{"1.2.0":{"author":{"name":"Eldar Gabdullin","email":"eldargab@gmail.com"},"name":"easy-table","description":"Nice text table for the CLI","keywords":["table","text","cli"],"version":"1.2.0","repository":{"type":"git","url":"git+https://github.com/eldargab/easy-table.git"},"main":"./table.js","types":"./table.d.ts","devDependencies":{"mocha":"^9.1.2","should":"^13.2.3"},"license":"MIT","scripts":{"test":"mocha -R dot --check-leaks"},"optionalDependencies":{"wcwidth":"^1.0.1"},"dependencies":{"ansi-regex":"^5.0.1","wcwidth":"^1.0.1"},"gitHead":"e80b1d1044c702e42e8c4e931569800de089d9c3","bugs":{"url":"https://github.com/eldargab/easy-table/issues"},"homepage":"https://github.com/eldargab/easy-table#readme","_id":"easy-table@1.2.0","_nodeVersion":"14.18.0","_npmVersion":"6.14.15","dist":{"shasum":"ba9225d7138fee307bfd4f0b5bc3c04bdc7c54eb","size":7160,"noattachment":false,"key":"/easy-table/-/easy-table-1.2.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/easy-table/download/easy-table-1.2.0.tgz"},"_npmUser":{"name":"eldar","email":"eldargab@gmail.com"},"directories":{},"maintainers":[{"name":"eldar","email":"eldargab@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/easy-table_1.2.0_1633551614688_0.0800217491253834"},"_hasShrinkwrap":false,"publish_time":1633551614876,"_cnpm_publish_time":1633551614876},"1.1.1":{"author":{"name":"Eldar Gabdullin","email":"eldargab@gmail.com"},"name":"easy-table","description":"Nice text table for the CLI","keywords":["table","text","cli"],"version":"1.1.1","repository":{"type":"git","url":"git+https://eldargab@github.com/eldargab/easy-table.git"},"main":"./table.js","devDependencies":{"mocha":"*","should":"*"},"license":"MIT","scripts":{"test":"mocha -R dot --check-leaks"},"optionalDependencies":{"wcwidth":">=1.0.1"},"dependencies":{"ansi-regex":"^3.0.0","wcwidth":">=1.0.1"},"gitHead":"0c94cd5e94949faa71704a3ed9e08eba3dd58abb","bugs":{"url":"https://github.com/eldargab/easy-table/issues"},"homepage":"https://github.com/eldargab/easy-table#readme","_id":"easy-table@1.1.1","_npmVersion":"5.5.1","_nodeVersion":"9.2.0","_npmUser":{"name":"eldar","email":"eldargab@gmail.com"},"dist":{"shasum":"c1b9b9ad68a017091a1c235e4bcba277540e143f","size":5981,"noattachment":false,"key":"/easy-table/-/easy-table-1.1.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/easy-table/download/easy-table-1.1.1.tgz"},"maintainers":[{"name":"eldar","email":"eldargab@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/easy-table-1.1.1.tgz_1515406720928_0.02160707674920559"},"directories":{},"publish_time":1515406721866,"_cnpm_publish_time":1515406721866,"_hasShrinkwrap":false},"1.1.0":{"author":{"name":"Eldar Gabdullin","email":"eldargab@gmail.com"},"name":"easy-table","description":"Nice text table for the CLI","keywords":["table","text","cli"],"version":"1.1.0","repository":{"type":"git","url":"git+https://eldargab@github.com/eldargab/easy-table.git"},"main":"./table.js","devDependencies":{"mocha":"*","should":"*"},"license":"MIT","scripts":{"test":"mocha -R dot --check-leaks"},"optionalDependencies":{"wcwidth":">=1.0.1"},"gitHead":"d5c111226d431038e097d8775d34e14fe2156e4a","bugs":{"url":"https://github.com/eldargab/easy-table/issues"},"homepage":"https://github.com/eldargab/easy-table#readme","dependencies":{"wcwidth":">=1.0.1"},"_id":"easy-table@1.1.0","_shasum":"86f9ab4c102f0371b7297b92a651d5824bc8cb73","_from":".","_npmVersion":"3.10.3","_nodeVersion":"6.4.0","_npmUser":{"name":"eldar","email":"eldargab@gmail.com"},"dist":{"shasum":"86f9ab4c102f0371b7297b92a651d5824bc8cb73","size":5984,"noattachment":false,"key":"/easy-table/-/easy-table-1.1.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/easy-table/download/easy-table-1.1.0.tgz"},"maintainers":[{"name":"eldar","email":"eldargab@gmail.com"}],"_npmOperationalInternal":{"host":"packages-12-west.internal.npmjs.com","tmp":"tmp/easy-table-1.1.0.tgz_1491470599237_0.604193679522723"},"directories":{},"publish_time":1491470601062,"_hasShrinkwrap":false,"_cnpm_publish_time":1491470601062},"1.0.0":{"author":{"name":"Eldar Gabdullin","email":"eldargab@gmail.com"},"name":"easy-table","description":"Nice text table for the CLI","keywords":["table","text","cli"],"version":"1.0.0","repository":{"type":"git","url":"https://eldargab@github.com/eldargab/easy-table.git"},"main":"./lib/table","devDependencies":{"mocha":"*","should":"*"},"license":"MIT","scripts":{"test":"mocha -R dot --check-leaks"},"gitHead":"700a001ba26ca0bc92c5d7681fb4d10b7784a31f","bugs":{"url":"https://github.com/eldargab/easy-table/issues"},"homepage":"https://github.com/eldargab/easy-table","_id":"easy-table@1.0.0","_shasum":"29db2d0855d36316e4382e5a3d85d9cb5fc93216","_from":".","_npmVersion":"2.0.0","_npmUser":{"name":"eldar","email":"eldargab@gmail.com"},"maintainers":[{"name":"eldar","email":"eldargab@gmail.com"}],"dist":{"shasum":"29db2d0855d36316e4382e5a3d85d9cb5fc93216","size":5291,"noattachment":false,"key":"/easy-table/-/easy-table-1.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/easy-table/download/easy-table-1.0.0.tgz"},"directories":{},"publish_time":1432645378953,"_cnpm_publish_time":1432645378953,"_hasShrinkwrap":false},"0.3.0":{"author":{"name":"Eldar Gabdullin","email":"eldargab@gmail.com"},"name":"easy-table","description":"Nice text table for the CLI","keywords":["table","text","cli"],"version":"0.3.0","repository":{"type":"git","url":"https://eldargab@github.com/eldargab/easy-table.git"},"main":"./lib/table","devDependencies":{"mocha":"*","should":"*"},"bugs":{"url":"https://github.com/eldargab/easy-table/issues"},"_id":"easy-table@0.3.0","dist":{"shasum":"46f3b04418273a716c2ce8c52f1caca9d0241cb7","size":5066,"noattachment":false,"key":"/easy-table/-/easy-table-0.3.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/easy-table/download/easy-table-0.3.0.tgz"},"_from":".","_npmVersion":"1.3.11","_npmUser":{"name":"eldar","email":"eldargab@gmail.com"},"maintainers":[{"name":"eldar","email":"eldargab@gmail.com"}],"directories":{},"publish_time":1391330098573,"_cnpm_publish_time":1391330098573,"_hasShrinkwrap":false},"0.2.0":{"author":{"name":"Eldar Gabdullin","email":"eldargab@gmail.com"},"name":"easy-table","description":"Nice text table for the CLI","keywords":["table","text","cli"],"version":"0.2.0","repository":{"type":"git","url":"https://eldargab@github.com/eldargab/easy-table.git"},"main":"./lib/table","devDependencies":{"mocha":"*","should":"*"},"_id":"easy-table@0.2.0","dist":{"shasum":"aa2d2834dade18220ec2f7dba452a0b95363fdfe","size":5075,"noattachment":false,"key":"/easy-table/-/easy-table-0.2.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/easy-table/download/easy-table-0.2.0.tgz"},"maintainers":[{"name":"eldar","email":"eldargab@gmail.com"}],"directories":{},"publish_time":1343727378664,"_cnpm_publish_time":1343727378664,"_hasShrinkwrap":false},"0.0.3":{"author":{"name":"Eldar Gabdullin","email":"eldargab@gmail.com"},"name":"easy-table","description":"Nice text table for the CLI","keywords":["table","text","cli"],"version":"0.0.3","repository":{"type":"git","url":"git://github.com/eldargab/easy-table.git"},"main":"./lib/table","devDependencies":{"mocha":"*","should":"*"},"_npmUser":{"name":"Eldar","email":"eldargab@gmail.com"},"_id":"easy-table@0.0.3","dependencies":{},"optionalDependencies":{},"engines":{"node":"*"},"_engineSupported":true,"_npmVersion":"1.1.16","_nodeVersion":"v0.6.15","_defaultsLoaded":true,"dist":{"shasum":"9cde1318be0c055c08da75fd455e72e1a2772ead","size":3893,"noattachment":false,"key":"/easy-table/-/easy-table-0.0.3.tgz","tarball":"http://registry.cnpm.dingdandao.com/easy-table/download/easy-table-0.0.3.tgz"},"maintainers":[{"name":"eldar","email":"eldargab@gmail.com"}],"directories":{},"publish_time":1334637781959,"_cnpm_publish_time":1334637781959,"_hasShrinkwrap":false},"0.0.2":{"author":{"name":"Eldar Gabdullin","email":"eldargab@gmail.com"},"name":"easy-table","description":"Nice text table for the CLI","keywords":["table","text","cli"],"version":"0.0.2","repository":{"type":"git","url":"git://github.com/eldargab/easy-table.git"},"main":"./lib/table","devDependencies":{"mocha":"*","should":"*"},"_npmUser":{"name":"Eldar","email":"eldargab@gmail.com"},"_id":"easy-table@0.0.2","dependencies":{},"optionalDependencies":{},"engines":{"node":"*"},"_engineSupported":true,"_npmVersion":"1.1.4","_nodeVersion":"v0.6.12","_defaultsLoaded":true,"dist":{"shasum":"15371ad43141b1da5dc48c5511ee58faf32cb045","size":3246,"noattachment":false,"key":"/easy-table/-/easy-table-0.0.2.tgz","tarball":"http://registry.cnpm.dingdandao.com/easy-table/download/easy-table-0.0.2.tgz"},"maintainers":[{"name":"eldar","email":"eldargab@gmail.com"}],"directories":{},"publish_time":1332256295616,"_cnpm_publish_time":1332256295616,"_hasShrinkwrap":false},"0.0.1":{"author":{"name":"Eldar Gabdullin","email":"eldargab@gmail.com"},"name":"easy-table","description":"Nice text table for the CLI","keywords":["table","text","cli"],"version":"0.0.1","repository":{"type":"git","url":"git://github.com/eldargab/easy-table.git"},"main":"./lib/table","devDependencies":{"mocha":"*","should":"*"},"_npmUser":{"name":"Eldar","email":"eldargab@gmail.com"},"_id":"easy-table@0.0.1","dependencies":{},"optionalDependencies":{},"engines":{"node":"*"},"_engineSupported":true,"_npmVersion":"1.1.4","_nodeVersion":"v0.6.12","_defaultsLoaded":true,"dist":{"shasum":"dbd809177a1dd7afc06b4849d1ca7eff13e299eb","size":2592,"noattachment":false,"key":"/easy-table/-/easy-table-0.0.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/easy-table/download/easy-table-0.0.1.tgz"},"maintainers":[{"name":"eldar","email":"eldargab@gmail.com"}],"directories":{},"publish_time":1331643284459,"_cnpm_publish_time":1331643284459,"_hasShrinkwrap":false}},"readme":"# Easy table\n\nNice utility for rendering text tables with javascript.\n\n## Usage\n\n```javascript\nvar Table = require('easy-table')\n\nvar data = [\n  { id: 123123, desc: 'Something awesome', price: 1000.00 },\n  { id: 245452, desc: 'Very interesting book', price: 11.45},\n  { id: 232323, desc: 'Yet another product', price: 555.55 }\n]\n\nvar t = new Table\n\ndata.forEach(function(product) {\n  t.cell('Product Id', product.id)\n  t.cell('Description', product.desc)\n  t.cell('Price, USD', product.price, Table.number(2))\n  t.newRow()\n})\n\nconsole.log(t.toString())\n```\n\nThe script above will render:\n\n```\nProduct Id  Description            Price, USD\n----------  ---------------------  ----------\n123123      Something awesome         1000.00\n245452      Very interesting book       11.45\n232323      Yet another product        555.55\n```\n\n`t.printTransposed()` returns\n\n```\nProduct Id  : 245452                : 232323              : 123123\nDescription : Very interesting book : Yet another product : Something awesome\nPrice, USD  : 11.45                 : 555.55              : 1000.00\n```\n\n`t.print()` shows just rows you pushed and nothing more\n\n```\n123123  Something awesome      1000.00\n245452  Very interesting book    11.45\n232323  Yet another product     555.55\n```\n\n### How it works\n\nThe full signature of `.cell()` is:\n\n```javascript\nt.cell(column, value, printer)\n```\n\nRendering occures in two phases. At the first phase `printer`\nis called to get the minimal width required to fit the cell content.\nAt the second phase `printer` is called again with\nadditional `width` parameter to get actual string to render.\n\nFor example, here is how currency printer might be defined\n\n``` javascript\nfunction currency(val, width) {\n  var str = val.toFixed(2)\n  return width ? Table.padLeft(str, width) : str\n}\n```\n\n### Table.print()\n\nWhen you already have an array, explicit table instantiation and iteration\nbecomes an overhead. For such cases it is convenient to use `Table.print()`.\n\n``` javascript\nconsole.log(Table.print(data))\n```\n\n```\nid      desc                   price\n------  ---------------------  ------\n123123  Something awesome      1000\n245452  Very interesting book  11.45\n232323  Yet another product    555.55\n```\n\nIt is possible to pass some options\n\n``` javascript\nTable.print(data, {\n  desc: {name: 'description'}\n  price: {printer: Table.number(2)}\n})\n```\n\n```\nid      description            price\n------  ---------------------  -------\n123123  Something awesome      1000.00\n245452  Very interesting book    11.45\n232323  Yet another product     555.55\n```\n\nor have a full control over rendering\n\n``` javascript\nTable.print(data, function(item, cell) {\n  cell('Product id', item.id)\n  cell('Price, USD', item.price)\n}, function(table) {\n  return table.print()\n})\n```\n\n`Table.print()` also accepts objects\n\n``` javascript\nTable.print(data[0])\n```\n\n```\nid    : 123123\ndesc  : Something awesome\nprice : 1000\n```\n\n### Sorting\n\nYou can sort a table by calling `.sort()`, and optionally passing in a list of\ncolumn names to sort on (by default uses all columns), or a custom comparator\nfunction. It is also possible to specify the sort order. For example:\n\n``` javascript\nt.sort(['Price, USD|des']) // will sort in descending order\nt.sort(['Price, USD|asc']) // will sort in ascending order\nt.sort(['Price, USD']) // sorts in ascending order by default\n```\n\n### Totaling\n\nEasy table can help to calculate and render totals:\n\n``` javascript\nt.total('Price, USD')\n```\n\n```\nProduct Id  Description            Price, USD\n----------  ---------------------  ----------\n245452      Very interesting book       11.45\n232323      Yet another product        555.55\n123123      Something awesome         1000.00\n----------  ---------------------  ----------\n                                      1567.00\n```\n\nHere is a more elaborate example\n\n```javascript\nt.total('Price, USD', {\n  printer: Table.aggr.printer('Avg: ', currency),\n  reduce: Table.aggr.avg,\n  init: 0\n})\n\n// or alternatively\n\nt.total('Price, USD', {\n  printer: function(val, width) {\n    return padLeft('Avg: ' + currency(val), width)\n  },\n  reduce: function(acc, val, idx, len) {\n    acc = acc + val\n    return idx + 1 == len ? acc/len : acc\n  }\n})\n```\n\n```\nProduct Id  Description            Price, USD\n----------  ---------------------  -----------\n245452      Very interesting book        11.45\n232323      Yet another product         555.55\n123123      Something awesome          1000.00\n----------  ---------------------  -----------\n                                   Avg: 522.33\n```\n\n## Installation\n\nvia npm\n\n```\n$ npm install easy-table\n```\n\n## License\n\n(The MIT License)\n\nCopyright (c) 2015 Eldar Gabdullin <eldargab@gmail.com>\n\nPermission is hereby granted, free of charge, to any person obtaining\na copy of this software and associated documentation files (the\n'Software'), to deal in the Software without restriction, including\nwithout limitation the rights to use, copy, modify, merge, publish,\ndistribute, sublicense, and/or sell copies of the Software, and to\npermit persons to whom the Software is furnished to do so, subject to\nthe following conditions:\n\nThe above copyright notice and this permission notice shall be\nincluded in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,\nEXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\nIN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY\nCLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,\nTORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\nSOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n","_attachments":{},"homepage":"https://github.com/eldargab/easy-table#readme","bugs":{"url":"https://github.com/eldargab/easy-table/issues"},"license":"MIT"}