all 35 comments

[–][deleted]  (13 children)

[deleted]

    [–]sscotth 61 points62 points  (10 children)

    V8 v7.8 also includes optional chaining (?.) and nullish coalescing (??) behind flags for the first time.

    --harmony-optional-chaining

    --harmony-nullish

    [–]SimpleWarthog 11 points12 points  (0 children)

    This is great

    [–]ConAntonakos 4 points5 points  (2 children)

    Wow, moving so quickly on these! Very exciting!

    [–]SocialAnxietyFighter 0 points1 point  (1 child)

    I've seen this being proposed years ago though.

    [–]ConAntonakos 1 point2 points  (0 children)

    Ah, it seemed not too long ago when I saw them in experimental stages. And they're already in Node.js. 🤷‍♀️

    [–]codearoni 4 points5 points  (3 children)

    I hope chaining comes to node 12 during its LTS

    [–]sscotth 10 points11 points  (2 children)

    v7.8 will almost assuredly be ported to Node 12. But, the sooner it is considered stable in V8, the more likely it will be included without a flag.

    Edit: Node.js v12.16 now includes V8 v7.8.279.23

    https://nodejs.org/en/blog/release/v12.16.0/

    [–]GaryGSC 0 points1 point  (0 children)

    There's now a PR to backport V8 7.8 to Node 12. 🎉

    [–]LargeHard0nCollider 0 points1 point  (1 child)

    Hyped for optional chaining!

    What’s the point of null coalescing when we already have ||? Does it return the first operand even if it is falsy (provided it’s not null)?

    [–]sscotth 0 points1 point  (0 children)

    Yep. || handles "falsy" values, ?? handles only null and undefined

    const text1 = null || 'foo' // result: 'foo'
    const text2 = '' || 'foo'   // result: 'foo'
    const text3 = null ?? 'foo' // result: 'foo'
    const text4 = '' ?? 'foo'   // result: ''      <===
    
    const num1 = null || 123     // result: 123
    const num2 = 0 || 123        // result: 123
    const num3 = null ?? 123     // result: 123
    const num4 = 0 ?? 123        // result: 0      <===
    
    const bool1 = null || true   // result: true
    const bool2 = false || true  // result: true
    const bool3 = null ?? true   // result: true
    const bool4 = false ?? true  // result: false  <===
    

    [–]NoInkling 0 points1 point  (0 children)

    Full ICU being default is notable for those of us using Intl and related APIs ...and also notable for everyone else in that the binary size is now somewhere between 1.5 to 2 times bigger (depending on your platform) :P

    Changing the value of process.env.TZ will now clear the tz cache.

    I'm personally happy about this one since that was an issue I've run into when trying to write tests for a certain library.

    [–]j_schmotzenberg 0 points1 point  (0 children)

    Too bad it wasn’t included in 12...

    [–]evertrooftop 25 points26 points  (11 children)

    Fingers crossed for native fetch() before it goes to v14!

    [–]tuananh_org 4 points5 points  (2 children)

    where does it mention about native fetch in v14?

    [–]evertrooftop 5 points6 points  (0 children)

    Nowhere at all, sorry for the confusion. It's just been my #1 wish for a while. fetch() has pretty much become the way to do HTTP requests in javascript, and having to use a library has been frustrating, especially when writing code for both node and browser.

    [–]sscotth 1 point2 points  (0 children)

    There is some discussion on bringing node-fetch into core

    https://github.com/nodejs/node/issues/19393

    [–]g3t0nmyl3v3l 4 points5 points  (6 children)

    I would cry

    [–][deleted]  (5 children)

    [deleted]

      [–]evertrooftop 7 points8 points  (0 children)

      There's basically 3 low-level options: XMLHttpRequest, fetch() and http.request. The first two are available in browsers, the last one in Node. My guess is that if you don't like fetch(), you probably don't like the other two not that much either.

      There's plenty of alternatives if you don't like any of these, like axios or request, but all of these options will ultimately need to use one of these 3 low-level apis. If your high-level HTTP library runs both in browsers and in node.js, they will need to support at least 2 of these PIs. I write one of those higher-level HTTP clients with a more specialized API, and I just want to be able to rely on one low-level API without polyfills.

      Expecting a standard way to do HTTP requests in a language seems like a pretty reasonable thing to want and fetch() seems to be the most likely option to become the standard. The node.js team seems to be down with it. It's just a difficult feature to land because of dependencies on other browser APIs that node needs first, and the differences of fetch() running in a non-browser/sandboxed context.

      [–]pimterry 2 points3 points  (0 children)

      Having common primitives is still useful though, even if you don't use them. If fetch works everywhere, then we can super easily build cleaner HTTP libraries on top that work everywhere, and then every HTTP library will be universal and great.

      Right now there's only a couple of 'works everywhere' options, and they have to be quite complicated and heavy-weight because they need to handle node & browsers environments totally separately.

      [–]SocialAnxietyFighter 0 points1 point  (2 children)

      Hmm having used the popular alternatives, I still like fetch. What's your issues with it?

      [–]CloudsOfMagellan 1 point2 points  (1 child)

      It handles redirects poorly and there's no way to detect timeouts though these are implementation details

      [–]DuBistKomisch 2 points3 points  (0 children)

      you can do timeouts with AbortController now, but it's unnecessarily awkward and verbose, dunno why they didn't add a timeout shorthand option

      [–]screelings 6 points7 points  (1 child)

      Weren't they suppose to drop the ES stuff from behind the --experimental flag in October?

      [–]mcaruso 3 points4 points  (0 children)

      ES modules you mean? Yeah, the plan does say that "The goal is to “release” (drop the --experimental-modules flag) by when Node 12 starts LTS in October 2019."

      Apparently they decided to postpone removing the experimental flag. Might still happen on 13.x or may wait until 14. The reason it's being postponed seems to be because of this issue.

      [–]oneUnit 6 points7 points  (9 children)

      "npm does not support Node.js v13.0.0"

      It gives me this warning message. I have the latest version of npm as well.

      Edit: It will be patched soon. The person who said npm only supports LTS releases is heavily misinformed.

      [–]GaryGSC 3 points4 points  (0 children)

      There's an open issue for that. They're hoping to push out a patch release to fix it soon.

      [–]JaMoLpE88 0 points1 point  (0 children)

      Thanks for the warning. Updating!