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

core-decorators

Package Overview
Dependencies
Maintainers
1
Versions
51
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

core-decorators - npm Package Compare versions

Comparing version 0.6.0 to 0.7.0

lib/decorate.js

10

lib/autobind.js

@@ -82,11 +82,3 @@ 'use strict';

},
set: function set(newValue) {
Object.defineProperty(this, key, {
configurable: true,
writable: true,
// IS enumerable when reassigned by the outside word
enumerable: true,
value: newValue
});
}
set: (0, _privateUtils.createDefaultSetter)(key)
};

@@ -93,0 +85,0 @@ }

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

exports.getOwnPropertyDescriptors = getOwnPropertyDescriptors;
exports.createDefaultSetter = createDefaultSetter;

@@ -79,2 +80,16 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }

return descs;
}
function createDefaultSetter(key) {
return function set(newValue) {
Object.defineProperty(this, key, {
configurable: true,
writable: true,
// IS enumerable when reassigned by the outside word
enumerable: true,
value: newValue
});
return newValue;
};
}
{
"name": "core-decorators",
"version": "0.6.0",
"version": "0.7.0",
"description": "Library of ES7 decorators inspired by languages that come with built-ins like @override, @deprecated, etc",

@@ -5,0 +5,0 @@ "main": "lib/core-decorators.js",

@@ -28,2 +28,3 @@ # core-decorators.js [![Build Status](https://travis-ci.org/jayphelps/core-decorators.js.svg?branch=master)](https://travis-ci.org/jayphelps/core-decorators.js)

* [@nonconfigurable](#nonconfigurable)
* [@decorate](#decorate)

@@ -35,3 +36,2 @@ ##### For Classes

##### Proposed (not implemented, PRs welcome!):
* @mixin
* @instrument/profile

@@ -237,2 +237,29 @@ * @throttle

### @decorate
Immediately applies the provided function and arguments to the method, allowing you to wrap methods with arbitrary helpers like [those provided by lodash](https://lodash.com/docs#after). The first argument is the function to apply, all further arguments will be passed to that decorating function.
```js
import { decorate } from 'core-decorators';
import { memoize } from 'lodash';
var count = 0;
class Task {
@decorate(memoize)
doSomethingExpensive(data) {
count++;
// something expensive;
return data;
}
}
var task = new Task();
task.doSomethingExpensive([1, 2, 3]);
task.doSomethingExpensive([1, 2, 3]);
count === 1;
// true
```
### @mixin (alias: @mixins)

@@ -239,0 +266,0 @@

@@ -1,2 +0,2 @@

import { decorate } from './private/utils';
import { decorate, createDefaultSetter } from './private/utils';

@@ -76,11 +76,3 @@ function bind(fn, context) {

},
set(newValue) {
Object.defineProperty(this, key, {
configurable: true,
writable: true,
// IS enumerable when reassigned by the outside word
enumerable: true,
value: newValue
});
}
set: createDefaultSetter(key)
};

@@ -87,0 +79,0 @@ }

@@ -66,1 +66,15 @@ const { defineProperty, getOwnPropertyDescriptor,

}
export function createDefaultSetter(key) {
return function set(newValue) {
Object.defineProperty(this, key, {
configurable: true,
writable: true,
// IS enumerable when reassigned by the outside word
enumerable: true,
value: newValue
});
return newValue;
};
}
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