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

downloadjs

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

downloadjs - npm Package Compare versions

Comparing version 1.3.1 to 1.4.1

34

download.js

@@ -1,2 +0,3 @@

//download.js v4.0, by dandavis; 2008-2015. [CCBY2] see http://danml.com/download.html for tests/usage
//download.js v4.1, by dandavis; 2008-2015. [CCBY2] see http://danml.com/download.html for tests/usage
// v1 landed a FF+Chrome compat way of downloading strings to local un-named files, upgraded to use a hidden frame and optional mime

@@ -6,2 +7,3 @@ // v2 added named files via a[download], msSaveBlob, IE (10+) support, and window.URL support for larger+faster saves than dataURLs

// v4 adds AMD/UMD, commonJS, and plain browser support
// v4.1 adds url download capability via solo URL argument (same domain/CORS only)
// https://github.com/rndme/download

@@ -30,12 +32,14 @@

x = data,
url = !strFileName && !strMimeType && x,
D = document,
a = D.createElement("a"),
z = function(a){return String(a);},
B = (self.Blob || self.MozBlob || self.WebKitBlob || z);
B=B.call ? B.bind(self) : Blob ;
var fn = strFileName || "download",
B = (self.Blob || self.MozBlob || self.WebKitBlob || z),
fn = strFileName || "download",
blob,
fr;
fr,
ajax;
B= B.call ? B.bind(self) : Blob ;
if(String(this)==="true"){ //reverse arguments, allowing download.bind(true, "text/xml", "export.xml") to act as a callback

@@ -48,6 +52,21 @@ x=[x, m];

if(url && url.length< 2048){
fn = url.split("/").pop().split("?")[0];
a.href = url; // assign href prop to temp anchor
if(a.href.indexOf(url) !== -1){ // if the browser determines that it's a potentially valid url path:
var ajax=new XMLHttpRequest();
ajax.open( "GET", url, true);
ajax.responseType = 'blob';
ajax.onload= function(e){
download(e.target.response, fn, u);
};
ajax.send();
return ajax;
} // end if valid url?
} // end if url?
//go ahead and download dataURLs right away
if(String(x).match(/^data\:[\w+\-]+\/[\w+\-]+[,;]/)){
if(/^data\:[\w+\-]+\/[\w+\-]+[,;]/.test(x)){
return navigator.msSaveBlob ? // IE10 can't do a[download], only Blobs:

@@ -82,2 +101,3 @@ navigator.msSaveBlob(d2b(x), fn) :

a.setAttribute("download", fn);
a.className = "download-js-link";
a.innerHTML = "downloading...";

@@ -84,0 +104,0 @@ D.body.appendChild(a);

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

//download.js v3.1, by dandavis; 2008-2015. [CCBY2] see http://danml.com/download.html for tests/usage
(function(f,a){"function"==typeof define&&define.amd?define([],a):"object"==typeof exports?module.exports=a():f.download=a()})(this,function(){return function(f,a,b){function n(l){var a=l.split(/[:;,]/);l=a[1];var a=("base64"==a[2]?atob:decodeURIComponent)(a.pop()),c=a.length,b=0,d=new Uint8Array(c);for(b;b<c;++b)d[b]=a.charCodeAt(b);return new g([d],{type:l})}function k(a,b){if("download"in d)return d.href=a,d.setAttribute("download",m),d.innerHTML="downloading...",h.body.appendChild(d),setTimeout(function(){d.click(),h.body.removeChild(d),!0===b&&setTimeout(function(){e.URL.revokeObjectURL(d.href)},250)},66),!0;if("undefined"!=typeof safari)return a="data:"+a.replace(/^data:([\w\/\-\+]+)/,"application/octet-stream"),!window.open(a)&&confirm("Displaying New Document\n\nUse Save As... to download, then click back to return to this page.")&&(location.href=a),!0;var c=h.createElement("iframe");h.body.appendChild(c),b||(a="data:"+a.replace(/^data:([\w\/\-\+]+)/,"application/octet-stream")),c.src=a,setTimeout(function(){h.body.removeChild(c)},333)}var e=window;b=b||"application/octet-stream";var c=f,h=document,d=h.createElement("a");f=function(a){return String(a)};var g=e.Blob||e.MozBlob||e.WebKitBlob||f,g=g.call?g.bind(e):Blob,m=a||"download";"true"===String(this)&&(c=[c,b],b=c[0],c=c[1]);if(String(c).match(/^data\:[\w+\-]+\/[\w+\-]+[,;]/))return navigator.msSaveBlob?navigator.msSaveBlob(n(c),m):k(c);a=c instanceof g?c:new g([c],{type:b});if(navigator.msSaveBlob)return navigator.msSaveBlob(a,m);if(e.URL)k(e.URL.createObjectURL(a),!0);else{if("string"==typeof a||a.constructor===f)try{return k("data:"+b+";base64,"+e.btoa(a))}catch(p){return k("data:"+b+","+encodeURIComponent(a))}b=new FileReader,b.onload=function(a){k(this.result)},b.readAsDataURL(a)}return!0}});
//download.js v4.1, by dandavis; 2008-2015. [CCBY2] see http://danml.com/download.html for tests/usage
(function(q,k){"function"==typeof define&&define.amd?define([],k):"object"==typeof exports?module.exports=k():q.download=k()})(this,function(){return function k(b,c,e){function r(n){var a=n.split(/[:;,]/);n=a[1];var a=("base64"==a[2]?atob:decodeURIComponent)(a.pop()),b=a.length,d=0,c=new Uint8Array(b);for(d;d<b;++d)c[d]=a.charCodeAt(d);return new g([c],{type:n})}function l(a,b){if("download"in d)return d.href=a,d.setAttribute("download",m),d.className="download-js-link",d.innerHTML="downloading...",h.body.appendChild(d),setTimeout(function(){d.click(),h.body.removeChild(d),!0===b&&setTimeout(function(){f.URL.revokeObjectURL(d.href)},250)},66),!0;if("undefined"!=typeof safari)return a="data:"+a.replace(/^data:([\w\/\-\+]+)/,"application/octet-stream"),!window.open(a)&&confirm("Displaying New Document\n\nUse Save As... to download, then click back to return to this page.")&&(location.href=a),!0;var c=h.createElement("iframe");h.body.appendChild(c),b||(a="data:"+a.replace(/^data:([\w\/\-\+]+)/,"application/octet-stream")),c.src=a,setTimeout(function(){h.body.removeChild(c)},333)}var f=window,a=e||"application/octet-stream";e=!c&&!e&&b;var h=document,d=h.createElement("a"),p=function(a){return String(a)},g=f.Blob||f.MozBlob||f.WebKitBlob||p,m=c||"download",g=g.call?g.bind(f):Blob;"true"===String(this)&&(b=[b,a],a=b[0],b=b[1]);if(e&&2048>e.length&&(m=e.split("/").pop().split("?")[0],d.href=e,-1!==d.href.indexOf(e)))return a=new XMLHttpRequest,a.open("GET",e,!0),a.responseType="blob",a.onload=function(a){k(a.target.response,m,"application/octet-stream")},a.send(),a;if(/^data\:[\w+\-]+\/[\w+\-]+[,;]/.test(b))return navigator.msSaveBlob?navigator.msSaveBlob(r(b),m):l(b);c=b instanceof g?b:new g([b],{type:a});if(navigator.msSaveBlob)return navigator.msSaveBlob(c,m);if(f.URL)l(f.URL.createObjectURL(c),!0);else{if("string"==typeof c||c.constructor===p)try{return l("data:"+a+";base64,"+f.btoa(c))}catch(n){return l("data:"+a+","+encodeURIComponent(c))}a=new FileReader,a.onload=function(a){l(this.result)},a.readAsDataURL(c)}return!0}});
{
"name": "downloadjs",
"main": "download.js",
"version": "1.3.1",
"description": "file downloading using client-side javascript",
"keywords": ["files", "dataURL", "blob", "download"],
"homepage": "http://danml.com/download.html",
"license": "CC-BY-4.0",
"author":
{
"name": "dandavis",
"email": "rndme@users.noreply.github.com",
"url": "http://danml.com/"
"name": "downloadjs",
"main": "download.js",
"version": "1.4.1",
"description": "file downloading using client-side javascript",
"keywords": [
"files",
"dataURL",
"blob",
"download"
],
"homepage": "http://danml.com/download.html",
"license": "CC-BY-4.0",
"author": {
"name": "dandavis",
"email": "rndme@users.noreply.github.com",
"url": "http://danml.com/"
},
"repository":
{
"type": "git",
"url": "https://github.com/rndme/download.git"
"repository": {
"type": "git",
"url": "https://github.com/rndme/download.git"
},
"bugs":
{
"email": "rndme@users.noreply.github.com"
"bugs": {
"email": "rndme@users.noreply.github.com"
},
"files": [
"download.js",
"download.min.js"
],
"npmName": "downloadjs",
"npmFileMap": [{
"basePath": "/",
"files": ["*.js"]
}]
"files": [
"download.js",
"download.min.js"
],
"npmName": "downloadjs",
"npmFileMap": [
{
"basePath": "/",
"files": [
"*.js"
]
}
]
}

@@ -11,2 +11,8 @@ download

#### Via NPM/Bower
`npm install downloadjs`
`bower install downloadjs`
`require("downloadjs")(data, strFileName, strMimeType);`
#### Simple global `download` function via `<script>` include

@@ -13,0 +19,0 @@ download(data, strFileName, strMimeType);

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