MCPcopy Create free account
hub / github.com/Distributive-Network/PythonMonkey / new

Function new

python/pythonmonkey/helpers.py:26–43  ·  view source on GitHub ↗

new function - emits function which wraps JS new operator, emitting a lambda which constructs a new JS object upon invocation.

(ctor)

Source from the content-addressed store, hash-verified

24
25
26def new(ctor):
27 """
28 new function - emits function which wraps JS new operator, emitting a lambda which constructs a new
29 JS object upon invocation.
30 """
31 if (typeof(ctor) == 'string'):
32 ctor = pm.eval(ctor)
33
34 newCtor = pm.eval("""'use strict'; (
35function pmNewFactory(ctor)
36{
37 return function newCtor(args) {
38 args = Array.from(args || []);
39 return new ctor(...args);
40 };
41}
42 )""", evalOpts)(ctor)
43 return (lambda *args: newCtor(list(args)))
44
45
46def simpleUncaughtExceptionHandler(loop, context):

Callers

nothing calls this directly

Calls 1

typeofFunction · 0.85

Tested by

no test coverage detected