JSPM

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

base-methods plugin that adds a `config` method for mapping declarative configuration values to other 'base' methods or custom functions.

Package Exports

  • base-config

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-config) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

base-config NPM version

base-methods plugin that adds a config method for mapping declarative configuration values to other 'base' methods or custom functions.

Install

Install with npm:

$ npm i base-config --save

Usage

var config = require('base-config');
var base = require('base-methods');
var app = base();

// register the plugin
app.use(config());

Mapped methods

The following methods are mapped by default, but any of them can be overridden using app.config.map():

  • .cwd
  • .data
  • .define
  • .del
  • .disable
  • .disabled
  • .enable
  • .enabled
  • .get
  • .has
  • .option
  • .set
  • .store
  • .use

Map custom methods

Map properties on a configuration object to methods on app.

Each key on the given object should match the name of a method on app.

// call `config` as a function
app.config({
  set: function(val) {
    app.visit('set', val);
  }
});
// or use the `map` method
app.config.map('set', function(val) {
  app.visit('set', val);
});

Process

Iterate over each property on the given object or array of objects, and call the mapped method that matches property key.

app.config.process({set: {foo: 'bar'}});
//=> calls `app.set('foo', 'bar');

API

create

Create a function for mapping app properties onto the given prop namespace.

Params

  • prop {String}: The namespace to use
  • argv {Object}
  • returns {Object}

Other plugins

  • base-cli: Plugin for base-methods that maps built-in methods to CLI args (also supports methods from a… more | homepage
  • base-data: adds a data method to base-methods. | homepage
  • base-methods: base-methods is the foundation for creating modular, unit testable and highly pluggable node.js applications, starting… more | homepage
  • base-options: Adds a few options methods to base-methods, like option, enable and disable. See the readme… more | homepage
  • base-plugins: Upgrade's plugin support in base-methods to allow plugins to be called any time after init. | homepage
  • base-store: Plugin for getting and persisting config values with your base-methods application. Adds a 'store' object… more | homepage

Tests

Running tests

Install dev dependencies:

$ npm i -d && npm test

Coverage

Statements : 100% (15/15)
Branches   : 100% (2/2)
Functions  : 100% (2/2)
Lines      : 100% (15/15)

Contributing

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

Author

Jon Schlinkert

License

Copyright © 2016 Jon Schlinkert Released under the MIT license.


This file was generated by verb on January 19, 2016.