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
// 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 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
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 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
"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 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
// 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 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 {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 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
/** | |
* 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 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 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 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
/* | |
* 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 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
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 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 Expedite from './'; | |
const getTest = async (testContext) => ({true: true, test: 'Hello World', testContext}); // pretend async thing thats not really | |
const pretendCreatePromise = ({uuid, name}) => Promise.resolve({uuid, name}); | |
export default class Test extends Expedite { | |
// req: express request object | |
// context: dependency injection (added at class initialise to avoid singletons) | |
async get(req, context) { // magically wrapped in try catch in the middleware, checks for this.error then defaults back to the next item in express | |
const res = await getTest(context); // database or whatever promise |