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

base-env

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.


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

base-env NPM version NPM downloads 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');
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`

You might also be interested in these projects:

  • base-generators: Adds project-generator support to your base application. | homepage
  • base-runner: Orchestrate multiple instances of base-methods at once. | homepage
  • base: base is the foundation for creating modular, unit testable and highly pluggable node.js applications, starting… more | homepage

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 April 21, 2016.

FAQs

Package last updated on 12 Jul 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