Js2Py icon indicating copy to clipboard operation
Js2Py copied to clipboard

Add partial support for ES6 Arrow function

Open worstperson opened this issue 3 years ago • 0 comments

This seems to work with all my tests, but does not follow spec. Has the properties of a function rather than an Arrow function.

The code I want to run looks something like this:

import js2py
context = js2py.EvalJs()

def String_prototype_includes(searchString, position = 0):
    this.cok()
    S = this.to_string().value
    searchStr = searchString.to_string().value
    pos = position.to_int()
    if S[pos:pos+len(S)].find(searchStr.lower()) != -1:
        return this.Js(True)
    return this.Js(False)
context.String.prototype.includes = String_prototype_includes

context.execute(r'''
const words = 'dead|beef'.split('|');
var sentence = ' This is a test'
let containsWord = words.some(word => sentence.toLowerCase().includes(word));
''')

worstperson avatar Apr 17 '22 02:04 worstperson