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.1.2 to 0.1.3

12

dist/decoratorFactory.js

@@ -42,3 +42,3 @@ 'use strict';

return fn.apply(undefined, [target[args[0]]].concat(_toConsumableArray(args.slice(1))));
return fn.apply(undefined, [resolveFunction(args[0], target)].concat(_toConsumableArray(args.slice(1))));
},

@@ -49,3 +49,3 @@

wrap: function wrap(fn, target, value) {
return fn(target[arguments[3]], value);
return fn(resolveFunction(arguments[3], target), value);
},

@@ -67,3 +67,3 @@ replace: function replace(fn, target, value) {

return fn.apply(undefined, [value].concat(_toConsumableArray(args.map(function (method) {
return target[method];
return resolveFunction(method, target);
}))));

@@ -82,2 +82,6 @@ },

function resolveFunction(method, target) {
return (0, _lodash.isFunction)(method) ? method : target[method];
}
function isGetter(getter) {

@@ -126,3 +130,3 @@ return Boolean(getter['' + _settings2['default'].annotationPrefix + 'isGetter']);

descriptor.value = TYPE_MAP[type].apply(TYPE_MAP, [root[method], target, value].concat(args));
copyMetaData(value, descriptor.get);
copyMetaData(value, descriptor.value);
}

@@ -129,0 +133,0 @@

{
"name": "lodash-decorators",
"author": "Steven Sojka",
"version": "0.1.2",
"version": "0.1.3",
"engines": {

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

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

- `defer`
- `bind`

@@ -71,3 +72,2 @@ #### Example

- `negate`
- `bind`

@@ -101,5 +101,5 @@ #### Example

These decorators take a `String` argument as their first parameter
instead of a `Function`. The argument is the name of a function on the
object you wish to partially apply arguments to.
These can take a `Function` as their first argument or a `String`.
If the argument is a `String` then a `Function` is resolved from
the current object.

@@ -126,30 +126,3 @@ #### Example

getLastName() {}
}
const person = new Person('Joe', 'Smith');
person.getFirstName(); // 'Joe'
person.getLastName(); // 'Smith'
```
### Wraps
Wraps work the same way as partials by taking a `String` argument
of the function you wish to wrap.
#### Example
```javascript
import { wrap } from 'lodash-decorators'
class Person {
constructor(firstName, lastName) {
this.firstName = firstName;
this.lastName = lastName;
}
getName() {
return `${this.firstName} ${this.lastName}`;
}
@wrap('getName')

@@ -163,2 +136,4 @@ getUpperCaseName(fn) {

person.getFirstName(); // 'Joe'
person.getLastName(); // 'Smith'
person.getUpperCaseName(); // JOE SMITH

@@ -170,4 +145,4 @@ ```

You can use methods like `compose` and `flow` similiar to
partials. It takes any number of `String` arguments that resolve
to `Function`s on the object.
partials. The arguments are resolved the same way partials
are resolved.

@@ -178,2 +153,3 @@ #### Example

import { compose } from 'lodash-decorators'
import { kebabCase } from 'lodash';

@@ -190,7 +166,3 @@ class Person {

upperCaseName(name) {
return name.toUpperCase();
}
@compose('upperCaseName', 'getName')
@compose(kebabCase, 'getName')
logName(name) {

@@ -203,3 +175,3 @@ console.log(name);

person.logName(); // JOE SMITH
person.logName(); // joe-smith
```

@@ -206,0 +178,0 @@

@@ -14,11 +14,11 @@ 'use strict';

// on the object referenced by string name.
partial: (fn, target, value, ...args) => fn(target[args[0]], ...args.slice(1)),
partial: (fn, target, value, ...args) => fn(resolveFunction(args[0], target), ...args.slice(1)),
// Wrap is a different case since the original function value
// needs to be given to the wrap method.
wrap: (fn, target, value, ...args) => fn(target[args[0]], value),
wrap: (fn, target, value, ...args) => fn(resolveFunction(args[0], target), value),
replace: (fn, target, value, ...args) => fn(...args),
// Calls the function with key functions and the value
compose: (fn, target, value, ...args) => fn(value, ...args.map(method => target[method])),
compose: (fn, target, value, ...args) => fn(value, ...args.map(method => resolveFunction(method, target))),
partialed: (fn, target, value, ...args) => partial(fn, value, ...args)

@@ -29,2 +29,6 @@ };

function resolveFunction(method, target) {
return isFunction(method) ? method : target[method];
}
function isGetter(getter) {

@@ -64,3 +68,3 @@ return Boolean(getter[`${settings.annotationPrefix}isGetter`]);

descriptor.value = TYPE_MAP[type](root[method], target, value, ...args);
copyMetaData(value, descriptor.get);
copyMetaData(value, descriptor.value);
}

@@ -67,0 +71,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