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

collection-map-js

v1.0.1

Published

A Map with additional utility methods for significantly improved performance and ease-of-use.

Downloads

6

Readme

collection-map-js

A Map with additional utility methods for significantly improved performance and ease-of-use. Inspired by Discord.Js's collection, includes almost all of the function Discord.Js Collection (.reduce() is missing).

Help, Issued & Support

If you have encountered a bug with the library, open a pull request

Methods

The Collection extends Map. collection is reffered as const collection = new Collection(); where Collection is reffered as const Collection = require("collection-map-js").Collection;.

// [Parameter] means that that parameter is optional, do not include []'s.

collection.filter(function); // function takes in 'value'
collection.clone(); // returns an exact same copy of current collection
collection.first([count]); // returns first x or first value of the collection
collection.firstKey([count]); // returns first x or first key of the collection
collection.array(); // array of collection values
collection.last([count]); // returns last x or first value of the collection
collection.lastKey([count]); // returns last x or first key of the collection
collection.deleteAll(); // calls delete method on all items of the collection
collection.every(function); // returns boolean, true if every item of the collection makes function returns true, function takes in 'value'
collecton.equals(collection2); // return boolean, true if collection2 and collection have a 100% key-vaue pairs matching
collection.keyArray(); // array of collection keys
collection.map(); // equal to Array.map();
collection.partition(function); // returns array of 2 collections, first collection item that passed function and second collection items that failed function ([collection1, collection2] or [passed, failed]), function takes in value
collection.random([count]); // returns array of 'count' random values from the collection, there can (and will be) duplicates (regardless of array length but more likely count represents a big portion of collection's size)
collection.randomKeys([count]); // returns array of 'count' random keys from the collection, there can (and will be) duplicates (regardless of array length but more likely count represents a big portion of collection's size)
collection.some(function); // returns true if at least 1 element of collection passed function, function takes in value
collection.find(function); // filters the collection and returns the first item value passing function, function takes in value