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
export default class Deferred<T> { | |
promise: Promise<T> | |
resolve: (value?: T | PromiseLike<T>) => void | |
reject: (reason?: any) => void | |
constructor() { | |
this.resolve = () => {} | |
this.reject = () => {} | |
this.promise = new Promise<T>((resolve, reject) => { | |
this.reject = reject; |
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 ( | |
"fmt" | |
"sync" | |
) | |
type Fetcher interface { | |
// Fetch returns the body of URL and | |
// a slice of URLs found on that page. |
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 ( | |
"fmt" | |
"golang.org/x/tour/tree" | |
) | |
//type Tree struct { | |
// Left *Tree | |
// Value int |
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
/// <reference types="node" /> | |
declare module 'through2-spy' { | |
import stream = require('stream'); | |
function through2_spy(transform?: SpyFunction): stream.Transform; | |
type SpyFunction = (this: stream.Transform, chunk: any) => void; | |
export = through2_spy; |
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 ( | |
"io" | |
"os" | |
"strings" | |
) | |
type rot13Reader struct { | |
r io.Reader |
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 ( | |
"io" | |
"os" | |
"strings" | |
) | |
type rot13Reader struct { | |
r io.Reader |
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
import "strings" | |
func WordCount(s string) map[string]int { | |
counts := make(map[string]int) | |
words := strings.Fields(s) | |
for _, word := range words { | |
count, ok := counts[word] | |
if ok { | |
counts[word] = count + 1 | |
} else { |
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
import { Dispatch } from 'redux' | |
type ErrorAction = { payload: Error } | |
function isErrorAction(action: any): action is ErrorAction { | |
return (<ErrorAction>action).payload instanceof Error | |
} | |
const errorLoggerMiddleware = (store: any) => (next: Dispatch) => ( | |
action: any |