|
|
|
|
|
by anonytrary
2805 days ago
|
|
> You can, for example, pass an object {string:booleanish} and it will add only the keys whose values are truthy. Why is this something you can't do on your own in a few lines of code? const classNames = (o, c=[]) => {
for (let k in o) if (o[k]) c.push(k) // booleanish
return c.join(" ")
}
This is not cool at all! Why import a trivial function over NPM to do this for you? Better to lower your dependency count and have a "util.js" file for helpers like this. |
|
The cost of using it is the same as locally, and creation cost is lower per-project if you let npm manage your own libs. Plus, bug fixes are automatically propagated.
[1] https://github.com/sindresorhus/ama/issues/10#issuecomment-1...
[2] https://github.com/franciscop/fetch