Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

nenv

Package Overview
Dependencies
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

nenv - npm Package Compare versions

Comparing version 0.2.1 to 0.2.2

53

lib/index.js
var defaults = ['test', 'devel', 'stage', 'production'];
/**
* Default function for extracting the current environment.
* Default function for getting the current environment.
*/
function extract() {
function dget() {
return process.env.NODE_ENV;

@@ -11,26 +11,36 @@ }

/**
* Default function for setting the current environment.
*/
function dset(val) {
var value = this.value;
process.env.NODE_ENV = val;
return function revert() {
process.env.NODE_ENV = value;
}
}
/**
* Get an environment object.
*
* @param available Array or map of available environments.
* @param opts Options used to control the behaviour.
* @param get A custom get function.
*
* @return An environment object.
*/
function nenv(available) {
var init
, k
, arr
, l
function nenv(available, get, set) {
if(typeof available === 'function') {
get = available;
available = null;
}
var k, arr, l
, args = [].slice.call(arguments);
// last arg is extract function
if(args.length
&& typeof args[args.length - 1] === 'function') {
init = args[args.length - 1];
// last arg is get function
if(args.length && typeof args[0] !== 'function') {
args.shift();
}
// use default function
if(typeof init !== 'function') {
init = extract;
}
// use default function(s)
get = get || dget;
set = set || dset;

@@ -107,3 +117,3 @@ // available list as map is preferred

// initial value
query.value = init();
query.value = get();

@@ -116,5 +126,5 @@ // object map

// reference function used to get
// the current value
query.get = extract;
// get and set functions
query.get = get.bind(query);
query.set = set.bind(query);

@@ -125,4 +135,5 @@ return query;

nenv.defaults = defaults;
nenv.extract = extract;
nenv.dget = dget;
nenv.dset = dset;
module.exports = nenv;
{
"name": "nenv",
"description": "Utility for managing node development environments",
"version": "0.2.1",
"version": "0.2.2",
"author": "muji <noop@xpm.io>",

@@ -6,0 +6,0 @@ "main": "lib/index.js",

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc