thread.js
function ConvertArgs(args, baseResponse) {
    var baseResponse = Object.assign({}, baseResponse);
    args.forEach(function(arg, i) {
        if (typeof(arg) == "object" && arg._classname == "SerializedFunction") {
            var idRemoteFunction = arg.id;
            args[i] = function() {
                process.send(Object.assign(baseResponse, {name: "thread-execute-remote-function", args: [{id: idRemoteFunction, args: SerializeForProcess(CopyArguments(arguments))}]}));
            };
        }
    });
    return args;
}
function ConvertArgs(args, baseResponse) {
    var baseResponse = Object.assign({}, baseResponse);
    args.forEach(function(arg, i) {
        if (typeof(arg) == "object" && arg._classname == "SerializedFunction") {
            var idRemoteFunction = arg.id;
            args[i] = function() {
                process.send(Object.assign(baseResponse, {name: "thread-execute-remote-function", args: [{id: idRemoteFunction, args: SerializeForProcess(CopyArguments(arguments))}]}));
            };
        }
    });
    return args;
}
function ConvertArgs ( args , baseResponse ) { var baseResponse = Object . assign ( { } , baseResponse ) ; args . forEach ( function ( arg , i ) { if ( typeof ( arg ) == "object" && arg . _classname == "SerializedFunction" ) { var idRemoteFunction = arg . id ; args [ i ] = function ( ) { process . send ( Object . assign ( baseResponse , { name : "thread-execute-remote-function" , args : [ { id : idRemoteFunction , args : SerializeForProcess ( CopyArguments ( arguments ) ) } ] } ) ) ; } ; } } ) ; return args ; }
Convert SerializedFunction objects to function, so when called
we execute the function in the original thread
Convert SerializedFunction objects to function so when called we execute the function in the original thread