Nefarious Planetary Meddling
    Wondering what’s next for npm?Check out our public roadmap! »

    detect-format

    1.0.0 • Public • Published

    detect-format

    build status

    Detects the format of a given buffer or string. It works a lot better if you give it a few lines.

    var data = 'a,b,c\n1,2,3\n4,5,6\n7,8,9'
    detectFormat(data)
    { format: 'csv', separator : ',' }
     
    var data = 'a\tb\tc\n1\t2\t3'
    detectFormat(data)
    { format: 'csv',  separator : '\t' }
     
    var data = 'a|b|c\n1|2|3'
    detectFormat(data)
    { format: 'csv',  separator : '|' }
     
    var data = '[{"a": 1, "b": 2, "c": 3}, {"a": 4, "b": 5, "c": 6}]'
    detectFormat(data)
    { format: 'json', style: 'array', selector: '*' }
     
    var data = 'bliblup'
    detectFormat(data)
    false // unable to detect format

    Install

    npm i detect-format

    DownloadsWeekly Downloads

    137

    Version

    1.0.0

    License

    ISC

    Last publish

    Collaborators

    • avatar
    • avatar