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