1.0.2 • Published 4 years ago

csv-differ v1.0.2

Weekly downloads
213
License
ISC
Repository
github
Last release
4 years ago

csv-differ

This plugin parses a CSV and outputs an item-by-item diff against a collection of objects. It will accept both File and String arguments as CSV.

Example usage:

Initialize service

const service = await detectChanges(
  csvFileOrString,
   {
    records: [{ slug: 'test', firstName: 'Nate' }],
    identifier: 'slug',
    updateFunction(record, changes) {
      $axios.patch(apiUrl(record.slug), changes)
    }
  }
)

Get all records with detected changes

service.changedRecords
// => [
// {
// "record":{"slug":"test","firstName":"Aaron"},
// "diff":{"added":{},"deleted":{},"updated":{"firstName":"Aaron"}}
// },
// ..
// ]

Update a single record (assuming you provided a function)

service.update('test')

Update all changed records

service.updateAll()