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 { identity, map, compose, forEach } from 'ramda' | |
const withCatchAll = fn => (...args) => fn(...args).catch(identity) | |
const unsafeInsert = witchCatchAll(insert) | |
await Promise.all(map(compose(unsafeInsert, stripOneMandatoryParam)), MANDATORY_PARAMS).then(forEach(expectToThrow)) |
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 obj = { books: 10, ruler: 1, pencils: 5 } |
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
{ | |
Alderaan: { | |
brown: 1 | |
}, | |
Naboo: { | |
red: 1 | |
}, | |
Stewjon: { | |
'blue-gray': 1, | |
Tatooine: { |
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 character_ids = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] |
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 { reduce } from 'conductor' | |
const homeworld_stats = reduce(reducer, character_ids) | |
// { Alderaan: 1, Naboo: 1, Stewjon: 1, Tatooine: 7 } |
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 { compose, get } from 'conductor' | |
const getHomeworldName = compose(get('name'), fetchJSON, get('homeworld'), fetchCharacter) | |
// getHomeworldName(1) == { name: 'Tatooine', ... } |
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 { compose } from 'conductor' | |
const countHomeworld = compose(countOne, getHomeworldName) | |
// countHomeworld(1) == { Tatooine: 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
import { map } from 'conductor' | |
const character_ids = [1, 2, 3, 4, 5] | |
const fetchCharacter = id => fetch(`https://swapi.co/api/people/${id}`).then(res => res.json()) | |
await map(fetchCharacter, characters_ids) // [{ name: 'Luke Skywalker }, { name: 'C-3PO' }, ...] |
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 { compose, equals, filter, get } from 'conductor' | |
const character_ids = [1, 2, 3, 4, 5] | |
const fetchCharacter = id => fetch(`https://swapi.co/api/people/${id}`).then(res => res.json()) | |
const hasBlueEyes = compose(equals('blue'), get('eye_color'), fetchCharacter)) | |
await filter(hasBlueEyes, characters_ids) // [{ name: 'Luke Skywalker }, { name: 'Owen Lars' }, ...] |
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 { map } from 'conductor' | |
const numbers = [1, 2, 3] | |
const add1 = x => x + 1 | |
map(add1)(numbers) // == map(add1, numbers) == [2, 3, 4] |
OlderNewer