Consider the following scenario
function invert(color) {
var lookup = {
black: 'white',
white: 'black'
}
import React from 'react' | |
export default function connectToStores(...stores) { | |
return function(Component) { | |
return class StoreConnection extends React.Component { | |
constructor(props) { | |
super(props) | |
this.state = Component.getPropsFromStores() | |
this.handleStoresChanged = this.handleStoresChanged.bind(this) | |
} |
// Based on idea from @nolsto | |
function makeDecorator(decorator) { | |
return function(target, key, descriptor) { | |
if (typeof descriptor !== 'undefined') { | |
descriptor.value = decorator(descriptor.value); | |
return descriptor | |
} else { | |
return decorator(target); | |
} |
import React from 'react'; | |
import { configureDragDrop, configureDragDropContext } from 'react-dnd'; | |
import HTML5Backend from 'react-dnd/modules/backends/HTML5'; | |
// Note: @configureDragDropContext is called a “decorator”. | |
// This desugars roughly as class App { ... } App = configureDragDropContext(HTML5Backend)(App); | |
// You can enable decorators by putting { "stage": 1 } in your .babelrc. | |
@configureDragDropContext(HTML5Backend) | |
export default class App extends React.Component { |
export const Types= React.PropTypes | |
// These functions are meant for use with ES7 decorators... (use babel!) | |
export function ContextTypes( contextTypes={}) { | |
return function( component) { | |
return _setOrExtend( component, 'contextTypes', contextTypes) | |
} | |
} |
This post has moved to my personal blog: http://maximilianschmitt.me/posts/iojs-command-line-apps-nodejs/
#!/bin/sh | |
sed 's/,,/, ,/g;s/,,/, ,/g' | column -s, -t | vim +"set nowrap" - |
/* bling.js */ | |
window.$ = document.querySelector.bind(document); | |
window.$$ = document.querySelectorAll.bind(document); | |
Node.prototype.on = window.on = function(name, fn) { this.addEventListener(name, fn); }; | |
NodeList.prototype.__proto__ = Array.prototype; | |
NodeList.prototype.on = function(name, fn) { this.forEach((elem) => elem.on(name, fn)); }; |
npm-debug.log | |
node_modules |