to-method
v1.0.0
Published
Convert c-like functions to class methods.
Downloads
4
Maintainers
Readme
to-method
Convert c-like functions to class methods.
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