is-where 1.0.1 → 1.0.2
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/cjs/index.cjs +31 -0
- package/dist/cjs/index.d.cts +45 -0
- package/dist/{types/index.d.ts → index.d.ts} +45 -43
- package/dist/index.js +23 -0
- package/package.json +19 -13
- package/dist/index.cjs +0 -80
- package/dist/index.es.js +0 -72
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
function isNode() {
|
|
4
|
+
return typeof process !== "undefined" && process.versions != null && process.versions.node != null;
|
|
5
|
+
}
|
|
6
|
+
function isBrowser() {
|
|
7
|
+
return typeof window !== "undefined" && typeof window.document !== "undefined";
|
|
8
|
+
}
|
|
9
|
+
function isWebWorker() {
|
|
10
|
+
return typeof self === "object" && self.constructor && self.constructor.name === "DedicatedWorkerGlobalScope";
|
|
11
|
+
}
|
|
12
|
+
function isJsDom() {
|
|
13
|
+
return typeof window !== "undefined" && window.name === "nodejs" || typeof navigator !== "undefined" && (navigator.userAgent.includes("Node.js") || navigator.userAgent.includes("jsdom"));
|
|
14
|
+
}
|
|
15
|
+
function isDeno() {
|
|
16
|
+
return typeof Deno !== "undefined" && typeof Deno.core !== "undefined";
|
|
17
|
+
}
|
|
18
|
+
function isWebKit() {
|
|
19
|
+
return isBrowser() && !!navigator.vendor && navigator.vendor.indexOf("Apple") !== -1 && !!navigator.userAgent;
|
|
20
|
+
}
|
|
21
|
+
function isSafari() {
|
|
22
|
+
return isBrowser() && !!navigator.vendor && navigator.vendor.indexOf("Apple") !== -1 && !!navigator.userAgent && navigator.userAgent.indexOf("CriOS") == -1 && navigator.userAgent.indexOf("FxiOS") == -1;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
exports.isBrowser = isBrowser;
|
|
26
|
+
exports.isDeno = isDeno;
|
|
27
|
+
exports.isJsDom = isJsDom;
|
|
28
|
+
exports.isNode = isNode;
|
|
29
|
+
exports.isSafari = isSafari;
|
|
30
|
+
exports.isWebKit = isWebKit;
|
|
31
|
+
exports.isWebWorker = isWebWorker;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* returns `true` if the current environment is Node
|
|
3
|
+
*/
|
|
4
|
+
declare function isNode(): boolean;
|
|
5
|
+
/**
|
|
6
|
+
* returns `true` if the current environment is a browser
|
|
7
|
+
*/
|
|
8
|
+
declare function isBrowser(): boolean;
|
|
9
|
+
/**
|
|
10
|
+
* returns `true` if the current environment is a Web Worker
|
|
11
|
+
*/
|
|
12
|
+
declare function isWebWorker(): boolean;
|
|
13
|
+
/**
|
|
14
|
+
* returns `true` if the current environment is JS DOM
|
|
15
|
+
*/
|
|
16
|
+
declare function isJsDom(): boolean;
|
|
17
|
+
/**
|
|
18
|
+
* returns `true` if the current environment is Deno
|
|
19
|
+
*/
|
|
20
|
+
declare function isDeno(): boolean;
|
|
21
|
+
/**
|
|
22
|
+
* returns `true` if the current browser is based on WebKit
|
|
23
|
+
*
|
|
24
|
+
* This includes:
|
|
25
|
+
* - Safari on macOS
|
|
26
|
+
* - Safari on iOS & iPadOS
|
|
27
|
+
* - Google Chrome on iOS & iPadOS
|
|
28
|
+
* - Firefox on iOS & iPadOS
|
|
29
|
+
* - ... on iOS & iPadOS
|
|
30
|
+
*
|
|
31
|
+
* All mobile browsers on iOS & iPadOS use WebKit
|
|
32
|
+
*/
|
|
33
|
+
declare function isWebKit(): boolean;
|
|
34
|
+
/**
|
|
35
|
+
* returns `true` if the current browser is Safari
|
|
36
|
+
*
|
|
37
|
+
* This includes:
|
|
38
|
+
* - Safari on macOS
|
|
39
|
+
* - Safari on iOS & iPadOS
|
|
40
|
+
*
|
|
41
|
+
* It does not include other browser on iOS & iPadOS
|
|
42
|
+
*/
|
|
43
|
+
declare function isSafari(): boolean;
|
|
44
|
+
|
|
45
|
+
export { isBrowser, isDeno, isJsDom, isNode, isSafari, isWebKit, isWebWorker };
|
|
@@ -1,43 +1,45 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* returns `true` if the current environment is Node
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* returns `true` if the current environment is a browser
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* returns `true` if the current environment is a Web Worker
|
|
11
|
-
*/
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* returns `true` if the current environment is JS DOM
|
|
15
|
-
*/
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* returns `true` if the current environment is Deno
|
|
19
|
-
*/
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* returns `true` if the current browser is based on WebKit
|
|
23
|
-
*
|
|
24
|
-
* This includes:
|
|
25
|
-
* - Safari on macOS
|
|
26
|
-
* - Safari on iOS & iPadOS
|
|
27
|
-
* - Google Chrome on iOS & iPadOS
|
|
28
|
-
* - Firefox on iOS & iPadOS
|
|
29
|
-
* - ... on iOS & iPadOS
|
|
30
|
-
*
|
|
31
|
-
* All mobile browsers on iOS & iPadOS use WebKit
|
|
32
|
-
*/
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* returns `true` if the current browser is Safari
|
|
36
|
-
*
|
|
37
|
-
* This includes:
|
|
38
|
-
* - Safari on macOS
|
|
39
|
-
* - Safari on iOS & iPadOS
|
|
40
|
-
*
|
|
41
|
-
* It does not include other browser on iOS & iPadOS
|
|
42
|
-
*/
|
|
43
|
-
|
|
1
|
+
/**
|
|
2
|
+
* returns `true` if the current environment is Node
|
|
3
|
+
*/
|
|
4
|
+
declare function isNode(): boolean;
|
|
5
|
+
/**
|
|
6
|
+
* returns `true` if the current environment is a browser
|
|
7
|
+
*/
|
|
8
|
+
declare function isBrowser(): boolean;
|
|
9
|
+
/**
|
|
10
|
+
* returns `true` if the current environment is a Web Worker
|
|
11
|
+
*/
|
|
12
|
+
declare function isWebWorker(): boolean;
|
|
13
|
+
/**
|
|
14
|
+
* returns `true` if the current environment is JS DOM
|
|
15
|
+
*/
|
|
16
|
+
declare function isJsDom(): boolean;
|
|
17
|
+
/**
|
|
18
|
+
* returns `true` if the current environment is Deno
|
|
19
|
+
*/
|
|
20
|
+
declare function isDeno(): boolean;
|
|
21
|
+
/**
|
|
22
|
+
* returns `true` if the current browser is based on WebKit
|
|
23
|
+
*
|
|
24
|
+
* This includes:
|
|
25
|
+
* - Safari on macOS
|
|
26
|
+
* - Safari on iOS & iPadOS
|
|
27
|
+
* - Google Chrome on iOS & iPadOS
|
|
28
|
+
* - Firefox on iOS & iPadOS
|
|
29
|
+
* - ... on iOS & iPadOS
|
|
30
|
+
*
|
|
31
|
+
* All mobile browsers on iOS & iPadOS use WebKit
|
|
32
|
+
*/
|
|
33
|
+
declare function isWebKit(): boolean;
|
|
34
|
+
/**
|
|
35
|
+
* returns `true` if the current browser is Safari
|
|
36
|
+
*
|
|
37
|
+
* This includes:
|
|
38
|
+
* - Safari on macOS
|
|
39
|
+
* - Safari on iOS & iPadOS
|
|
40
|
+
*
|
|
41
|
+
* It does not include other browser on iOS & iPadOS
|
|
42
|
+
*/
|
|
43
|
+
declare function isSafari(): boolean;
|
|
44
|
+
|
|
45
|
+
export { isBrowser, isDeno, isJsDom, isNode, isSafari, isWebKit, isWebWorker };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
function isNode() {
|
|
2
|
+
return typeof process !== "undefined" && process.versions != null && process.versions.node != null;
|
|
3
|
+
}
|
|
4
|
+
function isBrowser() {
|
|
5
|
+
return typeof window !== "undefined" && typeof window.document !== "undefined";
|
|
6
|
+
}
|
|
7
|
+
function isWebWorker() {
|
|
8
|
+
return typeof self === "object" && self.constructor && self.constructor.name === "DedicatedWorkerGlobalScope";
|
|
9
|
+
}
|
|
10
|
+
function isJsDom() {
|
|
11
|
+
return typeof window !== "undefined" && window.name === "nodejs" || typeof navigator !== "undefined" && (navigator.userAgent.includes("Node.js") || navigator.userAgent.includes("jsdom"));
|
|
12
|
+
}
|
|
13
|
+
function isDeno() {
|
|
14
|
+
return typeof Deno !== "undefined" && typeof Deno.core !== "undefined";
|
|
15
|
+
}
|
|
16
|
+
function isWebKit() {
|
|
17
|
+
return isBrowser() && !!navigator.vendor && navigator.vendor.indexOf("Apple") !== -1 && !!navigator.userAgent;
|
|
18
|
+
}
|
|
19
|
+
function isSafari() {
|
|
20
|
+
return isBrowser() && !!navigator.vendor && navigator.vendor.indexOf("Apple") !== -1 && !!navigator.userAgent && navigator.userAgent.indexOf("CriOS") == -1 && navigator.userAgent.indexOf("FxiOS") == -1;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export { isBrowser, isDeno, isJsDom, isNode, isSafari, isWebKit, isWebWorker };
|
package/package.json
CHANGED
|
@@ -1,17 +1,22 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "is-where",
|
|
3
|
-
"
|
|
4
|
-
"type": "module",
|
|
5
|
-
"version": "1.0.1",
|
|
3
|
+
"version": "1.0.2",
|
|
6
4
|
"description": "JS environment check functions like `isWebkit() isSafari() isBrowser() isNode()` etc. A simple & small integration.",
|
|
7
|
-
"
|
|
8
|
-
"
|
|
9
|
-
"types": "./dist/
|
|
5
|
+
"type": "module",
|
|
6
|
+
"sideEffects": false,
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"module": "./dist/index.js",
|
|
9
|
+
"main": "./dist/index.js",
|
|
10
10
|
"exports": {
|
|
11
11
|
".": {
|
|
12
|
-
"
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
"require": {
|
|
13
|
+
"types": "./dist/cjs/index.d.cts",
|
|
14
|
+
"default": "./dist/cjs/index.cjs"
|
|
15
|
+
},
|
|
16
|
+
"import": {
|
|
17
|
+
"types": "./dist/index.d.ts",
|
|
18
|
+
"default": "./dist/index.js"
|
|
19
|
+
}
|
|
15
20
|
}
|
|
16
21
|
},
|
|
17
22
|
"files": [
|
|
@@ -23,7 +28,7 @@
|
|
|
23
28
|
"scripts": {
|
|
24
29
|
"test": "vitest run",
|
|
25
30
|
"lint": "tsc --noEmit && eslint ./src --ext .ts",
|
|
26
|
-
"build": "rollup
|
|
31
|
+
"build": "rollup -c ./rollup.config.js",
|
|
27
32
|
"release": "npm run lint && del dist && npm run build && np"
|
|
28
33
|
},
|
|
29
34
|
"repository": {
|
|
@@ -65,14 +70,15 @@
|
|
|
65
70
|
"devDependencies": {
|
|
66
71
|
"@typescript-eslint/eslint-plugin": "^5.59.2",
|
|
67
72
|
"@typescript-eslint/parser": "^5.59.2",
|
|
68
|
-
"del-cli": "^
|
|
73
|
+
"del-cli": "^5.0.0",
|
|
69
74
|
"eslint": "^8.40.0",
|
|
70
75
|
"eslint-config-prettier": "^8.8.0",
|
|
71
76
|
"eslint-plugin-tree-shaking": "^1.10.0",
|
|
72
77
|
"np": "^7.7.0",
|
|
73
78
|
"prettier": "^2.8.8",
|
|
74
|
-
"rollup": "^3.
|
|
75
|
-
"rollup-plugin-
|
|
79
|
+
"rollup": "^3.23.0",
|
|
80
|
+
"rollup-plugin-dts": "^5.3.0",
|
|
81
|
+
"rollup-plugin-esbuild": "^5.0.0",
|
|
76
82
|
"typescript": "^4.9.5",
|
|
77
83
|
"vitest": "^0.31.0"
|
|
78
84
|
},
|
package/dist/index.cjs
DELETED
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* returns `true` if the current environment is Node
|
|
5
|
-
*/
|
|
6
|
-
function isNode() {
|
|
7
|
-
return typeof process !== 'undefined' && process.versions != null && process.versions.node != null;
|
|
8
|
-
}
|
|
9
|
-
/**
|
|
10
|
-
* returns `true` if the current environment is a browser
|
|
11
|
-
*/
|
|
12
|
-
function isBrowser() {
|
|
13
|
-
return typeof window !== 'undefined' && typeof window.document !== 'undefined';
|
|
14
|
-
}
|
|
15
|
-
/**
|
|
16
|
-
* returns `true` if the current environment is a Web Worker
|
|
17
|
-
*/
|
|
18
|
-
function isWebWorker() {
|
|
19
|
-
return (typeof self === 'object' &&
|
|
20
|
-
self.constructor &&
|
|
21
|
-
self.constructor.name === 'DedicatedWorkerGlobalScope');
|
|
22
|
-
}
|
|
23
|
-
/**
|
|
24
|
-
* returns `true` if the current environment is JS DOM
|
|
25
|
-
*/
|
|
26
|
-
function isJsDom() {
|
|
27
|
-
return ((typeof window !== 'undefined' && window.name === 'nodejs') ||
|
|
28
|
-
(typeof navigator !== 'undefined' &&
|
|
29
|
-
(navigator.userAgent.includes('Node.js') || navigator.userAgent.includes('jsdom'))));
|
|
30
|
-
}
|
|
31
|
-
/**
|
|
32
|
-
* returns `true` if the current environment is Deno
|
|
33
|
-
*/
|
|
34
|
-
function isDeno() {
|
|
35
|
-
// @ts-ignore
|
|
36
|
-
return typeof Deno !== 'undefined' && typeof Deno.core !== 'undefined';
|
|
37
|
-
}
|
|
38
|
-
/**
|
|
39
|
-
* returns `true` if the current browser is based on WebKit
|
|
40
|
-
*
|
|
41
|
-
* This includes:
|
|
42
|
-
* - Safari on macOS
|
|
43
|
-
* - Safari on iOS & iPadOS
|
|
44
|
-
* - Google Chrome on iOS & iPadOS
|
|
45
|
-
* - Firefox on iOS & iPadOS
|
|
46
|
-
* - ... on iOS & iPadOS
|
|
47
|
-
*
|
|
48
|
-
* All mobile browsers on iOS & iPadOS use WebKit
|
|
49
|
-
*/
|
|
50
|
-
function isWebKit() {
|
|
51
|
-
return (isBrowser() &&
|
|
52
|
-
!!navigator.vendor &&
|
|
53
|
-
navigator.vendor.indexOf('Apple') !== -1 &&
|
|
54
|
-
!!navigator.userAgent);
|
|
55
|
-
}
|
|
56
|
-
/**
|
|
57
|
-
* returns `true` if the current browser is Safari
|
|
58
|
-
*
|
|
59
|
-
* This includes:
|
|
60
|
-
* - Safari on macOS
|
|
61
|
-
* - Safari on iOS & iPadOS
|
|
62
|
-
*
|
|
63
|
-
* It does not include other browser on iOS & iPadOS
|
|
64
|
-
*/
|
|
65
|
-
function isSafari() {
|
|
66
|
-
return (isBrowser() &&
|
|
67
|
-
!!navigator.vendor &&
|
|
68
|
-
navigator.vendor.indexOf('Apple') !== -1 &&
|
|
69
|
-
!!navigator.userAgent &&
|
|
70
|
-
navigator.userAgent.indexOf('CriOS') == -1 &&
|
|
71
|
-
navigator.userAgent.indexOf('FxiOS') == -1);
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
exports.isBrowser = isBrowser;
|
|
75
|
-
exports.isDeno = isDeno;
|
|
76
|
-
exports.isJsDom = isJsDom;
|
|
77
|
-
exports.isNode = isNode;
|
|
78
|
-
exports.isSafari = isSafari;
|
|
79
|
-
exports.isWebKit = isWebKit;
|
|
80
|
-
exports.isWebWorker = isWebWorker;
|
package/dist/index.es.js
DELETED
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* returns `true` if the current environment is Node
|
|
3
|
-
*/
|
|
4
|
-
function isNode() {
|
|
5
|
-
return typeof process !== 'undefined' && process.versions != null && process.versions.node != null;
|
|
6
|
-
}
|
|
7
|
-
/**
|
|
8
|
-
* returns `true` if the current environment is a browser
|
|
9
|
-
*/
|
|
10
|
-
function isBrowser() {
|
|
11
|
-
return typeof window !== 'undefined' && typeof window.document !== 'undefined';
|
|
12
|
-
}
|
|
13
|
-
/**
|
|
14
|
-
* returns `true` if the current environment is a Web Worker
|
|
15
|
-
*/
|
|
16
|
-
function isWebWorker() {
|
|
17
|
-
return (typeof self === 'object' &&
|
|
18
|
-
self.constructor &&
|
|
19
|
-
self.constructor.name === 'DedicatedWorkerGlobalScope');
|
|
20
|
-
}
|
|
21
|
-
/**
|
|
22
|
-
* returns `true` if the current environment is JS DOM
|
|
23
|
-
*/
|
|
24
|
-
function isJsDom() {
|
|
25
|
-
return ((typeof window !== 'undefined' && window.name === 'nodejs') ||
|
|
26
|
-
(typeof navigator !== 'undefined' &&
|
|
27
|
-
(navigator.userAgent.includes('Node.js') || navigator.userAgent.includes('jsdom'))));
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
* returns `true` if the current environment is Deno
|
|
31
|
-
*/
|
|
32
|
-
function isDeno() {
|
|
33
|
-
// @ts-ignore
|
|
34
|
-
return typeof Deno !== 'undefined' && typeof Deno.core !== 'undefined';
|
|
35
|
-
}
|
|
36
|
-
/**
|
|
37
|
-
* returns `true` if the current browser is based on WebKit
|
|
38
|
-
*
|
|
39
|
-
* This includes:
|
|
40
|
-
* - Safari on macOS
|
|
41
|
-
* - Safari on iOS & iPadOS
|
|
42
|
-
* - Google Chrome on iOS & iPadOS
|
|
43
|
-
* - Firefox on iOS & iPadOS
|
|
44
|
-
* - ... on iOS & iPadOS
|
|
45
|
-
*
|
|
46
|
-
* All mobile browsers on iOS & iPadOS use WebKit
|
|
47
|
-
*/
|
|
48
|
-
function isWebKit() {
|
|
49
|
-
return (isBrowser() &&
|
|
50
|
-
!!navigator.vendor &&
|
|
51
|
-
navigator.vendor.indexOf('Apple') !== -1 &&
|
|
52
|
-
!!navigator.userAgent);
|
|
53
|
-
}
|
|
54
|
-
/**
|
|
55
|
-
* returns `true` if the current browser is Safari
|
|
56
|
-
*
|
|
57
|
-
* This includes:
|
|
58
|
-
* - Safari on macOS
|
|
59
|
-
* - Safari on iOS & iPadOS
|
|
60
|
-
*
|
|
61
|
-
* It does not include other browser on iOS & iPadOS
|
|
62
|
-
*/
|
|
63
|
-
function isSafari() {
|
|
64
|
-
return (isBrowser() &&
|
|
65
|
-
!!navigator.vendor &&
|
|
66
|
-
navigator.vendor.indexOf('Apple') !== -1 &&
|
|
67
|
-
!!navigator.userAgent &&
|
|
68
|
-
navigator.userAgent.indexOf('CriOS') == -1 &&
|
|
69
|
-
navigator.userAgent.indexOf('FxiOS') == -1);
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
export { isBrowser, isDeno, isJsDom, isNode, isSafari, isWebKit, isWebWorker };
|