Fork me on GitHub

Experimental ES.next transpiler

Try using <|, .{, and super.

These utility functions are used in the translated version:

 1     if (!Object.getOwnPropertyDescriptors) {
 2         Object.getOwnPropertyDescriptors = function (obj) {
 3             var descriptors = {};
 4             Object.getOwnPropertyNames(obj).forEach(function (prop) {
 5                 descriptors[prop] = Object.getOwnPropertyDescriptor(obj, prop);
 6                 });
 7             return descriptors;
 8         };
 9     }
10     var __DMP__ = "__DEFMETHPROP__";
11     Object.defineMethod = function (obj, name, method) {
12         if (__DMP__ in method) {
13             var proto = Object.getPrototypeOf(obj);
14             obj[name] = method[__DMP__](proto);
15         } else {
16             obj[name] = method;
17         }
18         return obj;
19     };
20 
21     function __extend (a, b) {
22         return Object.defineProperties(a, Object.getOwnPropertyDescriptors(b));
23     }
24     function __prototypeForObject (proto, obj) {
25         return Object.create(proto, Object.getOwnPropertyDescriptors(obj));
26     }
27     function __prototypeForFunction (proto, obj) {
28         obj.__proto__ = proto;
29         obj.prototype = {
30             __proto__: proto.prototype,
31             constructor: obj
32         };
33         return obj;
34     }
35     function __get (sup, prop, that) {
36         var desc = Object.getOwnPropertyDescriptor(sup, prop);
37         return desc.get ?
38             desc.get.call(that) :
39             desc.value;
40     }
41     function __set (sup, prop, that, val) {
42         var desc = Object.getOwnPropertyDescriptor(sup, prop);
43         return desc.get ?
44             desc.set.call(that, val) :
45             that[prop] = val;
46     }
47     function __prototypeForLiteral (proto, obj) {
48         obj.__proto__ = proto;
49         return obj;
50     }
51 

There's also a command-line version:

npm install reflect-next

Use:

reflect-next examples/person.js