Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor and use dush (v2) #15

Open
tunnckoCore opened this issue Mar 12, 2017 · 1 comment
Open

Refactor and use dush (v2) #15

tunnckoCore opened this issue Mar 12, 2017 · 1 comment

Comments

@tunnckoCore
Copy link
Collaborator

Make it not rely on this and use the dush as core event emitter

@tunnckoCore
Copy link
Collaborator Author

tunnckoCore commented Apr 1, 2017

Need updates to minibase-is-registered and dush-promise plugins.
And probably update minibase-create-plugin

  • supports named plugins with .use('foobar', pluginFn) or .use(function foobar () {})
  • supports unnamed plugins .use((app) => {})
  • works on node 0.10 if options.Promise is passed or if ANY promise is detected in deps
  • never throws, emit error event and also can app.catch() errors
  • has .use, .on, .off, .once and .emit methods through dush
  • has .isRegistered through minibase-is-registered
  • has .then, .catch, .resolve and .reject through dush-promise
  • has .define and .delegate methods through dush-methods from minibase-is-registered
/*!
 * minibase <https://github.com/tunnckoCore/minibase>
 *
 * Copyright (c) Charlike Mike Reagent <@tunnckoCore> (https://i.am.charlike.online)
 * Released under the MIT license.
 */

'use strict'

var dush = require('dush')
var extend = require('extend-shallow')
var betterUse = require('dush-better-use')

// from `dush`:
// .on
// .off
// .once
// .emit
// .use
//
// from `dush-better-use` (overrides the default `dush` .use):
// .use
//
// from `minibase-is-registered`:
// .isRegistered
//
// from `dush-methods` (registered at `minibase-is-registered`):
// .define
// .delegate
//

function MiniBase (options) {
  return dush()
    .use(function optionsPlugin (app) {
      app.options = extend({}, options)
      return app
    })
    .use(betterUse())
}

module.exports = MiniBase

@tunnckoCore tunnckoCore changed the title Refactor and use dush Refactor and use dush (v2) Apr 1, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant