Set the name ordering & small fixes
This commit is contained in:
parent
402f75f50c
commit
910d7e200f
4 changed files with 74 additions and 44 deletions
|
|
@ -12,14 +12,35 @@ const phoneticMethod3 = _.flow(_.split(' '), _.map(phoneticMethod2))
|
|||
|
||||
// Combine name-parts in a standard order.
|
||||
|
||||
const fullNameFromParts = _.flow(
|
||||
_.toPairs,
|
||||
_.sortBy(_.first), // sort by part name,
|
||||
_.map(_.last), // get part value
|
||||
const commonOrderings = [
|
||||
['firstName', 'lastName'],
|
||||
['firstName', 'middleName', 'lastName'],
|
||||
['firstName', 'maidenName', 'lastName'],
|
||||
['firstName', 'patronymic', 'lastName'],
|
||||
['firstName', 'matronymic', 'lastName']
|
||||
]
|
||||
|
||||
// const getFrom = _.flip()
|
||||
|
||||
const getFrom = _.curry((obj, key) => obj[key])
|
||||
|
||||
const getOrderedParts = (parts, ordering) => _.map(getFrom(parts), ordering)
|
||||
|
||||
const combineParts = _.curryN(2, _.flow(
|
||||
getOrderedParts,
|
||||
_.compact,
|
||||
_.join(' ')
|
||||
))
|
||||
|
||||
const makeAllOrderings = parts => _.map(combineParts(parts), commonOrderings)
|
||||
|
||||
const makeFullNames = _.flow(
|
||||
makeAllOrderings,
|
||||
_.uniq
|
||||
)
|
||||
|
||||
|
||||
module.exports = {
|
||||
fullNameFromParts,
|
||||
makeFullNames,
|
||||
phonetic: phoneticMethod3
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue