{"id":15286537,"url":"https://github.com/rdmurphy/quaff","last_synced_at":"2025-04-13T02:32:11.332Z","repository":{"id":29593642,"uuid":"33133613","full_name":"rdmurphy/quaff","owner":"rdmurphy","description":":sake: A data pipeline helper written in node to convert a folder of JS/ArchieML/JSON/YAML/CSV/TSV files into usable data.","archived":false,"fork":false,"pushed_at":"2023-09-04T13:29:14.000Z","size":765,"stargazers_count":46,"open_issues_count":6,"forks_count":3,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-26T20:49:29.075Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/quaff","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rdmurphy.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2015-03-30T16:07:52.000Z","updated_at":"2024-06-10T03:02:52.000Z","dependencies_parsed_at":"2024-06-18T18:30:11.701Z","dependency_job_id":"08a377f1-39f3-42f9-a607-04ee3aff405e","html_url":"https://github.com/rdmurphy/quaff","commit_stats":null,"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rdmurphy%2Fquaff","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rdmurphy%2Fquaff/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rdmurphy%2Fquaff/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rdmurphy%2Fquaff/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rdmurphy","download_url":"https://codeload.github.com/rdmurphy/quaff/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248657793,"owners_count":21140842,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-09-30T15:16:22.018Z","updated_at":"2025-04-13T02:32:10.903Z","avatar_url":"https://github.com/rdmurphy.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\n  \u003cimg src=\"https://i.imgur.com/yC80ftQ.png\" width=\"150\" height=\"217\" alt=\"quaff\"\u003e\n\u003c/p\u003e\n\u003ch1 align=\"center\"\u003e\n  quaff\n\u003c/h1\u003e\n\u003cp align=\"center\"\u003e\n  \u003cbr\u003e\u003cbr\u003e\n  \u003ca href=\"https://www.npmjs.org/package/quaff\"\u003e\u003cimg src=\"https://img.shields.io/npm/v/quaff.svg?style=flat\" alt=\"npm\"\u003e\u003c/a\u003e\n  \u003ca href=\"https://github.com/rdmurphy/quaff/actions?query=workflow%3ACI\"\u003e\u003cimg src=\"https://img.shields.io/github/workflow/status/rdmurphy/quaff/CI/master\" alt=\"github actions\"\u003e\u003c/a\u003e\n  \u003ca href=\"https://packagephobia.now.sh/result?p=quaff\"\u003e\u003cimg src=\"https://packagephobia.now.sh/badge?p=quaff\" alt=\"install size\"\u003e\u003c/a\u003e\n\u003c/p\u003e\n\n## Important!\n\n`quaff` is now a [pure ESM package](https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c). It can no longer be `require()`'d from CommonJS. If this functionality is still needed please continue to use `quaff@^4`.\n\n## Key features\n\n- 🚚 A **data pipeline helper** written in Node.js that works similar to [Middleman](https://middlemanapp.com/)'s [Data Files](https://middlemanapp.com/advanced/data_files/) collector\n- 📦 Point the library at a folder filled with JS, AML ([ArchieML](http://archieml.org)), JSON, YAML, CSV and/or TSV files and **get a JavaScript object back that reflects the folder's structure and content/exports**\n- 🤓 Under the hood it uses [`parse-json`](https://github.com/sindresorhus/parse-json) (for better JSON error support), [`js-yaml`](https://github.com/nodeca/js-yaml) and [`d3-dsv`](https://github.com/d3/d3-dsv) to **read files efficiently**\n\n## Installation\n\n```sh\nnpm install quaff --save-dev\n```\n\n`quaff` requires **Node.js 12.20.0 or later**.\n\n## Usage\n\nAssume a folder with this structure.\n\n```txt\ndata/\n  mammals/\n    cats.json\n    dogs.json\n    bears.csv\n  birds/\n    parrots.yml\n    story.aml\n```\n\nAfter `import`'ing `quaff`:\n\n```js\nimport { load } from 'quaff';\n\nconst data = await load('./data/');\nconsole.log(data);\n```\n\nAnd the results...\n\n```json\n{\n\t\"mammals\": {\n\t\t\"cats\": [\"Marty\", \"Sammy\"],\n\t\t\"dogs\": [\"Snazzy\", \"Cally\"],\n\t\t\"bears\": [\n\t\t\t{\n\t\t\t\t\"name\": \"Steve\",\n\t\t\t\t\"type\": \"Polar bear\"\n\t\t\t},\n\t\t\t{\n\t\t\t\t\"name\": \"Angelica\",\n\t\t\t\t\"type\": \"Sun bear\"\n\t\t\t}\n\t\t]\n\t},\n\t\"birds\": {\n\t\t\"parrots\": {\n\t\t\t\"alive\": [\"Buzz\"],\n\t\t\t\"dead\": [\"Moose\"]\n\t\t},\n\t\t\"story\": {\n\t\t\t\"title\": \"All about birds\",\n\t\t\t\"prose\": [\n\t\t\t\t{ \"type\": \"text\", \"value\": \"Do you know how great birds are?\" },\n\t\t\t\t{ \"type\": \"text\", \"value\": \"Come with me on this journey.\" }\n\t\t\t]\n\t\t}\n\t}\n}\n```\n\nAs of `5.0.0` it's now possible to load a single file at a time, enabling more custom approaches in case `load` doesn't work exactly the way you'd like.\n\n```js\nimport { loadFile } from 'quaff';\n\nconst data = await loadFile('./data/mammals/bears.csv');\nconsole.log(data);\n```\n\nAnd the results...\n\n```json\n[\n\t{\n\t\t\"name\": \"Steve\",\n\t\t\"type\": \"Polar bear\"\n\t},\n\t{\n\t\t\"name\": \"Angelica\",\n\t\t\"type\": \"Sun bear\"\n\t}\n]\n```\n\n## Advanced Usage with JavaScript files\n\nOne of the biggest features added in `quaff` 4.0 is the ability to load JavaScript files. But how exactly does that work?\n\nJavaScript files that are consumed by `quaff` have to follow one simple rule - they must `export default` a function, an async function or value. All three of these are valid and return the same value:\n\n```js\nexport default [\n\t{\n\t\tname: 'Pudge',\n\t\tinstagram: 'https://instagram.com/pudgethecorgi/',\n\t},\n];\n```\n\n```js\nexport default () =\u003e [\n\t{\n\t\tname: 'Pudge',\n\t\tinstagram: 'https://instagram.com/pudgethecorgi/',\n\t},\n];\n```\n\n```js\nexport default async () =\u003e [\n\t{\n\t\tname: 'Pudge',\n\t\tinstagram: 'https://instagram.com/pudgethecorgi/',\n\t},\n];\n```\n\nThe final example above is the most interesting one - `async` functions also work! This means you can write code to hit API endpoints, or do other asynchronous work, and `quaff` will wait for those to resolve.\n\n```js\nimport fetch from 'node-fetch';\n\nexport default async () =\u003e {\n\tconst res = await fetch('https://my-cool-api/');\n\tconst data = await res.json();\n\n\t// whatever the API returned will be added to the quaff object!\n\treturn data;\n};\n```\n\nDon't have a `Promise` to do async work with? Working with a callback interface? Just wrap it in one!\n\n```js\nimport {apiHelper } from 'my-callback-api';\n\nexport default () =\u003e {\n\treturn new Promise((resolve, reject) =\u003e {\n\t\tapiHelper('people', (err, data) =\u003e {\n\t\t\tif (err) return reject(err);\n\n\t\t\t// quaff will take it from here!\n\t\t\tresolve(data);\n\t\t});\n\t});\n};\n```\n\n## License\n\nBy [Ryan Murphy](https://twitter.com/rdmurphy).\n\nAvailable under the MIT license.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frdmurphy%2Fquaff","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frdmurphy%2Fquaff","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frdmurphy%2Fquaff/lists"}