@modern-js/utils 2.4.1-beta.0 → 2.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (102) hide show
  1. package/CHANGELOG.md +7 -1
  2. package/dist/FileSizeReporter.d.ts +5 -5
  3. package/dist/FileSizeReporter.js +143 -136
  4. package/dist/alias.d.ts +14 -12
  5. package/dist/alias.js +94 -54
  6. package/dist/analyzeProject.d.ts +1 -1
  7. package/dist/analyzeProject.js +58 -33
  8. package/dist/applyOptionsChain.d.ts +1 -1
  9. package/dist/applyOptionsChain.js +55 -27
  10. package/dist/chainId.d.ts +256 -184
  11. package/dist/chainId.js +132 -187
  12. package/dist/clearConsole.d.ts +1 -1
  13. package/dist/clearConsole.js +29 -7
  14. package/dist/commands.d.ts +1 -1
  15. package/dist/commands.js +33 -10
  16. package/dist/compatRequire.d.ts +3 -3
  17. package/dist/compatRequire.js +74 -38
  18. package/dist/compiled.d.ts +2 -1
  19. package/dist/compiled.js +137 -72
  20. package/dist/constants.d.ts +127 -105
  21. package/dist/constants.js +298 -281
  22. package/dist/debug.d.ts +1 -1
  23. package/dist/debug.js +28 -11
  24. package/dist/emptyDir.d.ts +1 -1
  25. package/dist/emptyDir.js +51 -9
  26. package/dist/ensureAbsolutePath.d.ts +1 -1
  27. package/dist/ensureAbsolutePath.js +33 -14
  28. package/dist/ensureArray.d.ts +1 -1
  29. package/dist/ensureArray.js +30 -8
  30. package/dist/findExists.d.ts +1 -1
  31. package/dist/findExists.js +37 -17
  32. package/dist/format.d.ts +3 -3
  33. package/dist/format.js +93 -81
  34. package/dist/generateMetaTags.d.ts +3 -3
  35. package/dist/generateMetaTags.js +56 -43
  36. package/dist/getBrowserslist.d.ts +1 -1
  37. package/dist/getBrowserslist.js +31 -7
  38. package/dist/getCoreJsVersion.d.ts +1 -1
  39. package/dist/getCoreJsVersion.js +39 -35
  40. package/dist/getEntryOptions.d.ts +1 -1
  41. package/dist/getEntryOptions.js +51 -24
  42. package/dist/getPackageManager.d.ts +1 -1
  43. package/dist/getPackageManager.js +75 -28
  44. package/dist/getPort.d.ts +7 -4
  45. package/dist/getPort.js +104 -58
  46. package/dist/getServerConfig.d.ts +1 -1
  47. package/dist/getServerConfig.js +61 -32
  48. package/dist/import.d.ts +2 -2
  49. package/dist/import.js +31 -8
  50. package/dist/index.d.ts +1 -1
  51. package/dist/index.js +59 -59
  52. package/dist/is/index.d.ts +5 -1
  53. package/dist/is/index.js +81 -94
  54. package/dist/is/node-env.d.ts +1 -1
  55. package/dist/is/node-env.js +39 -17
  56. package/dist/is/platform.d.ts +1 -1
  57. package/dist/is/platform.js +30 -10
  58. package/dist/is/type.d.ts +1 -1
  59. package/dist/is/type.js +48 -22
  60. package/dist/logger.d.ts +48 -48
  61. package/dist/logger.js +127 -95
  62. package/dist/monorepo.d.ts +3 -3
  63. package/dist/monorepo.js +117 -74
  64. package/dist/nodeEnv.d.ts +1 -1
  65. package/dist/nodeEnv.js +72 -25
  66. package/dist/path.d.ts +3 -1
  67. package/dist/path.js +76 -59
  68. package/dist/pathSerializer.d.ts +6 -6
  69. package/dist/pathSerializer.js +65 -43
  70. package/dist/plugin.d.ts +1 -1
  71. package/dist/plugin.js +45 -26
  72. package/dist/prettyInstructions.d.ts +4 -4
  73. package/dist/prettyInstructions.js +107 -65
  74. package/dist/printBuildError.d.ts +1 -1
  75. package/dist/printBuildError.js +54 -40
  76. package/dist/react.d.ts +1 -1
  77. package/dist/react.js +57 -21
  78. package/dist/readTsConfig.d.ts +1 -1
  79. package/dist/readTsConfig.js +38 -12
  80. package/dist/removeSlash.d.ts +1 -1
  81. package/dist/removeSlash.js +33 -9
  82. package/dist/routes.d.ts +1 -1
  83. package/dist/routes.js +49 -22
  84. package/dist/runtimeExports.d.ts +3 -3
  85. package/dist/runtimeExports.js +59 -39
  86. package/dist/ssr.d.ts +2 -1
  87. package/dist/ssr.js +30 -7
  88. package/dist/storage.d.ts +3 -3
  89. package/dist/storage.js +65 -59
  90. package/dist/test-utils.d.ts +1 -1
  91. package/dist/test-utils.js +30 -24
  92. package/dist/tryResolve.d.ts +2 -1
  93. package/dist/tryResolve.js +45 -33
  94. package/dist/types.d.ts +1 -1
  95. package/dist/types.js +15 -2
  96. package/dist/version.d.ts +1 -1
  97. package/dist/version.js +83 -24
  98. package/dist/wait.d.ts +1 -1
  99. package/dist/wait.js +28 -6
  100. package/dist/watch.d.ts +3 -3
  101. package/dist/watch.js +82 -55
  102. package/package.json +7 -8
