Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

table-to-string

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

table-to-string

Generates a string representation of a table.

  • 1.0.1
  • unpublished
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

table-to-string

Generates a string representation of a table.

build status npm version

Installation

# with npm
npm install table-to-string

# with yarn
yarn add table-to-string

Usage

const tableToString = require('table-to-string');

const isThatA = [
  ['Jotaro Kujo', 'Star Platinum'],
  ['Josuke Higashikata', 'Crazy Diamond'],
  ['Giorno Giovanna', 'Gold Experience Requiem'],
  ['Jolyne Cujoh', 'Stone Free'],
  ['Johnny Joestar', 'Tusk'],
];

tableToString(isThatA);
//=> Jotaro Kujo         Star Platinum
//=> Josuke Higashikata  Crazy Diamond
//=> Giorno Giovanna     Gold Experience Requiem
//=> Jolyne Cujoh        Stone Free
//=> Johnny Joestar      Tusk

const jojoReference = [
  ['Dio', 'The World'],
  ['Yoshikage Kira', 'Killer Queen'],
  ['Diavolo', 'King Crimson'],
  ['Enrico Pucci', 'Made in Heaven'],
  ['Funny Valentine', 'Dirty Deeds Done Dirt Cheap'],
];

tableToString(jojoReference, {
  align: ['r', 'c'],
  str: (item) => `"${item}"`,
  sep: ' | ',
});
//=>             "Dio" |          "The World"
//=>  "Yoshikage Kira" |        "Killer Queen"
//=>         "Diavolo" |        "King Crimson"
//=>    "Enrico Pucci" |       "Made in Heaven"
//=> "Funny Valentine" | "Dirty Deeds Done Dirt Cheap"

Options

NameTypeDefault valueDescription
align('l' | 'c' | 'r' | undefined)[][] (which is equivalent to ['l', 'l', 'l', ...])The alignment for each column. It can be 'l' (left), 'c' (center) or 'r' (right). undefined is considered 'l'.
len(item: string, column: number) => number(item) => item.lengthThe function used to get the item length.
str(item: any, column: number) => stringString(item != null ? item : '')The function used to transform the item into a string.
sepstring' ' (two whitespaces)The separator between each item.
lfstring'\n'The line feed used for new lines.

License

This package is under a MIT license.

Keywords

FAQs

Package last updated on 29 Aug 2020

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc