denoはいいぞ2019
入れ方
code:bash
code:bashrc
export PATH=~/.deno/bin:${PATH}
確認
code:bash
$ deno -v
deno: 0.3.2
v8: 7.4.238
typescript: 3.2.1
書いてみる
code:ts
import open = Deno.open
const {copy} = Deno
async function main() {
const f = await open("README.md", "w")
await copy(f, new StringReader("Hello Deno!"))
f.close()
}
main()
型定義とtsconfig.jsonを作る
code:bash
$ deno types > deno.d.ts
code:tsconfig.json
{
"compilerOptions": {
"target": "esnext",
"module": "esnext",
"baseUrl": "/Users/keroxp/Library/Caches",
"paths": {
}
}
}
http server立ててみる
code:ts
async function main() {
listenAndServe(":8888", async req => {
await req.respond({
status: 200,
headers: new Headers({
"content-type": "text/plain"
}),
body: new TextEncoder().encode("hello deno!")
})
});
}
main();