A simple module for helping you write debugger outputs. Makes debug outputs look neat and organized.
Copy and paste the index.ts
file to some debug.ts
file.
import createDebugger from './debug';
export type Links = { [key: string]: Link }; | |
export type StatusCode = | |
| "400" | |
| "401" | |
| "402" | |
| "403" | |
| "404" | |
| "405" | |
| "406" |
const path = require("path"); | |
module.exports = { | |
entry: "./src/index.js", | |
output: { | |
path: path.resolve(__dirname, "dist"), | |
filename: "bundle.js", | |
libraryTarget: "commonjs", | |
}, | |
devtool: "source-map", |
/** | |
* This is a class that is analogous to the DOM's `EventTarget` API. | |
* | |
* It is the class for adding event listeners, and emitting events. | |
* | |
* Usage: | |
* | |
* const emitter = new EventEmitter() | |
* | |
* emitter.addEventListener('foo', (value) => { |
This was my attempt at implementing the TC39's observable proposal.
Unfortunately, way too many tests fail.
If you want, you can give it a try to have all the tests pass.
// If I don't care about the status code | |
function fetchJSON(...params) { | |
return fetch(...params).then(res => res.json()); | |
} | |
// If I do care about the status code, but don't care about the type of error. | |
async function fetchJSON(...params) { | |
const res = await fetch(...params); | |
if (res.status >= 400) { | |
throw new Error(res.statusText); |
A trie is a key-value pair data structure, that allows you to store a value, by associating it with some string value. If you happen to know what that string value is, then you can retrieve the original value associated with the string.
If the string value is not associated to any value, then a null is returned.
As opposed to an associative array, tries actually save memory, by not storing redundant character prefixes of strings.
import Trie from './trie';
package main | |
import ( | |
"bufio" | |
"errors" | |
"fmt" | |
"io" | |
"log" | |
"net" | |
"net/http" |