Socket
Socket
Sign inDemoInstall

environment

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

environment

Provides node's `process.env` object functionality as stand-alone functions instead of a C++ fake object that does weird things. As an added bonus, if running node with Proxies enabled ("node --harmony") it also exports a function that creates an `Environment` object that is similar to `process.env` but behaves like a real object.


Version published
Weekly downloads
4.2M
increased by6.31%
Maintainers
1
Weekly downloads
 
Created
Source

Environment

Provides node's process.env object functionality as stand-alone functions instead of a C++ fake object that does weird things. As an added bonus, if running node with Proxies enabled ("node --harmony") it also exports a function that creates an Environment object that is similar to process.env but behaves like a real object.

Install

	npm install environment

Use

Mostly self-explanatory:

  • environment.get(key)
  • environment.set(key, value)
  • environment.delete(key)
  • environment.enumerate()

Environment object

If Proxy is available, due to running node using the --harmony flag, a constructor is exported as well which allows the creation of Environment objects.

These objects aren't entirely normal JavaScript objects, but they're much closer than node's process.env. Environment.prototype doesn't inherit from Object.prototype but it does have most of the functions from it. toString, valueOf, isPrototypeOf, hasOwnProperty, as well as constructor pointing to Environment.

It's possible to add methods to Environment.prototype and have them work on instances correctly. It's possible to change an instance's __proto__ and point it to something else and also have that work correctly (though Object.getPrototypeOf may not reflect the change).

// normal creation
var env = require('environment').create();
// or modifying the prototype
var Environment = require('environment');
Environment.prototype.paths = function paths(){
	return this.PATH.split(process.platform === 'win32' ? ';' : ':');
}

var env = new Environment;
console.log(env.paths());

Keywords

FAQs

Package last updated on 27 Jun 2012

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

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