env-dot-prop alternatives and similar modules
Based on the "Miscellaneous" category.
Alternatively, view env-dot-prop alternatives based on common mentions on social networks and blogs.
-
Electron
:electron: Build cross-platform desktop apps with JavaScript, HTML, and CSS -
cheerio
The fast, flexible, and elegant library for parsing and manipulating HTML and XML. -
jsdom
A JavaScript implementation of various web standards, for use with Node.js -
v86
x86 virtualization in your browser, recompiling x86 to wasm on the fly -
ssh2
SSH2 client and server modules written in pure JavaScript for node.js -
hypernova
A service for server-side rendering your JavaScript views -
file-type
Detect the file type of a Buffer/Uint8Array/ArrayBuffer -
webworker-threads
Lightweight Web Worker API implementation with native threads -
node-pre-gyp
Node.js tool for easy binary deployment of C++ addons -
Bottleneck
Job scheduler and rate limiter, supports Clustering -
mem
Memoize functions - an optimization technique used to speed up consecutive function calls by caching the result of calls with identical input -
hasha
Hashing made simple. Get the hash of a buffer/string/stream/file. -
dot-prop
Get, set, or delete a property from a nested object using a dot path -
node-bell
Real-time anomalies detection for periodic time series. -
basic-ftp
FTP client for Node.js, supports FTPS over TLS, passive mode over IPv6, async/await, and Typescript. -
schemapack
Create a schema object to encode/decode your JSON in to a compact byte buffer with no overhead. -
nar
node.js application archive - create self-contained binary like executable applications that are ready to ship and run -
cashify
💸 Lightweight currency conversion library, successor of money.js -
stringify-object
Stringify an object/array like JSON.stringify just without all the double-quotes -
node-video-lib
Node.js Video Library / MP4 & FLV parser / MP4 builder / HLS muxer -
resolve-from
Resolve the path of a module like require.resolve() but from a given path
Appwrite - The Open Source Firebase alternative introduces iOS support
* Code Quality Rankings and insights are calculated and provided by Lumnify.
They vary from L1 to L5 with "L5" being the highest.
Do you think we are missing an alternative of env-dot-prop or a related project?
README
<!-- Version - npm --> <!-- Downloads - npm --> <!-- License - MIT --> <!-- Awesome - Node -->
<!-- Lint --> <!-- Test - macOS --> <!-- Test - Ubuntu --> <!-- Test - Windows -->
<!-- Coverage - Codecov --> <!-- DM - Snyk --> <!-- DM - David -->
<!-- Code Style - XO-Prettier --> <!-- Test Runner - AVA --> <!-- Test Coverage - Istanbul --> <!-- Init - ni --> <!-- Release - np --> ♻️ Get, set, or delete nested properties of process.env using a dot path
Coded with ❤️ by Simone Primarosa.
Background
This package aim to let you access to your environment variables as if they were JavaScript object. See this guide to understand how to use this package to create a 12 Factor compliant configuration system for you app.
Install
$ npm install --save env-dot-prop
Usage
const envDotProp = require('env-dot-prop');
// Let's assume process.env contains the following keys
process.env = {
FOO_BAR: 'unicorn',
'FOO_DOT.DOT': 'pony',
'FOO_UND\\_UND': 'whale'
};
console.log(process.env);
// => { FOO_BAR: 'unicorn', 'FOO_DOT.DOT': 'pony', 'FOO_UND\_UND': 'whale' }
envDotProp.get('');
// => { foo: { bar: 'unicorn', 'dot.dot': 'pony', und_und: 'whale' } }
// getter
envDotProp.get('foo.bar');
// => 'unicorn'
envDotProp.get('foo.notDefined.deep');
// => undefined
envDotProp.get('foo.notDefined.deep', 'default value');
// => 'default value'
envDotProp.get('foo.dot\\.dot');
// => 'pony'
// setter
envDotProp.set('foo.bar', 'b');
envDotProp.get('foo.bar');
// => 'b'
envDotProp.get('');
// => { foo: { bar: 'b', 'dot.dot': 'pony', und_und: 'whale' } }
envDotProp.set('foo.baz.e', 'x');
envDotProp.get('foo.baz.e');
// => 'x'
envDotProp.get('foo.baz');
// => { e: 'x' }
envDotProp.get('');
// => { foo: { bar: 'b', baz: { e: 'x' }, 'dot.dot': 'pony', und_und: 'whale' } }
// has
envDotProp.has('foo.bar');
// => true
// deleter
envDotProp.delete('foo.bar');
envDotProp.get('foo');
// => { baz: { e: 'x' }, 'dot.dot': 'pony', und_und: 'whale' }
envDotProp.delete('foo.baz.e');
envDotProp.get('foo.baz');
// => undefined
envDotProp.set('n1', 42, {stringify: false});
envDotProp.get('n1', {parse: false});
// => 42
envDotProp.get('n1', {parse: true});
// => 42
envDotProp.set('n2', 42, {stringify: true});
envDotProp.get('n2', {parse: false});
// => '42'
envDotProp.get('n2', {parse: true});
// => 42
envDotProp.set('n3', 42);
envDotProp.get('n3');
// => 42
envDotProp.set('n4', '42');
envDotProp.get('n4');
// => '42'
envDotProp.get('');
// => { n1: '42', n1: 42, n3: 42, n4: '42', foo: { 'dot.dot': 'pony', und_und: 'whale' } }
console.log(process.env);
// => { 'FOO_DOT.DOT': 'pony', 'FOO_UND\_UND': 'whale', N1: '42', N2: 42, N3: 42, N4: '42' }
API
get(path, [defaultValue], [opts]) ⇒ any
Gets the values of environment variables at the path specified.
Kind: global function
Returns: any - The values of environment variables associated with the path specified.
Access: public
Param | Type | Default | Description |
---|---|---|---|
path | string | Dot separated path. | |
[defaultValue] | any | Default value to return if there is not any environment variable that matches the path provided. | |
[opts] | Object | Additional options. | |
[opts.parse] | boolean | false | If true the value retrieved is converted to the proper type. |
[opts.caseSensitive] | boolean | false | If true no case conversion will be performed from the dot path provided to the env key search. Eg: 'tesT.kEy' will look for tesT_kEy environment variable instead of TEST_KEY. |
set(path, value, [opts])
Sets an env key at the path specified. If nested keys are present they will be deleted.
Kind: global function
Access: public
Param | Type | Default | Description |
---|---|---|---|
path | string | Dot separated path. | |
value | string | Value to set. | |
[opts] | object | Additional options. | |
[opts.stringify] | boolean | false | If true the value provided is converted to string. |
[opts.caseSensitive] | boolean | false | If true no case conversion is performed from the dot path provided to the env key search. Eg: 'tesT.kEy' will look for tesT_kEy environment variable instead of TEST_KEY. |
del(path, [opts])
Deletes an env key at the path specified. If nested keys are present they will be deleted too.
Kind: global function
Access: public
Param | Type | Default | Description |
---|---|---|---|
path | string | A dot separated path. | |
[opts] | object | Additional options. | |
[opts.caseSensitive] | boolean | false | If true no case conversion is performed from the dot path provided to the env key search. Eg: 'tesT.kEy' will look for tesT_kEy environment variable instead of TEST_KEY. |
has(path, [opts]) ⇒ boolean
Returns whether an env key exists at the path specified.
Kind: global function
Returns: boolean - true if exists at least one environment variables with that
path prefix.
Access: public
Param | Type | Default | Description |
---|---|---|---|
path | string | Dot separated path. | |
[opts] | object | Additional options. | |
[opts.caseSensitive] | boolean | false | If true no case conversion is performed from the dot path provided to the env key search. Eg: 'tesT.kEy' will look for tesT_kEy environment variable instead of TEST_KEY. |
Authors
- Simone Primarosa - Github (@simonepri) • Twitter (@simoneprimarosa)
See also the list of contributors who participated in this project.
License
This project is licensed under the MIT License - see the license file for details.
<!-- Links -->
*Note that all licence references and agreements mentioned in the env-dot-prop README section above
are relevant to that project's source code only.