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

base-env

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

base-env

Base plugin, creates a normalized environment object from a function, filepath or instance of base.

  • 0.1.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
20K
decreased by-4.21%
Maintainers
1
Weekly downloads
 
Created
Source

base-env NPM version Build Status

Base plugin, creates a normalized environment object from a function, filepath or instance of base.

Install

Install with npm:

$ npm install base-env --save

Usage

var Base = require('base');
var env = require('base-env');

Prototype plugin

Register as a prototype plugin if you want the .createEnv method to be added to all instances of base:

Base.use(env());

Instance plugin

Register as an instance plugin if you only want the .createEnv method to be added to a specific instance:

var base = new Base();
base.use(env());

API

Create an env object with the given name, function, filepath or app instance, and options.

Params

  • name {String}
  • val {Object|Function|String}
  • options {Object}
  • returns {Object}

.env.isMatch

Returns true if the given str matches env.key, env.name or env.alias. When env is created from a filepath, the following properties are also checked:

  • env.dirname
  • env.path
  • env.basename

Params

  • str {String}: The string to match
  • returns {Boolean}: Retuns true if a match is made.

Example

var env = app.createEnv('foo', function() {});
env.isMatch('bar');
//=> false

.env.invoke

When env is created from an existing application instance, the instance is cached on env.app and env.invoke is a noop function that simply returns env.app.

  • returns {Object}: Returns the invoked instance.

Example

var foo = new Base();
var bar = new Base();

var env = foo.createEnv('bar', function() {});
env.invoke(bar);
//=> `env.fn` is invoked with `bar`

Contributing

Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.

Building docs

Generate readme and API documentation with verb:

$ npm install verb && npm run docs

Or, if verb is installed globally:

$ verb

Running tests

Install dev dependencies:

$ npm install -d && npm test

Author

Jon Schlinkert

License

Copyright © 2016 Jon Schlinkert Released under the MIT license.


This file was generated by verb, v0.9.0, on March 13, 2016.

FAQs

Package last updated on 13 Mar 2016

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