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

own-or-env

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

own-or-env - npm Package Compare versions

Comparing version 1.0.1 to 1.0.2

.nyc_output/0fbd60f7250d02710218b23ccff890a9.json

3

own-or-env.js

@@ -0,4 +1,5 @@

var proc = typeof process === 'object' && process ? process : { env: {} }
var ownOr = require('own-or')
module.exports = function ownOrEnv (object, field, env, bool) {
var res = ownOr(object, field, process.env[env])
var res = ownOr(object, field, proc.env[env])
if (bool)

@@ -5,0 +6,0 @@ res = !!+(res)

{
"name": "own-or-env",
"version": "1.0.1",
"version": "1.0.2",
"description": "Use an objects own property, or an environment variable. Optionally treat as a boolean if the env should be set to 1 or 0.",

@@ -5,0 +5,0 @@ "main": "own-or-env.js",

@@ -16,2 +16,23 @@ var assert = require('assert')

var proc = global.process
global.process = null
assert.equal(ownOrEnv(conf, 't', 'OWN_OR_BOOL_FALSE', true), true)
assert.equal(ownOrEnv(conf, 'x', 'OWN_OR_BOOL_FALSE', true), false)
assert.equal(ownOrEnv(conf, 'f', 'OWN_OR_BOOL_TRUE', true), false)
assert.equal(ownOrEnv(conf, 'x', 'OWN_OR_BOOL_TRUE', true), true)
assert.equal(ownOrEnv(conf, 's', 'OWN_OR_STRING'), 'bar')
assert.equal(ownOrEnv(conf, 'x', 'OWN_OR_STRING'), 'foo')
global.process = proc
delete require.cache[require.resolve('./')]
global.process = null
ownOrEnv = require('./')
assert.equal(ownOrEnv(conf, 't', 'OWN_OR_BOOL_FALSE', true), true)
assert.equal(ownOrEnv(conf, 'x', 'OWN_OR_BOOL_FALSE', true), false)
assert.equal(ownOrEnv(conf, 'f', 'OWN_OR_BOOL_TRUE', true), false)
assert.equal(ownOrEnv(conf, 'x', 'OWN_OR_BOOL_TRUE', true), false)
assert.equal(ownOrEnv(conf, 's', 'OWN_OR_STRING'), 'bar')
assert.equal(ownOrEnv(conf, 'x', 'OWN_OR_STRING'), undefined)
global.process = proc
console.log('TAP version 13\nok\n1..1')
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