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

data-bind-mapper

v1.0.3

Published

Bind data arrays to any type of JS objects

Readme

data-bind-mapper

NPM package Build Size NPM Downloads

A class to perform data joins with any type of JavaScript objects. Useful in digest cycles where it's important to minimize changes to a view for performance reasons, such as DOM manipulation. The module binds data points to objects via internal maps, and performs diffing comparisons across multiple iterations to ensure objects are not created or removed unnecessarily, thus keeping view changes to a minimum.

Quick start

import DataBindMapper from 'data-bind-mapper';

or using a script tag

<script src="//cdn.jsdelivr.net/npm/data-bind-mapper"></script>

then

const myData = [{ id: 0, val: 2 }, { id: 1, val: 4 }, { id: 2, val: 7 }];
const myView = new Set();

new DataBindMapper()
  .onCreateObj(() => {
    const obj = {};
    myView.add(obj);
    return obj;
  })
  .onUpdateObj((obj, d) => { obj.double = d.val * 2 })
  .onRemoveObj(obj => myView.delete(obj))
  .digest(myData);

API reference

Initialisation

new DataBindMapper()

Methods

| Method | Description | |-------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | getObj(datum) | Returns the object associated with this data element, or undefined if not found. | | getData(obj) | Returns the data element associated with this object, or undefined if not found. | | entries() | Returns all the data elements and associated objects, formatted as an array of tuples. | | id(str or fn) | Data element accessor function or attribute for the id to use when indexing the data. Should refer to a property unique to the data element. | | onCreateObj(fn(datum)) | The method to create an entering view object for a new data element that does not yet have a corresponding object. The data element is passed as single argument: d => { ... }. The method should return a new object. | | onUpdateObj(fn(obj, datum)) | The method to update an existing bound object with new data. The object and the data element are passed as arguments: (obj, d) => { ... }. This method is also called for entering objects after onCreateObj. | | onRemoveObj(fn(obj, id)) | The method to handle exiting objects which no longer have a corresponding data element. The unbound object and the lost data id are passed as arguments: (obj, id) => { ... }. | | digest(data) | Receives a new array of data which is diffed with the existing one and invokes onCreateObj, onUpdateObj and onRemoveObj as needed. | | clear() | Removes all registered data and objects. Equivalent to doing .digest([]). |