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

ithas

v0.6.0

Published

magical convenience for checking if any datatype has a value, key, or data in the datatype, or the key. Handles null, undefined, NaN, and every other edge case. Where lodash is too afraid to go, ithas is to the rescue!

Downloads

14

Readme

TL;DR

Where lodash is a huge box of bad-ass tools with great docs, ithas is a sharpened, surgical, sugary steel blade... only with terrible docs, endless 's' words , and way big fonts. But... like any powerful harlequin ninja, ithas, comes to you in a 3-pack of delciousnes magicalness:

Read more words!

ithas.data

format: ithas.data(anyDataType, path)

returns: boolean

tests ALL data types and as many keys deep as you wish (if checking object) to see if there is any data anywhere, in any of it. undefined, null, NaN, "", [], [""], {}, {key:null}, etc, etc, ad naeseum all return false. Good luck doing that on lodash lol. 49 cases covered by tests and more all the time. Fire and forget! Has a deep setting coming soon that is currently disabled for performance reasons.

ithas.data(0) == true
ithas.data("") == false
ithas.data([]) == false
ithas.data({} == false
ithas.data({key:null}) == false
ithas.data({key:0}) == true
ithas.data({key:null}, 'key') == false
ithas.data({key:undefined}, 'key') == false
ithas.data({key:NaN}, 'key') == false
... 49 tested cases and counting...

ithas.key

format: ithas.key(obj, path)

returns: boolean

WTF brah? Have you ever heard of lodash _.has? Yep. And it's mainly reliable. But, it evaluates false in scary places where things are wrapped that you don't know about (because they may call a toObject prototype behind the scenes to make it look and smell like an object, or JSON, but it's not!) Here's an example: if you try _.has against a mongoose document you just fetched, you will be suprised to see _.has declares that you have no keys! Boom! You just got lodashed in your balls!

Wait, wait, what about using _.get to check for undefined keys or values? Sure that works. What if the value is null? Nan? empty string? Empty array? Another nested key of emptiness? Sorry.


ithas.value

format: ithas.key(obj, path, value)

ithas.value(obj, path, value)

Pretty basic but pretty magic. Just pass it an object, a path as deep as you want in string format, and then value you want to evaluate for. Handle's all the weird cases of null, undefined, keys not there, wrapped crap, etc.

UPDATE: this is now just a sugary wrapper for lodash _.get(obj, path, val)

ps I apologize for my shitty code. I am currently busy levelling up.