utilizes.bind

Bind all methods of the given object to the object

Usage no npm install needed!

<script type="module">
  import utilizesBind from 'https://cdn.skypack.dev/utilizes.bind';
</script>

README

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.