package/dist/index.js CHANGED
@@ -1,60 +1,60 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __copyProps = (to, from, except, desc) => {
6
+ if (from && typeof from === "object" || typeof from === "function") {
7
+ for (let key of __getOwnPropNames(from))
8
+ if (!__hasOwnProp.call(to, key) && key !== except)
9
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
10
+ }
11
+ return to;
15
12
  };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./compiled"), exports);
18
- __exportStar(require("./commands"), exports);
19
- __exportStar(require("./format"), exports);
20
- __exportStar(require("./FileSizeReporter"), exports);
21
- __exportStar(require("./printBuildError"), exports);
22
- __exportStar(require("./debug"), exports);
23
- __exportStar(require("./findExists"), exports);
24
- __exportStar(require("./is"), exports);
25
- __exportStar(require("./compatRequire"), exports);
26
- __exportStar(require("./logger"), exports);
27
- __exportStar(require("./constants"), exports);
28
- __exportStar(require("./ensureArray"), exports);
29
- __exportStar(require("./ensureAbsolutePath"), exports);
30
- __exportStar(require("./clearConsole"), exports);
31
- __exportStar(require("./applyOptionsChain"), exports);
32
- __exportStar(require("./getBrowserslist"), exports);
33
- __exportStar(require("./removeSlash"), exports);
34
- __exportStar(require("./getEntryOptions"), exports);
35
- __exportStar(require("./getPort"), exports);
36
- __exportStar(require("./monorepo"), exports);
37
- __exportStar(require("./getPackageManager"), exports);
38
- __exportStar(require("./runtimeExports"), exports);
39
- __exportStar(require("./readTsConfig"), exports);
40
- __exportStar(require("./path"), exports);
41
- __exportStar(require("./pathSerializer"), exports);
42
- __exportStar(require("./generateMetaTags"), exports);
43
- __exportStar(require("./prettyInstructions"), exports);
44
- __exportStar(require("./alias"), exports);
45
- __exportStar(require("./import"), exports);
46
- __exportStar(require("./watch"), exports);
47
- __exportStar(require("./nodeEnv"), exports);
48
- __exportStar(require("./wait"), exports);
49
- __exportStar(require("./emptyDir"), exports);
50
- __exportStar(require("./getServerConfig"), exports);
51
- __exportStar(require("./ssr"), exports);
52
- __exportStar(require("./tryResolve"), exports);
53
- __exportStar(require("./analyzeProject"), exports);
54
- __exportStar(require("./chainId"), exports);
55
- __exportStar(require("./version"), exports);
56
- __exportStar(require("./plugin"), exports);
57
- __exportStar(require("./routes"), exports);
58
- __exportStar(require("./test-utils"), exports);
59
- __exportStar(require("./getCoreJsVersion"), exports);
60
- __exportStar(require("./react"), exports);
13
+ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
14
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
15
+ var src_exports = {};
16
+ module.exports = __toCommonJS(src_exports);
17
+ __reExport(src_exports, require("./compiled"), module.exports);
18
+ __reExport(src_exports, require("./commands"), module.exports);
19
+ __reExport(src_exports, require("./format"), module.exports);
20
+ __reExport(src_exports, require("./FileSizeReporter"), module.exports);
21
+ __reExport(src_exports, require("./printBuildError"), module.exports);
22
+ __reExport(src_exports, require("./debug"), module.exports);
23
+ __reExport(src_exports, require("./findExists"), module.exports);
24
+ __reExport(src_exports, require("./is"), module.exports);
25
+ __reExport(src_exports, require("./compatRequire"), module.exports);
26
+ __reExport(src_exports, require("./logger"), module.exports);
27
+ __reExport(src_exports, require("./constants"), module.exports);
28
+ __reExport(src_exports, require("./ensureArray"), module.exports);
29
+ __reExport(src_exports, require("./ensureAbsolutePath"), module.exports);
30
+ __reExport(src_exports, require("./clearConsole"), module.exports);
31
+ __reExport(src_exports, require("./applyOptionsChain"), module.exports);
32
+ __reExport(src_exports, require("./getBrowserslist"), module.exports);
33
+ __reExport(src_exports, require("./removeSlash"), module.exports);
34
+ __reExport(src_exports, require("./getEntryOptions"), module.exports);
35
+ __reExport(src_exports, require("./getPort"), module.exports);
36
+ __reExport(src_exports, require("./monorepo"), module.exports);
37
+ __reExport(src_exports, require("./getPackageManager"), module.exports);
38
+ __reExport(src_exports, require("./runtimeExports"), module.exports);
39
+ __reExport(src_exports, require("./readTsConfig"), module.exports);
40
+ __reExport(src_exports, require("./path"), module.exports);
41
+ __reExport(src_exports, require("./pathSerializer"), module.exports);
42
+ __reExport(src_exports, require("./generateMetaTags"), module.exports);
43
+ __reExport(src_exports, require("./prettyInstructions"), module.exports);
44
+ __reExport(src_exports, require("./alias"), module.exports);
45
+ __reExport(src_exports, require("./import"), module.exports);
46
+ __reExport(src_exports, require("./watch"), module.exports);
47
+ __reExport(src_exports, require("./nodeEnv"), module.exports);
48
+ __reExport(src_exports, require("./wait"), module.exports);
49
+ __reExport(src_exports, require("./emptyDir"), module.exports);
50
+ __reExport(src_exports, require("./getServerConfig"), module.exports);
51
+ __reExport(src_exports, require("./ssr"), module.exports);
52
+ __reExport(src_exports, require("./tryResolve"), module.exports);
53
+ __reExport(src_exports, require("./analyzeProject"), module.exports);
54
+ __reExport(src_exports, require("./chainId"), module.exports);
55
+ __reExport(src_exports, require("./version"), module.exports);
56
+ __reExport(src_exports, require("./plugin"), module.exports);
57
+ __reExport(src_exports, require("./routes"), module.exports);
58
+ __reExport(src_exports, require("./test-utils"), module.exports);
59
+ __reExport(src_exports, require("./getCoreJsVersion"), module.exports);
60
+ __reExport(src_exports, require("./react"), module.exports);
@@ -12,6 +12,7 @@ export declare const isDepExists: (appDirectory: string, name: string) => boolea
12
12
  * @param root - App directory.
13
13
  * @returns Whether to use typescript.
14
14
  */
15
+
15
16
  export declare const isTypescript: (root: string) => boolean;
16
17
  /**
17
18
  * Is Empty object
@@ -19,6 +20,7 @@ export declare const isTypescript: (root: string) => boolean;
19
20
  * @param o - Any object.
20
21
  * @returns Whether it is empty object.
21
22
  */
23
+
22
24
  export declare const isEmpty: (o: Record<string, unknown>) => boolean;
23
25
  /**
24
26
  * Is SSR project
@@ -26,6 +28,7 @@ export declare const isEmpty: (o: Record<string, unknown>) => boolean;
26
28
  * @param config - User config.
27
29
  * @returns Whether to use server side render.
28
30
  */
31
+
29
32
  export declare const isSSR: (config: any) => boolean;
30
33
  export declare const isUseSSRBundle: (config: any) => boolean;
31
34
  /**
@@ -34,8 +37,9 @@ export declare const isUseSSRBundle: (config: any) => boolean;
34
37
  * @param config - User config.
35
38
  * @returns Whether to use worker deploy.
36
39
  */
40
+
37
41
  export declare const isServiceWorker: (config: any) => boolean;
38
42
  export declare const isFastRefresh: () => boolean;
39
43
  export * from './node-env';
