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

objput

v0.1.2

Published

Put that value in that slot of that object, then call that callback.

Downloads

0

Readme

objput

Put that value in that slot of that object, then call that callback.

Usage

from test/usage.js:

var objPut = require('objput'), libTest = require('./lib_test'), myCb,
  counter = libTest.makePseudoAsyncCounter(), // -> counter(step, callback)
  results = { store: objPut.mthd },
  bad = new Error('Forgot my towel!'),
  test = libTest.accum(results);

// Basic use: destObj, destKey, value[, callback]
objPut(results, 'hello', 'world', function afterHello() {
  // update and verify our expectation:
  test.upd({ hello: 'world' });
  counter(0, objPut.cb(results, 'apple'));
  counter(2, objPut.cb(results, 'bacon'));
});
// check whether afterHello was called:
test.upd({ apple: 0, bacon: 2 });

// Easily create callbacks with .cb:
myCb = objPut.cb(results, 'cheese');
counter(3, myCb);
test.upd({ cheese: 5 });

// The "store" property from the object literal is a method:
myCb = results.store.bind(results, 'eggs');
results.store('dango', '🍡', function afterDango() {
  counter(5, myCb);
});
test.upd({ dango: '🍡', eggs: 10 });

// Using an Array as destKey spreads an Array-like value
// to assign multiple keys in destObj:
objPut(results,
  [ null, 'herbs',  'water',  'kettle', null,   'boil',   'tea' ],
  [ 101,  102,      103,      104,      105,    106   ]);
test.upd({ herbs: 102, water: 103, kettle: 104,
  // 105 was skipped because it had no target slot.
  boil: 106, tea: undefined });

// .args makes a callback that stores one of its arguments:
myCb = objPut.args(results, 'arg0', 0);
myCb('first', 'second', 'third');
test.upd({ arg0: 'first' });

myCb = objPut.args(results, 'arg2', 2, function followUp() {
  test.upd({ arg2: 'THIRD' });
  results.chainedCallback = 'supported';
});
myCb('FIRST', 'SECOND', 'THIRD');
test.upd({ chainedCallback: 'supported' });

// Set n=true to collect all arguments:
myCb = objPut.args(results, 'allArgs', true);
myCb('first', 'second', 'third');
test.upd({ allArgs: [ 'first', 'second', 'third' ] });

// To use one of the arguments as the callback, put its number…
function nextCallback() { results.nextCb = 'called'; }
myCb = objPut.args(results,
  [ 'hadError', 'data', null, 'fourth', 'fifth' ],  // spread the value
  true,   // use ALL arguments as value
  -1);    // use last argument as callback
myCb(null, 'foo',  '(ignored)',  nextCallback);
test.upd({ hadError: null, data: 'foo',
  // no slot for '(ignored)'
  fourth: nextCallback, fifth: undefined, nextCb: 'called' });

// … or "pop" or "shift" (useful for async.waterfall):
function popCallback() { results.popCb = 'popped'; }
myCb = objPut.args(results,
  [ 'hadError', null,     'data', 'fourth',   'fifth'  ], true, 'pop');
myCb(bad,       '(ign)',  'bar',  popCallback);
test.upd({ hadError: bad,  // .args doesn't assume error-first convention,
  data: 'bar',             // it just stores whatever is there.
  fourth: undefined, fifth: undefined, popCb: 'popped' });

function shiftCallback() { results.shiftCb = 'shifted'; }
myCb = objPut.args(results, 'allArgs', true, 'shift');
myCb(shiftCallback, 'not ignored', 'qux', popCallback);
test.upd({ shiftCb: 'shifted',
  allArgs: [ 'not ignored', 'qux', popCallback ] });

API

For more details, you'll have to look at the source for now.

Known issues

  • needs more/better tests and docs

 

License

ISC