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 Immutable = require('devtools/client/shared/vendor/seamless-immutable'); | |
var gentest = require('devtools/client/shared/vendor/gentest'); | |
var types = gentest.types; | |
function maybe(type) { | |
return types.oneOf([type, types.constantly(null)]); | |
} | |
var foo = 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
/* | |
* Top-level error handler for async functions. | |
*/ | |
async function errorWrap(cb, ...args) { | |
try { | |
await cb(...args); | |
} catch(err) { | |
if (err.stack) { | |
// `Error` object | |
console.log(err.stack); |
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 React from 'react'; | |
export class Sto extends React.Component{ | |
static defaultProps = { | |
store: x => x | |
} | |
state = { | |
value: this.props.store() | |
} | |
dispatch = action => this.setState({ |
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
/** | |
* Basic proof of concept. | |
* - Hot reloadable | |
* - Stateless stores | |
* - Stores and action creators interoperable with Redux. | |
*/ | |
import React, { Component } from 'react'; | |
export default function dispatch(store, atom, action) { |
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 {Dis} from 'disto'; | |
import {photo} from 'disto/record'; | |
let {register, dispatch, lock, unlock} = new Dis(); | |
let store = photo(register({x: 0}, o => ({x: o.x+1}))); // simple increments | |
store.subscribe(o => console.log(o.x)); // 0 | |
let t1 = store.snapshot(); | |
dispatch('xyz'); // 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
// Simple wrapper to use bootstrap's grid system to position elements side-by-side | |
var VerticalFieldsElement = React.createClass({ | |
render: function() { | |
return dom.div( | |
{ className: 'clearfix' }, | |
React.Children.map(this.props.children, function(child) { | |
if(!child) { | |
return child; | |
} |
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 [BRA, KET, IDENT] = ['BRA', 'KET', 'IDENT']; | |
function last(arr){ return arr[arr.length -1] }; | |
export default function act(src, prefix){ | |
var tree = src.split('').reduce((tokens, char)=> { | |
if(char==='{'){ | |
tokens.push({type: BRA}); |
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 Chrome = require('chrome-remote-interface') | |
Chrome({ | |
chooseTab: function(tabs) { | |
var idx = 0 | |
tabs.forEach(function(tab, i) { | |
if (tab.url === 'http://localhost:9966/') | |
idx = i | |
}) | |
return idx |
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
// array utils | |
// ================================================================================================= | |
const combine = (...arrays) => [].concat(...arrays); | |
const compact = arr => arr.filter(Boolean); | |
const contains = (() => Array.prototype.includes | |
? (arr, value) => arr.includes(value) | |
: (arr, value) => arr.some(el => el === value) |
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
oia(lets [go chan put take timeout alts] (require 'js-csp/lib/csp') (do | |
(fn fake [kind] | |
(fn [c query] | |
(go (gen [] | |
(yield (take (timeout (js Math.random()*200)))) | |
(yield (put c [kind query])))))) | |
(def web1 (fake :web1)) | |
(def web2 (fake :web2)) |