V8 javascript 引擎中的 http 函数
我想独立使用 V8 javascript 引擎,例如,我将按照此处的说明在命令行中运行它< /a>:
$> ./v8-shell -e 'print("10*10 = " + 10*10)'
我希望 javascript 执行一些 http 请求,最好使用 jQuery API,但 XMLHttpRequest 也可以。
V8中有没有内置方法可以做到这一点?如果没有,有什么方法可以在不实现访问器/cpp 扩展的情况下实现它?
I want to use the V8 javascript engine standalone, e.g. I will run it in command line as explained here:
gt; ./v8-shell -e 'print("10*10 = " + 10*10)'
I want the javascript to perform some http requests, preferably using jQuery APIs but XMLHttpRequest is also ok.
Is there any built in method in V8 to do this? If not is there any way to achieve it without implementing accessors/cpp extensions?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
不是直接在 V8 中,但是有 NodeJS 添加了网络和文件系统功能,以及其他功能。
从文档中窃取一个示例:
Not in V8 directly, but there is NodeJS that adds network and file system functionality, among other features.
To steal an example from the documentation:
V8 只是一个 JavaScript 引擎,它没有像 Alert 这样的浏览器宿主方法或像 XMLHttpRequest 这样的宿主对象。
V8 is just a javascript engine, it doesn't have browser host methods like alert or host objects like XMLHttpRequest.
这是一个很好的例子:当您使用 Node 的 vm.createContext() 方法时,基本上是直接绑定到 V8 功能,这就是全局上下文的内容:
它甚至没有 set/clearTimeout、set/ clearInternal(不是本机 javascript 函数)。 JavaScript 作为一种语言,其关注点比大多数人意识到的要紧密得多。它始终存在于在其上添加更多内容的主机环境中。
Here's a good example: when you use Node's
vm.createContext()
method, basically a direct binding to V8 functionality, here's what that global context has:It doesn't even have set/clearTimeout, set/clearInternal (not native javascript functions). JavaScript as a language is much more tightly focused than most realize. It always exists in a host environment that adds more stuff on top.