{"name":"class-autobind","version":"0.1.1","description":"Method auto-bind for ES6 (ES2015) classes","main":"lib/autobind.js","scripts":{"build-lib":"rimraf lib && babel src --ignore '_*' --out-dir lib","lint":"eslint --max-warnings 0 .","prepublish":"npm run build-lib","test":"npm run lint && npm run test-src","test-src":"mocha"},"dependencies":{},"devDependencies":{"babel-cli":"^6.6.5","babel-core":"^6.7.2","babel-eslint":"^5.0.0","babel-plugin-transform-class-properties":"^6.6.0","babel-preset-es2015":"^6.6.0","babel-preset-react":"^6.5.0","babel-preset-stage-2":"^6.5.0","eslint":"2.2.0","eslint-plugin-babel":"^3.1.0","eslint-plugin-flow-vars":"^0.2.1","eslint-plugin-react":"^4.2.1","expect":"^1.15.2","mocha":"^2.4.5","rimraf":"^2.5.2"},"repository":{"type":"git","url":"git+ssh://git@github.com/sstur/class-autobind.git"},"keywords":["react","autobind","es6-class"],"author":{"name":"sstur@me.com"},"license":"ISC","bugs":{"url":"https://github.com/sstur/class-autobind/issues"},"homepage":"https://github.com/sstur/class-autobind#readme","gitHead":"d04ce1dcfec3b82f26a41e0c87be7a6263c493f1","_id":"class-autobind@0.1.1","_shasum":"1cd1c0f81eb79ac56a9cae6177d2c4a4d386469c","_from":".","_npmVersion":"3.7.3","_nodeVersion":"5.8.0","_npmUser":{"name":"sstur","email":"sstur@me.com"},"dist":{"shasum":"1cd1c0f81eb79ac56a9cae6177d2c4a4d386469c","tarball":"http://registry-npm.ywwl.com/class-autobind/download/class-autobind-0.1.1.tgz","integrity":"sha512-IEyWvTBKBwMVgqPbor1qiQWEskYuY2KYESwZ6QkQBt+e/wmLB31+T73gm+yRL7hQAqj0Y4psczP5RGrE2f3LnA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCXr0y/3aPpLhf1tSfLDAzodRm8cy6wU4iqjjSHWl9kHQIhAIsB5TqD95MVP17Xe8K6K8B5vv/5yvaPO11Mvmz7R9gU"}],"size":2339,"noattachment":false,"key":"/class-autobind/-/class-autobind-0.1.1.tgz"},"maintainers":[{"name":"sstur","email":"sstur@me.com"}],"_npmOperationalInternal":{"host":"packages-12-west.internal.npmjs.com","tmp":"tmp/class-autobind-0.1.1.tgz_1458541632746_0.6573245257604867"},"directories":{},"readme":"# Method auto-bind for ES6 (ES2015) classes\n\nThis package provides a single function, `autobind`, for use within a constructor to bind all methods to the instance itself.\n\nFor example, this allows us to pass a method to an event handler `element.addEventListener('click', this.onClick)` and be sure the `onClick` method will always be called with the right context.\n\nNote: This has some specific logic for React, but could be used in any project.\n\n## Usage:\n\n```js\nimport autobind from 'class-autobind';\n\nclass MyComponent extends React.Component {\n  constructor() {\n    super(...arguments);\n    autobind(this);\n  }\n  render() {\n    return <button onClick={this.onClick}>Click Me</button>;\n  }\n  onClick() {\n    console.log('Button Clicked');\n  }\n}\n```\n\n## Advanced Usage:\n\nIf your component will possibly be subclassed (you really should not do this, but some third-party libraries like [react-css-modules](https://npmjs.com/package/react-css-modules) do so) then you will need to specify which prototype will be the source of methods that are to be automatically bound.\n\n```js\nimport autobind from 'class-autobind';\n\nclass MyComponent extends React.Component {\n  constructor() {\n    super(...arguments);\n    autobind(this, MyComponent.prototype); // Note the second parameter.\n  }\n  render() {\n    /* ... */\n  }\n}\n\nclass MySubClassedComponent extends MyComponent {\n  /* This is probably a very bad idea. */\n}\n```\n\n## License\n\nThis software is [BSD Licensed](/LICENSE).\n","publish_time":1458541633198,"_cnpm_publish_time":1458541633198,"dist-tags":{"latest":"0.1.4"}}