navigator.sendbeacon
Advanced tools
Comparing version 0.0.2 to 0.0.3
{ | ||
"name": "navigator.sendbeacon", | ||
"main": "Navigator.sendBeacon.js", | ||
"version": "0.0.2", | ||
"main": "sendbeacon.js", | ||
"version": "0.0.3", | ||
"homepage": "https://github.com/miguelmota/Navigator.sendBeacon", | ||
@@ -6,0 +6,0 @@ "authors": [ |
{ | ||
"name": "navigator.sendbeacon", | ||
"version": "0.0.2", | ||
"version": "0.0.3", | ||
"description": "Polyfill for navigator.sendBeacon()", | ||
"main": "Navigator.sendBeacon.js", | ||
"main": "sendbeacon.js", | ||
"directories": { | ||
@@ -27,5 +27,5 @@ "test": "test" | ||
"homepage": "https://github.com/miguelmota/Navigator.sendBeacon", | ||
"dependencies": { | ||
"devDependencies": { | ||
"tape": "^3.0.3" | ||
} | ||
} |
(function(root) { | ||
'use strict'; | ||
if (!('sendBeacon' in navigator)) { | ||
navigator.sendBeacon = function(url, data) { | ||
var xhr = ('XMLHttpRequest' in root) ? new XMLHttpRequest() : new ActiveXObject('Microsoft.XMLHTTP'); | ||
xhr.open('POST', url, false); | ||
xhr.setRequestHeader('Accept', '*/*'); | ||
if (typeof data === 'string') { | ||
xhr.setRequestHeader('Content-Type', 'text/plain;charset=UTF-8'); | ||
xhr.responseType = 'text/plain'; | ||
} else if (Object.prototype.toString.call(data) === '[object Blob]') { | ||
if (data.type) { | ||
xhr.setRequestHeader('Content-Type', data.type); | ||
} | ||
function sendBeacon(url, data) { | ||
var xhr = ('XMLHttpRequest' in window) ? new XMLHttpRequest() : new ActiveXObject('Microsoft.XMLHTTP'); | ||
xhr.open('POST', url, false); | ||
xhr.setRequestHeader('Accept', '*/*'); | ||
if (typeof data === 'string') { | ||
xhr.setRequestHeader('Content-Type', 'text/plain;charset=UTF-8'); | ||
xhr.responseType = 'text/plain'; | ||
} else if (Object.prototype.toString.call(data) === '[object Blob]') { | ||
if (data.type) { | ||
xhr.setRequestHeader('Content-Type', data.type); | ||
} | ||
xhr.send(data); | ||
return true; | ||
}; | ||
} | ||
xhr.send(data); | ||
return true; | ||
} | ||
if (!('sendBeacon' in navigator)) { | ||
navigator.sendBeacon = sendBeacon; | ||
} | ||
if (typeof exports !== 'undefined') { | ||
if (typeof module !== 'undefined' && module.exports) { | ||
exports = module.exports = sendBeacon; | ||
} | ||
exports.sendBeacon = sendBeacon; | ||
} else if (typeof define === 'function' && define.amd) { | ||
define([], function() { | ||
return sendBeacon; | ||
}); | ||
} | ||
})(this); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
5628
0
54
1
- Removedtape@^3.0.3
- Removeddeep-equal@0.2.2(transitive)
- Removeddefined@0.0.0(transitive)
- Removedglob@3.2.11(transitive)
- Removedinherits@2.0.4(transitive)
- Removedlru-cache@2.7.3(transitive)
- Removedminimatch@0.3.0(transitive)
- Removedobject-inspect@0.4.0(transitive)
- Removedresumer@0.0.0(transitive)
- Removedsigmund@1.0.1(transitive)
- Removedtape@3.6.1(transitive)
- Removedthrough@2.3.8(transitive)