Skip to content

I am writing a wrapper. But I have ERROR_ARG_1 #3

Description

@benzmuircroft

First, I found that in npm README.md you have a mistake

npm install threads_a_gogo

should be

npm install tagg2

you also have

require('threads_a_gogo'); // should be tagg2

secondly, I am trying to write a wrapper for tagg.create, but I keep getting the error

thread_obj.create first argument must be a run thread function or a  {poolsize:100, fastthread:false}

My wrapper is like this:

tagg.do=function(fun,args,callback){
    Function.prototype.getName=function(){return /function ([^(]*)/.exec( this+"" )[1];};
    args=JSON.stringify(args);
    this.create().eval(fun).eval((fun.getName()+'('+args+')'),callback);
    };

So I pass in the function as fun for the first eval, then I convert the args for the function to a string and get the function in the first eval as a string then combine the strings to execute in the second eval. the callback is simple...

Then I use it like this

function inAnotherThread(n){console.log('n='+n);}

tagg.do(inAnotherThread,1,function(){console.log('done!');});

Is the error talking about the first eval or the second?

I don't see why the typeof is wrong when:

function name(){console.log(1);}

function getTypeOf(fun){console.log(typeof fun);}

getTypeOf(name)

//result = function 

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions