Added npm dependency
This commit is contained in:
1 parent
888dd9af1e
commit
8dfc6caa7e
21061 files changed
+3885381
No files matched your search
+21
@@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2017 Ilya Kantor
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
### Install
|
||||
|
||||
```shell
|
||||
npm install --save detect-node
|
||||
```
|
||||
|
||||
### 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.
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
module.exports = false;
|
||||
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
// Only Node.JS has a process variable that is of [[Class]] process
|
||||
module.exports = Object.prototype.toString.call(typeof process !== 'undefined' ? process : 0) === '[object process]';
|
||||
+85
@@ -0,0 +1,85 @@
|
||||
{
|
||||
"_args": [
|
||||
[
|
||||
"detect-node@^2.0.4",
|
||||
"/home/ppinto/temp/spark/src/web/ui/node_modules/spdy-transport"
|
||||
]
|
||||
],
|
||||
"_from": "detect-node@>=2.0.4 <3.0.0",
|
||||
"_hasShrinkwrap": false,
|
||||
"_id": "detect-node@2.0.4",
|
||||
"_inCache": true,
|
||||
"_installable": true,
|
||||
"_location": "/detect-node",
|
||||
"_nodeVersion": "10.9.0",
|
||||
"_npmOperationalInternal": {
|
||||
"host": "s3://npm-registry-packages",
|
||||
"tmp": "tmp/detect-node_2.0.4_1535730743130_0.9044559921683464"
|
||||
},
|
||||
"_npmUser": {
|
||||
"email": "iliakan@gmail.com",
|
||||
"name": "iliakan"
|
||||
},
|
||||
"_npmVersion": "6.4.0",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"name": "detect-node",
|
||||
"raw": "detect-node@^2.0.4",
|
||||
"rawSpec": "^2.0.4",
|
||||
"scope": null,
|
||||
"spec": ">=2.0.4 <3.0.0",
|
||||
"type": "range"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/spdy-transport"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/detect-node/-/detect-node-2.0.4.tgz",
|
||||
"_shasum": "014ee8f8f669c5c58023da64b8179c083a28c46c",
|
||||
"_shrinkwrap": null,
|
||||
"_spec": "detect-node@^2.0.4",
|
||||
"_where": "/home/ppinto/temp/spark/src/web/ui/node_modules/spdy-transport",
|
||||
"author": {
|
||||
"name": "Ilya Kantor"
|
||||
},
|
||||
"browser": "browser.js",
|
||||
"bugs": {
|
||||
"url": "https://github.com/iliakan/detect-node/issues"
|
||||
},
|
||||
"dependencies": {},
|
||||
"description": "Detect Node.JS (as opposite to browser environment) (reliable)",
|
||||
"devDependencies": {},
|
||||
"directories": {},
|
||||
"dist": {
|
||||
"fileCount": 5,
|
||||
"integrity": "sha512-ZIzRpLJrOj7jjP2miAtgqIfmzbxa4ZOr5jJc601zklsfEx9oTzmmj2nVpIPRpNlRTIh8lc1kyViIY7BWSGNmKw==",
|
||||
"npm-signature": "-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJbiWQ3CRA9TVsSAnZWagAAMrwQAJUWqhr3R8fUX9E2H04D\nNcoFtX6tYlFDUWz7AegYBpyj8E2c85Osf16LOM/WCAYhusmIw0kkEfd1suU2\nw7tXK+hQeDvQvhh5WGXqT88fI6UY33ryXHK4/J6QX5k1AXMO4jm74EQ8hXCs\nINjy6O+DC2CEni+CgUgxxU1CmIABcRGaB7WIwFOuwlgaHo7QRUnVnpqeZ6ZN\n7RpVE+3ucJjvCW1s5d/6pLYiRoRZIfudBMRD9OYkdvFGzQ71BKo7AhPQa4Bz\n5w8g3i0UQ6sx7RSYrWNeXRlrAD798fwvGtXsUwIkUE9QJzfT+k5jdHS/aFJT\n3cIIq4+jwV9ODJkkGxmILaWRpuBLpHI+syh3/Xmb113bB1QpcLij1BXJS8sN\ncR1xnLlD72CuFYuAeDkxsTk47D+mK0IDVWa9HgDi8D7IqBSwNOZLW1tuddql\nThwQWn6KIzzCzMKlBajt0rqyIUt5J4kLVXVS7wKvJRQhyaCrguFrdE4jbsjy\npCoqBydwvtrBnLlydr0WbNE94xoLPudJPlxjnyWrAd/MmjvI3RfhAAM+oQkE\n6s00+x2fx2cT51wjX/w+STN5CvNLGZerpTM0xgZmztwB2aWUVBybvAxdtW4F\nhaIf21JXHvTl5F8UXqKHD4dv6mB1w9X1ZcDYZ/hxetoj70xhevfvmFGZ3mVs\n6W0B\r\n=HQIg\r\n-----END PGP SIGNATURE-----\r\n",
|
||||
"shasum": "014ee8f8f669c5c58023da64b8179c083a28c46c",
|
||||
"tarball": "https://registry.npmjs.org/detect-node/-/detect-node-2.0.4.tgz",
|
||||
"unpackedSize": 2549
|
||||
},
|
||||
"gitHead": "563e0b838ec1dd9b169d843268cdb220b78ddd91",
|
||||
"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.4"
|
||||
}
|
||||
Reference in new issue
Block a user