Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

lodash-decorators

Package Overview
Dependencies
Maintainers
1
Versions
68
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

lodash-decorators - npm Package Compare versions

Comparing version 1.0.6 to 1.1.0

attempt.js

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 @@

2

package.json

@@ -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 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc