kaue / jsonexport

{} → :page_facing_up: it's easy to convert JSON to CSV
http://kaue.github.io/jsonexport/
Apache License 2.0
247 stars 41 forks source link

Array outputs 'contains' when module is Webpacked/Browserify'd #3

Closed krishnaglick closed 8 years ago

krishnaglick commented 8 years ago

I'm working on a web app and need to convert JSON to CSV, so I grabbed this library and threw it into Webpack. However for some reason if I use it on an array the first column is 'contains' and all subsequent cells in that row are blank.

The issue is reproducible by going here: http://chojax.azurewebsites.net/ and entering 'jsonExport([], console.log)' into your console. I believe it to be something related to the application however I'm not sure what could be causing this. Using Webpack to export the library into a blank html page does not cause the issue to occur.

Any assistance is appreciated!

kaue commented 8 years ago

@krishnaglick I belive the problem is related headerCount.__proto__.contains() Image I am trying to understand why =/

krishnaglick commented 8 years ago

This is actually an issue with my code base. I prototyped a function onto array. Array.prototype.contains = function(eqObj) I removed it since I was only using it in once place. I think you can fix it using... for(let header in headerCount) if(headerCount.hasOwnProperty(header)) headerSort.push...

On second thought, that may be the wrong location but I believe it's the right idea.

kaue commented 8 years ago

@krishnaglick That would work, can you submit a pull request? =)

krishnaglick commented 8 years ago

Sure! I'll try to get to it this weekend. :+1:

krishnaglick commented 8 years ago

https://github.com/Cnova/jsonexport/pull/4