Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/floofies/nodestringtable
A fork of the console.table and cli_table NodeJS source code which returns strings, and works in web browsers.
https://github.com/floofies/nodestringtable
browser-polyfill cli-table console-table javascript nodejs string table tabular-data
Last synced: 22 days ago
JSON representation
A fork of the console.table and cli_table NodeJS source code which returns strings, and works in web browsers.
- Host: GitHub
- URL: https://github.com/floofies/nodestringtable
- Owner: Floofies
- Created: 2018-11-24T02:51:10.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2024-04-03T21:44:16.000Z (9 months ago)
- Last Synced: 2024-11-07T16:04:50.406Z (about 1 month ago)
- Topics: browser-polyfill, cli-table, console-table, javascript, nodejs, string, table, tabular-data
- Language: JavaScript
- Homepage:
- Size: 5.86 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# nodeStringTable
[![NPM](https://nodei.co/npm/nodestringtable.png?compact=true)](https://nodei.co/npm/nodestringtable/)
A fork of the [`console.table`](https://nodejs.org/api/console.html#console_console_table_tabulardata_properties) and `cli_table.js` NodeJS source code which returns Strings, and works in web browsers.
This module works almost exactly like the NodeJS [`console.table`](https://nodejs.org/api/console.html#console_console_table_tabulardata_properties), with the main difference being that it returns a string rather than logging it to the console.
## Usage
You can use the table function exactly like the NodeJS [`console.table`](https://nodejs.org/api/console.html#console_console_table_tabulardata_properties), but you must store the result as a string.
When using the web browser bundles, the module is available via the `nsTable` global.
```JavaScript
const nsTable = require("nodestringtable");
const tabularData = {
firstName: "John",
lastName: "Smith"
}
const table = nsTable(tabularData);
/* Creates a String table like this:
┌───────────┬─────────┐
│ (index) │ Values │
├───────────┼─────────┤
│ firstName │ 'John' │
│ lastName │ 'Smith' │
└───────────┴─────────┘
*/
```## Building for Browsers
Bundle `index.js` with Browserify in standalone mode, which should include a copy of the NodeJS `util` module to be used inside this module. The main bundle (`nsTable.js`) and an UglifyJS2 minified version (`nsTable.min.js`) will be saved to the `dist` directory.
You can just run the included NPM script which does this:
```bash
npm run bundle
```