Skip to content

Commit d07597c

Browse files
committed
Fix detect.js for AMD compatibility
1 parent 86f5b46 commit d07597c

File tree

3 files changed

+16
-48
lines changed

3 files changed

+16
-48
lines changed

amplitude.js

Lines changed: 10 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1468,7 +1468,6 @@ exports.right = function(str){
14681468

14691469
}, {}],
14701470
19: [function(require, module, exports) {
1471-
14721471
/**
14731472
* toString ref.
14741473
*/
@@ -1485,18 +1484,21 @@ var toString = Object.prototype.toString;
14851484

14861485
module.exports = function(val){
14871486
switch (toString.call(val)) {
1488-
case '[object Function]': return 'function';
14891487
case '[object Date]': return 'date';
14901488
case '[object RegExp]': return 'regexp';
14911489
case '[object Arguments]': return 'arguments';
14921490
case '[object Array]': return 'array';
1493-
case '[object String]': return 'string';
1491+
case '[object Error]': return 'error';
14941492
}
14951493

14961494
if (val === null) return 'null';
14971495
if (val === undefined) return 'undefined';
1496+
if (val !== val) return 'nan';
14981497
if (val && val.nodeType === 1) return 'element';
1499-
if (val === Object(val)) return 'object';
1498+
1499+
val = val.valueOf
1500+
? val.valueOf()
1501+
: Object.prototype.valueOf.apply(val)
15001502

15011503
return typeof val;
15021504
};
@@ -1835,7 +1837,7 @@ module.exports = localStorage;
18351837
* console.log(agentInfo.browser.family); // Chrome
18361838
*
18371839
*/
1838-
(function(root, undefined) {
1840+
var detect = (function(root, undefined) {
18391841
// Shim Array.prototype.map if necessary
18401842
// Production steps of ECMA-262, Edition 5, 15.4.4.19
18411843
// Reference: http://es5.github.com/#x15.4.4.19
@@ -2338,28 +2340,11 @@ module.exports = localStorage;
23382340
// Return context
23392341
return _this;
23402342
}();
2341-
// Export the Underscore object for **Node.js** and **"CommonJS"**,
2342-
// backwards-compatibility for the old `require()` API. If we're not
2343-
// CommonJS, add `_` to the global object via a string identifier
2344-
// the Closure Compiler "advanced" mode. Registration as an AMD
2345-
// via define() happens at the end of this file
2346-
if (typeof exports !== "undefined") {
2347-
if (typeof module !== "undefined" && module.exports) {
2348-
exports = module.exports = detect;
2349-
}
2350-
exports.detect = detect;
2351-
} else {
2352-
root["detect"] = detect;
2353-
}
2354-
// AMD define happens at the end for compatibility with AMD
2355-
// that don't enforce next-turn semantics on modules
2356-
if (typeof define === "function" && define.amd) {
2357-
define(function(require) {
2358-
return detect;
2359-
});
2360-
}
2343+
return detect;
23612344
})(window);
23622345

2346+
module.exports = detect;
2347+
23632348
}, {}],
23642349
12: [function(require, module, exports) {
23652350
module.exports = '2.0.1';

0 commit comments

Comments
 (0)