1.1.2 • Published 7 months ago

parse-my-file v1.1.2

Weekly downloads
-
License
ISC
Repository
github
Last release
7 months ago

Parse-My-File

Configuration

{
    // the character that separates columns
    delimiter: ',',
    // OPTIONAL: the javascript object shape to get from each row
    //// the value of each key is the header value of each column 
    //// if not provided, a basic shape will be provided for you
    shape: {
        id: 'ID',
        name: 'NAME',
        pricing: {
            price: 'PRICE',
            quantity: 'QTY'
        }
    }
}

Usage

ID, NAME, PRICE, QTY
1, A THING, $0.99, 5
import { parseMyFile } from 'parse-my-file'

const result = parseMyFile('test.txt', {
    delimiter: ',',
    shape: {
        id: 'ID',
        name: 'NAME',
        pricing: {
            price: 'PRICE',
            quantity: 'QTY',
        }
    }
})

console.log('result', result)
// [ { id: '1', name: 'A THING', pricing: { price '$0.99', quantity: '5' } } ]

// Alternatively, if you choose to not provide a shape
// it will default to using the header value as the keys
// [ { ID: '1', NAME: 'A THING', PRICE: '$0.99', QTY: '5' } ]
1.1.2

7 months ago

1.1.1

7 months ago

1.1.0

7 months ago

1.0.1

7 months ago

1.0.0

7 months ago