Socket
Socket
Sign inDemoInstall

autobind-decorator

Package Overview
Dependencies
Maintainers
2
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

autobind-decorator - npm Package Compare versions

Comparing version 1.3.0 to 1.3.1

25

lib/index.js

@@ -1,6 +0,1 @@

'use strict';
Object.defineProperty(exports, '__esModule', {
value: true
});
/**

@@ -20,2 +15,7 @@ * @copyright 2015, Andrey Popp <8mayday@gmail.com>

*/
'use strict';
Object.defineProperty(exports, '__esModule', {
value: true
});
exports['default'] = autobind;

@@ -40,15 +40,4 @@

// (Using reflect to get all keys including symbols)
var keys = undefined;
// Use Reflect if exists
if (typeof Reflect !== 'undefined') {
keys = Reflect.ownKeys(target.prototype);
} else {
keys = Object.getOwnPropertyNames(target.prototype);
// use symbols if support is provided
if (typeof Object.getOwnPropertySymbols === 'function') {
keys = keys.concat(Object.getOwnPropertySymbols(target.prototype));
}
}
keys.forEach(function (key) {
console.log(Object.getOwnPropertyNames(), Object.getOwnProperySymbols());
Reflect.ownKeys(target.prototype).forEach(function (key) {
// Ignore special case target method

@@ -55,0 +44,0 @@ if (key === 'constructor') {

{
"name": "autobind-decorator",
"version": "1.3.0",
"version": "1.3.1",
"description": "Decorator for binding method to an object",
"main": "lib/index.js",
"scripts": {
"test": "make test"
},
"author": "Andrey Popp <8mayday@gmail.com>",

@@ -7,0 +10,0 @@ "license": "MIT",

# autobind decorator
This is a class or method decorator which will bind methods it to an
object so `this` always points to an object instance within a method.
A class or method decorator which binds methods to the instance
so `this` is always correct, even when the method is detached.
This is particularly useful for situations like React components, where
you often pass methods as event handlers and would otherwise need to
`.bind(this)`.
```
Before:
<button onClick={ this.handleClick.bind(this) }></button>
After:
<button onClick={ this.handleClick }></button>
```
As decorators are a part of future ES7 standard they can only be used with

@@ -11,7 +22,6 @@ transpilers such as [Babel](http://babeljs.io).

% npm install autobind-decorator core-js
% npm install autobind-decorator
Example:
import 'core-js/modules/es6.reflect' // Reflect polyfill is required
import autobind from 'autobind-decorator'

@@ -18,0 +28,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