Socket
Socket
Sign inDemoInstall

tablemark

Package Overview
Dependencies
1
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    tablemark

Generate markdown tables from JSON data.


Version published
Weekly downloads
29K
decreased by-4.05%
Maintainers
1
Install size
8.23 kB
Created
Weekly downloads
 

Readme

Source

tablemark Version License Travis CI JavaScript Standard Style

Generate markdown tables from JSON data.

Parses arrays of objects into markdown tables, complete with configuration for renaming columns and left, center, or right-aligning them.

installation

npm i tablemark

usage

const tablemark = require('tablemark')
tablemark([
  { name: 'Bob', age: 21, isCool: false },
  { name: 'Sarah', age: 22, isCool: true },
  { name: 'Lee', age: 23, isCool: true }
])

// 'name | age | isCool'
// '----- | ----- | -----'
// 'Bob | 21 | false'
// 'Sarah | 22 | true'
// 'Lee | 23 | true'

... displays as:

nameageisCool
Bob21false
Sarah22true
Lee23true
tablemark([
  { name: 'Bob', age: 21, isCool: false },
  { name: 'Sarah', age: 22, isCool: true },
  { name: 'Lee', age: 23, isCool: true }
], {
  columns: [
    'first name',
    { name: 'how old', align: 'center' },
    'are they cool'
  ]
})

// first name | how old | are they cool
// ----- | :---: | -----
// Bob | 21 | false
// Sarah | 22 | true
// Lee | 23 | true

... displays as:

first namehow oldare they cool
Bob21false
Sarah22true
Lee23true

api

tablemark

tablemark(input, [options = {}])

Arguments

  • {Array<Object>} input: the data to table-ify
  • {Object} [options = {}]
keytypedefaultdescription
columns<Array>-Array of column descriptors.

The columns array can either contain objects, in which case their name and align properties will be used to alter the display of the column in the table, or any other type which will be coerced to a string if necessary and used as a replacement for the column name.

see also

license

MIT © Bo Lingen / citycide

Keywords

FAQs

Last updated on 22 Jan 2017

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc