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 { Component } from 'melody-component'; | |
import { component } from 'melody-idom'; | |
export default function mapProps(mapper) { | |
return Component => class MapPropsComponent extends Component { | |
render() { | |
return component(Component, 'child', mapper(props)); | |
} | |
}; | |
} |
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 { createComponent } from 'melody-component'; | |
import { component } from 'melody-idom'; | |
export default function mapProps(mapper) { | |
return Component => createComponent({ | |
render() { | |
return component(Component, 'child', mapper(props)); | |
} | |
}); | |
} |
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
// Stateful | |
const MyComponent = createComponent({ | |
render(state, props, children, childrenArgs) { | |
elementOpen('section'); | |
children(...childrenArgs); | |
elementClose('section'); | |
} | |
}); | |
// Stateless |
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
{% property 'expandable' with { type: 'boolean', required: true } %} | |
{% property 'expanded' with { type: 'boolean', required: true } %} | |
{% property 'toggle' with { type: 'function' } %} | |
{% property 'modifier' with { type: 'string' } %} | |
{% property 'children' with { type: 'node', required: true } %} | |
{% property 'title' with { type: 'node' } %} | |
<div | |
class={{ "box box--" + modifier }} |
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 { component } from 'melody-component'; | |
const mapProps = mapper => Component => props => component(Component, props.key, mapper(props)); |
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
const Box = props => { | |
const { children, childrenArgs, title } = props; | |
o('div', { className: 'box' }); | |
if (title) { | |
o('div', { className: 'box__title' }); | |
text(title); | |
c('div'); | |
} | |
o('div', { className: 'box__body' }); | |
children(...childrenArgs); |
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
const code = 'console.log("foo")'; | |
console.log(require("babylon").parse(code, { | |
// parse in strict mode and allow module declarations | |
sourceType: "module", | |
plugins: [ | |
// enable jsx and flow syntax | |
"jsx", |
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
const Inferno = require('inferno'); | |
const InfernoServer = require('inferno-server'); | |
const createElement = require('inferno-create-element'); | |
const tree = createElement('div', { className: 'basic' }, | |
createElement('span', { className: 'foo' }, 'Hello World') | |
); | |
const root = document.getElementById('root'); |
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
// https://github.com/salsita/geo-tree | |
// Red-black tree for geo coordinates, scalar indices with z-curve | |
import GeoTree from 'geo-tree'; | |
const gt = new GeoTree(); | |
// Items sorted by relevance, data holds itemId | |
const items = [ | |
{lat: 48.85886, lng: 2.34706, data: 3849712}, | |
{lat: 52.50754, lng: 13.42614, data: 234910}, |
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 { Observable } from 'rxjs/Observable'; | |
import { fromPromise } from 'rxjs/observable/fromPromise'; | |
import 'rxjs/add/operator/delay'; | |
import 'rxjs/add/operator/map'; | |
import 'rxjs/add/operator/expand'; | |
import 'rxjs/add/operator/takeWhile'; | |
import 'rxjs/add/operator/catch'; | |
const defaultIsComplete = () => false; | |
const defaultKeepIntervalLow = () => false; |