npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

object-bound

v0.7.2

Published

Object.prototype.bound - Bind functions to objects with pleasure.

Readme

object-bound

npm version Build Status Code Climate Test Coverage devDependencies Status js-standard-style

Convenient replacement for Function.prototype.bind

TL;DR

Replace this

wow.much.dots.so.fancy.very.suit.bind(wow.much.dots.so.fancy.very);
wow.much.dots.so.fancy.very.suit.bind(wow.much.dots.so.fancy.very, '!');
var cached = wow.much.dots.so.fancy.very.suit.bind(wow.much.dots.so.fancy.very);

With this

wow.much.dots.so.fancy.very.bound('suit');
wow.much.dots.so.fancy.very.bound('suit', '!');
wow.much.dots.so.fancy.very.bound.suit;

Usage

Binding

Let's make a bound suit()

var wow = { much: { dots: { so: { fancy: { very: {
  suit: function(suffix) {
    console.log(this.msg + (suffix || ''));
  },
  msg: 'Many compliments'
}}}}}};

To print the following

'Many compliments!'

Function.prototype.bind

var boundSuit = wow.much.dots.so.fancy.very.suit.bind(wow.much.dots.so.fancy.very, '!');
boundSuit(); // 'Many compliments!'

object-bound/function.js

Has all Function.prototype.bind features and a nicer syntax.

var boundSuit = wow.much.dots.so.fancy.very.bound('suit', '!');
boundSuit(); // 'Many compliments!'

object-bound/property.js

Cached function binding. Clears cache on demand. No arguments binding.

var boundSuit = wow.much.dots.so.fancy.very.bound.suit;
boundSuit('!'); // 'Many compliments!'

object-bound/proxy.js

NOTE: Depends on ES6 Proxy, but works for non enumerable functions, unlike object-bound/property.js.

Cached function binding. Clears cache on demand. No arguments binding.

var boundSuit = wow.much.dots.so.fancy.very.bound.suit;
boundSuit('!'); // 'Many compliments!'

Caching

Both property.js and proxy.js cache bound functions and can clear cache on demand.

With caching there is no need to store a reference to the bound function anymore.

var boundSuit1 = wow.much.dots.so.fancy.very.bound.suit;
var boundSuit2 = wow.much.dots.so.fancy.very.bound.suit;

// references the same function, always using .bound.suit gives the same result
boundSuit1 === boundSuit2; // true

Clear cache

Use .bound.bound to get the new cached bound function.

var oldSuit = wow.much.dots.so.fancy.very.bound.suit;

// .bound.bound clears the cache and returns new bound function
var newSuite = wow.much.dots.so.fancy.very.bound.bound.suit;
oldSuit === boundSuit; // false

// references the same function again
newSuite === wow.much.dots.so.fancy.very.bound.suit; // true

Typical property/proxy use case

Cached bound functions simplify working with event listeners.

class Greeter {
  constructor(el) {
    this.el = el;
    this.msg = 'Hi!';
    // no need to store the reference to 'this.bound.hi' somewhere
    this.el.addEventListener('click', this.bound.hi);
  }
  off() {
    // remove event listener using the same 'this.bound.hi'
    this.el.removeEventListener('click', this.bound.hi);
  }
  hi() {
    console.log(this.msg);
  }
}

// get 'Hi!' on each click on the element :)
var greeter = new Greeter(element);

// stop getting 'Hi!' on each click on the element
greeter.off();