Stable Node v5 release


    Nodejs v5 was released last week. This branch includes a portion of new features and will be developed in parallel with the Node v4.x branch, which is a stable LTS branch with a long support period of 30 months. Node v5.x releases will be available once every 8 months.

    If you decide to upgrade to this version, then you should know that this will require rebuilding the installed third-party extensions, and there are also changes that violate backward compatibility. Keep this in mind.

    Details under the cut.

    So what's new:
    • The developers switched to a new version of the V8 engine: 4.6.85.25.
    • npm has been updated to version 3.3.6.
    • Added the ability to transfer file descriptors to fs.readFile * (), fs.writeFile * () and fs.appendFile * () function calls.
    • Console.time output format changed
    • Buffer types 'raw' and 'raws' removed in buffer object
    • Discontinued support for calls to require.paths, util.p (), util.inherits (), require.registerExtension ()
    • Stricter requirements for HTTP method names and headers
    • ALSN support added to tls module. Now the minimum DH key size for tls.connect () has been increased to 1024 bits.
    • Discontinued support for the _linklist module.

    The full list of changes can be found on the official blog at nodejs.org/en/blog/release/v5.0.0

    Support for new ES6 syntax instructions


    New.target support

    The new operator is now used not only to create new objects, but also to be able to control the created object and obtain information about the object. The new.target operator will return a reference to the constructor of the function when creating the object. in a normal function call, new.target returns undefined.

    Examples of using

    new.target in function calls

    function Foo() {
      if (!new.target) throw "Foo() must be called with new";
      console.log("Foo instantiated with new");
    }
    Foo(); // throws "Foo() must be called with new"
    new Foo(); // logs "Foo instantiated with new"
    


    new.target in constructors
    
    class A {
      constructor() {
        console.log(new.target.name);
      }
    }
    class B extends A { constructor() { super(); } }
    var a = new A(); // logs "A"
    var b = new B(); // logs "B"
    

    Spread operator support

    The Spread operator allows you to expand expressions in cases where multiple arguments are used, such as function calls or as array literals.

    When calling functions:
    f(...iterableObj);
    


    In array literals:
    [...iterableObj, 4, 5, 6]
    


    In case of destructive assignment:
    [a, b, ...iterableObj] = [1, 2, 3, 4, 5];
    


    Where can be used

    let arr1 = [0, 1, 2],
         arr2 = [3, 4, 5];
    //Раньше мы писали так
    Array.prototype.push.apply(arr1, arr2);
    //Теперь это же можно написать так
    arr1.push(...arr2);
    

    The developers already have plans to release a new version of Node v6, which is scheduled for April 2016. This version will already have to get the status of LTS.

    Also popular now: