deno

Getting values from Deno stdin

佐手、 提交于 2020-01-16 03:57:36
问题 My question is really short, How can we get values from standard input ? I don't know how to use Deno.stdin ? An example would be appreciated. Thanks, 回答1: Deno.stdin is of type File, thus you can read from it by providing a Uint8Array as buffer and call Deno.stdin.read(buf) window.onload = async function main() { const buf = new Uint8Array(1024); /* Reading into `buf` from start. * buf.subarray(0, n) is the read result. * If n is instead Deno.EOF, then it means that stdin is closed. */ const

How can I add eventListner and attribute to HTML element in Deno

孤街醉人 提交于 2020-01-05 04:11:07
问题 I've the below code with Deno runtime, which is displating a button at the website: How can I change the attributes of this button How can I add eventListner for this button import { serve } from "https://deno.land/std@v0.24.0/http/server.ts" async function main() { const body = new TextEncoder().encode(`<button>click me</button>\n`); const s = serve({ port: 8000 }); console.log(`Server had been started at: http://localhost:8000/`); for await (const req of s) { req.respond({ body }); } };

deno vs ts-node : what's the difference

会有一股神秘感。 提交于 2019-12-30 00:58:49
问题 I'm working on a relative large typescript project, I'm using ts-node to run node testing and examples. As far as I understand, ts-node will compile ts files to js files and execute. Recently I heard about deno , which is a typescript runtime. I tried a few examples in typescript, which works using ts-node . I ran the example with deno , there were many compile messages printed in the console, then execute the code. And later I found there's cache files in /username/.deno . I don't feel the

Deno原理详解,让我们一起从源码分析开始

北慕城南 提交于 2019-11-30 12:34:26
Node之父ry:在“Node中的设计错误”演讲中表示: 不允许将任意本地函数绑定至 V8 当中。 所有系统调用都将通过消息传递完成(protobuf 序列化)。 两项原生函数:send 与 recv。 这既简化了设计流程,又使得系统更易于审计。 这几点很大程度上体现出了node和deno在设计本质上的区别,同时这几点体现了deno的安全性(利用 JavaScript 本身即为安全沙箱这一事实) V8worker2是Go和V8连接的桥梁 允许从GO程序执行JavaScript 只允许GO和V8之间的消息传递(传统:暴露C++函数作为函数在JavaScript。) 维护一个安全的JS沙箱 JS中只允许绑定3个函数:send(), recv(), print() 从图中可以清晰的看出,V8worker2是v8和Go之间实现调用的核心组件 可以看出V8worker2 是通过binding C++ 模块进行绑定V8,bingding暴露了基础操作方法:v8_init() 、worker_load()、worker_send_bytes()、worker_dispose()...提供给GO 进行调用 //binding.h const char* worker_version(); void worker_set_flags(int* argc, char** argv); void v8