Js2Py icon indicating copy to clipboard operation
Js2Py copied to clipboard

JsException: SyntaxError: Line 2: ObjectPattern is not supported by ECMA 5.1.

Open AbbeKamalov opened this issue 5 years ago • 1 comments

js = """
const { spawn } = require('child_process');

const ls = spawn('command', ['-m 117M g 'hello' -l 500'], {shell: true});

ls.stdout.on('data', data => {
    console.log(`stdout: ${data}`);
});

ls.stderr.on('data', data => {
    console.log(`stderr: ${data}`);
});

ls.on('error', (error) => {
    console.log(`error: ${error.message}`);
});

ls.on('close', code => {
    console.log(`child process exited with code ${code}`);
});
"""
import js2py
js2py.eval_js(js)


JsException: SyntaxError: Line 2: ObjectPattern is not supported by ECMA 5.1.

How can this be solved?

AbbeKamalov avatar Oct 30 '20 21:10 AbbeKamalov

You have to use Babel to support ECMA6; from the readme:

    >>> js2py.eval_js6('let a = () => 11; a()')
    11

worstperson avatar Oct 30 '20 21:10 worstperson