Example doesn't run, unfamiliar syntax
dskvr opened this issue · comments
Never seen the syntax var {foo}
before, does this library require precompiler? When removing this unfamiliar syntax, more issues arise at the promises Response => ...
. I am certainly not a nodejs expert, so I did quite a bit of research before reaching out, but could find nothing relevant to these pattern decisions.
Really curious about this syntax and why it was used.
Thank you for any information you can provide.
npm ERR! Linux 3.13.0-77-generic
npm ERR! argv "/usr/bin/node" "/usr/bin/npm" "bugs" "steem-rpc"
npm ERR! node v0.12.15
npm ERR! npm v2.15.1
npm ERR! path xdg-open
npm ERR! code ENOENT
npm ERR! errno ENOENT
npm ERR! syscall spawn xdg-open
> steem-rpc@0.5.2 example /home/vagrant/node_modules/steem-rpc
> node ./examples/example.js
/home/vagrant/node_modules/steem-rpc/examples/example.js:7
const {Client} = require("../src/index");
^
SyntaxError: Unexpected token {
at exports.runInThisContext (vm.js:73:16)
at Module._compile (module.js:443:25)
at Object.Module._extensions..js (module.js:478:10)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)
at Function.Module.runMain (module.js:501:10)
at startup (node.js:129:16)
at node.js:814:3
This is ES6 destructuring syntax, it requires Node >= v6. If you're using an older version you will need to use the --harmony flag. To rewrite it in ES5 you simply do var Client = require("../src/index).Client;
The =>
is called an arrow function and is another ES6 feature.
I had a feeling it had to do with versioning. Thanks for the lesson, looking forward to researching ES6!