1.0.3 • Published 4 years ago

bind-root v1.0.3

Weekly downloads
15
License
MIT
Repository
github
Last release
4 years ago

bind-root

bind a single js object to all underlying functions


Why on earth would you use this?

So all functions from within an object have the same this variable, allowing you to use exactly the same code throughout the object to perform some action.


Install

npm install --save bind-root

Usage

const bindRoot = require('bind-root');

// Define placeholder api object
const yourApi = {
  v1: {
    account: {
      get: function(id) {
        // Your code here
      },
      me: function() {
        return this.account.get(null);
      },
    },
  },
};

// Bind all functions to the root api
bindRoot(yourApi.v1);
1.0.3

4 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago

0.0.9

5 years ago

0.0.8

5 years ago

0.0.7

5 years ago

0.0.6

5 years ago

0.0.5

5 years ago

0.0.4

5 years ago

0.0.3

5 years ago

0.0.2

5 years ago

0.0.1

5 years ago