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
var Benchmark = require('benchmark'); | |
var t = require('transducers.js'); | |
var Immutable = require('immutable'); | |
var suite = Benchmark.Suite('transducers'); | |
function benchArray(n) { | |
var arr = new Immutable.Range(0, n).toVector(); | |
var transform = t.compose( | |
t.map(function(x) { return x + 10; }), |
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
var Benchmark = require('benchmark'); | |
var t = require('transducers.js'); | |
var Immutable = require('immutable'); | |
var suite = Benchmark.Suite('transducers'); | |
function benchArray(n) { | |
var arr = new Immutable.Range(0, n).toVector(); | |
suite | |
.add('Immutable map/filter (' + n + ')', function() { |
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
class Geocoder{ | |
// google maps api key | |
String apiKey; | |
Geocoder(String apiKey){ | |
this.apiKey = apiKey; | |
} | |
double[] locate(String location){ |
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
var data = {...} | |
var react = React.renderComponentToString(<Component data={data} />); | |
writeToClient( | |
'<html><head><script src="myCompiledJS.js"></script></head>' + | |
'<body><div id="foo">' + react + '</div>' + | |
'<script>React.renderComponent('+ | |
'Component({data:'+ JSON.stringify(data) + '}), document.getElementById("foo")'+ | |
')</script>' + | |
'</body></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
function handleClick(element, event) { | |
if (event.button === 1) { | |
return { count: 0 }; | |
} | |
if (element.props.onClick) { | |
element.onClick(); | |
} | |
element.updateState(s => {...s, count: s.count + 1 }); | |
} |
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
var insertCSS = require('insert-css') | |
insertCSS('.foo { color: red; }') | |
var React = require('react/addons'); | |
var CSSCore = require('react/lib/CSSCore'); | |
window.r = React; | |
var Component = React.createFactory(React.createClass({ | |
render: function() { |
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 a trivial example of using Immutable structures as React state. | |
Note that replaceState() must be used instead of setState(), as setState expects | |
an object literal and will merge it (Object.assign) with the previous state. | |
replaceState() is a simple swap. | |
*/ |
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
beforeEach(function () { | |
this.addMatchers({ | |
is: function(expected) { | |
return Immutable.is(this.actual, expected); | |
} | |
}) | |
}) |
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
/* | |
At some point I connected Facebook friends to Amazon wishlists. Now I get | |
multiple emails from Amazon for the birthday of everyone I ever met. | |
Removing people from this list requires a bunch of manual clicking. | |
Automation FTW. | |
1) http://www.amazon.com/gp/registry?ie=UTF8&type=wishlist |
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 * as foo from "foo" | |
var $foo = require("foo"); | |
var foo = $foo; | |
import foo from "foo" | |
var $foo = require("foo"); | |
var foo = $foo.default; | |
import { foo } from "foo" | |
var $foo = require("foo"); |
OlderNewer