允许使用CommonJS,AMD或不使用Javascript模块(类)

问题描述:

我创建了一个简单的Javascript模块。我想这是提供给CommonJS的实现,AMD实现和全球()允许使用CommonJS,AMD或不使用Javascript模块(类)

这里是我的类:

​​

就是我想实现可能吗?详尽的谷歌搜索没有得到任何结果

(function (global, factory) { 
    if (typeof define === "function" && define.amd) define(factory); //AMD 
    else if (typeof module === "object") module.exports = factory(); //CommonJS 
    else global.Geolocation = factory(); // for example browser (global will be window object) 
}(this, function() { 

var Geolocation = function(callback){ 
    this._latitude   = null; 
    this._longitude   = null; 
    this._accuracy   = null; 
} 

Geolocation.prototype = { 
    //prototype definitions in here 
} 

return Geolocation; 

}));