Prototype Support
Any chance prototype support will be added?
Hello there. I'm not sure what do you mean by that.
What is it supposed to do and it's not doing?
I have a class with prototype inheritance and anything within the prototype does now show up in the browser. I discovered I can use object.(prototype) and it will show that particular prototype object.
Under chrome dev tools the object would show up as:
- object
- key: value
- prototype
- key: value
Under node-codein it looks like this:
- object
- key: value
Yes, I see what you mean. I'll add support for that in the next few days.
Thanks.
Its a small fix but its working as expected. It does not show prototypes down the chain, which would be awesome, but it is showing them on the directly called object.
// EXECUTE COMMANDS
execute: function(q,s){
var post = '';
q.on('data', function(c){ post+=c; });
q.on('end', function(){
post = require('querystring').parse(post);
if(typeof(post.command)==='string'){
var r = {error:false};
try{
r.fnprefix = fnprefix;
- r.cnt = eval.apply(global, [post.command]);
+ var obj = {}
+ obj = eval.apply(global, [post.command]);
+ obj.prototype = eval('global.' + post.command + '.constructor.prototype');
+ r.cnt = obj;
r.type = (typeof(r.cnt)==='object' && r.cnt!==null) ?
get_constr(r.cnt) :
typeof(r.cnt);
}catch(e){ r.error=e.toString(); }
s.end(jsencr(r));
} else if(typeof(post.getsug)==='string'){
try{ var r = jsencr(dbg.getsug(JSON.parse(post.getsug))); }
catch(e){ var r = "[]"; }
s.writeHead(200, {'Content-type': dbg.mimes['txt'], 'Content-length': r.length});
s.end(r);
}else{
return dbg.serve500(s,'Command was not found');
}
});
},
Thanks for the effort.
Don't worry about it, I'll have to add a button for it anyway. The only take is that I'm on vacation, so I can't really test anything right now.
Sorry for the long wait, I saw what you did there, looks like that's not the way to do it.
Your implementation throws lots of TypeError: Cannot read property 'constructor' of undefined errors on the basic stuff.
My implementation (with regular type checking) doesn't work because the whole thing is being circular.
try{
r.fnprefix = fnprefix;
r.cnt = eval.apply(global, [post.command]);
// prototype
if(typeof(r.cnt)==='object' && r.cnt!==null &&
typeof(r.cnt.constructor)!='undefined' && typeof(r.cnt.constructor.prototype)!='undefined'
){
r.cnt._prototype = r.cnt.constructor.prototype;
}
r.type = (typeof(r.cnt)==='object' && r.cnt!==null) ?
get_constr(r.cnt) :
typeof(r.cnt);
}catch(e){ r.error=e.toString(); }
This one also doesn't work because prototype members don't seem to be enumerable (?)
try{
r.fnprefix = fnprefix;
r.cnt = eval.apply(global, [post.command]);
// prototype
if(typeof(r.cnt)==='object' && r.cnt!==null &&
typeof(r.cnt.constructor)!='undefined' && typeof(r.cnt.constructor.prototype)!='undefined'
){
r.cnt._prototype = {};
for(var i in r.cnt.constructor.prototype)
r.cnt._prototype[i] = r.cnt.constructor.prototype[i];
}
r.type = (typeof(r.cnt)==='object' && r.cnt!==null) ?
get_constr(r.cnt) :
typeof(r.cnt);
}catch(e){ r.error=e.toString(); }
Do you have any ideas?