Skip to content

Latest commit

 

History

History
142 lines (136 loc) · 24.9 KB

mapping.md

File metadata and controls

142 lines (136 loc) · 24.9 KB

Mapping for Lodash and Ramda

Remeda functions are not necessarily drop-in replacements for the listed Lodash and Ramda functions. Just as the Lodash function may behave differently than the Ramda equivalent, the Remeda function may also behave differently from either or both. Be sure to consult each library's documentation when migrating.

Remeda Lodash Ramda
add add add
addProp set set
allPass allPass
anyPass anyPass
ceil ceil
chunk chunk
clamp clamp clamp
clone cloneDeep clone
concat concat concat
conditional cond cond
constant constant always
debounce debounce
difference difference difference
differenceWith differenceWith differenceWith
divide divide divide
drop drop drop
dropLast dropRight dropLast
dropLastWhile dropRightWhile dropLastWhile
dropWhile dropWhile dropWhile
entries toPairs toPairs
evolve evolve
filter filter filter
find find find
findIndex findIndex findIndex
findLast findLast findLast
findLastIndex findLastIndex findLastIndex
first head head
flat flatten flatten
flat flattenDeep
flatMap flatMap chain
floor floor
forEach forEach forEach
forEachObj forEach forEachObjIndexed
groupBy groupBy groupBy
hasSubobject isMatch where
identity identity identity
indexBy keyBy indexBy
intersection intersection intersection
intersectionWith intersectionWith innerJoin
invert invert invertObj
isDeepEqual isEqual equals
isEmpty isEmpty isEmpty
isNonNullish isNotNil
isNullish isNil isNil
isObjectType isObjectLike
isPlainObject isPlainObject
isSymbol isSymbol
join join join
last last last
length size length
map map map
mapKeys mapKeys
mapValues mapValues mapValues
mapWithFeedback scan
meanBy meanBy
merge assign merge
mergeAll assign mergeAll
mergeDeep mergeDeepRight
multiply multiply multiply
objOf objOf
omit omit omit
omitBy omitBy
once once once
partition partition partition
pathOr get pathOr
pick pick pick
pickBy pickBy pickBy
pipe flow pipe
product product
prop get prop
randomString
range range range
reduce reduce reduce
reverse reverse reverse
round round
sample sampleSize*
set set assoc
setPath set assocPath
shuffle shuffle
sort sort
sortBy orderBy
sortBy sortBy sortBy
sortedIndex sortedIndex
sortedIndexBy sortedIndexBy
sortedLastIndex sortedLastIndex
sortedLastIndexBy sortedLastIndexBy
splice remove
splitAt splitAt
splitWhen splitWhen
stringToPath toPath
subtract subtract subtract
sum sum sum
sumBy sumBy
swapIndices swap
swapProps swap
take take take
takeLastWhile takeRightWhile takeLastWhile
takeWhile takeWhile takeWhile
tap tap tap
times times times
unique uniq uniq
uniqueBy uniqBy uniqBy
uniqueWith uniqWith uniqWith

Helpful one-liners

Some lodash and ramda functions don't have a Remeda equivalent, but can be easily replaced with a one-liner in TypeScript. Some of the most common are listed below.

TypeScript one-liners are not necessarily drop-in replacements that provide the exact functionality of the listed Lodash and Ramda functions. Be sure to consult each library's documentation and to check what features you are relying on when migrating.

Remeda Lodash Ramda
(arr, val) => [...arr, val] append
a?.b?.c path
n => a[n] nth nth
R.constant(undefined) noop
R.filter.indexed((item, index, array) => index === 0 || item !== array[index - 1]) sortedUniq
R.filter(R.isNot(fn)) reject reject
R.filter(R.isTruthy) compact
R.firstBy([fn, "desc"]) maxBy maxBy
R.firstBy([R.identity, "desc"]) max max
R.firstBy(fn) minBy minBy
R.firstBy(R.identity) min min
R.fromEntries.strict(R.zip(keys, values)) zipObj zipObj
str => str.split(/\s+/) words
x => x.a ?? defaultValue propOr
x => x.a === value propEq