JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 36886
  • Score
    100M100P100Q136263F
  • License MIT

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

Package Exports

  • base-env

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (base-env) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

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');

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`

You might also be interested in these projects:

  • base: base is the foundation for creating modular, unit testable and highly pluggable node.js applications, starting… more | homepage
  • base-generators: Adds project-generator support to your base application. | homepage
  • base-runner: Orchestrate multiple instances of base-methods at once. | 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, v, on April 05, 2016.