console.log("Wellcome to Deno");
$ deno run hello.ts
Wellcome to Deno
const url = Deno.args[0];
const res = await fetch(url);
const body = new Uint8Array(await res.arrayBuffer());
await Deno.stdout.write(body);
--allow-net
をつける。
$ deno run --allow-net http.ts https://deno.land/manual/getting_started/first_steps
console.log(Deno.args)
$ deno run args.ts 1 2 3
[ "1", "2", "3" ]
for (let i = 0; i < Deno.args.length; i++) {
let filename = Deno.args[i];
let file = await Deno.open(filename);
await Deno.copy(file, Deno.stdout);
file.close();
}
--allow-read
をつける。
$ deno run --allow-read read.ts args.ts
console.log(Deno.args);
const listener = Deno.listen({ port: 8080 });
console.log("listening on 0.0.0.0:8080");
for await (const conn of listener) {
Deno.copy(conn, conn);
}
$ deno run --allow-net server.ts