{"id":13846943,"url":"https://github.com/xpl/as-table","last_synced_at":"2025-04-05T12:07:06.378Z","repository":{"id":57184542,"uuid":"65133118","full_name":"xpl/as-table","owner":"xpl","description":"A simple function that prints objects as ASCII tables. Supports ANSI styling and weird Unicode 💩 emojis – they won't break the layout.","archived":false,"fork":false,"pushed_at":"2023-09-25T15:51:17.000Z","size":990,"stargazers_count":64,"open_issues_count":5,"forks_count":10,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-03-29T11:08:29.132Z","etag":null,"topics":["ascii-tables","javascript","pretty-print","stringify"],"latest_commit_sha":null,"homepage":"http://npmjs.com/package/as-table","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/xpl.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-08-07T12:55:25.000Z","updated_at":"2025-02-03T04:57:26.000Z","dependencies_parsed_at":"2024-06-18T13:39:09.429Z","dependency_job_id":"64d04270-10eb-4fa2-b801-656b99e4c044","html_url":"https://github.com/xpl/as-table","commit_stats":{"total_commits":119,"total_committers":7,"mean_commits":17.0,"dds":0.3613445378151261,"last_synced_commit":"8df56d83c335ec5689d9e5e5ec233968678ab858"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xpl%2Fas-table","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xpl%2Fas-table/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xpl%2Fas-table/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xpl%2Fas-table/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/xpl","download_url":"https://codeload.github.com/xpl/as-table/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247332609,"owners_count":20921853,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ascii-tables","javascript","pretty-print","stringify"],"created_at":"2024-08-04T18:00:50.750Z","updated_at":"2025-04-05T12:07:06.358Z","avatar_url":"https://github.com/xpl.png","language":"JavaScript","readme":"# as-table\n\n[![Build Status](https://travis-ci.org/xpl/as-table.svg?branch=master)](https://travis-ci.org/xpl/as-table) [![Coverage Status](https://coveralls.io/repos/github/xpl/as-table/badge.svg)](https://coveralls.io/github/xpl/as-table) [![npm](https://img.shields.io/npm/v/as-table.svg)](https://npmjs.com/package/as-table) [![dependencies Status](https://david-dm.org/xpl/as-table/status.svg)](https://david-dm.org/xpl/as-table) [![Scrutinizer Code Quality](https://img.shields.io/scrutinizer/g/xpl/as-table.svg)](https://scrutinizer-ci.com/g/xpl/as-table/?branch=master)\n\nA simple function that print objects and arrays as ASCII tables. Supports ANSI styling and weird 💩 Unicode emoji symbols (they won't break the layout), thanks to [`printable-characters`](https://github.com/xpl/printable-characters).\n\n```bash\nnpm install as-table\n```\n\n## Printing objects\n\n```javascript\nasTable = require ('as-table')\n\nasTable ([ { foo: true,  string: 'abcde',      num: 42 },\n           { foo: false, string: 'qwertyuiop', num: 43 },\n           {             string:  null,        num: 44 } ])\n```\n```\nfoo    string      num\n----------------------\ntrue   abcde       42 \nfalse  qwertyuiop  43 \n       null        44 \n```\n\n## Printing arrays\n\n```javascript\nasTable ([['qwe',       '123456789', 'zxcvbnm'],\n          ['qwerty',    '12',        'zxcvb'],\n          ['qwertyiop', '1234567',   'z']])\n```\n```\nqwe        123456789  zxcvbnm\nqwerty     12         zxcvb\nqwertyiop  1234567    z\n```\n\n## Limiting total width by proportionally trimming cells + setting columns delimiter\n\n```javascript\nasTable.configure ({ maxTotalWidth: 22, delimiter: ' | ' }) (data)\n```\n```\nqwe   | 1234… | zxc…\nqwer… | 12    | zxc…\nqwer… | 1234… | z   \n```\n\n## Right align\n\n```javascript\nasTable.configure ({ right: true }) (data)\n```\n```\n      foo        bar      baz\n-----------------------------\n      qwe  123456789  zxcvbnm\n   qwerty         12    zxcvb\nqwertyiop    1234567        z\n```\n\n## Providing a custom object printer\n\n```javascript\nasTable.configure ({ print: x =\u003e (typeof x === 'boolean') ? (x ? 'yes' : 'no') : String (x) }) (data)\n```\n```\nfoo  string      num\n--------------------\nyes  abcde       42 \nno   qwertyuiop  43 \n     null        44 \n```\n\nThe callback also receives a field name (in case of objects) or a column index (in case of arrays):\n\n```javascript\nasTable = require ('as-table').configure ({\n    print (x, k) {\n        if (k === 'timestamp') return new Date (x).toGMTString()\n        return String (x)\n    }\n})\n\nasTable ([ { name: 'A', timestamp: 1561202591572 },\n           { name: 'B', timestamp: 1558524240034 } ])\n```\n\n## Obtaining a pre-configured function\n\n```javascript\nasTable = require ('as-table').configure ({ maxTotalWidth: 25, delimiter: ' | ' })\n\nasTable (data)\n```\n\n## Customizing the title rendering and the header separator\n\nWith string coloring by [`ansicolor`](https://github.com/xpl/ansicolor) (just for the demo purposes, any library will fit):\n\n```javascript\nasTable = require ('as-table').configure ({ title: x =\u003e x.bright, delimiter: ' | '.dim.cyan, dash: '-'.bright.cyan })\n\nconsole.log (\n   asTable ([ { foo: true,  string: 'abcde',                             num: 42 },\n              { foo: false, string: 'qwertyuiop'.bgMagenta.green.bright, num: 43 } ])\n```\n\n\u003cimg width=\"179\" alt=\"screen shot 2017-07-21 at 23 46 14\" src=\"https://user-images.githubusercontent.com/1707/28481945-dcb0f8d6-6e6e-11e7-896e-dfad40662daf.png\"\u003e\n\n","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxpl%2Fas-table","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fxpl%2Fas-table","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxpl%2Fas-table/lists"}