{"id":26221715,"url":"https://github.com/push-based/micro-table","last_synced_at":"2025-03-12T16:29:20.420Z","repository":{"id":274196646,"uuid":"921883528","full_name":"push-based/micro-table","owner":"push-based","description":"A 0 dependency extremely small nodeJS lib for render tables in the terminal","archived":false,"fork":false,"pushed_at":"2025-01-25T15:42:27.000Z","size":0,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-01-25T16:25:54.479Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/push-based.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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":"2025-01-24T19:52:52.000Z","updated_at":"2025-01-25T15:43:12.000Z","dependencies_parsed_at":"2025-01-25T16:36:41.046Z","dependency_job_id":null,"html_url":"https://github.com/push-based/micro-table","commit_stats":null,"previous_names":["push-based/micro-cli-table"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/push-based%2Fmicro-table","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/push-based%2Fmicro-table/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/push-based%2Fmicro-table/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/push-based%2Fmicro-table/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/push-based","download_url":"https://codeload.github.com/push-based/micro-table/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243251743,"owners_count":20261268,"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":[],"created_at":"2025-03-12T16:29:19.796Z","updated_at":"2025-03-12T16:29:20.410Z","avatar_url":"https://github.com/push-based.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Micro Table\n\nA extremely lightweight TypeScript table rendering for the terminal.\n\n**Features:**\n\n- [x] Extremely lightweight\n- [x] No dependencies\n- [x] Custom border style\n- [x] Format hooks for rows\n\n## Benchmarks\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003ccode\u003etable.js\u003c/code\u003e\u003c/summary\u003e\n\n```typescript\nimport {Console} from 'node:console';\nimport {PassThrough} from 'node:stream';\n\nconst ts = new PassThrough();\nconst logger = () =\u003e {\n    return new Console({stdout: ts}).table(data);\n}\n\nexport function table(data: any, opt): string {\n    const rowFormats = opt?.rowFormats ?? [];\n    return String(logger.table(data) ?? ts.read())\n        .split(`\\n`)\n        .flatMap((line, _, rows) =\u003e\n            rowFormats\n                .reduce((acc, fn) =\u003e acc.flatMap(row =\u003e {\n                        const formatted = fn(row, acc.indexOf(row), rows);\n                        return Array.isArray(formatted) ? formatted : [formatted];\n                    }), [line])\n        )\n        .join(`\\n`);\n}\n```\n\n\u003c/details\u003e\n\n| **File Name**         | **CJS** | **ESM** |\n|-----------------------|---------|---------|\n| `alignment.format.js` | 1.0 KB  | 1.10 KB |\n| `border.format.js`    | 0.9 KB  | 0.95 KB |\n| `table.js`            | 2.37 KB | 2.33 KB |\n\n## Installation\n\n```sh   \nnpm install @push-based/micro-table\n```\n\n### Usage\n\n```ts\nimport {table} from '@push-based/micro-table';\n\nconst strigTable = table([\n    {\n        name: 'Alice',\n        age: 25,\n    },\n    {\n        name: 'Bob',\n        age: 30,\n    }\n]);\n\n// Output:\n// ┌───────┬─────┐\n// │ Name  │ Age │\n// ├───────┼─────┤\n// │ Alice │  25 │\n// │ Bob   │  30 │\n// └───────┴─────┘\nconsole.log(strigTable);\n```\n\n#### Border Style\n\nBy default, the table has a border style of `single`.\n\nYou can change the border style by using the `borderStyle` helper with one of the following styles:\n\n- `single`\n- `double`\n- `round`\n- `zigzag`\n\n```ts\nimport {table, borderStyle} from '@push-based/micro-table';\n\nconst strigTable = table(data, {\n    rowFormats: [\n        borderStyle('double')\n    ]\n});\n\n// Output:\n// ╔═══════╦═════╗\n// ║ Name  ║ Age ║\n// ╠═══════╬═════╣\n// ║ Alice ║ 30  ║\n// ║ Bob   ║ 25  ║\n// ╚═══════╩═════╝\nconsole.log(strigTable);\n```\n\n##### Custom Border Style\n\nYou can also create a custom border style by using the `borderStyle` helper with a custom character set.\n\n```ts\nimport {table, borderStyle} from '@push-based/micro-table';\n\nconst strigTable = table(data, {\n    rowFormats: [\n        borderStyle({\n            '┌': '┏',\n            '┐': '┓',\n            '└': '┗',\n            '┘': '┛',\n            '─': '━',\n            '│': '┃',\n            '┼': '╋',\n            '├': '┣',\n            '┤': '┫',\n            '┬': '┳',\n            '┴': '┻',\n        })\n    ]\n});\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpush-based%2Fmicro-table","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpush-based%2Fmicro-table","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpush-based%2Fmicro-table/lists"}