@commercetools/http-user-agent
Advanced tools
Comparing version 1.1.4 to 1.1.5
@@ -10,16 +10,12 @@ 'use strict'; | ||
Node.js or in a browser environment. In other cases, this won't be even a | ||
problem as webpack will provide the correct polyfill in the bundle. | ||
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. | ||
If we were to use checks at compile time (e.g. `webpack.DefinePlugin`) it | ||
would not be possible / easy to test such cases. | ||
Same thing for defining different entry points. | ||
The code below, on runtime, will evaluate the function expression, returning | ||
`true` or `false` if `window` is a global object. | ||
*/ | ||
// eslint-disable-next-line no-new-func | ||
var isBrowser = new Function('try { return typeof window === "object" } catch (e) { return false }'); | ||
var isBrowser = function isBrowser() { | ||
return typeof window !== 'undefined' && window.document && window.document.nodeType === 9; | ||
}; | ||
function getSystemInfo() { | ||
@@ -26,0 +22,0 @@ if (isBrowser()) return window.navigator.userAgent; |
@@ -8,16 +8,12 @@ /* */ | ||
Node.js or in a browser environment. In other cases, this won't be even a | ||
problem as webpack will provide the correct polyfill in the bundle. | ||
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. | ||
If we were to use checks at compile time (e.g. `webpack.DefinePlugin`) it | ||
would not be possible / easy to test such cases. | ||
Same thing for defining different entry points. | ||
The code below, on runtime, will evaluate the function expression, returning | ||
`true` or `false` if `window` is a global object. | ||
*/ | ||
// eslint-disable-next-line no-new-func | ||
var isBrowser = new Function('try { return typeof window === "object" } catch (e) { return false }'); | ||
var isBrowser = function isBrowser() { | ||
return typeof window !== 'undefined' && window.document && window.document.nodeType === 9; | ||
}; | ||
function getSystemInfo() { | ||
@@ -24,0 +20,0 @@ if (isBrowser()) return window.navigator.userAgent; |
@@ -14,16 +14,12 @@ (function (global, factory) { | ||
Node.js or in a browser environment. In other cases, this won't be even a | ||
problem as webpack will provide the correct polyfill in the bundle. | ||
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. | ||
If we were to use checks at compile time (e.g. `webpack.DefinePlugin`) it | ||
would not be possible / easy to test such cases. | ||
Same thing for defining different entry points. | ||
The code below, on runtime, will evaluate the function expression, returning | ||
`true` or `false` if `window` is a global object. | ||
*/ | ||
// eslint-disable-next-line no-new-func | ||
var isBrowser = new Function('try { return typeof window === "object" } catch (e) { return false }'); | ||
var isBrowser = function isBrowser() { | ||
return typeof window !== 'undefined' && window.document && window.document.nodeType === 9; | ||
}; | ||
function getSystemInfo() { | ||
@@ -30,0 +26,0 @@ if (isBrowser()) return window.navigator.userAgent; |
@@ -1,2 +0,2 @@ | ||
!function(e,r){"object"==typeof exports&&"undefined"!=typeof module?module.exports=r():"function"==typeof define&&define.amd?define(r):e.CommercetoolsHttpUserAgent=r()}(this,function(){"use strict";var e=new Function('try { return typeof window === "object" } catch (e) { return false }');return function(r){if(!r||0===Object.keys(r).length||!{}.hasOwnProperty.call(r,"name"))throw new Error("Missing required option `name`");var t=r.version?r.name+"/"+r.version:r.name,n=void 0;r.libraryName&&!r.libraryVersion?n=r.libraryName:r.libraryName&&r.libraryVersion&&(n=r.libraryName+"/"+r.libraryVersion);var o=void 0;return r.contactUrl&&!r.contactEmail?o="(+"+r.contactUrl+")":!r.contactUrl&&r.contactEmail?o="(+"+r.contactEmail+")":r.contactUrl&&r.contactEmail&&(o="(+"+r.contactUrl+"; +"+r.contactEmail+")"),[t,e()?window.navigator.userAgent:"Node.js/"+process.version.slice(1)+" ("+process.platform+"; "+process.arch+")",n,o].filter(function(e){return Boolean(e)}).join(" ")}}); | ||
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):e.CommercetoolsHttpUserAgent=n()}(this,function(){"use strict";var e=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 o=n.version?n.name+"/"+n.version:n.name,r=void 0;n.libraryName&&!n.libraryVersion?r=n.libraryName:n.libraryName&&n.libraryVersion&&(r=n.libraryName+"/"+n.libraryVersion);var t=void 0;return n.contactUrl&&!n.contactEmail?t="(+"+n.contactUrl+")":!n.contactUrl&&n.contactEmail?t="(+"+n.contactEmail+")":n.contactUrl&&n.contactEmail&&(t="(+"+n.contactUrl+"; +"+n.contactEmail+")"),[o,e()?window.navigator.userAgent:"Node.js/"+process.version.slice(1)+" ("+process.platform+"; "+process.arch+")",r,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": "1.1.4", | ||
"version": "1.1.5", | ||
"description": "Creates a proper HTTP User-Agent", | ||
@@ -10,0 +10,0 @@ "keywords": [ |
Sorry, the diff of this file is not supported yet
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
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
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
9892
10
126
1