1.0.0 • Published 7 years ago

to-method v1.0.0

Weekly downloads
2
License
MIT
Repository
github
Last release
7 years ago

to-method

Convert c-like functions to class methods.

travis codecov

to-method lets you bind c-like functions to classes. By c-like I mean functions that always take the target data structure as the first argument.

Install

npm install --save to-method

Usage

import toMethod from 'to-method'

function love(person1, person2) {
  console.log(`${person1.name} ❤ ${person2.name}`)
}

class Person {
  constructor(name) {
    this.name = name
  }
}
toMethod(Person, { love })

const me = new Person('I')
const sarra = new Person('Sarra')
me.love(sarra)
// => I ❤ Sarra

License

MIT © Nicolas Gryman