go run main.go
# Result should be in example.wav.
#
# Listen to the result using whatever audio player that supports WAV
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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';
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"bufio" | |
"errors" | |
"fmt" | |
"io" | |
"log" | |
"net" | |
"net/http" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package lib | |
import ( | |
"encoding/json" | |
"reflect" | |
"strings" | |
) | |
// IsZeroer implement this if you want some special definition of "zero" | |
type IsZeroer interface { |