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 🙏

© 2024 – Pkg Stats / Ryan Hefner

aggr

v0.0.2

Published

Object aggregation for node

Downloads

5

Readme

Aggr

Build Status

Object aggregation for node! This lib will essentially combine objects so long as they are overlapping within a single process tick.

Usage

var aggr = require('aggr')

aggr(namespace, data, [options], callback)

  • namespace - String namespace to prevent collisions
  • data - Data to aggregate, default type is object unless custom iterator is used
  • options - Change the default behavior of aggr (optional)
  • callback - Invoked when aggregation is completed

options

  • extra - custom callback to use in place of all callbacks after the first (default, false)
  • noop - ignore all callbacks after the first (default, false)
  • iterator - custom function to deal with each data aggregation (default, extend)
  • duration - set a time duration for when to stop aggregating (default, 0)
  • debounce - if using duration, set to reset the timer each call (default, false)

iterator

If using a custom iterator, note that the very first argument will be undefined. The default iterator is an object extend function, and it is assumed that objects are being passed in unless this option is set.

var ns = 'adding'

function add(a, b) {
  // First execution, `a` === `undefined`
  return (a || 0) + b
}

// This will be called 3 times with the final `total`
function done(total) {
  // total === `10`
}

var opt = {iterator: add}

aggr(ns, 4, opt, done)
aggr(ns, 5, opt, done)
aggr(ns, 1, opt, done)

extra and noop (no operation)

Sometimes only a single callback is needed, you can enable this behavior by passing in noop in the options, or an extra function to handle this.

var ns = 'no-operations'
  , opt = {noop: true}

// This function will only be called once
function done(all) {
  // all === {one: 1, two: 2, three: 3}
}
aggr(ns, {one: 1}, opt, done)   // Uses the callback
aggr(ns, {two: 2}, opt, done)   // No operation callback
aggr(ns, {three: 3}, opt, done) // No operation callback

Example

var ns = 'test'

// This will be called 4 times, one for each aggr call
function done(obj) {
  // combined data sent to callback
  // obj === {a: 'a', b: 'b', c: 10}
}
aggr(ns, {a: 'a'}, done)
aggr(ns, {b: 'b'}, done)
aggr(ns, {c: 'c'}, done)
aggr(ns, {c: 10}, done)

Install

With npm

npm install aggr

License

(The MIT License)

Copyright (c) 2013 Beau Sorensen [email protected]

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.