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

@gjmcn/xset

v0.1.0

Published

Subclass of JavaScript's built-in Set with extra methods.

Downloads

1

Readme

xset

Subclass of JavaScript's built-in Set with extra methods.

Usage:

Install:

install --save @gjmcn/xset

The module has a single named export: XSet.

Methods

Use any Set methods as well as:

| Method | Description | Return | |:---|:---|:---| | copy() | Shallow copy. xs.copy() is equivalent to new XSet(xs). | xset | | adds(iterable) | Add each element of iterable to the xset. | xset | | deletes(iterable) | Delete each element of iterable from the xset. | xset | | filter(f, returnArray) | Each element is passed to the function f; if f returns a truthy value, the element is included in the result. If returnArray is truthy, filter returns a new array, otherwise returns a new xset. | xset orarray | | map(f, returnArray) | Each element is passed to the function f; the returned values are collected in a new array (if returnArray is truthy) or a new xset. | xset orarray | | count(f) | Each element is passed to the function f; count returns the number of times that f returns a truthy value. | number | | find(f) | Each element is passed to the function f; the first time f returns a truthy value, the corresponding element is returned. find returns undefined if no element produces a truthy value. | any | | every(f) | Each element is passed to the function f; if f returns a truthy value every time, every returns true — and returns false otherwise. | boolean | | some(f) | Each element is passed to the function f; the first time f returns a truthy value, some returns true. If f returns a falsy value every time, some returns false. | boolean | | first() | First element of the set, or undefined if the set is empty. | any | | difference(iterable1, iterable2, ...) | Returns a new xset containing every element in the calling xset that is not in any of the passed iterables. | xset | | intersection(iterable1, iterable2, ...) | Returns a new xset containing every element that appears in the calling xset and all of the passed iterables. The order of elements in the returned xset matches their order in the calling xset. | xset | | union(iterable1, iterable2, ...) | Returns a new xset containing every element that appears in the calling xset or any of the passed iterables. The order of elements in the returned xset is based on their first occurrence in the calling xset and iterables. | xset |

Example

const s = new XSet([3, 4, 5]);   // XSet {3, 4, 5}
s.add(10);                       // XSet {3, 4, 5, 10}
s.adds([20, 30]);                // XSet {3, 4, 5, 10, 20, 30}

s.filter(e => e < 15);           // new Xset {3, 4, 5, 10}
s.intersection([0, 5, 10, 15]);  // new XSet {5, 10}