JSPM

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

Utility for [minibase][] and [base][] that helps you create plugins

Package Exports

  • minibase-create-plugin

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

Readme

minibase-create-plugin npmjs.com The MIT License npm downloads

Utility for minibase and base that helps you create plugins

code climate standard code style travis build status coverage status dependency status

Install

Install with npm

$ npm i minibase-create-plugin --save

Usage

For more use-cases see the tests

const minibaseCreatePlugin = require('minibase-create-plugin')

API

minibaseCreatePlugin

Creates a plugin for Base and MiniBase, that uses the minibase-is-registered under the hood to provide more stable and friendly API for plugins.

Params

  • name {String}: name of the plugin, passed to .isRegistered
  • fn {Function}: plugin function, passed to .use method, so called immediately
  • returns {Function}: plugin function that should be passed to .use method

Example

var minibase = require('minibase')
var createPlugin = require('minibase-create-plugin')

var called = 0

var plugin = createPlugin('foo-bar', function (self) {
  called++
  self.foo = 'bar'
  self.define('qux', function quxMethod () {})
  self.define('abc', function abc () {})
})

minibase.use(plugin)
minibase.use(plugin)

console.log(minibase.foo) // => 'bar'
console.log(minibase.qux) // => Function: qux
console.log(minibase.abc) // => Function: abc
console.log(minibase.registered) // => { 'foo-bar': ['qux', 'abc'] }

// called only once
console.log(called) // => 1

Contributing

Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.
But before doing anything, please read the CONTRIBUTING.md guidelines.

Charlike Make Reagent new message to charlike freenode #charlike

tunnckoCore.tk keybase tunnckoCore tunnckoCore npm tunnckoCore twitter tunnckoCore github