{"name":"bind-decorator","version":"1.0.7","description":"The fastest automatic method.bind(this) decorator","main":"index.js","typings":"index.d.ts","scripts":{"test":"tsc && jest --verbose","jest-cov":"tsc --sourceMap -p . && jest --verbose --coverage --collectCoverageFrom src/index.js","map-cov":"remap-istanbul -i ./coverage/coverage-final.json -t lcovonly -o ./lcov.info","report-cov":"codeclimate-test-reporter < ./lcov.info","coverage":"npm run jest-cov && npm run map-cov && npm run report-cov","typings":"typings install","npm":"npm run clean && tsc -d -p . && mv ./src/index.js . && mv ./src/index.d.ts .","clean":"rm -f ./src/index.js* ./__tests__/*.d.ts ./__tests__/*.js* ./lcov.info  && rm -f -R ./coverage"},"repository":{"type":"git","url":"git+https://github.com/NoHomey/bind-decorator.git"},"keywords":["bind","autobind","methodbind","bind-decorator","autobind-decorator","decorator"],"author":{"name":"Ivo Stratev"},"license":"MIT","bugs":{"url":"https://github.com/NoHomey/bind-decorator/issues"},"homepage":"https://github.com/NoHomey/bind-decorator#readme","devDependencies":{"codeclimate-test-reporter":"^0.3.3","jest":"^15.1.1","remap-istanbul":"^0.6.4","typescript":"^1.8.10","typings":"^1.3.3"},"gitHead":"59f948835dbadfbcdefb60ed3d6f2bfafc14bdce","_id":"bind-decorator@1.0.7","_shasum":"903c09de32e0691d6662fc9650352739278a8a1c","_from":".","_npmVersion":"3.10.3","_nodeVersion":"6.6.0","_npmUser":{"name":"nohomey","email":"ivo.stratev.tues@gmail.com"},"dist":{"shasum":"903c09de32e0691d6662fc9650352739278a8a1c","tarball":"http://registry-npm.ywwl.com/bind-decorator/download/bind-decorator-1.0.7.tgz","integrity":"sha512-kYqeoBFPJUVWG86JuYrlhIZsGpzaOldnmWRO0l4VyHnZ4vWW/l47cqbbq1xPdufJoctmx88BHWUxlgotwJJfmg==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCICCqFyal1eD3rJ8JvjKIrH3sDrbsC6rf4iaooz2EBTtNAiEAkNboGTrKfylNu++W9lHlqXeMEHGWJ2Dv5DdH4l2W67Q="}],"size":2831,"noattachment":false,"key":"/bind-decorator/-/bind-decorator-1.0.7.tgz"},"maintainers":[{"name":"nohomey","email":"ivo.stratev.tues@gmail.com"}],"_npmOperationalInternal":{"host":"packages-12-west.internal.npmjs.com","tmp":"tmp/bind-decorator-1.0.7.tgz_1474395550324_0.5349507264327258"},"directories":{},"readme":"# bind-decorator\n\nContext method binding decorator.\n\n[![npm version](https://badge.fury.io/js/bind-decorator.svg)](https://badge.fury.io/js/bind-decorator)\n[![license](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/NoHomey/bind-decorator)\n[![Build Status](https://semaphoreci.com/api/v1/nohomey/bind-decorator/branches/master/badge.svg)](https://semaphoreci.com/nohomey/bind-decorator)\n[![Code Climate](https://codeclimate.com/github/NoHomey/bind-decorator/badges/gpa.svg)](https://codeclimate.com/github/NoHomey/bind-decorator)\n[![Test Coverage](https://codeclimate.com/github/NoHomey/bind-decorator/badges/coverage.svg)](https://codeclimate.com/github/NoHomey/bind-decorator/coverage)\n[![Issue Count](https://codeclimate.com/github/NoHomey/bind-decorator/badges/issue_count.svg)](https://codeclimate.com/github/NoHomey/bind-decorator)\n![TypeScript](https://img.shields.io/badge/%3C%20%2F%3E-TypeScript-blue.svg)\n![Typings](https://img.shields.io/badge/typings-%E2%9C%93-brightgreen.svg)\n\n`@bind` is just a little faster version of [`@autobind`](https://github.com/andreypopp/autobind-decorator/blob/master/src/index.js) for decorating methods only, by binding them to the current context. It is written in TypeScript and follows the latest `decorator`s [proposal](http://tc39.github.io/proposal-decorators/).\n\n- It will `throw` exceptions if decorating anything other than `function`;\n- Since the implementation follows the latest `decorator`s [proposal](http://tc39.github.io/proposal-decorators/) where compartion betweeen `this` and `target` can not be trusted, `@bind` will always `return` a `configurable`, `get accessor propertyDescriptor` which will memomize the result of `descriptor.value.bind(this)` by re-defining the property descriptor of the method beeing decorated (Credits goes to [autobind-decorator](https://github.com/andreypopp/autobind-decorator/blob/master/src/index.js) for memoizing the result).\n\nIf you are looking for not just method decorator but rather full class bounding decorator check [`@autobind`](https://github.com/andreypopp/autobind-decorator/blob/master/src/index.js).\n\n# Install\n\nInstall with npm:\n\n```bash\n$ npm install bind-decorator\n```\n\n[![NPM](https://nodei.co/npm/bind-decorator.png?downloads=true&stars=true)](https://nodei.co/npm/bind-decorator/)\n\n# Usage\n\n## In JavaScript\n\n```javascript\nimport bind from 'bind-decorator';\n\nclass Test {\n    static what = 'static';\n    \n    @bind\n    static test() {\n        console.log(this.what);\n    }\n\n    constructor(what) {\n        this.what = what;\n    }\n\n    @bind\n    test() {\n        console.warn(this.what);\n    }\n}\n\nconst tester = new Test('bind');\nconst { test } = tester;\ntester.test(); // warns 'bind'.\ntest(); // warns 'bind'.\nTest.test(); // logs 'static'.\n```\n\n## In TypeScript\n\n```typescript\nimport bind from 'bind-decorator';\n\nclass Test {\n    public static what: string = 'static';\n    \n    @bind\n    public static test(): void {\n        console.log(this.what);\n    }\n\n    public constructor(public what: string) {\n        this.what = what;\n    }\n\n    @bind\n    public test(): void {\n        console.warn(this.what);\n    }\n}\n\nconst tester: Test = new Test('bind');\nconst { test } = tester;\ntester.test(); // warns 'bind'.\ntest(); // warns 'bind'.\nTest.test(); // logs 'static'.\n```\n\n# Testing\n\n1. `npm install`\n\n2. `npm test`\n\n# Contributing\n\n1. `npm install`\n\n2. Make changes\n\n3. If necessary add some tests to `__tests__`\n\n4. `npm test`\n\n5. Make a Pull Request","publish_time":1474395552129,"_cnpm_publish_time":1474395552129,"dist-tags":{"latest":"1.0.11"}}