lodash-decorators
Advanced tools
Comparing version 1.0.6 to 1.1.0
12
index.js
@@ -33,2 +33,10 @@ 'use strict'; | ||
var _mixin = require('./mixin'); | ||
var _mixin2 = _interopRequireDefault(_mixin); | ||
var _attempt = require('./attempt'); | ||
var _attempt2 = _interopRequireDefault(_attempt); | ||
var _decoratorFactory = require('./decoratorFactory'); | ||
@@ -74,3 +82,5 @@ | ||
tap: _tap2['default'], | ||
bindAll: _bindBindAll2['default'] | ||
bindAll: _bindBindAll2['default'], | ||
mixin: _mixin2['default'], | ||
attempt: _attempt2['default'] | ||
}); | ||
@@ -77,0 +87,0 @@ |
@@ -5,3 +5,3 @@ { | ||
"description": "A collection of decorators using lodash at it's core.", | ||
"version": "1.0.6", | ||
"version": "1.1.0", | ||
"engines": { | ||
@@ -8,0 +8,0 @@ "node": ">=0.12.0" |
@@ -26,10 +26,14 @@ # lodash-decorators | ||
- [Can I use decorators on getters/setters without these?](#can-i-use-decorators-on-getterssetters-without-these) | ||
- [Bind](#bind) | ||
- [Mixin](#mixin) | ||
- [Example](#example-5) | ||
- [Attempt](#attempt) | ||
- [Example](#example-6) | ||
- [Bind](#bind) | ||
- [Example](#example-7) | ||
- [Example](#example-8) | ||
- [Forcing Decorator on Prototype](#forcing-decorator-on-prototype) | ||
- [Example](#example-7) | ||
- [Example](#example-9) | ||
- [Extensions](#extensions) | ||
- [Deprecated](#deprecated) | ||
- [Example](#example-8) | ||
- [Example](#example-10) | ||
- [Validate](#validate) | ||
@@ -72,2 +76,3 @@ | ||
- `modArgs` | ||
- `mixin` | ||
@@ -107,2 +112,3 @@ #### Example | ||
- `tap` | ||
- `attempt` | ||
@@ -295,2 +301,55 @@ #### Example | ||
### Mixin | ||
You can mixin methods into a class by using the `Mixin` decorator. | ||
#### Example | ||
```javascript | ||
import { mixin } from 'lodash-decorators'; | ||
const MyOtherApi = { | ||
someCoolMethod() { | ||
// Do something cool | ||
} | ||
}; | ||
@mixin(MyOtherApi) | ||
class Person {} | ||
Person.prototype.someCoolMethod === MyOtherApi.someCoolMethod; // => true | ||
``` | ||
### Attempt | ||
You can wrap a method in a lodash attempt method. | ||
#### Example | ||
```javascript | ||
import { attempt } from 'lodash-decorators'; | ||
class Person { | ||
@attempt | ||
throwAnError() { | ||
throw new Error(); | ||
} | ||
@attempt | ||
doNotThrowAnError() { | ||
return '0_o'; | ||
} | ||
} | ||
const person = new Person(); | ||
let result = person.throwAnError(); | ||
result instanceof Error; // => true | ||
result = person.doNotThrowAnError(); | ||
result === '0_o'; // => true | ||
``` | ||
### Bind | ||
@@ -297,0 +356,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
60970
31
1043
497