listore

listore

npm version npm downloads bundle JSDocs License

Store data without defining key names multiple times

interface Pet {
species: string
name: string
age: number
}

const listore = new Listore<Pet>(['species', 'name', 'age'])
// listore instanceof Array

listore.push(['cat', 'Fluffy', 4])
listore.push(['dog', 'Spot', 7])
listore.push(['cat', 'Mittens', 2])

const objects = listore.toObjects()
/**
* [
* { species: 'cat', name: 'Fluffy', age: 4 },
* { species: 'dog', name: 'Spot', age: 7 },
* { species: 'cat', name: 'Mittens', age: 2 },
* ]
*/

const csv = listore.toCSV()
/**
* species,name,age
* cat,Fluffy,4
* dog,Spot,7
* cat,Mittens,2
*/

// or construct Listore from xxx
Listore.fromCSV(csv)
Listore.fromObjects(objects)

features

  • Easy to use, just like built-in Array
  • Self contained, ZERO dependency
  • Supports wide range of formats
    • CSV (in, out)
    • HTML table (out)
    • HTMLTableElement (in)