JSPM

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

Run a string through a plugin stack.

Package Exports

  • plugins

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

Readme

plugins NPM version

Run a string through a plugin stack.

Install

Install with npm:

npm i plugins --save-dev

API

Initialize Plugins

var plugins = new Plugins();

.use

Add a plugin fn to the plugins.

plugins
  .use(foo({}))
  .use(bar({}))
  .use(baz({}))

Params:

  • fn {Function}: Plugin function to add to the plugins stack.
  • return{Plugins} for chaining.

.run

Call each function in the plugins stack to iterate over arguments.

plugins.run( arguments[0], [arguments...] )
  • arguments {Array|Object|String}: The value to iterate over.

Creating plugins

A plugin takes an options object and returns a function that takes any arguments as parameters.

function myPlugin(options) {
  return function(str) {
    // do something to `str`
  }
}

Example:

function src(filepath) {
  return function() {
    return fs.readFileSync(filepath);
  }
}
function dest(filepath) {
  return function(str) {
    return fs.writeFileSync(filepath, str);
  }
}
function upper() {
  return function (str) {
    return str.toUpperCase();
  }
}

plugins
  .use(src('foo.txt'))
  .use(upper())
  .use(dest('dist/foo.txt'));

plugins.run();

Author

Jon Schlinkert

License

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


This file was generated by verb-cli on June 20, 2014.