@homer0/env-utils
Advanced tools
Comparing version 2.0.1 to 2.0.2
@@ -34,3 +34,9 @@ "use strict"; | ||
constructor() { | ||
/** | ||
* The current `NODE_ENV`. If the variable is empty, the value will be `development`. | ||
*/ | ||
__publicField(this, "env"); | ||
/** | ||
* Whether or not the environment is production. | ||
*/ | ||
__publicField(this, "production"); | ||
@@ -40,5 +46,19 @@ this.env = this.get("NODE_ENV", "development"); | ||
} | ||
/** | ||
* Checks whether an environment variable exists or not. | ||
* | ||
* @param name The name of the variable. | ||
*/ | ||
exists(name) { | ||
return typeof process.env[name] !== "undefined"; | ||
} | ||
/** | ||
* Gets the value of an environment variable. | ||
* | ||
* @param name The name of the variable. | ||
* @param defaultValue A fallback value in case the variable is `undefined`. | ||
* @param required If the variable is required and `undefined`, it will throw an | ||
* error. | ||
* @throws If `required` is set to `true` and the variable is `undefined`. | ||
*/ | ||
get(name, defaultValue = "", required = false) { | ||
@@ -53,2 +73,11 @@ if (this.exists(name)) { | ||
} | ||
/** | ||
* Sets the value of an environment variable. | ||
* | ||
* @param name The name of the variable. | ||
* @param value The value of the variable. | ||
* @param overwrite If the variable already exists, the method won't overwrite it, | ||
* unless you set this parameter to `true`. | ||
* @returns Whether or not the variable was set. | ||
*/ | ||
set(name, value, overwrite = false) { | ||
@@ -61,2 +90,5 @@ if (!this.exists(name) || overwrite) { | ||
} | ||
/** | ||
* Whether or not the environment is for development. | ||
*/ | ||
get development() { | ||
@@ -63,0 +95,0 @@ return !this.production; |
@@ -10,3 +10,9 @@ var __defProp = Object.defineProperty; | ||
constructor() { | ||
/** | ||
* The current `NODE_ENV`. If the variable is empty, the value will be `development`. | ||
*/ | ||
__publicField(this, "env"); | ||
/** | ||
* Whether or not the environment is production. | ||
*/ | ||
__publicField(this, "production"); | ||
@@ -16,5 +22,19 @@ this.env = this.get("NODE_ENV", "development"); | ||
} | ||
/** | ||
* Checks whether an environment variable exists or not. | ||
* | ||
* @param name The name of the variable. | ||
*/ | ||
exists(name) { | ||
return typeof process.env[name] !== "undefined"; | ||
} | ||
/** | ||
* Gets the value of an environment variable. | ||
* | ||
* @param name The name of the variable. | ||
* @param defaultValue A fallback value in case the variable is `undefined`. | ||
* @param required If the variable is required and `undefined`, it will throw an | ||
* error. | ||
* @throws If `required` is set to `true` and the variable is `undefined`. | ||
*/ | ||
get(name, defaultValue = "", required = false) { | ||
@@ -29,2 +49,11 @@ if (this.exists(name)) { | ||
} | ||
/** | ||
* Sets the value of an environment variable. | ||
* | ||
* @param name The name of the variable. | ||
* @param value The value of the variable. | ||
* @param overwrite If the variable already exists, the method won't overwrite it, | ||
* unless you set this parameter to `true`. | ||
* @returns Whether or not the variable was set. | ||
*/ | ||
set(name, value, overwrite = false) { | ||
@@ -37,2 +66,5 @@ if (!this.exists(name) || overwrite) { | ||
} | ||
/** | ||
* Whether or not the environment is for development. | ||
*/ | ||
get development() { | ||
@@ -39,0 +71,0 @@ return !this.production; |
@@ -34,3 +34,9 @@ "use strict"; | ||
constructor() { | ||
/** | ||
* The current `NODE_ENV`. If the variable is empty, the value will be `development`. | ||
*/ | ||
__publicField(this, "env"); | ||
/** | ||
* Whether or not the environment is production. | ||
*/ | ||
__publicField(this, "production"); | ||
@@ -40,5 +46,19 @@ this.env = this.get("NODE_ENV", "development"); | ||
} | ||
/** | ||
* Checks whether an environment variable exists or not. | ||
* | ||
* @param name The name of the variable. | ||
*/ | ||
exists(name) { | ||
return typeof process.env[name] !== "undefined"; | ||
} | ||
/** | ||
* Gets the value of an environment variable. | ||
* | ||
* @param name The name of the variable. | ||
* @param defaultValue A fallback value in case the variable is `undefined`. | ||
* @param required If the variable is required and `undefined`, it will throw an | ||
* error. | ||
* @throws If `required` is set to `true` and the variable is `undefined`. | ||
*/ | ||
get(name, defaultValue = "", required = false) { | ||
@@ -53,2 +73,11 @@ if (this.exists(name)) { | ||
} | ||
/** | ||
* Sets the value of an environment variable. | ||
* | ||
* @param name The name of the variable. | ||
* @param value The value of the variable. | ||
* @param overwrite If the variable already exists, the method won't overwrite it, | ||
* unless you set this parameter to `true`. | ||
* @returns Whether or not the variable was set. | ||
*/ | ||
set(name, value, overwrite = false) { | ||
@@ -61,2 +90,5 @@ if (!this.exists(name) || overwrite) { | ||
} | ||
/** | ||
* Whether or not the environment is for development. | ||
*/ | ||
get development() { | ||
@@ -63,0 +95,0 @@ return !this.production; |
{ | ||
"name": "@homer0/env-utils", | ||
"description": "A simple service to avoid calling process.env on multiples places", | ||
"version": "2.0.1", | ||
"version": "2.0.2", | ||
"repository": { | ||
@@ -26,9 +26,9 @@ "type": "git", | ||
"dependencies": { | ||
"@homer0/jimple": "^2.0.1" | ||
"@homer0/jimple": "^2.0.2" | ||
}, | ||
"devDependencies": { | ||
"jest": "^29.4.1", | ||
"jest": "^29.4.3", | ||
"ts-jest": "^29.0.5", | ||
"tsup": "^6.5.0", | ||
"typescript": "^4.9.4" | ||
"tsup": "^6.6.3", | ||
"typescript": "^4.9.5" | ||
}, | ||
@@ -49,3 +49,3 @@ "engine-strict": true, | ||
}, | ||
"gitHead": "59c0f6af6901b9f4edb8d2ec36abaf11f6b0780d" | ||
"gitHead": "1ed6ea29e2035f10f0dff60203b6b1d54c601dc8" | ||
} |
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
26461
358
Updated@homer0/jimple@^2.0.2