{"name":"bind-decorator","version":"1.0.0","description":"The fastest automatic method.bind(this) decorator","main":"./dist/index.js","typings":"./dist/index.d.ts","scripts":{"test":"echo \"Error: no test specified\" && exit 1","prepublish":"tsc -d -m commonjs  --moduleResolution node -t es5 --outDir ./dist ./src/index.ts"},"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":{"typescript":"^1.8.10"},"gitHead":"b0b3a4474534b174eea92e0a952a10890a7671cb","_id":"bind-decorator@1.0.0","_shasum":"490c2a5b049f2a9f63c4fa3ae518c35fa1d9f728","_from":".","_npmVersion":"3.10.3","_nodeVersion":"6.5.0","_npmUser":{"name":"nohomey","email":"ivo.stratev.tues@gmail.com"},"dist":{"shasum":"490c2a5b049f2a9f63c4fa3ae518c35fa1d9f728","tarball":"http://registry-npm.ywwl.com/bind-decorator/download/bind-decorator-1.0.0.tgz","integrity":"sha512-mNO1T1ptYEImgOijHx75T0rfiw5g7Vb+sFXkOBZpCYHHoTzAeaFePmSz616QZDqJeDxOgM9XFk+iLyJfUPxODQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCA5vznkEgkOv0NrNQjMCBmNdBO2hCNuaOJuaDkm7f6gwIhALU/R51UZlz+DVLmaMM/p1PZaIrex0rlhMRjFj6wD/Xx"}],"size":2838,"noattachment":false,"key":"/bind-decorator/-/bind-decorator-1.0.0.tgz"},"maintainers":[{"name":"nohomey","email":"ivo.stratev.tues@gmail.com"}],"_npmOperationalInternal":{"host":"packages-16-east.internal.npmjs.com","tmp":"tmp/bind-decorator-1.0.0.tgz_1473288179982_0.31031991145573556"},"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":1473288181148,"_cnpm_publish_time":1473288181148,"dist-tags":{"latest":"1.0.11"}}