A tiny (265 byte) utility to create state machine components using two pure functions.
The API is a single function that accepts 2 pure functions as arguments:
| ''' | |
| The MIT License (MIT) | |
| Copyright (c) 2013 Krishna Bharadwaj <krishna@krishnabharadwaj.info> | |
| Permission is hereby granted, free of charge, to any person obtaining a copy | |
| of this software and associated documentation files (the "Software"), to deal | |
| in the Software without restriction, including without limitation the rights | |
| to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
| copies of the Software, and to permit persons to whom the Software is |
| #if TARGET_OS_IPHONE | |
| #import <MobileCoreServices/MobileCoreServices.h> | |
| #else | |
| #import <CoreServices/CoreServices.h> | |
| #endif | |
| /* | |
| MIME type to UTI | |
| */ | |
| NSURLResponse *response = ... // assume a URL response from somewhere else. |
| import {stopEvent, hoistStatics} from 'util' | |
| let Types= React.PropTypes, | |
| _globalContainer= null | |
| export const PopoverSupport= Wrapped => { | |
| class PopoverSupport extends React.Component { | |
| // static propTypes= Wrapped.propTypes // Won't this be nice? |
| import React, { Component } from 'react' | |
| class ScrollPosition extends Component { | |
| state = { | |
| top: 0, | |
| left: 0 | |
| } | |
| render() { | |
| const child = this.props.children(this.state) |
| import { Component } from 'react' | |
| import { createStore, combineReducers } from 'redux' | |
| import parseLinkHeader from 'parse-link-header' | |
| const START = 'start' | |
| const SUCCEED = 'succeed' | |
| const ERROR = 'error' | |
| const inflight = (state={}, action) => ( | |
| ((state) => ( |
| import React, { Component } from 'react' | |
| import { View, Image, StyleSheet, ScrollView, Text, Animated, StatusBar, PixelRatio } from 'react-native' | |
| import Icon from 'react-native-vector-icons/MaterialIcons'; | |
| import MapView from 'react-native-maps'; | |
| const AMSTERDAM = { | |
| latitude: 52.3702, | |
| longitude: 4.8952, | |
| latitudeDelta: 0.0922, | |
| longitudeDelta: 0.0421, |
| /* | |
| This streams a CPU-side "shader" function into a really huge PNG image. | |
| */ | |
| const PNGEncoder = require('png-stream/encoder'); | |
| const fs = require('fs'); | |
| const path = require('path'); | |
| const Readable = require('readable-stream').Readable; | |
| const vec2 = require('gl-vec2'); | |
| const smoothstep = require('smoothstep'); |
A tiny (265 byte) utility to create state machine components using two pure functions.
The API is a single function that accepts 2 pure functions as arguments:
| /* | |
| Copy this into the console of any web page that is interactive and doesn't | |
| do hard reloads. You will hear your DOM changes as different pitches of | |
| honks. | |
| I have found this interesting for debugging, but also fun to hear web pages | |
| render like geese. | |
| */ | |
| const audioCtx = new (window.AudioContext || window.webkitAudioContext)(); | |
| const url = 'https://firebasestorage.googleapis.com/v0/b/mutation-honk.appspot.com/o/Honk1.mp3?alt=media'; |