如何确定v8中回调的源信息 [英] how to determine source information of callback in v8
本文介绍了如何确定v8中回调的源信息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是否可以确定v8中回调的源信息(文件,行号,列号)?
Is it possible to determine the source information (file, line number, column number) of a callback in v8?
function foo(callback) {
var x = callback();
if (typeof x !== "string") {
//hmmm, x is not as expected, I want to know more about the callback.
}
}
推荐答案
I 'm不知道你可以在JavaScript中这样做,但如果你可以调试它,它应该显示你的文件/行等。
I'm not aware that you can do this in JavaScript, but if you can debug it, it should show you the file/line etc..
我想这样做完全取决于您的设置,我从来没有做过 - 它看起来像节点(使用v8)有某种支持。
I guess doing that would depend exactly on your setup and I've never done it myself - it looks like node (uses v8) has some sort of support for that .
可能有用: v8 Debugger Protocol
这篇关于如何确定v8中回调的源信息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文