Skip to content

es-toolkit/compat ​

es-toolkit/compat mirrors Lodash's interface and behavior 1:1. It exists so you can lift an existing Lodash codebase into es-toolkit without rewriting call sites, and migrate to the strict API at your own pace.

If your project does not already use Lodash, please use es-toolkit instead.

✅ 100% compatibility since v1.39.3

es-toolkit/compat passes Lodash's own test suite, so behavior is identical while staying lighter and faster.

ts
// Same call signature as lodash, but coming from es-toolkit/compat
import { chunk } from 'es-toolkit/compat';

chunk([1, 2, 3, 4], 0);
// Returns [], identical to lodash

Migration flow ​

Recommended path for removing Lodash from an existing codebase:

  1. Swap the import path from lodash / lodash-es to es-toolkit/compat. Leave call sites as they are.
  2. Clean up call sites over time and switch the import to es-toolkit. Once done, you get a smaller bundle and faster runtime.

How it differs from es-toolkit ​

  • API shape: matches Lodash 1:1, including implicit type coercions, multiple argument shapes, and deprecated helpers. es-toolkit only exposes the type-safe, modern forms.
  • Bundle size and speed: slightly larger and slightly slower than es-toolkit, because it carries extra logic to match Lodash's behavior.
  • Deprecated functions: kept in compat for parity, not in es-toolkit. Clean them up during migration.

For function-level documentation, see the Compat Reference.

Design Principles ​

INFO

Design principles are subject to change.

Our compatibility layer aims to achieve feature parity with 100% accuracy for:

  • Features that are written as a test case in lodash.
  • Features that can be inferred from types of @types/lodash or @types/lodash-es.
  • Feature differences identified while migrating code from lodash to es-toolkit (please report these to our issues page).

However, the following are out of scope for es-toolkit/compat:

  • Implicit type conversions, such as converting an empty string to zero or false.
  • Functions that have specialized implementations for specific types of arrays, like sortedUniq.
  • Handling cases where internal object prototypes, like Array.prototype, have been modified.
  • Managing cases with JavaScript realms.
  • Method chaining support through "Seq" methods.

Implementation Status ​

INFO

The following emojis indicate the status of each feature:

  • ✅: Completed (The function is fully implemented and has passed all tests with lodash test code.)
  • 📝: In Review (The function is implemented but hasn't been tested with lodash test code yet.)
  • ❌: Not Implemented (The function hasn't been implemented.)

Even if a feature is marked "in review," it might already be under review to ensure it matches lodash perfectly, and it could already offer the same functionality.

"Array" method

Function NameImplementation Status
chunk✅
compact✅
concat✅
difference✅
differenceBy✅
differenceWith✅
drop✅
dropRight✅
dropRightWhile✅
dropWhile✅
fill✅
findIndex✅
findLastIndex✅
flatten✅
flattenDeep✅
flattenDepth✅
fromPairs✅
head✅
indexOf✅
initial✅
intersection✅
intersectionBy✅
intersectionWith✅
join✅
last✅
lastIndexOf✅
nth✅
pull✅
pullAll✅
pullAllBy✅
pullAllWith✅
pullAt✅
remove✅
reverse✅
slice✅
sortedIndex✅
sortedIndexBy✅
sortedIndexOf✅
sortedLastIndex✅
sortedLastIndexBy✅
sortedLastIndexOf✅
sortedUniqNo support
sortedUniqByNo support
tail✅
take✅
takeRight✅
takeRightWhile✅
takeWhile✅
union✅
unionBy✅
unionWith✅
uniq✅
uniqBy✅
uniqWith✅
unzip✅
unzipWith✅
without✅
xor✅
xorBy✅
xorWith✅
zip✅
zipObject✅
zipObjectDeep✅
zipWith✅

"Collection" method

Function NameImplementation Status
countBy✅
every✅
filter✅
find✅
findLast✅
flatMap✅
flatMapDeep✅
flatMapDepth✅
forEach✅
forEachRight✅
groupBy✅
includes✅
invokeMap✅
keyBy✅
map✅
orderBy✅
partition✅
reduce✅
reduceRight✅
reject✅
sample✅
sampleSize✅
shuffle✅
size✅
some✅
sortBy✅

"Date" method

Function NameImplementation Status
now✅

"Function" method

Function NameImplementation Status
after✅
ary✅
before✅
bind✅
bindKey✅
curry✅
curryRight✅
debounce✅
defer✅
delay✅
flip✅
memoize✅
negate✅
once✅
overArgs✅
partial✅
partialRight✅
rearg✅
rest✅
spread✅
throttle✅
unary✅
wrap✅

"Lang" method

Function NameImplementation Status
castArray✅
clone✅
cloneDeep✅
cloneDeepWith✅
cloneWith✅
conformsTo✅
eq✅
gt✅
gte✅
isArguments✅
isArray✅
isArrayBuffer✅
isArrayLike✅
isArrayLikeObject✅
isBoolean✅
isBuffer✅
isDate✅
isElement✅
isEmpty✅
isEqual✅
isEqualWith✅
isError✅
isFinite✅
isFunction✅
isInteger✅
isLength✅
isMap✅
isMatch✅
isMatchWith✅
isNaN✅
isNative✅
isNil✅
isNull✅
isNumber✅
isObject✅
isObjectLike✅
isPlainObject✅
isRegExp✅
isSafeInteger✅
isSet✅
isString✅
isSymbol✅
isTypedArray✅
isUndefined✅
isWeakMap✅
isWeakSet✅
lt✅
lte✅
toArray✅
toFinite✅
toInteger✅
toLength✅
toNumber✅
toPlainObject✅
toSafeInteger✅
toString✅

"Math" method

Function NameImplementation Status
add✅
ceil✅
divide✅
floor✅
max✅
maxBy✅
mean✅
meanBy✅
min✅
minBy✅
multiply✅
round✅
subtract✅
sum✅
sumBy✅

"Number" method

Function NameImplementation Status
clamp✅
inRange✅
random✅

"Object" method

Function NameImplementation Status
assign✅
assignIn✅
assignInWith✅
assignWith✅
at✅
create✅
defaults✅
defaultsDeep✅
findKey✅
findLastKey✅
forIn✅
forInRight✅
forOwn✅
forOwnRight✅
functions✅
functionsIn✅
get✅
has✅
hasIn✅
invert✅
invertBy✅
invoke✅
keys✅
keysIn✅
mapKeys✅
mapValues✅
merge✅
mergeWith✅
omit✅
omitBy✅
pick✅
pickBy✅
result✅
set✅
setWith✅
toPairs✅
toPairsIn✅
transform✅
unset✅
update✅
updateWith✅
values✅
valuesIn✅

"String" method

Function NameImplementation Status
camelCase✅
capitalize✅
deburr✅
endsWith✅
escape✅
escapeRegExp✅
kebabCase✅
lowerCase✅
lowerFirst✅
pad✅
padEnd✅
padStart✅
parseInt✅
repeat✅
replace✅
snakeCase✅
split✅
startCase✅
startsWith✅
template✅
toLower✅
toUpper✅
trim✅
trimEnd✅
trimStart✅
truncate✅
unescape✅
upperCase✅
upperFirst✅
words✅

"Util" method

Function NameImplementation Status
attempt✅
bindAll✅
cond✅
conforms✅
constant✅
defaultTo✅
flow✅
flowRight✅
identity✅
iteratee✅
matches✅
matchesProperty✅
method✅
methodOf✅
mixinNo support
noConflictNo support
noop✅
nthArg✅
over✅
overEvery✅
overSome✅
property✅
propertyOf✅
range✅
rangeRight✅
runInContextNo support
stubArray✅
stubFalse✅
stubObject✅
stubString✅
stubTrue✅
times✅
toPath✅
uniqueId✅

Released under the MIT License.