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 { scaleNames, TemperatureInput, BoilingVerdict } from "./presentation.jsx" | |
import { chan, putAsync } from "js-csp" | |
import { RenderProcess } from "upcoming-react-csp-framework" | |
let NA = Symbol("empty") | |
function sanitize(input) { | |
let parsed = parseFloat(input), invalid = Number.isNaN(parsed) && NA | |
return { input, parsed, invalid } | |
} |
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 { scaleNames, TemperatureInput, BoilingVerdict } from './presentation.jsx' | |
function toCelsius(fahrenheit) { | |
return (fahrenheit - 32) * 5 / 9 | |
} | |
function toFahrenheit(celsius) { | |
return (celsius * 9 / 5) + 32 | |
} |
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
export const scaleNames = { c: 'Celsius', f: 'Fahrenheit' } | |
export class TemperatureInput extends React.Component { | |
constructor(props) { | |
super(props); | |
this.handleChange = this.handleChange.bind(this); | |
} | |
handleChange(e) { | |
this.props.onChange(e.target.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
.markdown-here-wrapper { | |
font-size: 16px; | |
line-height: 1.8em; | |
letter-spacing: 0.1em; | |
} | |
pre, code { | |
font-size: 14px; | |
font-family: Roboto, 'Courier New', Consolas, Inconsolata, Courier, monospace; |
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
C:\Users\Ankit\Documents\code\js-csp>npm run build | |
> [email protected] build C:\Users\Ankit\Documents\code\js-csp | |
> npm run build:node && npm run build:es && npm run build:browser | |
> [email protected] build:node C:\Users\Ankit\Documents\code\js-csp | |
> node -e "require('ncp').ncp('./src', './lib')" && cross-env BABEL_ENV=production npm run babel:node | |
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
let next = it => v => it.next(v).value | |
function* mult(t) { | |
let acc = 0 | |
while (true) yield acc = acc + t | |
} | |
function* cell(value) { | |
value = yield (<th key={value}>{value}</th>) | |
while (true) value = yield (<td key={value}>{value}</td>) |
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
let TH = ({value}) => <th >{value}</th> | |
let TD = ({value}) => <td>{value}</td> | |
let Row = ({update, children}) => <tr onClick={update}>{children}</tr> | |
class Printer extends React.Component { | |
constructor(props) { | |
super(props) | |
this.state = {acc: []} | |
this.update = this.update.bind(this) | |
this.mult = this.mult.bind(this) |
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
let csp = require('js-csp') | |
let START, SHOULD_END, END | |
const app = () => { | |
START = +(new Date); | |
const ch = csp.chan(); | |
csp.go(function* () { | |
yield csp.timeout(1000); | |
yield csp.put(ch, 42); | |
}); |
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 {Component, PropTypes} from 'react' | |
import {beginPolling, putter, endPolling, endPollingAll, tryCloseAll} from './csp-utils' | |
const goPropKey = '$green' | |
let _isGreen = ctx => (props = ctx.props) => props[goPropKey] && ctx === props[goPropKey] | |
let _go = (outlet, mapper) => { | |
let put = putter(outlet) | |
return props => put(mapper(props, props[goPropKey])()) | |
} |
NewerOlder