Skip to content

Instantly share code, notes, and snippets.

View bartlomieju's full-sized avatar
🦕

Bartek Iwańczuk bartlomieju

🦕
View GitHub Profile
@bartlomieju
bartlomieju / test.json
Created October 29, 2019 15:27
Named imports from JSON file
{
a: 123,
b: [ 1, 2, 3 ],
c: null
}

CLI things that should be resources:

  • global_timer
  • start_time
  • other timers
  • metrics? (it'd be nice if they were resources, but I fear it might be slow because of double lookup for each op)

Problems with refactor:

  • no way for full polymorphism Tried with StreamResource enum:
'use strict';
const buff = new Uint8Array(16384);
const encode = new TextEncoder().encode;
function sendRequest (conn) {
console.log("sending request");
conn.write(encode('GET / HTTP/1.1\nHost: example.com\n\n')).then(() => console.log("request sent"));
}
@bartlomieju
bartlomieju / .DS_Store
Last active August 9, 2019 17:14
Deno profiles
@bartlomieju
bartlomieju / deno_dir.rs
Created July 20, 2019 18:45
Futures recursion
/// Asynchronously fetch remote source file specified by the URL following redirects.
fn fetch_remote_source_async(
self: &Self,
module_url: &Url,
) -> Box<impl Future<Item = SourceFile, Error = ErrBox>> {
use crate::http_util::FetchOnceResult;
let download_job = self.progress.add("Download", &module_url.to_string());
let module_uri = url_into_uri(&module_url);