mentie 0.1.21 → 0.1.23
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/modules/environment.js +12 -0
- package/modules/validations.js +2 -2
- package/package.json +1 -1
package/modules/environment.js
CHANGED
|
@@ -17,6 +17,12 @@ export const env = {}
|
|
|
17
17
|
*/
|
|
18
18
|
env.is_web = () => typeof window !== 'undefined'
|
|
19
19
|
|
|
20
|
+
/**
|
|
21
|
+
*
|
|
22
|
+
* @returns {boolean} True if running in a web browser and the URL includes 'localhost', otherwise false.
|
|
23
|
+
*/
|
|
24
|
+
env.is_localhost = () => env.is_web() && `${ location.href }`.includes( 'localhost' )
|
|
25
|
+
|
|
20
26
|
/**
|
|
21
27
|
* Checks if the code is running in the Cypress testing environment within a web browser.
|
|
22
28
|
* @returns {boolean} True if running in Cypress, otherwise false.
|
|
@@ -78,6 +84,12 @@ env.loglevel = () => env.web_loglevel() || env.node_loglevel() || env.dev() ? 'i
|
|
|
78
84
|
*/
|
|
79
85
|
export const is_web = env.is_web()
|
|
80
86
|
|
|
87
|
+
/**
|
|
88
|
+
* Checks if the code is running in a web environment and the URL includes 'localhost'.
|
|
89
|
+
* @returns {boolean} Returns true if the code is running in a web environment and the URL includes 'localhost', otherwise returns false.
|
|
90
|
+
*/
|
|
91
|
+
export const is_localhost = env.is_localhost()
|
|
92
|
+
|
|
81
93
|
/**
|
|
82
94
|
* Checks if the code is running within a Cypress environment.
|
|
83
95
|
* @returns {boolean} Returns true if the code is running in a Cypress environment, otherwise returns false.
|
package/modules/validations.js
CHANGED
|
@@ -31,8 +31,8 @@ export const require_props = ( obj={}, required_properties=[], error_on_fail=tru
|
|
|
31
31
|
const missing_properties = required_properties.filter( prop => !keys.includes( prop ) )
|
|
32
32
|
|
|
33
33
|
// If properties are missing, throw errors or return false
|
|
34
|
-
if( error_on_fail &&
|
|
35
|
-
if(
|
|
34
|
+
if( error_on_fail && missing_properties.length ) throw new Error( `Missing required properties on object: ${ missing_properties.join( ', ' ) }` )
|
|
35
|
+
if( missing_properties.length ) return false
|
|
36
36
|
|
|
37
37
|
// If all good, return true
|
|
38
38
|
return true
|