This file contains 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
main().catch(console.error); | |
async function main() { | |
const clicks = streamify(document, "click"); | |
let clickCount = 0; | |
for await (const event of clicks) { | |
console.log("click", event, clickCount); | |
if (clickCount++ > 2) { | |
clicks.return(); | |
} |
This file contains 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
main().catch(console.error); | |
async function main() { | |
const clicks = streamify(document, "click"); | |
let clickCount = 0; | |
for await (const event of clicks) { | |
console.log("click", event, clickCount); | |
if (clickCount++ > 2) { | |
clicks.return(); | |
} |
This file contains 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
#lang racket | |
(module+ test | |
(require rackunit)) | |
(define state-machine | |
'((init (c more)) | |
(more (a more) | |
(d more) | |
(r end)) |
This file contains 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
export default function trampoline (fn) { | |
return (...args) => { | |
let result = fn(...args); | |
while (result instanceof Function) { | |
result = result(); | |
} | |
return result; | |
}; | |
} |
This file contains 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
module ZipList exposing | |
( ZipList | |
, init, singleton | |
, toList, toSelectionList | |
, get, forward, back | |
, select | |
) | |
type ZipList a = |
This file contains 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
// Welcome! require() some modules from npm (like you were using browserify) | |
// and then hit Run Code to run your code on the right side. | |
// Modules get downloaded from browserify-cdn and bundled in your browser. | |
var escape = require('escape-string-regexp'); | |
var expr = '^https?://(www.)?example.com'; | |
var input = 'http://example.com'; | |
log(['w/o escape', expr, (new RegExp(expr, 'i')).test(input)]); | |
log(['w/ escape', escape(expr), (new RegExp(escape(expr), 'i')).test(input)]); |
This file contains 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
port module Main exposing (..) | |
import Html exposing (..) | |
import Html.App as App | |
import Html.Attributes exposing (class) | |
main = | |
App.program |
This file contains 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
import Html exposing (..) | |
import Html.App as App | |
import Html.Attributes exposing (..) | |
import Html.Events exposing (..) | |
import Json.Decode as Json | |
import String | |
main = | |
App.beginnerProgram |
This file contains 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
import Dict exposing (Dict) | |
import Html exposing (..) | |
import Html.App as App | |
import Html.Attributes exposing (..) | |
import Html.Events exposing (..) | |
import Json.Decode as Json | |
main = | |
App.beginnerProgram |
This file contains 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
'use strict'; | |
var hashpress = require('./hashpress'); | |
var obj = { | |
username: 'foo', | |
likes: ['cats', 'candy'], | |
quote: "I don't always program JavaScript...but when I do, I use Node.js" | |
}; |