Skip to content

Parses a CSV and outputs an item-by-item diff against a collection of objects.

Notifications You must be signed in to change notification settings

natemortensen/csv-differ

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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()

About

Parses a CSV and outputs an item-by-item diff against a collection of objects.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published