This commit is contained in:
chrosey
2017-09-13 07:52:34 +02:00
parent a1f16c37f4
commit 2340b0226b
24621 changed files with 2912161 additions and 149 deletions
+23
View File
@@ -0,0 +1,23 @@
Usage:
```js
var isNode = require('detect-node');
if (isNode) {
console.log("Running under Node.JS");
} else {
alert("Hello from browser (or whatever not-a-node env)");
}
```
The check is performed as:
```js
module.exports = false;
// Only Node.JS has a process variable that is of [[Class]] process
try {
module.exports = Object.prototype.toString.call(global.process) === '[object process]'
} catch(e) {}
```
Thanks to Ingvar Stepanyan for the initial idea. This check is both **the most reliable I could find** and it does not use `process` env directly, which would cause browserify to include it into the build.
+6
View File
@@ -0,0 +1,6 @@
module.exports = false;
// Only Node.JS has a process variable that is of [[Class]] process
try {
module.exports = Object.prototype.toString.call(global.process) === '[object process]'
} catch(e) {}
+82
View File
@@ -0,0 +1,82 @@
{
"_args": [
[
{
"raw": "detect-node@^2.0.3",
"scope": null,
"escapedName": "detect-node",
"name": "detect-node",
"rawSpec": "^2.0.3",
"spec": ">=2.0.3 <3.0.0",
"type": "range"
},
"c:\\xampp\\htdocs\\laravel\\node_modules\\spdy-transport"
]
],
"_from": "detect-node@>=2.0.3 <3.0.0",
"_id": "detect-node@2.0.3",
"_inCache": true,
"_location": "/detect-node",
"_npmUser": {
"name": "iliakan",
"email": "iliakan@gmail.com"
},
"_npmVersion": "1.4.21",
"_phantomChildren": {},
"_requested": {
"raw": "detect-node@^2.0.3",
"scope": null,
"escapedName": "detect-node",
"name": "detect-node",
"rawSpec": "^2.0.3",
"spec": ">=2.0.3 <3.0.0",
"type": "range"
},
"_requiredBy": [
"/spdy-transport"
],
"_resolved": "https://registry.npmjs.org/detect-node/-/detect-node-2.0.3.tgz",
"_shasum": "a2033c09cc8e158d37748fbde7507832bd6ce127",
"_shrinkwrap": null,
"_spec": "detect-node@^2.0.3",
"_where": "c:\\xampp\\htdocs\\laravel\\node_modules\\spdy-transport",
"author": {
"name": "Ilya Kantor"
},
"bugs": {
"url": "https://github.com/iliakan/detect-node/issues"
},
"dependencies": {},
"description": "Detect Node.JS (as opposite to browser environment) (reliable)",
"devDependencies": {},
"directories": {},
"dist": {
"shasum": "a2033c09cc8e158d37748fbde7507832bd6ce127",
"tarball": "https://registry.npmjs.org/detect-node/-/detect-node-2.0.3.tgz"
},
"gitHead": "4837fa0620d2e8db948a718a8b5f89a8073c8ff4",
"homepage": "https://github.com/iliakan/detect-node",
"keywords": [
"detect",
"node"
],
"license": "ISC",
"main": "index.js",
"maintainers": [
{
"name": "iliakan",
"email": "iliakan@gmail.com"
}
],
"name": "detect-node",
"optionalDependencies": {},
"readme": "ERROR: No README data found!",
"repository": {
"type": "git",
"url": "git+https://github.com/iliakan/detect-node.git"
},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"version": "2.0.3"
}