New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

jcsv

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jcsv - npm Package Compare versions

Comparing version 0.0.1 to 0.0.2

11

lib/converter.js

@@ -11,3 +11,3 @@ module.exports = function(list, options, cb){

headers = [],
row, key, i, idx;
row, key, i, idx, field;

@@ -26,10 +26,13 @@

row = [];
debugger;
for (key in obj){
if (obj.hasOwnProperty(key)){
idx = headers.indexOf(key);
field = obj[key];
if (idx===-1){
idx = headers.push(key) - 1;
}
row[(idx)] = obj[key]; // push and indexOf returns index+1, idx is idx-1
if (typeof field === "string"){
field = '"' + field + '';
}
row[(idx)] = field; // push and indexOf returns index+1, idx is idx-1
}

@@ -59,2 +62,2 @@ }

return cb(null, csv);
};
};

@@ -5,7 +5,7 @@ {

"description": "Simple node module for converting a json array [ {}, {} ] to CSV",
"version": "0.0.1",
"homepage": "github.com/cianclarke/jcsvsv",
"version": "0.0.2",
"homepage": "github.com/cianclarke/json2csv",
"repository": {
"type": "git",
"url": "git@github.com:cianclarke/jcsv.git"
"url": "git@github.com:cianclarke/json2csv.git"
},

@@ -12,0 +12,0 @@ "main": "./index.js",

@@ -10,3 +10,11 @@ [

"c" : 5
},
{
"a" : 6,
"b" : 7,
"c" : 8,
"d" : true,
"e" : "string",
"f" : { "a" : 1, "b" : 2}
}
]
]

@@ -8,8 +8,6 @@ var jcsv = require ('../index.js'),

assert.ok(typeof res === "string");
var resStr = "a,b,c;\n1,2,;\n3,4,5;\n";
assert.ok(res === resStr);
console.log(res);
var resStr = ['a,b,c,d,e,f;', '1,2,,,,;', '3,4,5,,,;', '6,7,8,true,"string,[object Object];'];
assert.ok(res === resStr.join('\n') + '\n');
console.log("Tests passed ok!");
});
});
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc