@js-utils-kit/env 1.4.0 → 1.5.0

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/dist/index.cjs CHANGED
@@ -1 +1 @@
1
- let e=require(`@js-utils-kit/types`),t=require(`node:process`);function n(){switch(process.env.NODE_ENV){case e.Environment.PROD:return e.Environment.PROD;case e.Environment.DEV:return e.Environment.DEV;case e.Environment.TEST:return e.Environment.TEST;default:return e.Environment.UNKNOWN}}const r=`AC_APPCIRCLE.AGOLA_GIT_REF.APPCENTER_BUILD_ID.APPVEYOR.bamboo_planKey.BITBUCKET_COMMIT.BITRISE_IO.BUDDY_WORKSPACE_ID.BUILD_ID.BUILD_NUMBER.BUILDER_OUTPUT.BUILDKITE.CF_BUILD_ID.CF_PAGES.CI_XCODE_PROJECT.CIRCLECI.CIRRUS_CI.CM_BUILD_ID.CODEBUILD_BUILD_ARN.DRONE.DSARI.EARTHLY_CI.EAS_BUILD.GERRIT_PROJECT.GITEA_ACTIONS.GITHUB_ACTIONS.GITLAB_CI.GO_PIPELINE_LABEL.HARNESS_BUILD_ID.HUDSON_URL.JENKINS_URL.LAYERCI.MAGNUM.NETLIFY.NEVERCODE.NOW_BUILDER.PROW_JOB_ID.RELEASE_BUILD_ID.RENDER.RUN_ID.SAILCI.SCREWDRIVER.SEMAPHORE.STRIDER.TASK_ID.TEAMCITY_VERSION.TF_BUILD.TRAVIS.VELA.VERCEL.WORKERS_CI.XCS`.split(`.`),i=[`CI`,`CONTINUOUS_INTEGRATION`],a=[`codeship`,`sourcehut`,`woodpecker`],o=e=>{let n=t.env[e]??t.env[e.toUpperCase()]??t.env[e.toLowerCase()];return n!=null&&n!==`0`&&n.toLowerCase()!==`false`},s=r.some(o),c=s||i.some(o)&&(s||typeof t.env.CI_NAME==`string`&&a.includes(t.env.CI_NAME.toLowerCase()));exports.getRunTimeEnvironment=n,exports.isCI=c;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});let e=require(`@js-utils-kit/types`),t=require(`node:process`);function n(){switch(process.env.NODE_ENV){case e.Environment.PROD:return e.Environment.PROD;case e.Environment.DEV:return e.Environment.DEV;case e.Environment.TEST:return e.Environment.TEST;default:return e.Environment.UNKNOWN}}const r=`AC_APPCIRCLE.AGOLA_GIT_REF.APPCENTER_BUILD_ID.APPVEYOR.bamboo_planKey.BITBUCKET_COMMIT.BITRISE_IO.BUDDY_WORKSPACE_ID.BUILD_ID.BUILD_NUMBER.BUILDER_OUTPUT.BUILDKITE.CF_BUILD_ID.CF_PAGES.CI_XCODE_PROJECT.CIRCLECI.CIRRUS_CI.CM_BUILD_ID.CODEBUILD_BUILD_ARN.DRONE.DSARI.EARTHLY_CI.EAS_BUILD.GERRIT_PROJECT.GITEA_ACTIONS.GITHUB_ACTIONS.GITLAB_CI.GO_PIPELINE_LABEL.HARNESS_BUILD_ID.HUDSON_URL.JENKINS_URL.LAYERCI.MAGNUM.NETLIFY.NEVERCODE.NOW_BUILDER.PROW_JOB_ID.RELEASE_BUILD_ID.RENDER.RUN_ID.SAILCI.SCREWDRIVER.SEMAPHORE.STRIDER.TASK_ID.TEAMCITY_VERSION.TF_BUILD.TRAVIS.VELA.VERCEL.WORKERS_CI.XCS`.split(`.`),i=[`CI`,`CONTINUOUS_INTEGRATION`],a=[`codeship`,`sourcehut`,`woodpecker`],o=e=>{let n=t.env[e]??t.env[e.toUpperCase()]??t.env[e.toLowerCase()];return n!=null&&n!==`0`&&n.toLowerCase()!==`false`},s=r.some(o),c=s||i.some(o)&&(s||typeof t.env.CI_NAME==`string`&&a.includes(t.env.CI_NAME.toLowerCase())),l=typeof window<`u`&&window.document!==void 0,u=typeof process<`u`&&process.env.NODE_ENV===e.Environment.DEV,d=typeof process<`u`&&process.env.NODE_ENV===e.Environment.PROD,f=typeof process<`u`&&process.env.NODE_ENV===e.Environment.TEST,p=typeof process<`u`&&process.versions!=null&&process.versions.node!=null;exports.getRunTimeEnvironment=n,exports.isBrowser=l,exports.isCI=c,exports.isDev=u,exports.isNode=p,exports.isProd=d,exports.isTest=f;
package/dist/index.d.cts CHANGED
@@ -42,4 +42,86 @@ declare function getRunTimeEnvironment(): Environment;
42
42
  */
