Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/hugw/isenv
Environment Utility Functions (DEPRECATED)
https://github.com/hugw/isenv
environment node nodejs
Last synced: about 1 month ago
JSON representation
Environment Utility Functions (DEPRECATED)
- Host: GitHub
- URL: https://github.com/hugw/isenv
- Owner: hugw
- Created: 2017-10-20T22:22:06.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2018-07-08T23:03:04.000Z (over 6 years ago)
- Last Synced: 2024-04-13T23:06:09.703Z (7 months ago)
- Topics: environment, node, nodejs
- Language: JavaScript
- Homepage:
- Size: 5.86 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Environment Utility Functions (DEPRECATED)
This package has been deprecated in favor of [Node Toolkit](https://github.com/hugw/ndtk).
```
$ npm install isenv
```## API
### CURRENT_ENV
Return current environment.
Usage:
```javascript
import { CURRENT_ENV } from 'isenv'
console.log(CURRENT_ENV) # => development
```### IS_DEV / IS_TEST / IS_STAG / IS_PROD
Return a boolean based on current environment variable tested.
Usage:
```javascript
import { IS_DEV, IS_TEST, IS_STAG, IS_PROD } from 'isenv'console.log(process.env.NODE_ENV) # => production
console.log(IS_DEV) # => false
console.log(IS_STAG) # => false
console.log(IS_TEST) # => false
console.log(IS_PROD) # => true
```### isDev / isStag / isTest / isProd
Test current the environment and return variables passed as arguments
in case of position and negative results. Second param is optional and defaults to "false".Usage:
```javascript
import { isDev, isStag, isTest, isProd } from 'isenv'const a = 'a'
const b = 'b'console.log(process.env.NODE_ENV) # => production
console.log(isDev(a, b)) # => b
console.log(isDev(a)) # => falseconsole.log(isStag(a, b)) # => b
console.log(isStag(a)) # => falseconsole.log(isTest(a, b)) # => b
console.log(isTest(a)) # => falseconsole.log(isProd(a, b)) # => a
console.log(isProd(a)) # => a
```### isntDev / isntStag / isntTest / isntProd
Test current the environment using exclusive contexts and return variables passed as arguments
in case of position and negative results. Second param is optional and defaults to "false".Usage:
```javascript
import { isntDev, isntStag, isntTest, isntProd } from 'isenv'const a = 'a'
const b = 'b'console.log(process.env.NODE_ENV) # => production
console.log(isntDev(a, b)) # => a
console.log(isntDev(a)) # => aconsole.log(isntStag(a, b)) # => a
console.log(isntStag(a)) # => aconsole.log(isntTest(a, b)) # => a
console.log(isntTest(a)) # => aconsole.log(isntProd(a, b)) # => b
console.log(isntProd(a)) # => false
```***
The MIT License (MIT)
Copyright (c) 2017 Hugo W. - [email protected]
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.