52 lines
3.9 KiB
JavaScript
52 lines
3.9 KiB
JavaScript
/// <reference path="typings/main.d.ts" />
|
|
exports.getEnvString = function () {
|
|
if (typeof window !== "undefined") {
|
|
return "browser";
|
|
}
|
|
else if (typeof process !== "undefined") {
|
|
return "node";
|
|
}
|
|
};
|
|
exports.getUserAgentString = function () {
|
|
if (exports.isBrowser()) {
|
|
return navigator.userAgent;
|
|
}
|
|
else {
|
|
return undefined;
|
|
}
|
|
};
|
|
exports.isNode = function () {
|
|
if (exports.getEnvString() === "node") {
|
|
return true;
|
|
}
|
|
else {
|
|
return false;
|
|
}
|
|
};
|
|
exports.getNodeVersion = function () {
|
|
return process.version;
|
|
};
|
|
exports.isBrowser = function () {
|
|
return !exports.isNode();
|
|
};
|
|
exports.isCI = function () {
|
|
if (process.env.CI) {
|
|
return true;
|
|
}
|
|
else {
|
|
return false;
|
|
}
|
|
;
|
|
};
|
|
exports.isTravis = function () {
|
|
if (process.env.TRAVIS) {
|
|
return true;
|
|
}
|
|
else {
|
|
return false;
|
|
}
|
|
;
|
|
};
|
|
|
|
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInNtYXJ0ZW52LmNsYXNzZXMuaGVscGVycy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSwwQ0FBMEM7QUFFL0Isb0JBQVksR0FBRztJQUN0QixFQUFFLENBQUMsQ0FBQyxPQUFPLE1BQU0sS0FBSyxXQUFXLENBQUMsQ0FBQyxDQUFDO1FBQ2hDLE1BQU0sQ0FBQyxTQUFTLENBQUM7SUFDckIsQ0FBQztJQUFDLElBQUksQ0FBQyxFQUFFLENBQUMsQ0FBQyxPQUFPLE9BQU8sS0FBSyxXQUFXLENBQUMsQ0FBQyxDQUFDO1FBQ3hDLE1BQU0sQ0FBQyxNQUFNLENBQUM7SUFDbEIsQ0FBQztBQUNMLENBQUMsQ0FBQztBQUVTLDBCQUFrQixHQUFHO0lBQzVCLEVBQU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