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

is-this-a-pigeon

v0.8.0

Published

This project is just a template for creation of new projects

Downloads

334

Readme

Actions Status Actions Status Actions Status Test Coverage Maintainability Packages npm version

is-this-a-pigeson-logo

Just a project with some type guard functions to identify the type of an object not vanilla covered and some dummy functions for better readability and to use as some common callbacks

How to install

npm i is-this-a-pigeon

How to Use it

Just call the function you want, like this simple type guard:

function iterateIfYouCan(maybeAnIterable: unknown) {
  if (isIterable(maybeAnIterable)) {
    for (const item of maybeAnIterable) {
      console.log(item);
    }
  }
}

There you go. Inside the if, even maybeAnIterable not being typed as an iterable, you can safely iterate over it and TypeScript will not scream at you. This is a simple type guard for iterable. There is plenty of others type guards in this library, you may check it out.

We also have some dummy functions for use in simple callbacks for better readability. Examples:

 // identity returns the received argument. This filter will return an array excluding all the falsy elements
[0, 1, false, 'a', null, NaN, true].filter(identity);
 // greaterThan returns a functions that evaluates to true only when the argument is greater than the informed value
[1, 2, 3, 4, 5, 6].filter(greaterThan(3));
// Filters all values where property "a" is greater than 3. Directly passing as a parameter of filter or something similar, you have a strongly typed property key!
// Thanks to TypeScript contextual typing
[{ a: 1 }, { a: 2 }, { a: 3 }, { a: 4 }, { a: 5 }, { a: 6 }].filter(compareProp('a', greaterThan(3)));
// Filters all values where property "a" is truthy
[{ a: 0 }, { a: 1 }, { a: false }, { a: 'a' }, { a: null }, { a: NaN }, { a: true }].filter(prop('a'));

But why though?

The kind of function I made here is a repeating code for many projects I work with. So, I just wanted to group it in a single package with the best typing possible

License

Licensed under MIT.