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
// @flow | |
import React from 'react'; | |
import { render } from 'react-dom'; | |
type Field = 0 | 1; | |
type Position = [Field, Field, Field, Field]; | |
type Unit = [Position, Position, Position, Position]; |
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
http://jsfiddle.net/CrossEye/Gk6uu/light/ | |
(function(R) { | |
var incomplete = R.filter(R.where({complete: false})); | |
var sortByDate = R.sortBy(R.prop('dueDate')); | |
var sortByDateDescend = R.compose(R.reverse, sortByDate); | |
var importantFields = R.project(['title', 'dueDate']); | |
var groupByUser = R.partition(R.prop('username')); | |
var activeByUser = R.compose(groupByUser, incomplete); | |
var gloss = R.compose(importantFields, R.take(5), sortByDateDescend); |
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
'use strict'; | |
var R = require('ramda'); | |
var CATEGORIES = [ | |
{category_type: 'cuisine', id: 1, name: 'French', type: 'categroy'}, | |
{category_type: 'diets', id: 2, name: 'Vegetarian', type: 'category'} | |
]; | |
var children = { |
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 {prop, compose, apply, defaultTo, juxt} from 'ramda' | |
const player = { | |
id: 1, | |
name: 'Bnaya', | |
file: { | |
img: 'http://foo.bar/bnaya-zil.png' | |
} | |
} |
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 R from 'ramda' | |
const mergePlan = (x, y) => { | |
if(Array.isArray(x) && Array.isArray(y)) { | |
return R.uniq(R.concat(x, y)); | |
} | |
if(typeof x === 'object' && typeof y === 'object'){ | |
return R.mergeWith(mergePlan, x, y) | |
} |
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
var R = require('ramda'); | |
var states = [ | |
{symbol: 'CT', name: 'Connecticut', pop: 3574097}, | |
{symbol: 'ME', name: 'Maine', pop: 1328361}, | |
{symbol: 'MA', name: 'Massachusetts', pop: 6547629}, | |
{symbol: 'NH', name: 'New Hampshire', pop: 1316470}, | |
{symbol: 'RI', name: 'Rhode Island', pop: 1052567}, | |
{symbol: 'VT', name: 'Vermont', pop: 623741}, | |
]; |
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
var byMonth = R.groupBy(R.prop('Month')); | |
var byAuthor = R.groupBy(R.prop('Author')); | |
var royalty_key = 'Royalty (SUM)'; | |
var months_keys = R.uniq(R.map(R.prop('Month'), data)).sort(); | |
var monthly_revenue = | |
R.map((group) => | |
R.reduce((acc, record) => acc + parseMoney(record[royalty_key]), 0, group), | |
byMonth(data)); |
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 { lensPath, view } from 'ramda'; | |
const complexObject = { level1: { level2: { prop1: 1, prop2: 2 } } }; | |
const prop1Lens = lensPath(['level1', 'level2', 'prop1']); | |
console.assert(view(prop1Lens, complexObject) === 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
render() { | |
const { loading, data } = props; | |
if (loading) return <Loader />; | |
return <DisplayData data={data} /> | |
} |
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 names = ['John', 'Jack', 'Rose', 'Alex', 'Mercy', 'Emma', 'Peter'] | |
const fourLengthNames = names.filter(name => name.length === 4); | |
const greetingEveryone = names.map(name => `Hello ${name}`); |
OlderNewer