Open daveisfera opened 4 years ago
Can you give a bit more complete example with imports and such? Does Lodash provide curried versions of functions out of the box? It might be hard to track wether the function is curried or not and what to do and when.
Something like this
const a = [{ bogus: true }, { count: 100 }, { missing: true }];
const b = flow([
filter(get('count')),
get([0, 'count']),
])(a);
Could be changed to:
const b = flow([
filter(v => v?.count),
v => v?.[0]?.count,
])(a);
Also, the number of arguments should be an indication of it being curried (i.e. 2 arguments to get()
is a "standard call" and 1 argument to get()
is a "curried call")
One last big thanks for the awesome codemod!
Curried versions of
get()
andgetOr()
cause an error:But they could be turned into fat arrow functions using the existing logic, like the following:
get('value')
tov => v?.value
getOr(default, 'value')
tov => v?.value ?? default