
Security News
AGENTS.md Gains Traction as an Open Format for AI Coding Agents
AGENTS.md is a fast-growing open format giving AI coding agents a shared, predictable way to understand project setup, style, and workflows.
A transformer for JSON to delimiter-separated values, such as CSV and TSV
Transform JSON to delimiter-separated values, such as CSV and TSV. Supports streams.
npm install json-dsv
var JsonDSV = require('json-dsv');
var transformer = new JsonDSV(options);
readableStream
.pipe(transformer.dsv(addlOptions))
.pipe(writableStream);
var JsonDSV = require('json-dsv');
var transformer = new JsonDSV(options);
var data = data; // Object[]
transformer.dsv(data, options, function(err, dsv) {
// buffered dsv result
});
{
delimiter: ',', // use a different field separator char, eg `\t`
default: '' // if value is undefined at `value` path
includeHeader: true, // Boolean, determines whether or not CSV file will contain a title column
newLine: '\r\n', // String, overrides the default OS line ending (i.e. `\n` on Unix and `\r\n` on Windows).
fields: [
// Supports label -> simple path
{
label: 'some label', // (optional, column will be labeled 'path.to.something' if not defined)
value: 'path.to.something', // data.path.to.something
default: 'NULL' // default if value is not found (optional, overrides `options.default` for column)
},
// Supports label -> derived value
{
label: 'some label', // Supports duplicate labels (required, else your column will be labeled [function])
value: function(row) {
return row.path1 + row.path2;
},
default: 'NULL' // default if value fn returns undefined
},
// Supports Array path for nested values
{
value: ['path', 'to.something'] // {path: {'to.something': 'here'}}
},
// Support pathname -> pathvalue
'simplepath' // equivalent to {value:'simplepath'}
'path.to.value' // also equivalent to {label:'path.to.value', value:'path.to.value'}
]
}
# new JsonDSV(options)
Constructs a new JSON-DSV transformer.
# JsonDSV.dsv([addlOptions])
Transforms data
to DSV (CSV by default). Streams data per line.
.csv
and .tsv
are available as convenience methods.
Specified addlOptions
override options
.
var options = {
fields: [{value: 'make', label: 'Brand'}, 'model']
};
var data = [
{ make: 'nissan', model: '350z'},
{ make: 'bmw', model: '328i'}
];
var JsonDSV = require('json-dsv');
var transformer = new JsonDSV(options);
var es = require('event-stream');
es.readArray(data)
.pipe(transformer.dsv())
.pipe(process.stdout);
// Brand,model
// nissan,350z
// bmw,328i
# JsonDSV.dsv(data[, addlOptions], callback])
Transforms data
to DSV (CSV by default). Callback passes on buffered output.
.csv
and .tsv
are available as convenience methods.
Specified addlOptions
override options
.
var options = {
fields: [{value: 'make', label: 'Brand'}, 'model']
};
var data = [
{ make: 'nissan', model: '350z'},
{ make: 'bmw', model: '328i'}
];
var JsonDSV = require('json-dsv');
var transformer = new JsonDSV(options);
transformer.dsv(data, function(err, csv) {
console.log(csv);
});
// Brand,model
// nissan,350z
// bmw,328i
npm test
FAQs
A transformer for JSON to delimiter-separated values, such as CSV and TSV
The npm package json-dsv receives a total of 709 weekly downloads. As such, json-dsv popularity was classified as not popular.
We found that json-dsv 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
AGENTS.md is a fast-growing open format giving AI coding agents a shared, predictable way to understand project setup, style, and workflows.
Security News
/Research
Malicious npm package impersonates Nodemailer and drains wallets by hijacking crypto transactions across multiple blockchains.
Security News
This episode explores the hard problem of reachability analysis, from static analysis limits to handling dynamic languages and massive dependency trees.