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

clctr

v0.0.2

Published

Event emitting collections with iterators (like Backbone.Collection).

Downloads

3

Readme

clctr

Event emitting collections with iterators (like Backbone.Collection).

Warning: Developer preview release. Lots of broken stuff, I'm sure.

contains(list, value):Boolean

Checks if collection contains value.

contains({a: 1, b: 2, c: 'bar'}, 2); // true
contains([1, 2, 3], 'foo');  // false

every(list, callback, [thisObj]):Boolean

Tests whether all values in the collection pass the test implemented by the provided callback.

var obj = {
    a: 1,
    b: 2,
    c: 3,
    d: 'string'
};
 
every(obj, isNumber); // false

filter(list, callback, [thisObj]):Object

Filter collection properties.

find(list, callback, [thisObj]):*

Loops through all the values in the collection and returns the first one that passes a truth test (callback).

Important: loop order over objects properties isn't guaranteed to be the same on all environments.

find({a: 'foo', b: 12}, isString); // 'foo'
find(['foo', 12], isNumber); // 12

forEach(list, callback, [thisObj])

Loop through all values of the collection.

map(list, callback, [thisObj]):Object

Returns a new collection where the properties values are the result of calling the callback for each property in the original collection.

max(list, [iterator]):*

Returns maximum value inside collection or use a custom iterator to define how items should be compared.

max({a: 100, b: 2, c: 1, d: 3, e: 200}); // 200
max(['foo', 'lorem', 'amet'], function(val){
    return val.length;
}); // 'lorem'

min(list, [iterator]):*

Returns minimum value inside collection or use a custom iterator to define how items should be compared.

min([10, 2, 7]); // 2
min({a: 'foo', b: 'lorem', c: 'amet'}, function(val){
    return val.length;
}); // 'foo'

pluck(list, propName):Array

Extract a list of property values.

var users = [
    {
        name : 'John',
        age : 21
    },
    {
        name : 'Jane',
        age : 27
    }
];
 
pluck(users, 'name'); // ["John", "Jane"]
pluck(users, 'age'); // [21, 27]
 
users = {
    first: {
        name : 'John',
        age : 21
    },
    second: {
        name : 'Mary',
        age : 25
    }
};
 
pluck(users, 'name'); // ['John', 'Mary']

reduce(list, callback, initial, [thisObj]):*

Apply a function against an accumulator and each value in the collection as to reduce it to a single value.

var obj = {a: 1, b: 2, c: 3, d: 4};
 
function sum(prev, cur, key, list) {
    return prev + cur;
}
 
reduce(obj, sum); // 10

reject(obj, callback, thisObj):Object

Returns a new object containing all properties where callback returns true, similar to Array/reject. It does not use properties from the object's prototype. Opposite of filter().

var obj = {a: 1, b: 2, c: 3, d: 4, e: 5};
reject(obj, function(x) { return (x % 2) !== 0; }); // {b: 2, d: 4}

size(list):Number

Returns the number of values in the collection.

var obj = {
    foo : 1,
    bar : 2,
    lorem : 3
};
size(obj);     // 3
size([1,2,3]); // 3
size(null);    // 0

some(list, callback, [thisObj]):Boolean

Tests whether any values in the collection pass the test implemented by the provided callback.

var obj = {
    a: 1,
    b: 2,
    c: 3,
    d: 'string'
};
 
some(obj, isNumber);      // true
some(obj, isString);      // true

Events

var co = require('./clctr.js');
var c = co();

c.on('set', function () { console.log([].slice.call(arguments)); });

c.set('bar', 'baz');
// [ { name: 'bar', value: 'baz', previousValue: undefined } ]