A data pipeline helper written in node that works similar to Middleman's Data Files collector.
Point the library at a folder filled with JSON, YAML, CSV and/or TSV files and get a JavaScript object back that reflects the folder's structure. Great for pulling data in to templates!
Under the hood it uses JavaScript's built in JSON support, js-yaml
and d3-dsv
to read files.
npm install quaff --save-dev
Requires node>=4
.
Assume a folder with this structure.
data/
mammals/
cats.json
dogs.json
bears.csv
birds/
parrots.yml
After require()
'ing quaff
:
var quaff = require('quaff');
var data = quaff('./data/');
console.log(data);
And the results...
{
"mammals": {
"cats": [
"Marty",
"Sammy"
],
"dogs": [
"Snazzy",
"Cally"
],
"bears": [
{
"name": "Steve",
"type": "Polar bear"
},
{
"name": "Angelica",
"type": "Sun bear"
}
]
},
"birds": {
"parrots": {
"alive": [
"Buzz"
],
"dead": [
"Moose"
]
}
}
}
By Ryan Murphy.
Available under the MIT license.