utilizes.bind

v1.2.1
Bind all methods of the given object to the object
bind util

bind

Bind all methods of the given object to the object

Usage: bind(this): this

import { bind } from 'utilizes.bind'

class CoolService {

  constructor() {
    bind(this) // binding this via utilizes.bind
  }

  count = 0

  increment() {
    this.count++
  }

}

const coolService = new CoolService()

const increment = coolService.increment

increment() // 'this.count++' point to coolService.count

console.log(coolService.count)
// Output: 1

This module exported from utilizes project.

npm i utilizes.bind

Metadata

  • MIT
  • Whatever
  • Natan Farkash
  • released 5/31/2021

Downloads

Maintainers