Skip to content

Latest commit

 

History

History
127 lines (80 loc) · 3.03 KB

README.md

File metadata and controls

127 lines (80 loc) · 3.03 KB

noun NPM version

.use() plugins to manipulate objects. Easy to use and extend. Load locally defined plugins, or define a namespace to automatically load plugins from load modules.

Noun makes it easy to extend your application with basic plugin functionality.

Usage

var Noun = require('noun');

npm plugins

By default, plugins named noun-* are automatically loaded from node_modules.

Pass a namespace to use your own naming convention:

// load plugins named `my-app-*`
var noun = new Noun('my-app');

Note that plugins are only loaded if they are listed in dependencies or devDependencies in package.json.

See the examples and tests for a better understanding of how Noun works.

local plugins

For local plugins, simply use a leading dot ./ in the path, just like require() rules:

noun.loadPlugins('./plugins/*.js');

Install

Install with npm

npm i noun --save

Run tests

npm test

API

Create an instance of Noun using the given namespace.

  • options {Object}
var Noun = require('noun');
var noun = new Noun('foo');

Define a Noun plugin.

  • fn {Function}: The function to call.
  • returns {Object}: Returns Noun for chaining.
noun
  .plugin(foo())
  .plugin(bar())
  .plugin(baz())

Called in the constructor to load plugins from node_modules using the given namespace. For example, the namespace foo will load plugins from the foo-* glob pattern.

  • pattern {String}: Optionally pass a glob pattern when calling the method directly.
  • returns {Object}: Returns an object of plugins loaded from node_modules.

You may also call the .loadPlugins() method directly.

noun.loadPlugins('baz-*');

Run an object of plugins. By default, the .run() method is called in the constructor, but it may also be used directly.

  • fns {Object}: Object of plugins.

When used directly, each plugin is a key-value pair, where the key is the plugin name, and the value is the function to be called.

Currently, the plugin name is useless, so this could have been setup to take an array. However, there are plans to add additional features to take advantage of this configuration.

Example:

noun.run({'myPlugin': [function]});

Contributing

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

Author

Jon Schlinkert

License

Copyright (c) 2014 Jon Schlinkert, contributors.
Released under the MIT license


This file was generated by verb-cli on October 22, 2014.