@commercetools/http-user-agent
Advanced tools
Comparing version 2.0.0 to 2.1.0
(function (global, factory) { | ||
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : | ||
typeof define === 'function' && define.amd ? define(factory) : | ||
(global = global || self, global.CommercetoolsHttpUserAgent = factory()); | ||
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : | ||
typeof define === 'function' && define.amd ? define(factory) : | ||
(global = global || self, global.CommercetoolsHttpUserAgent = factory()); | ||
}(this, function () { 'use strict'; | ||
/* global window */ | ||
var global$1 = typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}; | ||
/* | ||
This is the easiest way, for this use case, to detect if we're running in | ||
Node.js or in a browser environment. In other cases, this won't be even a | ||
problem as Rollup will provide the correct polyfill in the bundle. | ||
The main advantage by doing it this way is that it allows to easily test | ||
the code running in both environments, by overriding `global.window` in | ||
the specific test. | ||
*/ | ||
var isBrowser = function isBrowser() { | ||
return typeof window !== 'undefined' && window.document && window.document.nodeType === 9; | ||
}; | ||
// shim for using process in browser | ||
// based off https://github.com/defunctzombie/node-process/blob/master/browser.js | ||
function defaultSetTimout() { | ||
throw new Error('setTimeout has not been defined'); | ||
} | ||
function getSystemInfo() { | ||
if (isBrowser()) return window.navigator.userAgent; | ||
var nodeVersion = process.version.slice(1); | ||
var platformInfo = "(".concat(process.platform, "; ").concat(process.arch, ")"); | ||
return "Node.js/".concat(nodeVersion, " ").concat(platformInfo); | ||
} | ||
function defaultClearTimeout() { | ||
throw new Error('clearTimeout has not been defined'); | ||
} | ||
function createUserAgent(options) { | ||
if (!options || Object.keys(options).length === 0 || !{}.hasOwnProperty.call(options, 'name')) throw new Error('Missing required option `name`'); // Main info | ||
var cachedSetTimeout = defaultSetTimout; | ||
var cachedClearTimeout = defaultClearTimeout; | ||
var baseInfo = options.version ? "".concat(options.name, "/").concat(options.version) : options.name; // Library info | ||
if (typeof global$1.setTimeout === 'function') { | ||
cachedSetTimeout = setTimeout; | ||
} | ||
var libraryInfo; | ||
if (options.libraryName && !options.libraryVersion) libraryInfo = options.libraryName;else if (options.libraryName && options.libraryVersion) libraryInfo = "".concat(options.libraryName, "/").concat(options.libraryVersion); // Contact info | ||
if (typeof global$1.clearTimeout === 'function') { | ||
cachedClearTimeout = clearTimeout; | ||
} | ||
var contactInfo; | ||
if (options.contactUrl && !options.contactEmail) contactInfo = "(+".concat(options.contactUrl, ")");else if (!options.contactUrl && options.contactEmail) contactInfo = "(+".concat(options.contactEmail, ")");else if (options.contactUrl && options.contactEmail) contactInfo = "(+".concat(options.contactUrl, "; +").concat(options.contactEmail, ")"); // System info | ||
function runTimeout(fun) { | ||
if (cachedSetTimeout === setTimeout) { | ||
//normal enviroments in sane situations | ||
return setTimeout(fun, 0); | ||
} // if setTimeout wasn't available but was latter defined | ||
var systemInfo = getSystemInfo(); | ||
return [baseInfo, systemInfo, libraryInfo, contactInfo].filter(function (x) { | ||
return Boolean(x); | ||
}).join(' '); | ||
} | ||
return createUserAgent; | ||
if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) { | ||
cachedSetTimeout = setTimeout; | ||
return setTimeout(fun, 0); | ||
} | ||
try { | ||
// when when somebody has screwed with setTimeout but no I.E. maddness | ||
return cachedSetTimeout(fun, 0); | ||
} catch (e) { | ||
try { | ||
// When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally | ||
return cachedSetTimeout.call(null, fun, 0); | ||
} catch (e) { | ||
// same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error | ||
return cachedSetTimeout.call(this, fun, 0); | ||
} | ||
} | ||
} | ||
function runClearTimeout(marker) { | ||
if (cachedClearTimeout === clearTimeout) { | ||
//normal enviroments in sane situations | ||
return clearTimeout(marker); | ||
} // if clearTimeout wasn't available but was latter defined | ||
if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) { | ||
cachedClearTimeout = clearTimeout; | ||
return clearTimeout(marker); | ||
} | ||
try { | ||
// when when somebody has screwed with setTimeout but no I.E. maddness | ||
return cachedClearTimeout(marker); | ||
} catch (e) { | ||
try { | ||
// When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally | ||
return cachedClearTimeout.call(null, marker); | ||
} catch (e) { | ||
// same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error. | ||
// Some versions of I.E. have different rules for clearTimeout vs setTimeout | ||
return cachedClearTimeout.call(this, marker); | ||
} | ||
} | ||
} | ||
var queue = []; | ||
var draining = false; | ||
var currentQueue; | ||
var queueIndex = -1; | ||
function cleanUpNextTick() { | ||
if (!draining || !currentQueue) { | ||
return; | ||
} | ||
draining = false; | ||
if (currentQueue.length) { | ||
queue = currentQueue.concat(queue); | ||
} else { | ||
queueIndex = -1; | ||
} | ||
if (queue.length) { | ||
drainQueue(); | ||
} | ||
} | ||
function drainQueue() { | ||
if (draining) { | ||
return; | ||
} | ||
var timeout = runTimeout(cleanUpNextTick); | ||
draining = true; | ||
var len = queue.length; | ||
while (len) { | ||
currentQueue = queue; | ||
queue = []; | ||
while (++queueIndex < len) { | ||
if (currentQueue) { | ||
currentQueue[queueIndex].run(); | ||
} | ||
} | ||
queueIndex = -1; | ||
len = queue.length; | ||
} | ||
currentQueue = null; | ||
draining = false; | ||
runClearTimeout(timeout); | ||
} | ||
function nextTick(fun) { | ||
var args = new Array(arguments.length - 1); | ||
if (arguments.length > 1) { | ||
for (var i = 1; i < arguments.length; i++) { | ||
args[i - 1] = arguments[i]; | ||
} | ||
} | ||
queue.push(new Item(fun, args)); | ||
if (queue.length === 1 && !draining) { | ||
runTimeout(drainQueue); | ||
} | ||
} // v8 likes predictible objects | ||
function Item(fun, array) { | ||
this.fun = fun; | ||
this.array = array; | ||
} | ||
Item.prototype.run = function () { | ||
this.fun.apply(null, this.array); | ||
}; | ||
var title = 'browser'; | ||
var platform = 'browser'; | ||
var browser = true; | ||
var env = {}; | ||
var argv = []; | ||
var version = ''; // empty string to avoid regexp issues | ||
var versions = {}; | ||
var release = {}; | ||
var config = {}; | ||
function noop() {} | ||
var on = noop; | ||
var addListener = noop; | ||
var once = noop; | ||
var off = noop; | ||
var removeListener = noop; | ||
var removeAllListeners = noop; | ||
var emit = noop; | ||
function binding(name) { | ||
throw new Error('process.binding is not supported'); | ||
} | ||
function cwd() { | ||
return '/'; | ||
} | ||
function chdir(dir) { | ||
throw new Error('process.chdir is not supported'); | ||
} | ||
function umask() { | ||
return 0; | ||
} // from https://github.com/kumavis/browser-process-hrtime/blob/master/index.js | ||
var performance = global$1.performance || {}; | ||
var performanceNow = performance.now || performance.mozNow || performance.msNow || performance.oNow || performance.webkitNow || function () { | ||
return new Date().getTime(); | ||
}; // generate timestamp or delta | ||
// see http://nodejs.org/api/process.html#process_process_hrtime | ||
function hrtime(previousTimestamp) { | ||
var clocktime = performanceNow.call(performance) * 1e-3; | ||
var seconds = Math.floor(clocktime); | ||
var nanoseconds = Math.floor(clocktime % 1 * 1e9); | ||
if (previousTimestamp) { | ||
seconds = seconds - previousTimestamp[0]; | ||
nanoseconds = nanoseconds - previousTimestamp[1]; | ||
if (nanoseconds < 0) { | ||
seconds--; | ||
nanoseconds += 1e9; | ||
} | ||
} | ||
return [seconds, nanoseconds]; | ||
} | ||
var startTime = new Date(); | ||
function uptime() { | ||
var currentTime = new Date(); | ||
var dif = currentTime - startTime; | ||
return dif / 1000; | ||
} | ||
var process = { | ||
nextTick: nextTick, | ||
title: title, | ||
browser: browser, | ||
env: env, | ||
argv: argv, | ||
version: version, | ||
versions: versions, | ||
on: on, | ||
addListener: addListener, | ||
once: once, | ||
off: off, | ||
removeListener: removeListener, | ||
removeAllListeners: removeAllListeners, | ||
emit: emit, | ||
binding: binding, | ||
cwd: cwd, | ||
chdir: chdir, | ||
umask: umask, | ||
hrtime: hrtime, | ||
platform: platform, | ||
release: release, | ||
config: config, | ||
uptime: uptime | ||
}; | ||
/* global window */ | ||
/* | ||
This is the easiest way, for this use case, to detect if we're running in | ||
Node.js or in a browser environment. In other cases, this won't be even a | ||
problem as Rollup will provide the correct polyfill in the bundle. | ||
The main advantage by doing it this way is that it allows to easily test | ||
the code running in both environments, by overriding `global.window` in | ||
the specific test. | ||
*/ | ||
var isBrowser = function isBrowser() { | ||
return typeof window !== 'undefined' && window.document && window.document.nodeType === 9; | ||
}; | ||
function getSystemInfo() { | ||
if (isBrowser()) return window.navigator.userAgent; | ||
var nodeVersion = process.version.slice(1); | ||
var platformInfo = "(".concat(process.platform, "; ").concat(process.arch, ")"); | ||
return "Node.js/".concat(nodeVersion, " ").concat(platformInfo); | ||
} | ||
function createUserAgent(options) { | ||
if (!options || Object.keys(options).length === 0 || !{}.hasOwnProperty.call(options, 'name')) throw new Error('Missing required option `name`'); // Main info | ||
var baseInfo = options.version ? "".concat(options.name, "/").concat(options.version) : options.name; // Library info | ||
var libraryInfo; | ||
if (options.libraryName && !options.libraryVersion) libraryInfo = options.libraryName;else if (options.libraryName && options.libraryVersion) libraryInfo = "".concat(options.libraryName, "/").concat(options.libraryVersion); // Contact info | ||
var contactInfo; | ||
if (options.contactUrl && !options.contactEmail) contactInfo = "(+".concat(options.contactUrl, ")");else if (!options.contactUrl && options.contactEmail) contactInfo = "(+".concat(options.contactEmail, ")");else if (options.contactUrl && options.contactEmail) contactInfo = "(+".concat(options.contactUrl, "; +").concat(options.contactEmail, ")"); // System info | ||
var systemInfo = getSystemInfo(); | ||
return [baseInfo, systemInfo, libraryInfo, contactInfo].filter(function (x) { | ||
return Boolean(x); | ||
}).join(' '); | ||
} | ||
return createUserAgent; | ||
})); | ||
//# sourceMappingURL=commercetools-http-user-agent.umd.js.map |
@@ -1,2 +0,2 @@ | ||
!function(n,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(n=n||self).CommercetoolsHttpUserAgent=t()}(this,function(){"use strict";var c=function(){return"undefined"!=typeof window&&window.document&&9===window.document.nodeType};return function(n){if(!n||0===Object.keys(n).length||!{}.hasOwnProperty.call(n,"name"))throw new Error("Missing required option `name`");var t,o,e=n.version?"".concat(n.name,"/").concat(n.version):n.name;return n.libraryName&&!n.libraryVersion?t=n.libraryName:n.libraryName&&n.libraryVersion&&(t="".concat(n.libraryName,"/").concat(n.libraryVersion)),n.contactUrl&&!n.contactEmail?o="(+".concat(n.contactUrl,")"):!n.contactUrl&&n.contactEmail?o="(+".concat(n.contactEmail,")"):n.contactUrl&&n.contactEmail&&(o="(+".concat(n.contactUrl,"; +").concat(n.contactEmail,")")),[e,function(){if(c())return window.navigator.userAgent;var n=process.version.slice(1),t="(".concat(process.platform,"; ").concat(process.arch,")");return"Node.js/".concat(n," ").concat(t)}(),t,o].filter(function(n){return Boolean(n)}).join(" ")}}); | ||
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(e=e||self).CommercetoolsHttpUserAgent=n()}(this,function(){"use strict";var e="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{};function t(){throw new Error("setTimeout has not been defined")}function r(){throw new Error("clearTimeout has not been defined")}var o=t,i=r;function c(n){if(o===setTimeout)return setTimeout(n,0);if((o===t||!o)&&setTimeout)return o=setTimeout,setTimeout(n,0);try{return o(n,0)}catch(e){try{return o.call(null,n,0)}catch(e){return o.call(this,n,0)}}}"function"==typeof e.setTimeout&&(o=setTimeout),"function"==typeof e.clearTimeout&&(i=clearTimeout);var a,u=[],l=!1,f=-1;function s(){l&&a&&(l=!1,a.length?u=a.concat(u):f=-1,u.length&&m())}function m(){if(!l){var e=c(s);l=!0;for(var n=u.length;n;){for(a=u,u=[];++f<n;)a&&a[f].run();f=-1,n=u.length}a=null,l=!1,function(n){if(i===clearTimeout)return clearTimeout(n);if((i===r||!i)&&clearTimeout)return i=clearTimeout,clearTimeout(n);try{i(n)}catch(e){try{return i.call(null,n)}catch(e){return i.call(this,n)}}}(e)}}function d(e,n){this.fun=e,this.array=n}d.prototype.run=function(){this.fun.apply(null,this.array)};function n(){}var w=n,h=n,p=n,y=n,v=n,g=n,b=n;var T=e.performance||{},E=T.now||T.mozNow||T.msNow||T.oNow||T.webkitNow||function(){return(new Date).getTime()};var N=new Date;var U={nextTick:function(e){var n=new Array(arguments.length-1);if(1<arguments.length)for(var t=1;t<arguments.length;t++)n[t-1]=arguments[t];u.push(new d(e,n)),1!==u.length||l||c(m)},title:"browser",browser:!0,env:{},argv:[],version:"",versions:{},on:w,addListener:h,once:p,off:y,removeListener:v,removeAllListeners:g,emit:b,binding:function(e){throw new Error("process.binding is not supported")},cwd:function(){return"/"},chdir:function(e){throw new Error("process.chdir is not supported")},umask:function(){return 0},hrtime:function(e){var n=.001*E.call(T),t=Math.floor(n),r=Math.floor(n%1*1e9);return e&&(t-=e[0],(r-=e[1])<0&&(t--,r+=1e9)),[t,r]},platform:"browser",release:{},config:{},uptime:function(){return(new Date-N)/1e3}},j=function(){return"undefined"!=typeof window&&window.document&&9===window.document.nodeType};return function(e){if(!e||0===Object.keys(e).length||!{}.hasOwnProperty.call(e,"name"))throw new Error("Missing required option `name`");var n,t,r=e.version?"".concat(e.name,"/").concat(e.version):e.name;return e.libraryName&&!e.libraryVersion?n=e.libraryName:e.libraryName&&e.libraryVersion&&(n="".concat(e.libraryName,"/").concat(e.libraryVersion)),e.contactUrl&&!e.contactEmail?t="(+".concat(e.contactUrl,")"):!e.contactUrl&&e.contactEmail?t="(+".concat(e.contactEmail,")"):e.contactUrl&&e.contactEmail&&(t="(+".concat(e.contactUrl,"; +").concat(e.contactEmail,")")),[r,function(){if(j())return window.navigator.userAgent;var e=U.version.slice(1),n="(".concat(U.platform,"; ").concat(U.arch,")");return"Node.js/".concat(e," ").concat(n)}(),n,t].filter(function(e){return Boolean(e)}).join(" ")}}); | ||
//# sourceMappingURL=commercetools-http-user-agent.umd.min.js.map |
@@ -7,3 +7,3 @@ { | ||
"name": "@commercetools/http-user-agent", | ||
"version": "2.0.0", | ||
"version": "2.1.0", | ||
"description": "Creates a proper HTTP User-Agent", | ||
@@ -37,3 +37,3 @@ "keywords": [ | ||
}, | ||
"gitHead": "313ea01030d33fb6c262c9cce428d19b5008ec9f" | ||
"gitHead": "4dc966050b39b73e3875d7bd32a89c82f92fdfa2" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
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
59261
319
1