Skip to content

Instantly share code, notes, and snippets.

View lucacasonato's full-sized avatar
🖥️
Programming

Luca Casonato lucacasonato

🖥️
Programming
View GitHub Profile
@lucacasonato
lucacasonato / README.md
Created July 18, 2020 12:34
Run oak in a worker

deno run -A --unstable ./main.ts

@lucacasonato
lucacasonato / deno.ts
Last active June 2, 2020 20:09
Read text from body
import { serve } from "https://deno.land/std@0.55.0/http/server.ts";
const s = serve({ port: 8000 });
console.log("http://localhost:8000/");
const decoder = new TextDecoder();
for await (const req of s) {
const body = await Deno.readAll(req.body);
const str = decoder.decode(body);
console.log(`Body: ${str}`);
req.respond({ body: str });
}
function decorate(target: any) {}
@decorate
class Foo {}
Deno.utime();
@lucacasonato
lucacasonato / deno_doc_polyfill.ts
Last active April 15, 2020 17:41
Deno.doc pollyfill
export enum DocNodeKind {
Function = "function",
Variable = "variable",
Class = "class",
Enum = "enum",
Interface = "interface",
TypeAlias = "typeAlias",
Namespace = "namespace",
}
export interface DocNodeLocation {
export function example(param?: string) {
return "test";
}
export function greeter(name?: string) {
console.log("Hello" + (name ? " " + name : "") + "!");
}
const test = "hello";
export { test };
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
/// <reference no-default-lib="true" />
/// <reference lib="esnext" />
export namespace Deno {
/** The current process id of the runtime. */
export let pid: number;
/** Reflects the NO_COLOR environment variable.
@lucacasonato
lucacasonato / code.js
Created April 1, 2020 19:38
Issue with large amounts of piped data in Deno.run
const proc = Deno.run({
cmd: ["deno", "doc", "lib.deno.d.ts", "--json", "--reload"],
stdout: "piped",
stderr: "piped"
});
const status = await proc.status();
await Deno.copy(Deno.stdout, proc.stdout)