{"name":"class-autobind","version":"0.1.0","description":"Method auto-bind for ES6 (ES2015) classes","main":"lib/autobind.js","scripts":{"build":"babel src --ignore '_*' --out-dir lib","lint":"eslint --max-warnings 0 .","prepublish":"npm run build","test":"npm run lint && npm run test-src","test-src":"mocha"},"dependencies":{},"devDependencies":{"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"},"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":"26bc3e708e5f50e93c800d493f3c9875cb6235e4","_id":"class-autobind@0.1.0","_shasum":"ba70e83bbe38be64512de3770bd867e60ab4b561","_from":".","_npmVersion":"3.7.3","_nodeVersion":"5.8.0","_npmUser":{"name":"sstur","email":"sstur@me.com"},"dist":{"shasum":"ba70e83bbe38be64512de3770bd867e60ab4b561","tarball":"http://registry-npm.ywwl.com/class-autobind/download/class-autobind-0.1.0.tgz","integrity":"sha512-aISZWGp5R16ZbgNJ2n3LfnDvPqTSBCitOW7c6cgvpywnLEk+K5IumzkBjUjSFrDLzpYXqo6plluvUGRiIIrZvA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIFJ9x0HanqfAqiPSO5gqZceXaSPjv9puxC4eH+nHwVfTAiEA5YJcDdxiUTaplvjOo/8eSHECVot0A/r0nPEQjea7Iog="}],"size":7276,"noattachment":false,"key":"/class-autobind/-/class-autobind-0.1.0.tgz"},"maintainers":[{"name":"sstur","email":"sstur@me.com"}],"_npmOperationalInternal":{"host":"packages-12-west.internal.npmjs.com","tmp":"tmp/class-autobind-0.1.0.tgz_1457922377584_0.872461739461869"},"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":1457922378050,"_cnpm_publish_time":1457922378050,"dist-tags":{"latest":"0.1.4"}}