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 0.4.7 to 0.4.8

extensions/deprecated.js

22

Applicator.js

@@ -110,3 +110,18 @@ 'use strict';

/**
* Applys a specific method signature onto a set of arguments. This is due to the various different APIs
* these functions provide.
*/
var Applicator = {
/**
* Invokes an applicator method.
*
* @param {Function} applicator The applicator function.
* @param {Function} method The function the applicator if being applied to.
* @param {Object} target The target object given to the decorator.
* @param {Function} value The value the decorator is being applied to.
* @param {...*} [args] Any additional arguments passed to the applicator.
* @returns {Function} A function with __method__ applied to __value__
* with the __applicator__s signature.
*/
invoke: function invoke(applicator, method, target, value) {

@@ -120,2 +135,9 @@ for (var _len11 = arguments.length, args = Array(_len11 > 4 ? _len11 - 4 : 0), _key11 = 4; _key11 < _len11; _key11++) {

/**
* Resolves a function on the current target object.
*
* @param {Function|String} method The method or method name.
* @param {Object} [target] The target object to resolve from.
* @returns {Function} The resolved function.
*/
resolveFunction: function resolveFunction(method, target) {

@@ -122,0 +144,0 @@ return (0, _lodashLangIsFunction2['default'])(method) ? method : target[method];

26

bindAll.js

@@ -22,2 +22,14 @@ 'use strict';

var _utilsWrapConstructor = require('./utils/wrapConstructor');
var _utilsWrapConstructor2 = _interopRequireDefault(_utilsWrapConstructor);
/**
* Binds all class methods to the instance upon instantiation. This
* extends the current constructor and copies over all properties,
* including static methods. We could do an ES6 class extend instead
* but we need to bind all the class methods BEFORE we call the super
* constructor, which ES6 classes won't let us do.
*/
function bindAllWrapper() {

@@ -39,7 +51,5 @@ for (var _len = arguments.length, methods = Array(_len), _key = 0; _key < _len; _key++) {

var Ctor = properties[0];
function BindAllConstructor() {
for (var _len3 = arguments.length, args = Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
args[_key3] = arguments[_key3];
return (0, _utilsWrapConstructor2['default'])(properties[0], function (Ctor) {
for (var _len3 = arguments.length, args = Array(_len3 > 1 ? _len3 - 1 : 0), _key3 = 1; _key3 < _len3; _key3++) {
args[_key3 - 1] = arguments[_key3];
}

@@ -50,7 +60,3 @@

return Ctor.apply(this, args);
}
BindAllConstructor.prototype = Ctor.prototype;
return (0, _utilsAssignAll2['default'])(BindAllConstructor, Ctor, _utilsAssignAll.FUNCTION_PROPERTY_EXCLUDES);
});
};

@@ -57,0 +63,0 @@ }

@@ -45,2 +45,13 @@ 'use strict';

exports.decorateTargets = decorateTargets;
/**
* Gets a decorators target type.
*
* @param {Object} target The decorator target.
* @param {String} name The property name.
* @param {Object} descriptor The property descriptor.
* @param {CompositeKeyWeakMap} getterSetterMap The getter/setter map
* for the decorator. This is needed to check whether the getter or setter
* has been set.
* @returns {String} A decorator target type.
*/

@@ -61,2 +72,10 @@ function getDecoratorTarget(target, name, descriptor, getterSetterMap) {

/**
* Creates a decorator that uses an applicator to wrap a transform function.
*
* @param {Function} method The method that will __wrap__ the function being decorated.
* @param {Function} [applicator=applicators.pre] The applicator function to apply the __method__ with.
* @returns {Function} The decorator function or decorator wrapper function.
*/
function createDecorator(method) {

@@ -90,2 +109,13 @@ var applicator = arguments[1] === undefined ? applicators.pre : arguments[1];

/**
* Creates an instance decorator that uses an applicator to wrap a transform function.
* This has different behaviour than a decorator that is applied to a class as a whole.
*
* This uses a WeakMap to keep track of instances and methods.
*
* @param {Function} method The method that will __wrap__ the function being decorated.
* @param {Function} [applicator=applicators.pre] The applicator function to apply the __method__ with.
* @returns {Function} The decorator function or decorator wrapper function.
*/
function createInstanceDecorator(method) {

@@ -92,0 +122,0 @@ var applicator = arguments[1] === undefined ? applicators.pre : arguments[1];

@@ -29,2 +29,6 @@ 'use strict';

var _deprecated = require('./deprecated');
var _deprecated2 = _interopRequireDefault(_deprecated);
exports['default'] = (0, _utilsNormalizeExport2['default'])({

@@ -35,2 +39,3 @@ configurable: _configurable2['default'],

writable: _writable2['default'],
deprecated: _deprecated2['default'],
readonly: (0, _writable2['default'])(false),

@@ -37,0 +42,0 @@ nonenumerable: (0, _enumerable2['default'])(false),

@@ -11,4 +11,2 @@ 'use strict';

var _Applicator = require('../Applicator');
var _utilsReturnAtIndex = require('../utils/returnAtIndex');

@@ -15,0 +13,0 @@

@@ -5,3 +5,3 @@ {

"description": "A collection of decorators using lodash at it's core.",
"version": "0.4.7",
"version": "0.4.8",
"engines": {

@@ -8,0 +8,0 @@ "node": ">=0.12.0"

@@ -103,3 +103,2 @@ # lodash-decorators

```javascript
import { uniqueId } from 'lodash';
import { once } from 'lodash-decorators'

@@ -323,3 +322,3 @@

### Extensions
## Extensions

@@ -329,6 +328,38 @@ Extensions are decorators that aren't necessarily Lodash functions, but use Lodash under the hood. They

These can be found in `src/extensions`
- `deprecated`
- `writable`
- `configurable`
- `returnsArg`
- `enumerable`
- `nonenumerable` -> `enumerable(false)`
- `nonconfigurable` -> `configurable(false)`
- `readonly` -> `writable(false)`
### Validate
### Deprecated
Warns when a deprecated class is istantiated or a deprecated class method is invoked.
#### Example
```javascript
import { deprecated } from 'lodash-decorators/extensions'
@deprecated
class Person {
constructor() {}
}
class OtherPerson {
@deprecated
fn() {}
}
let person = new Person(); //=> Warning!
let otherPerson = new OtherPerson();
otherPerson.fn(); //=> Warning!
```
## Validate
The validate module contains decorators that can validate function arguments and return value.

@@ -335,0 +366,0 @@

@@ -17,2 +17,6 @@ 'use strict';

/**
* Returns the first argument from the function regardless of
* the decorated functions return value.
*/
exports['default'] = (0, _decoratorFactory.createDecorator)(function tapDecorator(fn) {

@@ -19,0 +23,0 @@ return (0, _utilsReturnAtIndex2['default'])(fn, 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