Skip to content

Lodash와의 호환성

tsx
// es-toolkit/compat은 lodash와 100% 동일한 동작을 제공하도록 목표하고 있어요
import { chunk } from 'es-toolkit/compat';

// es-toolkit은 원래 chunk의 size로 0을 지원하지 않았어요
chunk([1, 2, 3, 4], 0);
// es-toolkit/compat은 lodash와 같은 []을 반환해요

lodash와 최대 호환성을 위해서는 es-toolkit/compat 라이브러리를 사용하세요.

es-toolkit은 매끄러운 마이그레이션을 보장하기 위해, 두 라이브러리 사이의 동작 차이가 없는 es-toolkit/compat 라이브러리를 개발하고 있어요. lodash와 동일한 API와 기능을 제공하여, 수월하게 마이그레이션을 할 수 있도록 도와줄 예정이에요.

es-toolkit/compat은 실제 lodash 테스트 코드를 이용해서 테스트돼요.

es-toolkit/compat는 원래 es-toolkit에 비해 런타임 퍼포먼스나 번들 크기가 최적은 아닐 수 있어요. 마이그레이션 중에 사용하는 도구로 생각해 주시고, 새로운 기능은 es-toolkit로 개발해주세요.

설계 원칙

INFO

es-toolkit/compat 설계 원칙의 방향성은 변경될 수 있어요.

es-toolkit/compat은 다음과 같은 기능들에 대해서 lodash와 100% 동일한 기능을 제공하는 것을 목표로 해요.

  • lodash의 테스트 케이스로 작성된 기능
  • @types/lodash 또는 @types/lodash-es의 타입에서 추론할 수 있는 기능

아래와 같은 기능은 es-toolkit/compat에서 지원하지 않아요.

  • 암시적 타입 변환: 빈 문자열을 0 또는 false로 변환하는 것과 같은 동작
  • 어떤 경우에 특화된 구현: sortedUniq와 같이 정렬된 배열만 받는 함수
  • JavaScript 내장 객체의 프로토타입이 바뀐 경우에 대응하는 코드
  • JavaScript Realm에 대응하는 코드
  • 메서드 체이닝: _(arr).map(...).filter(...)와 같은 메서드 체이닝

구현 상태

INFO

아래 이모지로 현재 구현 상태를 나타내고 있어요.

  • ✅: 완료 (구현됐고, lodash 테스트 코드를 모두 통과해요.)
  • 📝: 리뷰 중 (구현됐지만, lodash 테스트 코드로 테스트되지는 않았어요.)
  • ❌: 아직 구현되지 않음

"리뷰 중"으로 표시되었더라고 하더라도, 이미 lodash와 100% 동일한 기능을 제공하고 있을 수도 있어요.

"Array" 메소드

함수 이름구현 상태
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지원하지 않음
sortedUniq지원하지 않음
sortedUniqBy지원하지 않음
tail
take
takeRight
takeRightWhile📝
takeWhile📝
union📝
unionBy📝
unionWith📝
uniq
uniqBy📝
uniqWith📝
unzip📝
unzipWith📝
without
xor📝
xorBy📝
xorWith📝
zip📝
zipObject📝
zipObjectDeep
zipWith📝

"Collection" 메소드

함수 이름구현 상태
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" 메소드

함수 이름구현 상태
now

"Function" 메소드

함수 이름구현 상태
after📝
ary
before📝
bind
bindKey
curry
curryRight
debounce
defer
delay📝
flip
memoize📝
negate📝
once📝
overArgs
partial📝
partialRight📝
rearg
rest
spread
throttle
unary📝
wrap

"Lang" 메소드

함수 이름구현 상태
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" 메소드

함수 이름구현 상태
add
ceil
divide
floor
max
maxBy📝
mean📝
meanBy📝
min
minBy📝
multiply
round
subtract
sum📝
sumBy📝

"Number" 메소드

함수 이름구현 상태
clamp📝
inRange📝
random📝

"Object" 메소드

함수 이름구현 상태
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" 메소드

함수 이름구현 상태
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" 메소드

함수 이름구현 상태
attempt
bindAll
cond
conforms
constant
defaultTo
flow
flowRight
identity
iteratee
matches
matchesProperty
method
methodOf
mixin지원하지 않음
noConflict지원하지 않음
noop📝
nthArg
over
overEvery
overSome
property
propertyOf
range📝
rangeRight
runInContext지원하지 않음
stubArray
stubFalse
stubObject
stubString
stubTrue
times
toPath
uniqueId

MIT 라이선스에 따라 배포됩니다.