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

navigator.sendbeacon

Package Overview
Dependencies
Maintainers
1
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

navigator.sendbeacon - npm Package Compare versions

Comparing version 0.0.2 to 0.0.3

4

bower.json
{
"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);
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