@modern-js/utils 2.4.0 → 2.5.0-alpha.0
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.md +14 -0
- package/dist/FileSizeReporter.d.ts +5 -5
- package/dist/FileSizeReporter.js +143 -136
- package/dist/alias.d.ts +16 -14
- package/dist/alias.js +94 -54
- package/dist/analyzeProject.d.ts +1 -1
- package/dist/analyzeProject.js +58 -33
- package/dist/applyOptionsChain.d.ts +1 -1
- package/dist/applyOptionsChain.js +55 -27
- package/dist/chainId.d.ts +256 -184
- package/dist/chainId.js +132 -187
- package/dist/clearConsole.d.ts +1 -1
- package/dist/clearConsole.js +29 -7
- package/dist/commands.d.ts +1 -1
- package/dist/commands.js +33 -10
- package/dist/compatRequire.d.ts +3 -3
- package/dist/compatRequire.js +74 -38
- package/dist/compiled.d.ts +2 -1
- package/dist/compiled.js +137 -72
- package/dist/constants.d.ts +131 -105
- package/dist/constants.js +298 -277
- package/dist/debug.d.ts +1 -1
- package/dist/debug.js +28 -11
- package/dist/emptyDir.d.ts +1 -1
- package/dist/emptyDir.js +51 -9
- package/dist/ensureAbsolutePath.d.ts +1 -1
- package/dist/ensureAbsolutePath.js +33 -14
- package/dist/ensureArray.d.ts +1 -1
- package/dist/ensureArray.js +30 -8
- package/dist/findExists.d.ts +1 -1
- package/dist/findExists.js +37 -17
- package/dist/format.d.ts +3 -3
- package/dist/format.js +93 -81
- package/dist/generateMetaTags.d.ts +4 -4
- package/dist/generateMetaTags.js +56 -43
- package/dist/getBrowserslist.d.ts +1 -1
- package/dist/getBrowserslist.js +31 -7
- package/dist/getCoreJsVersion.d.ts +1 -1
- package/dist/getCoreJsVersion.js +39 -35
- package/dist/getEntryOptions.d.ts +1 -1
- package/dist/getEntryOptions.js +51 -24
- package/dist/getPackageManager.d.ts +1 -1
- package/dist/getPackageManager.js +75 -28
- package/dist/getPort.d.ts +7 -4
- package/dist/getPort.js +104 -58
- package/dist/getServerConfig.d.ts +1 -1
- package/dist/getServerConfig.js +61 -32
- package/dist/import.d.ts +2 -2
- package/dist/import.js +31 -8
- package/dist/index.d.ts +2 -0
- package/dist/index.js +61 -59
- package/dist/is/index.d.ts +12 -1
- package/dist/is/index.js +83 -82
- package/dist/is/node-env.d.ts +1 -1
- package/dist/is/node-env.js +39 -17
- package/dist/is/platform.d.ts +1 -1
- package/dist/is/platform.js +30 -10
- package/dist/is/type.d.ts +1 -1
- package/dist/is/type.js +48 -22
- package/dist/logger.d.ts +51 -51
- package/dist/logger.js +127 -95
- package/dist/monorepo.d.ts +3 -3
- package/dist/monorepo.js +117 -74
- package/dist/nestedRoutes.d.ts +9 -0
- package/dist/nestedRoutes.js +144 -0
- package/dist/nodeEnv.d.ts +1 -1
- package/dist/nodeEnv.js +72 -25
- package/dist/path.d.ts +3 -1
- package/dist/path.js +76 -59
- package/dist/pathSerializer.d.ts +7 -7
- package/dist/pathSerializer.js +65 -43
- package/dist/plugin.d.ts +1 -1
- package/dist/plugin.js +45 -26
- package/dist/prettyInstructions.d.ts +4 -4
- package/dist/prettyInstructions.js +107 -65
- package/dist/printBuildError.d.ts +1 -1
- package/dist/printBuildError.js +54 -40
- package/dist/react.d.ts +1 -1
- package/dist/react.js +57 -21
- package/dist/readTsConfig.d.ts +1 -1
- package/dist/readTsConfig.js +38 -12
- package/dist/remix-router.d.ts +1 -0
- package/dist/remix-router.js +17 -0
- package/dist/removeSlash.d.ts +1 -1
- package/dist/removeSlash.js +33 -9
- package/dist/routes.d.ts +1 -1
- package/dist/routes.js +49 -22
- package/dist/runtimeExports.d.ts +3 -3
- package/dist/runtimeExports.js +59 -39
- package/dist/serialize.d.ts +1 -0
- package/dist/serialize.js +36 -0
- package/dist/ssr.d.ts +2 -1
- package/dist/ssr.js +30 -7
- package/dist/storage.d.ts +3 -3
- package/dist/storage.js +65 -59
- package/dist/test-utils.d.ts +1 -1
- package/dist/test-utils.js +30 -24
- package/dist/tryResolve.d.ts +2 -1
- package/dist/tryResolve.js +45 -33
- package/dist/types.d.ts +1 -1
- package/dist/types.js +15 -2
- package/dist/version.d.ts +1 -1
- package/dist/version.js +83 -24
- package/dist/wait.d.ts +1 -1
- package/dist/wait.js +28 -6
- package/dist/watch.d.ts +5 -5
- package/dist/watch.js +82 -55
- package/package.json +31 -9
package/dist/index.js
CHANGED
@@ -1,60 +1,62 @@
|
|
1
|
-
|
2
|
-
var
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
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
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
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);
|
61
|
+
__reExport(src_exports, require("./nestedRoutes"), module.exports);
|
62
|
+
__reExport(src_exports, require("./serialize"), module.exports);
|
package/dist/is/index.d.ts
CHANGED
@@ -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,9 +28,18 @@ 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;
|
34
|
+
/**
|
35
|
+
* Is Worker project
|
36
|
+
*
|
37
|
+
* @param config - User config.
|
38
|
+
* @returns Whether to use worker deploy.
|
39
|
+
*/
|
40
|
+
|
41
|
+
export declare const isServiceWorker: (config: any) => boolean;
|
31
42
|
export declare const isFastRefresh: () => boolean;
|
32
43
|
export * from './node-env';
|
33
44
|
export * from './platform';
|
34
|
-
export * from './type';
|
45
|
+
export * from './type';
|
package/dist/is/index.js
CHANGED
@@ -1,93 +1,94 @@
|
|
1
|
-
|
2
|
-
var
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
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
|
17
|
-
|
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
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
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
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
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
|
-
|
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
|
-
|
68
|
-
|
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
|
-
|
72
|
-
|
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
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
71
|
+
const { output } = config;
|
72
|
+
if (output == null ? void 0 : output.ssg) {
|
73
|
+
return true;
|
74
|
+
}
|
75
|
+
return isSSR(config);
|
76
|
+
};
|
77
|
+
const isServiceWorker = (config) => {
|
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;
|
87
83
|
};
|
88
|
-
|
89
|
-
|
90
|
-
exports
|
91
|
-
|
92
|
-
|
93
|
-
|
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
|
+
});
|
package/dist/is/node-env.d.ts
CHANGED
@@ -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;
|
package/dist/is/node-env.js
CHANGED
@@ -1,17 +1,39 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
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
|
+
});
|
package/dist/is/platform.d.ts
CHANGED
@@ -1,2 +1,2 @@
|
|
1
1
|
export declare const isNodeJS: () => boolean;
|
2
|
-
export declare const isBrowser: () => boolean;
|
2
|
+
export declare const isBrowser: () => boolean;
|
package/dist/is/platform.js
CHANGED
@@ -1,10 +1,30 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
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
|
-
|
2
|
-
|
3
|
-
|
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
|
-
|
31
|
+
return typeof str === "string";
|
6
32
|
}
|
7
|
-
exports.isString = isString;
|
8
33
|
function isUndefined(obj) {
|
9
|
-
|
34
|
+
return typeof obj === "undefined";
|
10
35
|
}
|
11
|
-
exports.isUndefined = isUndefined;
|
12
36
|
function isArray(obj) {
|
13
|
-
|
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
|
-
|
40
|
+
return typeof func === "function";
|
19
41
|
}
|
20
|
-
exports.isFunction = isFunction;
|
21
42
|
function isObject(obj) {
|
22
|
-
|
43
|
+
return obj !== null && typeof obj === "object";
|
23
44
|
}
|
24
|
-
exports.isObject = isObject;
|
25
45
|
function isPlainObject(obj) {
|
26
|
-
|
46
|
+
return isObject(obj) && Object.prototype.toString.call(obj) === "[object Object]";
|
27
47
|
}
|
28
|
-
exports.isPlainObject = isPlainObject;
|
29
48
|
function isPromise(obj) {
|
30
|
-
|
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
|
-
|
52
|
+
return Object.prototype.toString.call(obj) === "[object RegExp]";
|
37
53
|
}
|
38
|
-
|
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
|
+
});
|