40
44
  export * from './platform';
41
- export * from './type';
45
+ export * from './type';
package/dist/is/index.js CHANGED
@@ -1,107 +1,94 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
15
10
  };
16
- var __importDefault = (this && this.__importDefault) || function (mod) {
17
- return (mod && mod.__esModule) ? mod : { "default": mod };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
18
  };
19
- Object.defineProperty(exports, "__esModule", { value: true });
20
- exports.isFastRefresh = exports.isServiceWorker = exports.isUseSSRBundle = exports.isSSR = exports.isEmpty = exports.isTypescript = exports.isDepExists = void 0;
21
- const fs_1 = __importDefault(require("fs"));
22
- const path_1 = __importDefault(require("path"));
23
- const debug_1 = require("../debug");
24
- const node_env_1 = require("./node-env");
25
- const debug = (0, debug_1.createDebugger)('judge-depExists');
26
- /**
27
- * Check if the package name is in dependencies or devDependencies.
28
- *
29
- * @param appDirectory - Project root directory.
30
- * @param name - Package name.
31
- * @returns True if the name is in dependencies or devDependencies, false otherwise.
32
- */
19
+ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
22
+ mod
23
+ ));
24
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
25
+ var is_exports = {};
26
+ __export(is_exports, {
27
+ isDepExists: () => isDepExists,
28
+ isEmpty: () => isEmpty,
29
+ isFastRefresh: () => isFastRefresh,
30
+ isSSR: () => isSSR,
31
+ isServiceWorker: () => isServiceWorker,
32
+ isTypescript: () => isTypescript,
33
+ isUseSSRBundle: () => isUseSSRBundle
34
+ });
35
+ module.exports = __toCommonJS(is_exports);
36
+ var import_fs = __toESM(require("fs"));
37
+ var import_path = __toESM(require("path"));
38
+ var import_debug = require("../debug");
39
+ var import_node_env = require("./node-env");
40
+ __reExport(is_exports, require("./node-env"), module.exports);
41
+ __reExport(is_exports, require("./platform"), module.exports);
42
+ __reExport(is_exports, require("./type"), module.exports);
43
+ const debug = (0, import_debug.createDebugger)("judge-depExists");
33
44
  const isDepExists = (appDirectory, name) => {
34
- const pkgPath = path_1.default.resolve(appDirectory, './package.json');
35
- if (!fs_1.default.existsSync(pkgPath)) {
36
- debug(`can't find package.json under: %s`, appDirectory);
37
- return false;
38
- }
39
- const json = require(pkgPath);
40
- const { dependencies = {}, devDependencies = {} } = json;
41
- return (dependencies.hasOwnProperty(name) || devDependencies.hasOwnProperty(name));
45
+ const pkgPath = import_path.default.resolve(appDirectory, "./package.json");
46
+ if (!import_fs.default.existsSync(pkgPath)) {
47
+ debug(`can't find package.json under: %s`, appDirectory);
48
+ return false;
49
+ }
50
+ const json = require(pkgPath);
51
+ const { dependencies = {}, devDependencies = {} } = json;
52
+ return dependencies.hasOwnProperty(name) || devDependencies.hasOwnProperty(name);
42
53
  };
