View weil.js
export default iterator =>
function * (cursor) {
while(cursor = iterator(cursor))
cursor = yield(cursor)
}
}
View patchinko.js
export {patch, scope}
function patch(a, b){
for(var key in b)
if(b.hasOwnProperty(key))
a[key] = (
b[key] instanceof scope
? scope.apply(a[key])
: b[key]
)
View range_selection_caret.js
dom.focus()
const range = document.createRange()
range.setStart(selection.anchorNode.nextSibling.nextSibling, 0)
range.collapse(true)
selection.removeAllRanges()
selection.addRange(range)
View package.json
{
"scripts": {
"start": "server.js"
}
}
View Spanner.jsx
export default const Spanner = ({ children = '', split = /\b/ }) =>
<span className="spanner">
{[].concat(children).map(string =>
string.split(split).map(substring =>
<span className={/^\s*$/.test(substring) ? 'whitespace' : 'word'}>
{substring}
</span>
)
)}
</span>
View conditional_fragment.jsx
import React from 'react';
import Input from './Input.js';
const InputGroup = props => (
<div>
{props.inputHasLabel &&
<label
htmlFor={props.inputName}
className="label"
>
View unfuckReact.js
const mounted = new WeakSet()
export default const unfucker = (component, displayName = component.displayName || component.name || 'React.Component') => {
const host = {
[displayName] : class extends React.Component {
constructor(){
this.state = {}
component.apply(this, arguments)
}
View EventComponent.js
// EventComponents have a `handlers` hash which they can use to listen for DOM events on the document.
// These are bound and unbound safely to avoid lifecycle race condition exceptions.
export default class EventComponent extends React.Component {
componentDidMount() {
for(const key in this.events || {})
$(document).on(key, this.events[key])
}
componentWillUnmount() {
for(const key in this.events || {})
View patdj.js
function patdj(target, update, preserve = true) {
if (update.nodeType != 1 && update.nodeType == target.nodeType)
target.nodeValue = update.nodeValue
else if (update.nodeType != target.nodeType || update.tagName !== target.tagName || update.type !== target.type){
const { nextSibling, parentNode } = target;
const replacement = preserve ? update.cloneNode(true) : update;
parentNode.removeChild(target);
View component.js
componentDidMount() {
fetchPosts().then(({posts}) => {
this.setState({posts});
});
fetchComments().then(({comments}) => {
this.setState({comments});
});
}