mentie 0.1.5 → 0.1.6

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.
@@ -11,7 +11,7 @@ export const is_web = typeof window !== 'undefined'
11
11
  * Checks if the code is running in a Node environment.
12
12
  * @returns {boolean} Returns true if the code is running in a Node environment, otherwise returns false.
13
13
  */
14
- export const is_node = typeof process !== 'undefined' && process.versions && process.versions.node
14
+ export const is_node = typeof process !== 'undefined' && process.versions && process.versions?.node
15
15
 
16
16
  /**
17
17
  * Checks if the code is running in a Firebase functions emulator environment.
@@ -42,11 +42,43 @@ export const web_loglevel = is_web && new URLSearchParams( location?.search ).ge
42
42
  * The log level for the Node environment.
43
43
  * @type {string} - Log level. Valid values are: 'info', 'warn', 'error'
44
44
  */
45
- export const node_loglevel = process.env?.LOG_LEVEL
45
+ export const node_loglevel = typeof process !== 'undefined' && process.env?.LOG_LEVEL
46
46
 
47
47
 
48
48
  /**
49
49
  * The log level used in the environment.
50
50
  * @type {string}
51
51
  */
52
- export const loglevel = web_loglevel || node_loglevel || 'info'
52
+ export const loglevel = web_loglevel || node_loglevel || 'info'
53
+
54
+
55
+ /**
56
+ * Logs the environment details.
57
+ * @param {Function} logger - Optional logger function to use for logging the environment details.
58
+ */
59
+ export const log_environment = logger => {
60
+
61
+ // Environment trail
62
+ const env = {
63
+ web: {
64
+ is_web,
65
+ loglevel: web_loglevel,
66
+ window: typeof window !== 'undefined' && window,
67
+ search: typeof location !== 'undefined' && location.search
68
+ },
69
+ node: {
70
+ is_node,
71
+ loglevel: node_loglevel,
72
+ process: typeof process !== 'undefined' && process
73
+ },
74
+ environment: {
75
+ dev,
76
+ is_emulator
77
+ }
78
+ }
79
+
80
+ // Log the environment
81
+ if( !logger ) logger = console.log
82
+ logger( 'Environment:', env )
83
+
84
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mentie",
3
- "version": "0.1.5",
3
+ "version": "0.1.6",
4
4
  "description": "Mentor's toolbelt",
5
5
  "type": "module",
6
6
  "main": "index.js",