43
- exports.isDepExists = isDepExists;
44
- /**
45
- * Is typescript project.
46
- *
47
- * @param root - App directory.
48
- * @returns Whether to use typescript.
49
- */
50
- const isTypescript = (root) => fs_1.default.existsSync(path_1.default.resolve(root, './tsconfig.json'));
51
- exports.isTypescript = isTypescript;
52
- /**
53
- * Is Empty object
54
- *
55
- * @param o - Any object.
56
- * @returns Whether it is empty object.
57
- */
54
+ const isTypescript = (root) => import_fs.default.existsSync(import_path.default.resolve(root, "./tsconfig.json"));
58
55
  const isEmpty = (o) => Object.entries(o).length === 0 && o.constructor === Object;
59
- exports.isEmpty = isEmpty;
60
- /**
61
- * Is SSR project
62
- *
63
- * @param config - User config.
64
- * @returns Whether to use server side render.
65
- */
66
56
  const isSSR = (config) => {
67
- const { server } = config;
68
- if (server === null || server === void 0 ? void 0 : server.ssr) {
57
+ const { server } = config;
58
+ if (server == null ? void 0 : server.ssr) {
59
+ return true;
60
+ }
61
+ if ((server == null ? void 0 : server.ssrByEntries) && !isEmpty(server.ssrByEntries)) {
62
+ for (const name of Object.keys(server.ssrByEntries)) {
63
+ if (server.ssrByEntries[name]) {
69
64
  return true;
65
+ }
70
66
  }
71
- if ((server === null || server === void 0 ? void 0 : server.ssrByEntries) && !(0, exports.isEmpty)(server.ssrByEntries)) {
72
- for (const name of Object.keys(server.ssrByEntries)) {
73
- if (server.ssrByEntries[name]) {
74
- return true;
75
- }
76
- }
77
- }
78
- return false;
67
+ }
68
+ return false;
79
69
  };
80
- exports.isSSR = isSSR;
81
70
  const isUseSSRBundle = (config) => {
82
- const { output } = config;
83
- if (output === null || output === void 0 ? void 0 : output.ssg) {
84
- return true;
85
- }
86
- return (0, exports.isSSR)(config);
71
+ const { output } = config;
72
+ if (output == null ? void 0 : output.ssg) {
73
+ return true;
74
+ }
75
+ return isSSR(config);
87
76
  };
88
- exports.isUseSSRBundle = isUseSSRBundle;
89
- /**
90
- * Is Worker project
91
- *
92
- * @param config - User config.
93
- * @returns Whether to use worker deploy.
94
- */
95
77
  const isServiceWorker = (config) => {
96
- const { output, server } = config;
97
- if ((server === null || server === void 0 ? void 0 : server.worker) && ((output === null || output === void 0 ? void 0 : output.ssg) || (0, exports.isSSR)(config))) {
98
- return true;
99
- }
100
- return false;
78
+ const { output, server } = config;
79
+ if ((server == null ? void 0 : server.worker) && ((output == null ? void 0 : output.ssg) || isSSR(config))) {
80
+ return true;
81
+ }
82
+ return false;
101
83
  };
102
- exports.isServiceWorker = isServiceWorker;
103
- const isFastRefresh = () => (0, node_env_1.isDev)() && process.env.FAST_REFRESH !== 'false';
104
- exports.isFastRefresh = isFastRefresh;
105
- __exportStar(require("./node-env"), exports);
106
- __exportStar(require("./platform"), exports);
107
- __exportStar(require("./type"), exports);
84
+ const isFastRefresh = () => (0, import_node_env.isDev)() && process.env.FAST_REFRESH !== "false";
85
+ // Annotate the CommonJS export names for ESM import in node:
86
+ 0 && (module.exports = {
87
+ isDepExists,
88
+ isEmpty,
89
+ isFastRefresh,
90
+ isSSR,
91
+ isServiceWorker,
92
+ isTypescript,
93
+ isUseSSRBundle
94
+ });
@@ -5,4 +5,4 @@ export declare const getNodeEnv: () => string;
5
5
  export declare const isDev: () => boolean;
6
6
  export declare const isProd: () => boolean;
7
7
  export declare const isTest: () => boolean;
8
- export declare const isProdProfile: () => boolean;
8
+ export declare const isProdProfile: () => boolean;
@@ -1,17 +1,39 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isProdProfile = exports.isTest = exports.isProd = exports.isDev = exports.getNodeEnv = void 0;
4
- /**
5
- * Get the current NODE_ENV, or default to 'development' if not set.
6
- */
7
- const getNodeEnv = () => process.env.NODE_ENV || 'development';
8
- exports.getNodeEnv = getNodeEnv;
9
- const isDev = () => (0, exports.getNodeEnv)() === 'development';
10
- exports.isDev = isDev;
11
- const isProd = () => (0, exports.getNodeEnv)() === 'production';
12
- exports.isProd = isProd;
13
- const isTest = () => (0, exports.getNodeEnv)() === 'test';
14
- exports.isTest = isTest;
15
- // Variable used for enabling profiling in Production.
16
- const isProdProfile = () => (0, exports.isProd)() && process.argv.includes('--profile');
17
- exports.isProdProfile = isProdProfile;
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+ var node_env_exports = {};
19
+ __export(node_env_exports, {
20
+ getNodeEnv: () => getNodeEnv,
21
+ isDev: () => isDev,
22
+ isProd: () => isProd,
23
+ isProdProfile: () => isProdProfile,
24
+ isTest: () => isTest
25
+ });
26
+ module.exports = __toCommonJS(node_env_exports);
27
+ const getNodeEnv = () => process.env.NODE_ENV || "development";
28
+ const isDev = () => getNodeEnv() === "development";
29
+ const isProd = () => getNodeEnv() === "production";
30
+ const isTest = () => getNodeEnv() === "test";
31
+ const isProdProfile = () => isProd() && process.argv.includes("--profile");
32
+ // Annotate the CommonJS export names for ESM import in node:
33
+ 0 && (module.exports = {
34
+ getNodeEnv,
35
+ isDev,
36
+ isProd,
37
+ isProdProfile,
38
+ isTest
39
+ });
@@ -1,2 +1,2 @@
1
1
  export declare const isNodeJS: () => boolean;
2
- export declare const isBrowser: () => boolean;
2
+ export declare const isBrowser: () => boolean;
@@ -1,10 +1,30 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isBrowser = exports.isNodeJS = void 0;
4
- const isNodeJS = () => typeof process !== 'undefined' &&
5
- process.versions != null &&
6
- process.versions.node != null &&
7
- process.versions.electron == null;
8
- exports.isNodeJS = isNodeJS;
9
- const isBrowser = () => typeof window !== 'undefined';
10
- exports.isBrowser = isBrowser;
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+ var platform_exports = {};
19
+ __export(platform_exports, {
20
+ isBrowser: () => isBrowser,
21
+ isNodeJS: () => isNodeJS
22
+ });
23
+ module.exports = __toCommonJS(platform_exports);
24
+ const isNodeJS = () => typeof process !== "undefined" && process.versions != null && process.versions.node != null && process.versions.electron == null;
25
+ const isBrowser = () => typeof window !== "undefined";
26
+ // Annotate the CommonJS export names for ESM import in node:
27
+ 0 && (module.exports = {
28
+ isBrowser,
29
+ isNodeJS
30
+ });
package/dist/is/type.d.ts CHANGED
@@ -5,4 +5,4 @@ export declare function isFunction(func: any): func is Function;
5
5
  export declare function isObject(obj: unknown): obj is Record<string, any>;
6
6
  export declare function isPlainObject(obj: unknown): obj is Record<string, any>;
7
7
  export declare function isPromise(obj: any): obj is Promise<any>;
8
- export declare function isRegExp(obj: any): obj is RegExp;
8
+ export declare function isRegExp(obj: any): obj is RegExp;
package/dist/is/type.js CHANGED
@@ -1,38 +1,64 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isRegExp = exports.isPromise = exports.isPlainObject = exports.isObject = exports.isFunction = exports.isArray = exports.isUndefined = exports.isString = void 0;
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+ var type_exports = {};
19
+ __export(type_exports, {
20
+ isArray: () => isArray,
21
+ isFunction: () => isFunction,
22
+ isObject: () => isObject,
23
+ isPlainObject: () => isPlainObject,
24
+ isPromise: () => isPromise,
25
+ isRegExp: () => isRegExp,
26
+ isString: () => isString,
27
+ isUndefined: () => isUndefined
28
+ });
29
+ module.exports = __toCommonJS(type_exports);
4
30
  function isString(str) {
5
- return typeof str === 'string';
31
+ return typeof str === "string";
6
32
  }
7
- exports.isString = isString;
8
33
  function isUndefined(obj) {
9
- return typeof obj === 'undefined';
34
+ return typeof obj === "undefined";
10
35
  }
11
- exports.isUndefined = isUndefined;
12
36
  function isArray(obj) {
13
- return Array.isArray(obj);
37
+ return Array.isArray(obj);
14
38
  }
15
- exports.isArray = isArray;
16
- // eslint-disable-next-line @typescript-eslint/ban-types
17
39
  function isFunction(func) {
18
- return typeof func === 'function';
40
+ return typeof func === "function";
19
41
  }
20
- exports.isFunction = isFunction;
21
42
  function isObject(obj) {
22
- return obj !== null && typeof obj === 'object';
43
+ return obj !== null && typeof obj === "object";
23
44
  }
24
- exports.isObject = isObject;
25
45
  function isPlainObject(obj) {
26
- return (isObject(obj) && Object.prototype.toString.call(obj) === '[object Object]');
46
+ return isObject(obj) && Object.prototype.toString.call(obj) === "[object Object]";
27
47
  }
28
- exports.isPlainObject = isPlainObject;
29
48
  function isPromise(obj) {
30
- return (Boolean(obj) &&
31
- (typeof obj === 'object' || typeof obj === 'function') &&
32
- typeof obj.then === 'function');
49
+ return Boolean(obj) && (typeof obj === "object" || typeof obj === "function") && typeof obj.then === "function";
33
50
  }
34
- exports.isPromise = isPromise;
35
51
  function isRegExp(obj) {
36
- return Object.prototype.toString.call(obj) === '[object RegExp]';
52
+ return Object.prototype.toString.call(obj) === "[object RegExp]";
37
53
  }
38
- exports.isRegExp = isRegExp;
54
+ // Annotate the CommonJS export names for ESM import in node:
55
+ 0 && (module.exports = {
56
+ isArray,
57
+ isFunction,
58
+ isObject,
59
+ isPlainObject,
60
+ isPromise,
61
+ isRegExp,
62
+ isString,
63
+ isUndefined
64
+ });