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

@humanwhocodes/env

Package Overview
Dependencies
Maintainers
1
Versions
23
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@humanwhocodes/env - npm Package Compare versions

Comparing version 1.0.0 to 1.0.1

2

dist/env.cjs.js

@@ -25,3 +25,3 @@ 'use strict';

if (typeof Deno !== "undefined") {
return Deno.env();
return Deno.env.toObject();
}

@@ -28,0 +28,0 @@

@@ -21,3 +21,3 @@ /**

if (typeof Deno !== "undefined") {
return Deno.env();
return Deno.env.toObject();
}

@@ -24,0 +24,0 @@

@@ -1,1 +0,1 @@

const defaultEnvSource=(()=>"object"==typeof process?process.env:"undefined"==typeof Deno?{}:Deno.env())();function keyNotFound(a){throw new Error(`Required environment variable '${a}' not found.`)}function emptyString(a){throw new Error(`Required environment variable '${a}' is an empty string.`)}class Env{constructor(a=defaultEnvSource){this.source=a}get(a,b=null){return a in this.source?this.source[a]:b}has(a){return a in this.source}first(a,b=null){if(!Array.isArray(a)||2>a.length)throw new TypeError("First argument must be an array of two or more strings.");for(const c of a)if(c in this.source)return this.source[c];return b}require(a){const b=this.get(a);if(null===b)keyNotFound(a);else if(""===b)throw emptyString(a);else return b}get exists(){const a=new Proxy(this.source,{get(a,b){return b in a?a[b]:void keyNotFound(b)}});return Object.defineProperty(this,"exists",{value:a,writable:!1,enumerable:!1,configurable:!1}),a}get required(){const a=new Proxy(this.source,{get(a,b){return b in a?(""===a[b]&&emptyString(b),a[b]):void keyNotFound(b)}});return Object.defineProperty(this,"required",{value:a,writable:!1,enumerable:!1,configurable:!1}),a}}export{Env};
const defaultEnvSource=(()=>"object"==typeof process?process.env:"undefined"==typeof Deno?{}:Deno.env.toObject())();function keyNotFound(a){throw new Error(`Required environment variable '${a}' not found.`)}function emptyString(a){throw new Error(`Required environment variable '${a}' is an empty string.`)}class Env{constructor(a=defaultEnvSource){this.source=a}get(a,b=null){return a in this.source?this.source[a]:b}has(a){return a in this.source}first(a,b=null){if(!Array.isArray(a)||2>a.length)throw new TypeError("First argument must be an array of two or more strings.");for(const c of a)if(c in this.source)return this.source[c];return b}require(a){const b=this.get(a);if(null===b)keyNotFound(a);else if(""===b)throw emptyString(a);else return b}get exists(){const a=new Proxy(this.source,{get(a,b){return b in a?a[b]:void keyNotFound(b)}});return Object.defineProperty(this,"exists",{value:a,writable:!1,enumerable:!1,configurable:!1}),a}get required(){const a=new Proxy(this.source,{get(a,b){return b in a?(""===a[b]&&emptyString(b),a[b]):void keyNotFound(b)}});return Object.defineProperty(this,"required",{value:a,writable:!1,enumerable:!1,configurable:!1}),a}}export{Env};
{
"name": "@humanwhocodes/env",
"version": "1.0.0",
"version": "1.0.1",
"description": "A utility to verify that environment variables exist.",

@@ -5,0 +5,0 @@ "main": "dist/env.cjs.js",

@@ -45,3 +45,3 @@ # Env utility

By default, an `Env` instance will read from `Deno.env()`.
By default, an `Env` instance will read from `Deno.env`.

@@ -48,0 +48,0 @@ ### Browser

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