
Research
/Security News
Malicious npm Packages Target WhatsApp Developers with Remote Kill Switch
Two npm packages masquerading as WhatsApp developer libraries include a kill switch that deletes all files if the phone number isn’t whitelisted.
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
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.
Research
/Security News
Two npm packages masquerading as WhatsApp developer libraries include a kill switch that deletes all files if the phone number isn’t whitelisted.
Research
/Security News
Socket uncovered 11 malicious Go packages using obfuscated loaders to fetch and execute second-stage payloads via C2 domains.
Security News
TC39 advances 11 JavaScript proposals, with two moving to Stage 4, bringing better math, binary APIs, and more features one step closer to the ECMAScript spec.