Utilities for table parser packages
ArrayTable
to an ObjectTable
const { createObjectTable } = await import('table-parser-base')
const arrayTable = {
headers: ['id', 'name', 'email'],
rows: [
[1, 'John Doe', 'john-doe@gmail.com'],
[2, 'Peter Smith', 'petersmith22@outlook.com'],
[3, 'Julia Jones', 'jjones778@gmail.com']
]
}
const objectTable = createObjectTable(arrayTable)
for await (const item of objectTable) {
console.log(item)
}
Output:
{ id: 1, name: 'John Doe', email: 'john-doe@gmail.com' }
{ id: 2, name: 'Peter Smith', email: 'petersmith22@outlook.com' }
{ id: 3, name: 'Julia Jones', email: 'jjones778@gmail.com' }
ObjectTable
to an ArrayTable
const { createArrayTable } = await import('table-parser-base')
const objectTable = [
{ id: 1, name: 'John Doe', email: 'john-doe@gmail.com' },
{ id: 2, name: 'Peter Smith', email: 'petersmith22@outlook.com' },
{ id: 3, name: 'Julia Jones', email: 'jjones778@gmail.com' }
]
const arrayTable = await createArrayTable(objectTable)
console.log(arrayTable)
Output:
{
headers: [ 'id', 'name', 'email' ],
rows: [
[ 1, 'John Doe', 'john-doe@gmail.com' ],
[ 2, 'Peter Smith', 'petersmith22@outlook.com' ],
[ 3, 'Julia Jones', 'jjones778@gmail.com' ]
]
}
Generated using TypeDoc