Nocturnal Prancing Mosquito

    tsv-json
    TypeScript icon, indicating that this package has built-in type declarations

    2.0.0 • Public • Published

    tsv-json Build Status install size

    Convert between TSV and JSON (string[][])

    Highlights

    • Zero dependencies
    • Simple and to the point
    • Written in TypeScript
    • Handles double-quotes correctly

    Install

    $ npm install tsv-json
    

    Usage

    const { tsv2json, json2tsv } = require('tsv-json');
     
    console.log(json2tsv([
        ['foo', 'bar'],
        ['baz', 'qux']
    ]));
    //=> 'foo\tbar\nbaz\tqux'
     
    console.log(tsv2json('foo\tbar\nbaz\tqux'));
    //=> [['foo', 'bar'], ['baz', 'qux']]

    Handles tabs, newlines and double-quotes correctly.

    Asserts the input is of the expected type (string[][] for json2tsv, string for tsv2json).

    Tip for Excel

    If you copy any TSV generated by this package and paste directly on an Excel cell, Excel will automatically parse the TSV and fit everything in the appropriate rows and columns, starting at the cell highlighted by you.

    Related

    License

    MIT © Pedro Augusto de Paula Barbosa

    Install

    npm i tsv-json

    DownloadsWeekly Downloads

    166

    Version

    2.0.0

    License

    MIT

    Unpacked Size

    8.6 kB

    Total Files

    9

    Last publish

    Collaborators

    • papb