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
var R = require('ramda'); | |
var db = require('./db/queries'); | |
const a = db.filterUser({}, {}) | |
.addContact('contact') | |
.addCompany(['contact', 'company']) | |
.then(res => { | |
console.log(res.splice(0, 1)) | |
}); |
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
var R = require('ramda'); | |
var knex = require('knex')({ | |
client: 'pg', | |
connection: { | |
host: 'localhost', | |
port: '35432', | |
database: 'vamos', | |
password: 'vamos', | |
user: 'vamos', | |
} |
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 fs from 'fs'; | |
import { add, prop, lift } from 'ramda'; | |
import Task from 'data.task'; | |
import Box from './Box'; | |
import Maybe from './Maybe'; | |
var marked = require('marked'); | |
var TerminalRenderer = require('marked-terminal'); | |
marked.setOptions({ | |
// Define custom renderer |
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 phoneToString = phone => `${phone.prefix} ${phone.number}`; | |
const phones = [ | |
{ | |
prefix: '+33', | |
number: '102219123', | |
}, | |
{ | |
prefix: '+33', | |
number: '1111111111', |
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 DataLoader from 'dataloader'; | |
const getBatchUsers = (ids = []) => { | |
// runs sth like | |
// SELECT * FROM users WHERE id IN (:ids) | |
}; | |
// cache is disabled | |
const userLoader = new DataLoader(getBatchUsers, {cache: false}); |
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 Task from 'data.task'; | |
import R from 'ramda'; | |
const run = t => { | |
return t.fork( | |
err => console.log('err', err), | |
R.tap(console.log) | |
); | |
} |
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 _ from 'lodash/fp'; | |
const pipe = (...list) => | |
(args) => | |
_.flatten(list).reduce((p, fn) => p.then(fn), Promise.resolve(args)) | |
const branch = (...list) => | |
(args) => Promise.all(list.map(fn => fn(args))) | |
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
// Welcome! require() some modules from npm (like you were using browserify) | |
// and then hit Run Code to run your code on the right side. | |
// Modules get downloaded from browserify-cdn and bundled in your browser. | |
var Immutable = require('immutable'); | |
const b = new Immutable.Record({ | |
id: null, | |
name: null, | |
}); |
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 emailSpecification = email => { | |
const expression = 'user.email === email'; | |
return { | |
isSatisfiedBy(user) { | |
return eval(expression); | |
} | |
}; |
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 _ from 'lodash/fp'; | |
const mapValuesWithKey = _.mapValues.convert({ cap: false}); | |
const internals = { | |
/** | |
* Returns a function that transforms an object's subObjects based on a mapping configuration | |
* @param Object mapping a mapping configuration | |
* @return Function transformer a transformer function | |
*/ |