Live data from Hacker News

Show HN: SuperUtilsPlus – A Modern Alternative to Lodash

github.com

1–10 of 88 posts

Show HN: SuperUtilsPlus – A Modern Alternative to Lodash

#1
Hey HN!

After years of wrestling with Lodash's quirks and bundle size issues, I decided to build something better. SuperUtilsPlus is my attempt at creating the utility library I wish existed.

What makes it different?

TypeScript-first approach: Unlike Lodash's retrofitted types, I built this from the ground up with TypeScript. The type inference actually works the way you'd expect it to.

Sensible defaults: Some of Lodash's decisions always bugged me. Like isObject([]) returning true - arrays aren't objects in my mental model. Or isNumber(NaN) being true when NaN literally stands for "Not a Number". I fixed these footguns.

Modern JavaScript: Built for ES2020+ with proper ESM support. No more weird CommonJS/ESM dance. Actually tree-shakable: You can import from specific modules (super-utils/array, super-utils/object) for optimal bundling. Your users will thank you.

The best parts IMO:

compactNil() - removes only null/undefined, leaves falsy values like 0 and false alone

differenceDeep() - array difference with deep equality (surprisingly useful)

Better random utilities with randomUUID() and randomString()

debounce() that actually works how you expect with proper leading/trailing options

Also genuinely curious - what are your biggest pain points with utility libraries? Did I miss any must-have functions?

Show HN: SuperUtilsPlus – A Modern Alternative to Lodash
github.com

Re: Show HN: SuperUtilsPlus – A Modern Alternative to Lodash

#7
> Like isObject([]) returning true - arrays aren't objects in my mental model.

Correct me if I am wrong, but Array factually are JS objects and "[] instanceof Object" is true.

Fair enough if that does not fit your mental model, but I would not use any library that treats facts like opinions.

Re: Show HN: SuperUtilsPlus – A Modern Alternative to Lodash

#8
post #7

> Like isObject([]) returning true - arrays aren't objects in my mental model. Correct me if I am wrong, but Array factually are JS objects and "[] instanceof Object" is true. Fair enough if that does not fit your mental model, but I would not use any library that treats facts like opinions.

Distinction is tricky since you can use indexing on plain objects, e.g.

    const foo = {};
    foo[0] = "bar";

Re: Show HN: SuperUtilsPlus – A Modern Alternative to Lodash

#9
post #7

> Like isObject([]) returning true - arrays aren't objects in my mental model. Correct me if I am wrong, but Array factually are JS objects and "[] instanceof Object" is true. Fair enough if that does not fit your mental model, but I would not use any library that treats facts like opinions.

I agree with the author that it’s almost never what you want. But I agree with you that it’s the reality of the platform, ignoring it will cause its own problems.

I’d surface the footgun rather than trying to pretend it’s not there: isNonArrayObject and isObjectOrArray, or something like that

Re: Show HN: SuperUtilsPlus – A Modern Alternative to Lodash

#10
post #7

> Like isObject([]) returning true - arrays aren't objects in my mental model. Correct me if I am wrong, but Array factually are JS objects and "[] instanceof Object" is true. Fair enough if that does not fit your mental model, but I would not use any library that treats facts like opinions.

libraries of this sort, especially in JavaScript, often exist to enforce a more reasonable mental model rather than the model baked into the language.
Post reply on HN