UNPKG

@4a/env

Version:
54 lines (53 loc) 1.49 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.Env = void 0; const environment_1 = __importDefault(require("./environment")); class Env { constructor(env) { this.env = env || environment_1.default.PRODUCTION; } get isDev() { return this.env === environment_1.default.DEV || this.env === environment_1.default.DEVELOPMENT; } get isTest() { return this.env === environment_1.default.TEST; } get isTesting() { return this.env === environment_1.default.TESTING; } get isPreview() { return this.env === environment_1.default.PREVIEW; } get isProduction() { return this.env === environment_1.default.PRODUCTION; } get isOnline() { return this.isPreview || this.isProduction; } dev(callback) { !this.isDev || callback(); } test(callback) { !this.isTest || callback(); } testing(callback) { !this.isTesting || callback(); } preview(callback) { !this.isPreview || callback(); } production(callback) { !this.isProduction || callback(); } online(callback) { (!this.isPreview && !this.isProduction) || callback(); } get(config) { return config[this.env]; } } exports.Env = Env; exports.default = Env;