3 ms·
The only problem I see is the lack of a comprehensive standard library for Node.js.
by gtirloni 6y ago
The only problem I see is the lack of a comprehensive standard library for Node.js.
- captn3m0 6y agoRuby: x.is_a? Integer PHP: is_int($x) (alias of is_integer) Python: isinstance(x, int) Node.js[1]: typeof val === "number" && (!(typeof value !== 'number' || value !== value || value === Infinity || value === -Infinity)) && Math.floor(val) === val I think all supported Node.js versions now have Number.isInteger (via es262), but the is-integer package still gets a 200_000 downloads a week[2]. [1]: https://github.com/parshap/js-is-integer/blob/master/index.js#L4-L8 https://github.com/parshap/js-is-integer/blob/master/index.j... [2]: https://www.npmjs.com/package/is-integer https://www.npmjs.com/package/is-integer
- Xavdidtheshadow 6y agoThis actually taps into something I really like about npm. For things that "should be easy/obvious", there are usually edge cases, _especially_ around how `Object` is handled. The real answer is for Node to have built-ins that handle this (which they now do for `isInteger`, but absent that, I love that there are these specific packages that have unit tests and a simple API. People scoff at things at `isPromise`[1], but it's reliably filling a super important niche that the language doesn't handle. [1]: https://github.com/then/is-promise/blob/1d547300e780a4eca391236f15e5ccbf76a5789d/index.js https://github.com/then/is-promise/blob/1d547300e780a4eca391...
- captn3m0 6y agoMaybe we should adopt these packages into es262 and make the shims available by default directly with the language?
- deleted 6y ago[deleted]
- phiresky 6y agoYou could have found a better example. The package you referenced literally just does `Number.isInteger` unless you are on decade old versions of nodejs
- captn3m0 6y agoIt still gets downloaded and the code still runs. 200_000 times a week, irrespective of your node version. Even when the language migrates to a standard (NumberisInteger), the remaining ecosystem keeps depending on this package.
- tannhaeuser 6y agoThe Node.js core packages and eg express.js + middlewares on npmjs.com are the "standard library" for Node.js, developed cooperatively as part of the CommonJS effort back in 2010-12. Modular JSGI (connect/express) middlewares can target both Node.js' core http and express. Almost all modern asset management pipelines run on npm (webpack et al) anyway. What do you miss and where should this mythical "standard library" come from in your opinion?
- justinmeiners 6y agoThe node.js standard library is quite extensive, including networking, cryptography, OS access, etc. What more do you want from a standard lib?
- ByteJockey 6y agoI think a lot of people honestly don't know about them. I've met a lot of people (JS devs) who didn't know about fs, child_process, etc. Which is a shame. child_process + promises (and a couple of listeners) is really handy for orchestrating things in scripts. I don't really do much web dev these days, but JS is really convenient for these sorts of things. I still use it for a lot of scripts.
- CGamesPlay 6y agoWell from https://www.npmjs.com/browse/depended https://www.npmjs.com/browse/depended we can see a few candidates: - request, indicates that the built-in networking isn't working for everybody - moment, the JS nor Node have very comprehensive Date manipulation - express, again indicates that the built in networking library isn't working for everyone - fs-extra, literally filling the gaps in the built-in fs package - async, bluebird, these could easily be considered "standard library" material
- rodw 6y agoI don't know. While I commonly use several of these it feels like this easily bleeds into questions of subjective "taste" and domain-specific libraries. If you're not changing anything else about the management of these packages, what's the advantage of having request or express as part of the "standard" library? And if you are changing the management of these packages, then maybe that's the solution with or without expanding the core library? I think that Java for example has similar defacto-but-not-actual "standard libraries" that correspond to many of these domains. I'm not convinced that a larger "core" is addressing the root problem.
- justinmeiners 6y agoAll standard libraries get conveniences such as these built upon them. That is not the role of a standard lib, which is to provide a basic level of OS compatibly and some commonly useful data structures and utilities. The cost of standardization is rigidity, so they are typically kept thin. I happen to not like the design choices of many of those libraries you mentioned and choose to to use them. Express is an entire web framework. What other ecosystems have you used which would ship with these sorts of libraries?
- rglover 6y agoThis is why Deno is so promising.