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
const pipe = (...fns) => { | |
let [res] = fns; | |
for (let i = 1, n = fns.length; i < n; i++) res = fns[i](res); | |
return res; | |
}; | |
const concat = iter2 => async function* (iter1) { | |
yield* await iter1; | |
yield* await iter2; | |
}; |
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
const LIMIT = 10000; | |
let sinkRef, sending, completed, sourceDisposed; | |
const source = (type, data) => { | |
if (sourceDisposed || completed) { | |
return; | |
} | |
if (type === 0) { |
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
console.clear(); | |
function measure(msg, fn) { | |
const start = Date.now(); | |
fn(); | |
console.log(msg, Date.now() - start, 'ms'); | |
} | |
/** | |
* @description Will look for the first N elements that matches the predicate. |
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
const create = prod => (start, sink) => { | |
if (start !== 0) return; | |
if (typeof prod !== 'function') { | |
sink(0, () => {}); | |
return; | |
} | |
let init = got2 = false; | |
let unsub; | |
sink(0, t => { | |
got2 = got2 || t === 2; |
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
const AppView = props => | |
<div className='App'> | |
<PeopleList {...props.state} onDelete={props.deletePerson} /> | |
</div>; | |
class App extends Component { | |
constructor(props) { | |
super(props); |
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 React from 'react'; | |
const ListWrapper = ({ children }) => ( | |
<div className='people-list-wrapper'> | |
<ul className='people-list'> | |
{children} | |
</ul> | |
</div> | |
); |
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 * as React from 'react'; | |
import * as R from 'ramda'; | |
import { connect, Dispatch } from 'react-redux'; | |
import { bindActionCreators } from 'redux'; | |
import { Title } from '../../shared/components/title'; | |
import { StuffTypeItems } from '../../shared/components/subscription-calculator'; | |
import { Button } from '../../shared/components/button'; | |
import { ItemComponent } from './stuff-type/item'; | |
import { setStuffType, SubscriptionCalculatorActions } from '../store/subscription-calculator.actions'; |
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
angular | |
.module('myApp', []) | |
.factory('DataFactory', function DataFactory($q) { | |
return { | |
getData() { | |
return $q.when([ | |
{id: 1, name: 'A'}, | |
{id: 2, name: 'B'}, | |
{id: 3, name: 'C'}, | |
{id: 4, name: 'D'}, |
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
// Elixir | |
data = [ | |
%{ id: 1, value: 0 }, | |
%{ id: 2, value: 0 }, | |
%{ id: 3, value: 0 } | |
] | |
Enum.map data, fn item -> | |
if item.id == 2 do | |
%{ item | value: item.value + 1 } |
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
function compose(...fns) { | |
return arg => fns.reduceRight((prev, curr) => curr(prev), arg); | |
} | |
const fatherMixin = (BaseClass = class {}) => | |
class Father extends BaseClass { | |
constructor() { | |
super() | |
this.frontendLang = 'JavaScript'; | |
} |
NewerOlder