Skip to content

Commit

Permalink
fix(deps): dependencies update related changes
Browse files Browse the repository at this point in the history
  • Loading branch information
tunnckoCore committed Nov 1, 2016
1 parent 318b896 commit 2cfde06
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 19 deletions.
17 changes: 7 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ console.log(minimist.cache.baz) // => { a: 'b' }
console.log(minimist.cache.qux) // => 123
```

### [.use](index.js#L239)
### [.use](index.js#L236)
> Define a plugin `fn` function to be called immediately upon init. It is recommended `fn` to be synchronous and should not expect asynchronous plugins to work correctly - use plugins for this. Uses [try-catch-callback][] under the hood to handle errors and completion of that synchronous function. _**Never throws - emit events!™**_
See [try-catch-callback][] and/or [try-catch-core][] for more details.
Expand All @@ -178,21 +178,18 @@ const app = MiniBase({ silent: true, foo: 'bar' })

app
.once('error', (err) => console.error(err.stack || err))
.on('use', function (fn, res) {
// called on each `.use` call
console.log(res) // => 555
})
.use((app) => {
console.log(app.options) // => { silent: true, foo: 'bar' }
return 555
})
.use(function () {
console.log(this.options) // => { silent: true, foo: 'bar' }
// intentionally
foo bar
})
```

### [#delegate](index.js#L283)
### [#delegate](index.js#L281)
> Static method to delegate properties from `provider` to `receiver` and make them non-enumerable.
See [delegate-properties][] for more details, it is exact mirror.
Expand All @@ -217,7 +214,7 @@ console.log(obj.foo) // => 'bar'
console.log(obj.qux) // => 123
```

### [#define](index.js#L310)
### [#define](index.js#L308)
> Static method to define a non-enumerable property on an object.
See [define-property][] for more details, it is exact mirror.
Expand All @@ -241,7 +238,7 @@ console.log(obj.foo) // => 123
console.log(obj.bar()) // => 'qux'
```

### [#extend](index.js#L347)
### [#extend](index.js#L345)
> Static method for inheriting the prototype and static methods of the `MiniBase` class. This method greatly simplifies the process of creating inheritance-based applications.
See [static-extend][] for more details.
Expand Down Expand Up @@ -296,8 +293,8 @@ But before doing anything, please read the [CONTRIBUTING.md](./CONTRIBUTING.md)
[define-property]: https://github.com/jonschlinkert/define-property
[delegate-properties]: https://github.com/jonschlinkert/delegate-properties
[static-extend]: https://github.com/jonschlinkert/static-extend
[try-catch-callback]: https://github.com/tunnckocore/try-catch-callback
[try-catch-core]: https://github.com/tunnckocore/try-catch-core
[try-catch-callback]: https://github.com/hybridables/try-catch-callback
[try-catch-core]: https://github.com/hybridables/try-catch-core

[npmjs-url]: https://www.npmjs.com/package/minibase
[npmjs-img]: https://img.shields.io/npm/v/minibase.svg?label=minibase
Expand Down
14 changes: 6 additions & 8 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -211,15 +211,12 @@ utils.delegate(MiniBase.prototype, {
*
* app
* .once('error', (err) => console.error(err.stack || err))
* .on('use', function (fn, res) {
* // called on each `.use` call
* console.log(res) // => 555
* })
* .use((app) => {
* console.log(app.options) // => { silent: true, foo: 'bar' }
* return 555
* })
* .use(function () {
* console.log(this.options) // => { silent: true, foo: 'bar' }
* // intentionally
* foo bar
* })
Expand All @@ -237,17 +234,18 @@ utils.delegate(MiniBase.prototype, {
*/

use: function use (fn) {
fn = fn.bind(this, this)
utils.tryCatch(fn, (err, res) => {
utils.tryCatchCallback.call(this, fn, {
passCallback: true,
args: [this]
}, (err, res) => {
if (err) {
var anon = 'anonymous ' + (this._anonymousPluginsCount + 1)
err.fn = fn
err.fnName = utils.getFnName(fn) || anon
this.emit('error', err)
return
}
this.emit('use', fn, res)
}, true)
})
return this
}
})
Expand Down
2 changes: 1 addition & 1 deletion utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ require('eventemitter3', 'EventEmitter')
require('get-fn-name')
require('isobject', 'isObject')
require('static-extend')
require('try-catch-callback', 'tryCatch')
require('try-catch-callback')
require = fn // eslint-disable-line no-undef, no-native-reassign, no-global-assign

/**
Expand Down

0 comments on commit 2cfde06

Please sign in to comment.