43
43
  declare const isCI: boolean;
44
44
  //#endregion
45
- export { getRunTimeEnvironment, isCI };
45
+ //#region src/runtime.d.ts
46
+ /**
47
+ * Checks if the current runtime environment is a browser.
48
+ *
49
+ * This function helps detect whether code is executing in a web browser
50
+ * by confirming the existence of the global `window` and `document` objects.
51
+ *
52
+ * @returns `true` if running in a browser, otherwise `false`.
53
+ *
54
+ * @example
55
+ * ```ts
56
+ * if (isBrowser) {
57
+ * console.log('Running in a browser environment');
58
+ * }
59
+ * ```
60
+ */
61
+ declare const isBrowser: boolean;
62
+ /**
63
+ * Checks if the current environment is development.
64
+ *
65
+ * This is determined by comparing `process.env.NODE_ENV` with `'development'`.
66
+ *
67
+ * @returns `true` if `NODE_ENV` is set to development.
68
+ *
69
+ * @example
70
+ * ```ts
71
+ * if (isDev) {
72
+ * console.log('Dev mode enabled');
73
+ * }
74
+ * ```
75
+ */
76
+ declare const isDev: boolean;
77
+ /**
78
+ * Checks if the current environment is production.
79
+ *
80
+ * This is determined by comparing `process.env.NODE_ENV` with `'production'`.
81
+ *
82
+ * @returns `true` if `NODE_ENV` is set to production.
83
+ *
84
+ * @example
85
+ * ```ts
86
+ * if (isProd) {
87
+ * enableAnalytics();
88
+ * }
89
+ * ```
90
+ */
91
+ declare const isProd: boolean;
92
+ /**
93
+ * Checks if the current environment is testing.
94
+ *
95
+ * This is determined by comparing `process.env.NODE_ENV` with `'test'`.
96
+ *
97
+ * @returns `true` if `NODE_ENV` is set to test.
98
+ *
99
+ * @example
100
+ * ```ts
101
+ * if (isTest) {
102
+ * mockDatabase();
103
+ * }
104
+ * ```
105
+ */
106
+ declare const isTest: boolean;
107
+ /**
108
+ * Checks if the current runtime environment is Node.js.
109
+ *
110
+ * @remarks
111
+ * - It is useful to conditionally execute server-side logic.
112
+ * - It detects the Node.js environment by verifying the presence of the global `process` object and its `versions.node` property.
113
+ *
114
+ * @returns `true` if running in Node.js, otherwise `false`.
115
+ *
116
+ * @example
117
+ * ```ts
118
+ * if (isNode) {
119
+ * console.log('Running in Node.js environment');
120
+ * }
121
+ * ```
122
+ *
123
+ * @see {@link https://nodejs.org/api/process.html | Node.js process documentation}
124
+ */
125
+ declare const isNode: boolean;
126
+ //#endregion
127
+ export { getRunTimeEnvironment, isBrowser, isCI, isDev, isNode, isProd, isTest };
package/dist/index.d.mts CHANGED
@@ -42,4 +42,86 @@ declare function getRunTimeEnvironment(): Environment;
42
42
  */
43
43
  declare const isCI: boolean;
44
44
  //#endregion
45
- export { getRunTimeEnvironment, isCI };
45
+ //#region src/runtime.d.ts
46
+ /**
47
+ * Checks if the current runtime environment is a browser.
48
+ *
49
+ * This function helps detect whether code is executing in a web browser
50
+ * by confirming the existence of the global `window` and `document` objects.
51
+ *
52
+ * @returns `true` if running in a browser, otherwise `false`.
53
+ *
54
+ * @example
55
+ * ```ts
56
+ * if (isBrowser) {
57
+ * console.log('Running in a browser environment');
58
+ * }
59
+ * ```
60
+ */
61
+ declare const isBrowser: boolean;
62
+ /**
63
+ * Checks if the current environment is development.
64
+ *
65
+ * This is determined by comparing `process.env.NODE_ENV` with `'development'`.
66
+ *
67
+ * @returns `true` if `NODE_ENV` is set to development.
68
+ *
69
+ * @example
70
+ * ```ts
71
+ * if (isDev) {
72
+ * console.log('Dev mode enabled');
73
+ * }
74
+ * ```
75
+ */
76
+ declare const isDev: boolean;
77
+ /**
78
+ * Checks if the current environment is production.
79
+ *
80
+ * This is determined by comparing `process.env.NODE_ENV` with `'production'`.
81
+ *
82
+ * @returns `true` if `NODE_ENV` is set to production.
83
+ *
84
+ * @example
85
+ * ```ts
86
+ * if (isProd) {
87
+ * enableAnalytics();
88
+ * }
89
+ * ```
90
+ */
91
+ declare const isProd: boolean;
92
+ /**
93
+ * Checks if the current environment is testing.
94
+ *
95
+ * This is determined by comparing `process.env.NODE_ENV` with `'test'`.
96
+ *
97
+ * @returns `true` if `NODE_ENV` is set to test.
98
+ *
99
+ * @example
100
+ * ```ts
101
+ * if (isTest) {
102
+ * mockDatabase();
103
+ * }
104
+ * ```
105
+ */
106
+ declare const isTest: boolean;
107
+ /**
108
+ * Checks if the current runtime environment is Node.js.
109
+ *
110
+ * @remarks
111
+ * - It is useful to conditionally execute server-side logic.
112
+ * - It detects the Node.js environment by verifying the presence of the global `process` object and its `versions.node` property.
113
+ *
114
+ * @returns `true` if running in Node.js, otherwise `false`.
115
+ *
116
+ * @example
117
+ * ```ts
118
+ * if (isNode) {
119
+ * console.log('Running in Node.js environment');
120
+ * }
121
+ * ```
122
+ *
123
+ * @see {@link https://nodejs.org/api/process.html | Node.js process documentation}
124
+ */
125
+ declare const isNode: boolean;
126
+ //#endregion
127
+ export { getRunTimeEnvironment, isBrowser, isCI, isDev, isNode, isProd, isTest };
package/dist/index.mjs CHANGED
@@ -1 +1 @@
1
- import{Environment as e}from"@js-utils-kit/types";import{env as t}from"node:process";function n(){switch(process.env.NODE_ENV){case e.PROD:return e.PROD;case e.DEV:return e.DEV;case e.TEST:return e.TEST;default:return e.UNKNOWN}}const r=`AC_APPCIRCLE.AGOLA_GIT_REF.APPCENTER_BUILD_ID.APPVEYOR.bamboo_planKey.BITBUCKET_COMMIT.BITRISE_IO.BUDDY_WORKSPACE_ID.BUILD_ID.BUILD_NUMBER.BUILDER_OUTPUT.BUILDKITE.CF_BUILD_ID.CF_PAGES.CI_XCODE_PROJECT.CIRCLECI.CIRRUS_CI.CM_BUILD_ID.CODEBUILD_BUILD_ARN.DRONE.DSARI.EARTHLY_CI.EAS_BUILD.GERRIT_PROJECT.GITEA_ACTIONS.GITHUB_ACTIONS.GITLAB_CI.GO_PIPELINE_LABEL.HARNESS_BUILD_ID.HUDSON_URL.JENKINS_URL.LAYERCI.MAGNUM.NETLIFY.NEVERCODE.NOW_BUILDER.PROW_JOB_ID.RELEASE_BUILD_ID.RENDER.RUN_ID.SAILCI.SCREWDRIVER.SEMAPHORE.STRIDER.TASK_ID.TEAMCITY_VERSION.TF_BUILD.TRAVIS.VELA.VERCEL.WORKERS_CI.XCS`.split(`.`),i=[`CI`,`CONTINUOUS_INTEGRATION`],a=[`codeship`,`sourcehut`,`woodpecker`],o=e=>{let n=t[e]??t[e.toUpperCase()]??t[e.toLowerCase()];return n!=null&&n!==`0`&&n.toLowerCase()!==`false`},s=r.some(o),c=s||i.some(o)&&(s||typeof t.CI_NAME==`string`&&a.includes(t.CI_NAME.toLowerCase()));export{n as getRunTimeEnvironment,c as isCI};
1
+ import{Environment as e}from"@js-utils-kit/types";import{env as t}from"node:process";function n(){switch(process.env.NODE_ENV){case e.PROD:return e.PROD;case e.DEV:return e.DEV;case e.TEST:return e.TEST;default:return e.UNKNOWN}}const r=`AC_APPCIRCLE.AGOLA_GIT_REF.APPCENTER_BUILD_ID.APPVEYOR.bamboo_planKey.BITBUCKET_COMMIT.BITRISE_IO.BUDDY_WORKSPACE_ID.BUILD_ID.BUILD_NUMBER.BUILDER_OUTPUT.BUILDKITE.CF_BUILD_ID.CF_PAGES.CI_XCODE_PROJECT.CIRCLECI.CIRRUS_CI.CM_BUILD_ID.CODEBUILD_BUILD_ARN.DRONE.DSARI.EARTHLY_CI.EAS_BUILD.GERRIT_PROJECT.GITEA_ACTIONS.GITHUB_ACTIONS.GITLAB_CI.GO_PIPELINE_LABEL.HARNESS_BUILD_ID.HUDSON_URL.JENKINS_URL.LAYERCI.MAGNUM.NETLIFY.NEVERCODE.NOW_BUILDER.PROW_JOB_ID.RELEASE_BUILD_ID.RENDER.RUN_ID.SAILCI.SCREWDRIVER.SEMAPHORE.STRIDER.TASK_ID.TEAMCITY_VERSION.TF_BUILD.TRAVIS.VELA.VERCEL.WORKERS_CI.XCS`.split(`.`),i=[`CI`,`CONTINUOUS_INTEGRATION`],a=[`codeship`,`sourcehut`,`woodpecker`],o=e=>{let n=t[e]??t[e.toUpperCase()]??t[e.toLowerCase()];return n!=null&&n!==`0`&&n.toLowerCase()!==`false`},s=r.some(o),c=s||i.some(o)&&(s||typeof t.CI_NAME==`string`&&a.includes(t.CI_NAME.toLowerCase())),l=typeof window<`u`&&window.document!==void 0,u=typeof process<`u`&&process.env.NODE_ENV===e.DEV,d=typeof process<`u`&&process.env.NODE_ENV===e.PROD,f=typeof process<`u`&&process.env.NODE_ENV===e.TEST,p=typeof process<`u`&&process.versions!=null&&process.versions.node!=null;export{n as getRunTimeEnvironment,l as isBrowser,c as isCI,u as isDev,p as isNode,d as isProd,f as isTest};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@js-utils-kit/env",
3
- "version": "1.4.0",
3
+ "version": "1.5.0",
4
4
  "description": "Environment utilities",
5
5
  "private": false,
6
6
  "license": "MIT",
@@ -30,8 +30,8 @@
30
30
  "types": "./dist/index.d.cts",
31
31
  "exports": {
32
32
  ".": {
33
- "require": "./dist/index.cjs",
34
- "import": "./dist/index.mjs"
33
+ "import": "./dist/index.mjs",
34
+ "require": "./dist/index.cjs"
35
35
  }
36
36
  },
37
37
  "dependencies": {