Changes and new features of Node v8.0.0
-
We can now use the latest version of npm v5.0.0 with Node v8.0.0
-
--saveis no longer necessary. All installs will be saved by default. You can prevent saving with--no-save. -
Existing npm caches will no longer be used: you will have to redownload any cached packages. There is no tool or intention to reuse old caches
Get more detail
-
Allow native addons (modules) to be compiled once on a system and used across multiple versions of Node.js.
-
We now easier to maintain modules, no need to upgrade or recompile for every major Node.js release by using an ABI layer in Javascript VMs.
async_hooksis now in nodejs core, we can use by require it :
const async_hook = require('async_hooks');
- This allows developers a means of monitoring the operation of the Node.js event loop, tracking asynchronous requests and handles through their complete lifecycle
- The new URL implementation is now a fully supported, example :
const myURL = new URL('/foo', 'https://example.org/');
// https://example.org/foo
- API available in modern Web Browsers like Chrome, Firefox, Edge, and Safari, allowing code using URLs to be shared across environments.
- Using old version of
Buffer(num)will initialized memory and might have significant impact on performance
// Old version
const safeBuffer1 = Buffer.alloc(10);
const safeBuffer2 = new Buffer(10);
- New version of
Buffer(num)will allocate Buffer instances with uninitialized memory, sample :
// New version in Node.js 8
const unsafeBuffer = Buffer.allocUnsafe(10);
- Node.js 8.0.0 includes a new
util.promisify()API that allows standard Node.js callback style APIs to be wrapped in a function that returns a Promise. An example use ofutil.promisify()is shown below.
const fs = require('fs');
const util = require('util');
const readfile = util.promisify(fs.readFile);
readfile('/some/file')
.then((data) => { /** ... **/ })
.catch((err) => { /** ... **/ });
For more changes and features in Node v8.0.0