Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

csv4xls

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

csv4xls - npm Package Compare versions

Comparing version 0.0.2 to 0.1.0

7

CHANGELOG.md

@@ -1,3 +0,8 @@

# 0.0.2
# v0.1.0
- add `download` api for trigger csv download directly.
# v0.0.2
- quote double quote properly by converting single double quote to double double quote.

@@ -4,0 +9,0 @@ - quote all values when preparing csv strings from array to prevent from unexpected line-break or delimiter char.

@@ -48,2 +48,15 @@ (function(){

return URL.createObjectURL(blob);
},
download: function(data, name){
var href, a;
name == null && (name = "data.csv");
href = this.toHref(data);
a = document.createElement('a');
a.setAttribute('href', href);
a.setAttribute('download', name + (/\.csv$/i.exec(name) ? '' : '.csv'));
a.style.opacity = 0;
a.style.position = 'absolute';
document.body.appendChild(a);
a.click();
return document.body.removeChild(a);
}

@@ -50,0 +63,0 @@ };

2

dist/csv4xls.min.js

@@ -1,1 +0,1 @@

(function(){var reg;reg=function(cb){var ret;ret=cb();if(typeof module!="undefined"&&module!==null){return module.exports=ret}else if(typeof window!="undefined"&&window!==null){return window.csv4xls=ret}};reg(function(){var obj,ret;obj={toArray:function(data){var str,ba,i$,to$,i;str=data.map(function(d,i){return d.map(function(v,j){return v+""}).join("\t")}).join("\r\n");str=data.map(function(d,i){return d.map(function(v,j){return'"'+(""+v).replace(/"/g,'""').replace(/\n/g,"\r")+'"'}).join("\t")}).join("\r\n");ba=new Uint8Array(2+str.length*2);for(i$=0,to$=str.length;i$<to$;++i$){i=i$;ba[i*2+2]=str.charCodeAt(i);ba[i*2+3]=str.charCodeAt(i)>>8}ba[0]=255;ba[1]=254;return ba},toBlob:function(data){var ba;ba=obj.toArray(data);return new Blob([ba],{type:"text/csv"})},toHref:function(data){var blob;blob=obj.toBlob(data);return URL.createObjectURL(blob)}};ret=function(it){return obj.toHref(it)};return import$(ret,obj)});function import$(obj,src){var own={}.hasOwnProperty;for(var key in src)if(own.call(src,key))obj[key]=src[key];return obj}}).call(this);
(function(){var reg;reg=function(cb){var ret;ret=cb();if(typeof module!="undefined"&&module!==null){return module.exports=ret}else if(typeof window!="undefined"&&window!==null){return window.csv4xls=ret}};reg(function(){var obj,ret;obj={toArray:function(data){var str,ba,i$,to$,i;str=data.map(function(d,i){return d.map(function(v,j){return v+""}).join("\t")}).join("\r\n");str=data.map(function(d,i){return d.map(function(v,j){return'"'+(""+v).replace(/"/g,'""').replace(/\n/g,"\r")+'"'}).join("\t")}).join("\r\n");ba=new Uint8Array(2+str.length*2);for(i$=0,to$=str.length;i$<to$;++i$){i=i$;ba[i*2+2]=str.charCodeAt(i);ba[i*2+3]=str.charCodeAt(i)>>8}ba[0]=255;ba[1]=254;return ba},toBlob:function(data){var ba;ba=obj.toArray(data);return new Blob([ba],{type:"text/csv"})},toHref:function(data){var blob;blob=obj.toBlob(data);return URL.createObjectURL(blob)},download:function(data,name){var href,a;name==null&&(name="data.csv");href=this.toHref(data);a=document.createElement("a");a.setAttribute("href",href);a.setAttribute("download",name+(/\.csv$/i.exec(name)?"":".csv"));a.style.opacity=0;a.style.position="absolute";document.body.appendChild(a);a.click();return document.body.removeChild(a)}};ret=function(it){return obj.toHref(it)};return import$(ret,obj)});function import$(obj,src){var own={}.hasOwnProperty;for(var key in src)if(own.call(src,key))obj[key]=src[key];return obj}}).call(this);

@@ -10,3 +10,3 @@ {

"description": "csv generator friendly for Microsoft Excel",
"version": "0.0.2",
"version": "0.1.0",
"homepage": "https://github.com/plotdb/csv4xls",

@@ -13,0 +13,0 @@ "repository": {

@@ -17,5 +17,6 @@ # csv4xls

* toArray - convert given 2D array to an xls-compatible CSV file, stores in an Uint8Array and returns the array.
* toBlob - same as `toArray` but return a corresponding blob.
* toHref - same as `toBlob` but return a corresponding object url.
* toArray(data) - convert given 2D array to an xls-compatible CSV file, stores in an Uint8Array and returns the array.
* toBlob(data) - same as `toArray` but return a corresponding blob.
* toHref(data) - same as `toBlob` but return a corresponding object url.
* download(data, filename) - trigger file download

@@ -22,0 +23,0 @@

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