@platform/util.is
Advanced tools
Comparing version 0.0.0 to 0.0.1
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var Flags = (function () { | ||
function Flags() { | ||
} | ||
Object.defineProperty(Flags.prototype, "nodeEnv", { | ||
get: function () { | ||
return this.browser ? 'browser' : process.env.NODE_ENV || 'development'; | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
Object.defineProperty(Flags.prototype, "browser", { | ||
get: function () { | ||
return typeof window !== 'undefined'; | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
Object.defineProperty(Flags.prototype, "dev", { | ||
get: function () { | ||
var env = this.nodeEnv; | ||
return this.browser | ||
? window && window.location.hostname === 'localhost' | ||
: env !== 'production' && env !== 'prod'; | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
Object.defineProperty(Flags.prototype, "prod", { | ||
get: function () { | ||
return !this.dev; | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
Object.defineProperty(Flags.prototype, "test", { | ||
get: function () { | ||
return this.nodeEnv === 'test'; | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
Flags.prototype.toObject = function () { | ||
return { | ||
nodeEnv: this.nodeEnv, | ||
browser: this.browser, | ||
dev: this.dev, | ||
prod: this.prod, | ||
}; | ||
}; | ||
return Flags; | ||
}()); | ||
exports.is = new Flags(); |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var chai_1 = require("chai"); | ||
describe('dummy', function () { | ||
it('succeeds', function () { | ||
chai_1.expect(123).to.eql(123); | ||
var _1 = require("."); | ||
describe('is', function () { | ||
it('test', function () { | ||
chai_1.expect(_1.is.nodeEnv).to.eql('test'); | ||
chai_1.expect(_1.is.test).to.eql(true); | ||
}); | ||
it('browser', function () { | ||
chai_1.expect(_1.is.browser).to.eql(false); | ||
}); | ||
}); |
{ | ||
"name": "@platform/util.is", | ||
"version": "0.0.0", | ||
"version": "0.0.1", | ||
"description": "Environment flags.", | ||
@@ -5,0 +5,0 @@ "main": "lib/index", |
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
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
3769
123