blugavere / auto-ref

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

auto-ref NPM version Build Status Dependency Status Coverage percentage

Automatically create references to constructor arguments.

Installation

$ npm install --save auto-ref

Usage

const autoRef = require('auto-ref');

class Service {
  constructor(repo, baz) { // eslint-disable-line no-unused-vars
    autoRef(this, arguments);
  }
}

// or, with the third options arg

class Service {
  constructor() {
    autoRef(this, arguments, { names: ['repo', 'baz'] });
  }
}


const service = new Service('foo', 'bar');

console.log(service.repo); // => 'foo'
console.log(service.baz); // => 'bar'

License

Apache-2.0 © Ben Lugavere

About

License:MIT License


Languages

Language:JavaScript 100.0%