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 { map, nth, filter, getOr, set, startCase, get, flow, isEqual, rearg, identity, curry } = require('lodash/fp') | |
const R = require('ramda') | |
const { invoker, apply } = R |
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 parseHumans = flow([ | |
JSON.parse, | |
listToPeople, | |
filterHumans, | |
formatNames | |
]) |
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 parseHumans = jsonString => flow([ | |
JSON.parse, | |
listToPeople, | |
filterHumans, | |
formatNames | |
])(jsonString) |
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 parseHumans = jsonString => | |
formatNames( | |
filterHumans( | |
listToPeople( | |
JSON.parse(jsonString) | |
) | |
) | |
) |
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 getName = get('name') | |
const setName = set('name') | |
const getFixedName = flow([getName, startCase]) | |
const nameAndPerson = [{f: getFixedName}, {f: identity}] | |
const callF = invoker(1, 'f') | |
const flipMap = curry(rearg([1, 0], map)) | |
const mapNameAndPerson = flipMap(nameAndPerson) | |
const getFixedNameAndPerson = flow([callF, mapNameAndPerson]) | |
const setNameWithPersonNameAndPerson = apply(setName) | |
const mapFormatNames = flow([getFixedNameAndPerson, setNameWithPersonNameAndPerson]) |
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 getName = flow([get('name'), startCase]) | |
const setName = set('name') | |
const formatNames = | |
map( | |
list => setName(getName(list), list) | |
) |
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 formatNames = | |
map( | |
list => set('name', startCase(get('name', list)), list) | |
) |
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 formatNames = people => | |
map( | |
list => set('name', startCase(get('name', list)), list), | |
people | |
) |
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 getTypeOrUnknown = getOr('unknown', 'type') | |
const equalsHuman = isEqual('human') | |
const isHuman = flow([getTypeOrUnknown, equalsHuman]) | |
const filterHumans = filter(isHuman) |
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 getTypeOrUnknown = getOr('unknown', 'type') | |
const filterHumans = | |
filter( | |
person => getTypeOrUnknown(person) === 'human' | |
) |