![Oracle Drags Its Feet in the JavaScript Trademark Dispute](https://cdn.sanity.io/images/cgdhsj6q/production/919c3b22c24f93884c548d60cbb338e819ff2435-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Collect JS/JSON/YAML/YML/CSV/TSV/ArchieML files from a source folder and convert them into a single object.
parse-json
(for better JSON error support), js-yaml
and d3-dsv
to read files efficientlynpm install quaff --save-dev
quaff
requires Node.js 10 or later.
Assume a folder with this structure.
data/
mammals/
cats.json
dogs.json
bears.csv
birds/
parrots.yml
story.aml
After require()
'ing quaff
:
const quaff = require('quaff');
const data = await 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"]
},
"story": {
"title": "All about birds",
"prose": [
{ "type": "text", "value": "Do you know how great birds are?" },
{ "type": "text", "value": "Come with me on this journey." }
]
}
}
}
One of the biggest features added in quaff
4.0 is the ability to load JavaScript files. But how exactly does that work?
JavaScript files that are consumed by quaff
have to follow one simple rule - they must export a default function (or value) at module.exports
. All three of these are valid and return the same value:
module.exports = [
{
name: 'Pudge',
instagram: 'https://instagram.com/pudgethecorgi/',
},
];
module.exports = () => [
{
name: 'Pudge',
instagram: 'https://instagram.com/pudgethecorgi/',
},
];
module.exports = async () => [
{
name: 'Pudge',
instagram: 'https://instagram.com/pudgethecorgi/',
},
];
The final example above is the most interesting one - async
functions are supported! This means you can write code to hit API endpoints, or do other asynchronous work, and quaff
will wait for those to resolve as it prepares the data object it returns.
const fetch = require('node-fetch');
module.exports = async () => {
const res = await fetch('https://my-cool-api/');
const data = await res.json();
// whatever the API returned will be added to the quaff object!
return data;
};
Don't have a Promise
to do async work with? Working with a callback interface? Just wrap it in one!
const apiHelper = require('my-callback-api');
module.exports = () => {
return new Promise((resolve, reject) => {
apiHelper('people', (err, data) => {
if (err) return reject(err);
// quaff will take it from here!
resolve(data);
});
});
};
By Ryan Murphy.
Available under the MIT license.
[4.2.0] - 2020-07-16
quaff
will now throw an error when more than one input file attempts to use the same output key. This is caused by having multiple files in a directory with the same name but different extensions..yaml
or .yml
file fails to parse the thrown error will now include the file path.quaff
in Mac OS and Windows thanks to GitHub Actions. Don't expect that'll ever be an issue but good to know.FAQs
Collect JS/JSON/YAML/YML/CSV/TSV/ArchieML files from a source folder and convert them into a single object.
The npm package quaff receives a total of 306 weekly downloads. As such, quaff popularity was classified as not popular.
We found that quaff demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.