Re:NPM – "is-even", 160k weekly downloads
by beaconstudios on Tuesday November 16, 2021 @01:51PM
(#29244790)
Let me balance the chi by linking to a prolific open source contributor who makes actually-good repos: https://github.com/sindresorhus?tab=repositories&q=&type=&la...
[ Parent
| on HN ]
Re:NPM – "is-even", 160k weekly downloads
by avinassh on Tuesday November 16, 2021 @02:43PM
(#29245458)
umm... I just randomly checked and this person also seem to have packages which are of few lines. for e.g. I checked `is-fn`:
export default function isFunction(value) {
const type = Object.prototype.toString.call(value);
return type === '[object Function]' ||
type === '[object GeneratorFunction]' ||
type === '[object AsyncFunction]';
}
This has 120k weekly downloads: https://www.npmjs.com/package/is-fn
Re:NPM – "is-even", 160k weekly downloads
by beaconstudios on Tuesday November 16, 2021 @02:54PM
(#29245593)
It's a polyfill for a buggy function, so it's not just arbitrary.
Re:NPM – "is-even", 160k weekly downloads
by raverbashing on Wednesday November 17, 2021 @02:45AM
(#29250166)
The real question is why JS can't provide the answer to "isFunction" in a builtin method
Re:NPM – "is-even", 160k weekly downloads
by datagram on Wednesday November 17, 2021 @04:40PM
(#29259186)
It can: JavaScript has a `typeof` operator that can be used for this. If you read the readme for is-fn, it points out that the package is only useful for code that needs to run in certain older browsers that have a buggy implementation of `typeof`.