create account

The inside scoop on Node.js 9 by calastinone

View this thread on: hive.blogpeakd.comecency.com
· @calastinone ·
$0.02
The inside scoop on Node.js 9
First off just want to mention that Node.js 8.9.0 will have long term support under code name Carbon, this support will be maintained until 12-31-19. They have scheduled this to coordinate with OpenSSL-1.0.2.

Here is the link to the Node.js releases regarding all the repositories:  [Node.js Releases](https://github.com/nodejs/Release)

### Diving into Node.js 9

**HTTP/2**
HTTP2 began in Node.js 8.4 if you are unfamiliar with HTTP/2 here are some resources I recommend you take a look at:
* [HTTP/2 by EITF](https://http2.github.io/)
* [Intro to HTTP/2](https://developers.google.com/web/fundamentals/performance/http2/)
* [Rules to follow regarding HTTP/2](https://docs.google.com/document/d/1K0NykTXBbbbTlv60t5MyJvXjqKGsCVNYHyLEXIxYMv0/edit)

**You can start using the HTTP2 core Module:**
![Screen Shot 2017-11-12 at 4.21.18 PM.png](https://steemitimages.com/DQmQToddkx1z82k8kw6car9y3nknKiMesnGJyHVPnU6CEsG/Screen%20Shot%202017-11-12%20at%204.21.18%20PM.png)

In order to use the code above you have to generate a private key & certificate:
1. run cmd: *openssl req -newkey rsa:2048 -new -nodes -x509 -days 3650 -keyout key.pem -out cert.pem*
2. enter *localhost* for common name when it prompts you.

If you need some reference regarding Node.js HTTP/2 check out their documentation here:
[Node.js HTTP/2 documentation](https://nodejs.org/api/http2.html)

### Deep strict equal helper exposed in *util*
This method has been used since version 1.2.0, this was used for test purposes. It will throw if values don't match. The organization decided to expose this function because users modules needed this functionality. You can now use *util.isDeepStrictEqual(value1, value2)* methods to compare values:
![Screen Shot 2017-11-12 at 4.29.03 PM.png](https://steemitimages.com/DQmdmBALYDkeRBWTC1FLPtjPjM9xYKAWVmBrULMPacxVEpR/Screen%20Shot%202017-11-12%20at%204.29.03%20PM.png)

### callbackify added to *util*
*util.promisify* was added back in Node.js 8; because of incompatibility issues a method to convert promises to an error-first, callback taking function.
![Screen Shot 2017-11-12 at 4.31.23 PM.png](https://steemitimages.com/DQmeJsiMUvuRXZpdciVrDueNDX4BWWsXUaQHSPnpafQfxzo/Screen%20Shot%202017-11-12%20at%204.31.23%20PM.png)

### Static error codes
Static error codes have started to appear recently in Node.js core. This was used to solve the problem of string comparisons when there was a throw. It would have appeared like this:
![Screen Shot 2017-11-12 at 4.33.09 PM.png](https://steemitimages.com/DQmTJanXniy3AgQ44RtGRyraYxvSmkmMYw4qP7LQpFQmx2u/Screen%20Shot%202017-11-12%20at%204.33.09%20PM.png)

Even if you tried to fix a typo this would still cause a semVer major change. If you follow the paper trail it just gets worse as you fix the miss leading errors. Node.js has integrated static error codes to address this concern.

The code above could have been written like this instead:
![Screen Shot 2017-11-12 at 4.35.23 PM.png]
(https://steemitimages.com/DQmQY8S46ZRXD83e9CzgjsscboBrZAqUcWfSsrXvZ26BA15/Screen%20Shot%202017-11-12%20at%204.35.23%20PM.png)

### Two-Factor Authentication for npm
The new Node.js 9 comes with npm 5.5.1 this includes the two-factor auth. It is recommended if you are writing to enable this feature.
👍  , , , , , , , ,
properties (23)
authorcalastinone
permlinkthe-inside-scoop-on-node-js-9
categorynodejs9
json_metadata{"tags":["nodejs9","node9","js9","inside","scoop"],"image":["https://steemitimages.com/DQmQToddkx1z82k8kw6car9y3nknKiMesnGJyHVPnU6CEsG/Screen%20Shot%202017-11-12%20at%204.21.18%20PM.png","https://steemitimages.com/DQmdmBALYDkeRBWTC1FLPtjPjM9xYKAWVmBrULMPacxVEpR/Screen%20Shot%202017-11-12%20at%204.29.03%20PM.png","https://steemitimages.com/DQmeJsiMUvuRXZpdciVrDueNDX4BWWsXUaQHSPnpafQfxzo/Screen%20Shot%202017-11-12%20at%204.31.23%20PM.png","https://steemitimages.com/DQmTJanXniy3AgQ44RtGRyraYxvSmkmMYw4qP7LQpFQmx2u/Screen%20Shot%202017-11-12%20at%204.33.09%20PM.png","https://steemitimages.com/DQmQY8S46ZRXD83e9CzgjsscboBrZAqUcWfSsrXvZ26BA15/Screen%20Shot%202017-11-12%20at%204.35.23%20PM.png"],"links":["https://github.com/nodejs/Release","https://http2.github.io/","https://developers.google.com/web/fundamentals/performance/http2/","https://docs.google.com/document/d/1K0NykTXBbbbTlv60t5MyJvXjqKGsCVNYHyLEXIxYMv0/edit","https://nodejs.org/api/http2.html"],"app":"steemit/0.1","format":"markdown"}
created2017-11-12 22:37:57
last_update2017-11-12 22:37:57
depth0
children0
last_payout2017-11-19 22:37:57
cashout_time1969-12-31 23:59:59
total_payout_value0.024 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length3,249
author_reputation361,979,984,354
root_title"The inside scoop on Node.js 9"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id20,191,746
net_rshares12,348,950,992
author_curate_reward""
vote details (9)