is-where 1.0.1 → 2.0.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/{types/index.d.ts → index.d.ts} +48 -43
- package/dist/{index.cjs → index.js} +76 -79
- package/package.json +16 -61
- package/dist/index.es.js +0 -72
|
@@ -1,43 +1,48 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* returns `true` if the current environment
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
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
|
-
|
|
1
|
+
/**
|
|
2
|
+
* returns `true` if the current environment supports touch events
|
|
3
|
+
* @see https://stackoverflow.com/a/63666289/2697506
|
|
4
|
+
*/
|
|
5
|
+
export declare function isTouchSupported(): boolean;
|
|
6
|
+
/**
|
|
7
|
+
* returns `true` if the current environment is Node
|
|
8
|
+
*/
|
|
9
|
+
export declare function isNode(): boolean;
|
|
10
|
+
/**
|
|
11
|
+
* returns `true` if the current environment is a browser
|
|
12
|
+
*/
|
|
13
|
+
export declare function isBrowser(): boolean;
|
|
14
|
+
/**
|
|
15
|
+
* returns `true` if the current environment is a Web Worker
|
|
16
|
+
*/
|
|
17
|
+
export declare function isWebWorker(): boolean;
|
|
18
|
+
/**
|
|
19
|
+
* returns `true` if the current environment is JS DOM
|
|
20
|
+
*/
|
|
21
|
+
export declare function isJsDom(): boolean;
|
|
22
|
+
/**
|
|
23
|
+
* returns `true` if the current environment is Deno
|
|
24
|
+
*/
|
|
25
|
+
export declare function isDeno(): boolean;
|
|
26
|
+
/**
|
|
27
|
+
* returns `true` if the current browser is based on WebKit
|
|
28
|
+
*
|
|
29
|
+
* This includes:
|
|
30
|
+
* - Safari on macOS
|
|
31
|
+
* - Safari on iOS & iPadOS
|
|
32
|
+
* - Google Chrome on iOS & iPadOS
|
|
33
|
+
* - Firefox on iOS & iPadOS
|
|
34
|
+
* - ... on iOS & iPadOS
|
|
35
|
+
*
|
|
36
|
+
* All mobile browsers on iOS & iPadOS use WebKit
|
|
37
|
+
*/
|
|
38
|
+
export declare function isWebKit(): boolean;
|
|
39
|
+
/**
|
|
40
|
+
* returns `true` if the current browser is Safari
|
|
41
|
+
*
|
|
42
|
+
* This includes:
|
|
43
|
+
* - Safari on macOS
|
|
44
|
+
* - Safari on iOS & iPadOS
|
|
45
|
+
*
|
|
46
|
+
* It does not include other browser on iOS & iPadOS
|
|
47
|
+
*/
|
|
48
|
+
export declare function isSafari(): boolean;
|
|
@@ -1,80 +1,77 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
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
|
-
|
|
61
|
-
|
|
62
|
-
*
|
|
63
|
-
*
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
1
|
+
/**
|
|
2
|
+
* returns `true` if the current environment supports touch events
|
|
3
|
+
* @see https://stackoverflow.com/a/63666289/2697506
|
|
4
|
+
*/
|
|
5
|
+
export function isTouchSupported() {
|
|
6
|
+
return isBrowser() && matchMedia('(hover: none)').matches;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* returns `true` if the current environment is Node
|
|
10
|
+
*/
|
|
11
|
+
export function isNode() {
|
|
12
|
+
return typeof process !== 'undefined' && process.versions != null && process.versions.node != null;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* returns `true` if the current environment is a browser
|
|
16
|
+
*/
|
|
17
|
+
export function isBrowser() {
|
|
18
|
+
return typeof window !== 'undefined' && typeof window.document !== 'undefined';
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* returns `true` if the current environment is a Web Worker
|
|
22
|
+
*/
|
|
23
|
+
export function isWebWorker() {
|
|
24
|
+
return (typeof self === 'object' &&
|
|
25
|
+
self.constructor &&
|
|
26
|
+
self.constructor.name === 'DedicatedWorkerGlobalScope');
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* returns `true` if the current environment is JS DOM
|
|
30
|
+
*/
|
|
31
|
+
export function isJsDom() {
|
|
32
|
+
return ((typeof window !== 'undefined' && window.name === 'nodejs') ||
|
|
33
|
+
(typeof navigator !== 'undefined' &&
|
|
34
|
+
(navigator.userAgent.includes('Node.js') || navigator.userAgent.includes('jsdom'))));
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* returns `true` if the current environment is Deno
|
|
38
|
+
*/
|
|
39
|
+
export function isDeno() {
|
|
40
|
+
// @ts-expect-error Deno types not found
|
|
41
|
+
return typeof Deno !== 'undefined' && typeof Deno.core !== 'undefined';
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* returns `true` if the current browser is based on WebKit
|
|
45
|
+
*
|
|
46
|
+
* This includes:
|
|
47
|
+
* - Safari on macOS
|
|
48
|
+
* - Safari on iOS & iPadOS
|
|
49
|
+
* - Google Chrome on iOS & iPadOS
|
|
50
|
+
* - Firefox on iOS & iPadOS
|
|
51
|
+
* - ... on iOS & iPadOS
|
|
52
|
+
*
|
|
53
|
+
* All mobile browsers on iOS & iPadOS use WebKit
|
|
54
|
+
*/
|
|
55
|
+
export function isWebKit() {
|
|
56
|
+
return (isBrowser() &&
|
|
57
|
+
!!navigator.vendor &&
|
|
58
|
+
navigator.vendor.indexOf('Apple') !== -1 &&
|
|
59
|
+
!!navigator.userAgent);
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* returns `true` if the current browser is Safari
|
|
63
|
+
*
|
|
64
|
+
* This includes:
|
|
65
|
+
* - Safari on macOS
|
|
66
|
+
* - Safari on iOS & iPadOS
|
|
67
|
+
*
|
|
68
|
+
* It does not include other browser on iOS & iPadOS
|
|
69
|
+
*/
|
|
70
|
+
export function isSafari() {
|
|
71
|
+
return (isBrowser() &&
|
|
72
|
+
!!navigator.vendor &&
|
|
73
|
+
navigator.vendor.indexOf('Apple') !== -1 &&
|
|
74
|
+
!!navigator.userAgent &&
|
|
75
|
+
navigator.userAgent.indexOf('CriOS') == -1 &&
|
|
76
|
+
navigator.userAgent.indexOf('FxiOS') == -1);
|
|
72
77
|
}
|
|
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/package.json
CHANGED
|
@@ -2,28 +2,19 @@
|
|
|
2
2
|
"name": "is-where",
|
|
3
3
|
"sideEffects": false,
|
|
4
4
|
"type": "module",
|
|
5
|
-
"version": "
|
|
5
|
+
"version": "2.0.0",
|
|
6
6
|
"description": "JS environment check functions like `isWebkit() isSafari() isBrowser() isNode()` etc. A simple & small integration.",
|
|
7
|
-
"
|
|
8
|
-
"main": "./dist/index.cjs",
|
|
9
|
-
"types": "./dist/types/index.d.ts",
|
|
10
|
-
"exports": {
|
|
11
|
-
".": {
|
|
12
|
-
"types": "./dist/types/index.d.ts",
|
|
13
|
-
"import": "./dist/index.es.js",
|
|
14
|
-
"require": "./dist/index.cjs"
|
|
15
|
-
}
|
|
16
|
-
},
|
|
7
|
+
"exports": "./index.js",
|
|
17
8
|
"files": [
|
|
18
9
|
"dist"
|
|
19
10
|
],
|
|
20
11
|
"engines": {
|
|
21
|
-
"node": ">=
|
|
12
|
+
"node": ">=18"
|
|
22
13
|
},
|
|
23
14
|
"scripts": {
|
|
24
15
|
"test": "vitest run",
|
|
25
|
-
"lint": "tsc --noEmit && eslint ./src
|
|
26
|
-
"build": "
|
|
16
|
+
"lint": "tsc --noEmit && eslint ./src",
|
|
17
|
+
"build": "del-cli dist && tsc",
|
|
27
18
|
"release": "npm run lint && del dist && npm run build && np"
|
|
28
19
|
},
|
|
29
20
|
"repository": {
|
|
@@ -63,56 +54,20 @@
|
|
|
63
54
|
},
|
|
64
55
|
"homepage": "https://github.com/mesqueeb/is-where#readme",
|
|
65
56
|
"devDependencies": {
|
|
66
|
-
"@
|
|
67
|
-
"@
|
|
68
|
-
"
|
|
69
|
-
"
|
|
70
|
-
"eslint
|
|
71
|
-
"eslint-
|
|
72
|
-
"np": "^
|
|
73
|
-
"prettier": "^2.
|
|
74
|
-
"
|
|
75
|
-
"
|
|
76
|
-
"
|
|
77
|
-
"vitest": "^0.31.0"
|
|
78
|
-
},
|
|
79
|
-
"ava": {
|
|
80
|
-
"extensions": {
|
|
81
|
-
"ts": "module"
|
|
82
|
-
},
|
|
83
|
-
"nodeArguments": [
|
|
84
|
-
"--loader=ts-node/esm"
|
|
85
|
-
]
|
|
57
|
+
"@cycraft/tsconfig": "^0.1.1",
|
|
58
|
+
"@eslint/js": "^9.1.1",
|
|
59
|
+
"@types/node": "^20.12.8",
|
|
60
|
+
"del-cli": "^5.1.0",
|
|
61
|
+
"eslint": "^8.57.0",
|
|
62
|
+
"eslint-config-prettier": "^9.1.0",
|
|
63
|
+
"np": "^10.0.5",
|
|
64
|
+
"prettier": "^3.2.5",
|
|
65
|
+
"typescript": "^5.4.5",
|
|
66
|
+
"typescript-eslint": "^7.8.0",
|
|
67
|
+
"vitest": "^1.5.3"
|
|
86
68
|
},
|
|
87
69
|
"np": {
|
|
88
70
|
"yarn": false,
|
|
89
71
|
"branch": "production"
|
|
90
|
-
},
|
|
91
|
-
"eslintConfig": {
|
|
92
|
-
"ignorePatterns": [
|
|
93
|
-
"node_modules",
|
|
94
|
-
"dist",
|
|
95
|
-
"scripts",
|
|
96
|
-
"test"
|
|
97
|
-
],
|
|
98
|
-
"root": true,
|
|
99
|
-
"parser": "@typescript-eslint/parser",
|
|
100
|
-
"plugins": [
|
|
101
|
-
"@typescript-eslint",
|
|
102
|
-
"tree-shaking"
|
|
103
|
-
],
|
|
104
|
-
"extends": [
|
|
105
|
-
"eslint:recommended",
|
|
106
|
-
"plugin:@typescript-eslint/eslint-recommended",
|
|
107
|
-
"plugin:@typescript-eslint/recommended",
|
|
108
|
-
"prettier"
|
|
109
|
-
],
|
|
110
|
-
"rules": {
|
|
111
|
-
"@typescript-eslint/no-empty-function": "off",
|
|
112
|
-
"@typescript-eslint/no-explicit-any": "off",
|
|
113
|
-
"@typescript-eslint/ban-ts-ignore": "off",
|
|
114
|
-
"tree-shaking/no-side-effects-in-initialization": "error",
|
|
115
|
-
"@typescript-eslint/ban-ts-comment": "off"
|
|
116
|
-
}
|
|
117
72
|
}
|
|
118
73
|
}
|
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 };
|