Questions tagged [ecmascript-harmony]

ECMAScript Harmony is the code name for proposals aiming to extend the current ECMA-262 specification.

ECMAScript Harmony is the code name for proposals aiming to extend the current ECMA-262 specification and to form the new . It names the agreed design trajectory of post-ES5 editions. It will include syntactic extensions, but the changes will be more modest than ECMAScript 4 in both semantic and syntactic innovation.

Packages, namespaces, and early binding from ECMAScript 4 are no longer included for planned releases, and don't live under the roof of Harmony.

References

  1. ECMAScript - Wikipedia
  2. ECMAScriptHarmony - ECMAScript.org
239 questions
18
votes
1 answer

What does star (*) mean in JavaScript function definition in Koa framework?

I have been familiarising myself with Koa (http://koajs.com/). Many of the examples include star character in place of function name. For instance in the hello world example there is: var koa = require('koa'); var app = koa(); app.use(function…
jsalonen
  • 29,593
  • 15
  • 91
  • 109
17
votes
2 answers

SyntaxError: Unexpected Identifier (Generators in ES6)

I came up with this simple experiment after reading the documentation on generators from MDN: var nodes = { type: 'root', value: [ { type: 'char', value: 'a' }, { type: 'char', value: 'b' }, { type: 'char', value: 'c'…
Alix Axel
  • 151,645
  • 95
  • 393
  • 500
17
votes
2 answers

exception handling with generators

So recently generators kicked in in NodeJS and I'm able to do something like: Promise.coroutine(function *(query){ var handle = yield db.connect(Settings.connectionString); //async, returns promise var result = yield db.query(query); //…
Benjamin Gruenbaum
  • 270,886
  • 87
  • 504
  • 504
16
votes
4 answers

Find all classes in a Javascript application that extend a base class

I have code like this class Animal{} class Dog extends Animal {} class Cat extends Animal {} class Donkey extends Animal {} I want to look at all of the classes in my application's universe, and when I find one that descends from Animal, I want to…
obenjiro
  • 3,665
  • 7
  • 44
  • 82
16
votes
1 answer

Creating a regular weak-reference in Javascript using WeakMaps

I am trying to do the obvious thing with WeakMaps: I want to create a weak reference. In particular, I want to have a list of event-listeners without that list influencing the life of the listener. So I was very excited to find WeakMaps, until I…
16
votes
4 answers

Garbage-collected cache via Javascript WeakMaps

I want to cache large objects in JavaScript. These objects are retrieved by key, and it makes sense to cache them. But they won't fit in memory all at once, so I want them to be garbage collected if needed - the GC obviously knows better. It is…
16
votes
5 answers

Implementing monads in JavaScript

Now that node.js supports ECMAScript Harmony generators we can write monadic code succinctly ala do blocks in Haskell: function monad(unit, bind) { return function (f) { return function () { var g = f.apply(this,…
Aadit M Shah
  • 72,912
  • 30
  • 168
  • 299
15
votes
1 answer

TypeError: redeclaration of let error in Firebug console if running ES6 code

I am learning ES6, so bear me please. Following is the code which is running fine, if I click the Run button one time, but on second hit it starts showing TypeError: redeclaration of let myArr error. Let me know about this weird (may be not)…
Nesh
  • 2,389
  • 7
  • 33
  • 54
15
votes
2 answers

Splitting up class definition in ES 6 / Harmony

Suppose I have a class in one big file like this: export default class { constructor () {} methodA () {} methodB () {} methodC () {} } And I want to break up the class definition so that methodA, methodB, and methodC are each defined in…
0x8890
  • 515
  • 1
  • 4
  • 12
15
votes
3 answers

node.js / ES6 / class creation : SyntaxError: Unexpected reserved word

I try to create a class on my node.js / express app. It works in basic js / prototype mode such as : function MyClass() { /* constructor code */ }; MyClass.prototype.myMethod = function() { /* method code */ }; module.exports =…
ceadreak
  • 1,662
  • 2
  • 18
  • 27
15
votes
2 answers

NodeJS harmony gives SyntaxError on import

I was testing node with ES6 with the flag child_process --harmony but it fails at first step when I import. Any ideas? import {'spawn'} from child_process; console.log(spawn); And i run: node --harmony test.js And I get: :1 (function (exports,…
piggyback
  • 9,034
  • 13
  • 51
  • 80
15
votes
2 answers

Is there a list of flags for Node.js?

I'm trying to find a list of all flags that Node.js accepts, specially those for ES6-Harmony features, but I can't find any. Is there anything like this?
juandopazo
  • 6,283
  • 2
  • 26
  • 29
14
votes
1 answer

how to start global npm module with harmony flag

I wrote a npm module which can be installed globally dm-npm. I like to use co in that module. How can i told the module that it runs with the harmony flag when started globally? Here is the package.json: { "name": "dm-npm", "version": "0.0.3", …
divramod
  • 1,454
  • 2
  • 20
  • 35
14
votes
2 answers

Arrow functions not working in node --harmony under Ubuntu

I'm trying to use arrow functions in node v0.10.33 under Ubuntu 14.04 (I'm running node with --harmony flag), but I'm getting this error: console.log( [1,2,3,4].map(x => x*x) ); ^ SyntaxError: Unexpected token > at…
Adrian Baran
  • 885
  • 7
  • 23
14
votes
2 answers

What's the JavaScript equivalent of Ruby's splat operator?

In Ruby, you can use the splat (*) operator to capture a variable number of arguments to a function, or to send the contents of an array to a function as an argument, like so: def example(arg1, *more_args) puts "Argument 1: #{arg1.inspect}" puts…
Ajedi32
  • 45,670
  • 22
  • 127
  • 172
1 2
3
15 16