View machine.js
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
function createApprovalMachine(context) { | |
return Machine({ | |
id: 'approval', | |
initial: 'initializing', | |
context, | |
states: { | |
initializing: { | |
on: { | |
'': [ |
View match.js
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
const invalidMatchSignal = new Error(); | |
function makeProxyThrower(input) { | |
return new Proxy(input, { | |
get(target, prop, receiver) { | |
if (prop in target) { | |
const result = Reflect.get(target, prop, receiver); | |
if (typeof result === "object" && result !== null) { | |
return makeProxyThrower(result); |
View demo.js
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
// @flow | |
const proxyCache = new WeakMap(); | |
const extensionMethods = new WeakMap(); | |
function extended<T>(instance: T): $Supertype<T> { | |
if (isPrimitive(instance)) { | |
return instance; | |
} | |
const existingProxy = proxyCache.get(instance); |
View constraints.js
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
// paste me into https://codemix.github.io/flow-runtime/#/try | |
// (no gist support yet :( ) | |
import t, {reify} from 'flow-runtime'; | |
type ValidURL = string; | |
(reify: ValidURL).addConstraint(url => { | |
if (/^(.|\/)/.test(url)) { | |
return "Don't use relative URLs for some reason"; |
View somefile.js
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
type Linkable = { | |
name: string, | |
profileURL: string | |
}; | |
function bigOldObject () { | |
return { | |
id: 1, | |
name: 'foo', | |
email: 'foo@bar.com', |
View react.js
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
// This is how the world looks at the moment | |
import {render} from 'react-dom'; | |
render( | |
<Router> | |
<Route path="/" component={HomeScreen} /> | |
</Router>, | |
document.getElementById('root') | |
); |
View index.html
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"/> | |
<title>Untitled benchmark</title> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/benchmark/1.0.0/benchmark.min.js"></script> | |
<script src="./suite.js"></script> | |
</head> | |
<body> | |
<h1>Open the console to view the results</h1> |
View index.html
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"/> | |
<title>Array#forEach</title> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/benchmark/1.0.0/benchmark.min.js"></script> | |
<script src="./suite.js"></script> | |
</head> | |
<body> | |
<h1>Open the console to view the results</h1> |
View input.js
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
function demo (input: Array<number>): Array<number> { | |
return function blah () { | |
return function foo () { | |
return input.map(item => item + 1).map(item => item + 2); | |
}; | |
}; | |
} |
View leaky-args.js
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'; | |
function leakyArgs (item) { | |
var args = Array.prototype.slice.call(arguments, 1); | |
var total = item; | |
for (var i = 0, length = args.length; i < length; i++) { | |
total += args[i] + (300 * 234 * 234234 * 235 * 23433); | |
} | |
return total; | |
} |
NewerOlder