Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Which harmony flag for default parameters in nodejs v4

I'm using node.js v4.0.0 and am trying to get some code working without the need of transpiling it first. While most is working, I can't use

import

which might be because of the not finalized stage, but I also can't find a flag that enables it. I've tried all of them:

--harmony_modules (enable "harmony modules" (in progress))
  --harmony_array_includes (enable "harmony Array.prototype.includes" (in progress))
  --harmony_regexps (enable "harmony regular expression extensions" (in progress))
  --harmony_proxies (enable "harmony proxies" (in progress))
  --harmony_sloppy (enable "harmony features in sloppy mode" (in progress))
  --harmony_unicode_regexps (enable "harmony unicode regexps" (in progress))
  --harmony_reflect (enable "harmony Reflect API" (in progress))
  --harmony_destructuring (enable "harmony destructuring" (in progress))
  --harmony_sharedarraybuffer (enable "harmony sharedarraybuffer" (in progress))
  --harmony_atomics (enable "harmony atomics" (in progress))
  --harmony_new_target (enable "harmony new.target" (in progress))

(useless to say that I didn't use regexps for it... :))

While I get the reason for import, I don't see why default parameters are failing as they seem to be finalized and I can't find a flag which seems to handle it.

Is there a flag for import and default parameters?

The code that doesn't work is

class foo extends bar {
    constructor(options = {})
    ....
}

error is

unexpected = illegal token

like image 289
baao Avatar asked Sep 12 '15 18:09

baao


2 Answers

Node 4 uses the version of V8 that shipped with Chrome 45 - and V8 v4.5.103.3 doesn't ship with default arguments, even behind a flag. Default arguments landed in the version of V8 that shipped with Chrome 49 and will be in Node 6+.

like image 124
Sean Vieira Avatar answered Oct 20 '22 00:10

Sean Vieira


the flag is : --harmony_default_parameters

like image 37
Elior Cohen Avatar answered Oct 20 '22 01:10

Elior Cohen