Skip to content

Instantly share code, notes, and snippets.

@MarlonPassos-git
Forked from aleclarson/lodash_parity.md
Last active September 28, 2024 01:15
Show Gist options
  • Select an option

  • Save MarlonPassos-git/abe919f53645c1f8d48fe7b70a166cbc to your computer and use it in GitHub Desktop.

Select an option

Save MarlonPassos-git/abe919f53645c1f8d48fe7b70a166cbc to your computer and use it in GitHub Desktop.

Here's the Lodash parity data I've compiled so far.

The status "100" means it's an exact match with the Lodash implementation.

Implemented

name notes status rename
capitalize 100
uniqBy • Renamed to unique. yes unique
groupBy • Renamed to group.
• Property shorthand not supported (but coming soon).
yes group
pickBy • Renamed to pick. yes pick
castArray • If the given value is an array, the array is shallow copied.
• We also have castArrayIfExists which is similar but null/undefined are returned as is.
yes
pick • Exactly one array of keys must be passed. No more, no less.
• You may pass a selector function instead (pickBy functionality).
yes
zip 100
set • “Key arrays” are not supported. Only string-based JSON paths. yes
clone • Unsure about the differences as of now. Help wanted. yes
flow • Renamed to chain.
• Full type safety with TypeScript (to a max of 10 functions).
• Instead of taking an array of functions, each function is an argument to chain.
yes chain
isPlainObject • Returns false for built-in namespaces like Math, JSON, etc.
• Returns false for the arguments object of a function call.
yes
get • “Key arrays” are not supported. Only string-based JSON paths. yes
isFunction 100
isString • Boxed strings (e.g. new String("foo")) are not supported. yes
debounce • No leading or trailing option. Only a trailing debounce is supported.
• No maxWait option. The function may be debounced indefinitely if called frequently enough.
• The pending method is renamed to isPending.
yes
isBoolean • Boxed values (e.g. new Boolean(true)) are not supported. yes
isNumber • Boxed numbers (e.g. new Number(0)) are not supported. yes
throttle • No leading or trailing option. Only a trailing behavior is supported.
• The pending method is renamed to isThrottled.
• No cancel or flush method.
yes
isObject • Returns false for RegExp, Date, and other built-in, complex objects.
• Returns false for arrays.
• Returns false for functions.
yes
isEmpty • There are likely quite a bit of differences here. Help wanted on this! yes
snakeCase • Renamed to snake. yes snake
startCase • Renamed to title. yes title
once • Support for clearing the cached result to allow running the function again. See the once.reset function. yes
kebabCase • Renamed to dash. yes dash
memoize • Built-in support for TTL (time to live) invalidation.- By default, the cache key is computed with JSON.stringify of the arguments array. Lodash only uses the first argument if a custom key resolver is not provided.
• Lodash uses a Map to support any type of cache key, while only JSON-compatible arguments are supported in Radashi.
• No cache property, so the cache is not directly accessible.
yes memo
uniq • Renamed to unique. yes unique
camelCase • Renamed to camel. yes camel
cloneDeep • Ours accepts a custom strategy (similar to cloneDeepWith). yes
flatten • Renamed to flat. yes flat
difference • Renamed to diff.
• Requires two arrays exactly. No more, no less.
• Supports an “identity function” that enables comparison through a property or other computation.
yes diff
differenceWith • Renamed to diff.
• Requires two arrays exactly. No more, no less.
• Use an “identity function” that enables comparison through a property or other computation insted of an comparator function
yes diff
isArray 100
isBoolean 100
isDate 100
isEqual 100
isError 100
isInteger • Renamed to isInt.
Radash is function is for tree-shaking, and it gets removed when your code is minified
Improve type inference
yes isInt

Not implemented

name notes status rename
reduce • “Collection” polymorphism is unaligned with Radashi's vision. no
filter • “Collection” polymorphism is unaligned with Radashi's vision. no
some • “Collection” polymorphism is unaligned with Radashi's vision. no
values • Use Object.values instead. no
map • “Collection” polymorphism is unaligned with Radashi's vision. no
padEnd • Use String.prototype.padEnd instead. no
forEach • “Collection” polymorphism is unaligned with Radashi's vision. no
flattenDeep • Use Array.prototype.flat instead. no
keys • Use Object.keys instead.
• Radashi has its own keys function that is unrelated to Lodash keys.
no

Unknown

name notes status rename
defaults
merge • Radashi has a merge function, but it's for merging two arrays based on a key function.
truncate no
union no
isArguments no
mergeWith no
escapeRegExp no
escape no
isMatch no
isUndefined no
isNil no
has no
deburr no
defaultsDeep - voce pode usar assign passando o valor default como primeiro pametro. lodash.defaultsDeep(obj, default) === radashi.assing(default, obj)

yes
unescape no
toPath no
reject no
transform
lowerCase no
toLower use String.toLowerCase instead no
padStart use String.padStart instead no
isTypedArray no
chunk • Renamed to cluster. yes cluster
pad no
without
toArray
maxBy
xorBy
flatMap
startsWith
invokeMap
isEqualWith no
every
uniqueId
uniqWith
tail
forOwn
intersection
compact
orderBy
last - tem um propriedade opcional que permite passar valor default yes
pullAll
repeat
keysIn
create
range
indexOf
zipObject
lowerFirst
unset
keyBy
eq
trim
shuffle
trimStart
unionWith
isError
cond
toNumber
size
trimEnd
clamp
isObjectLike
at
differenceWith
cloneDeepWith
head
hasIn
isRegExp
sample
words
isDate
toPlainObject
endsWith
round
unionBy
xor
findLast
sortedLastIndex
invert
partition
setWith
random
result
findKey
defer
times
initial
invoke
pull
upperCase
isLength
isNull no
inRange
sampleSize
remove
toString
parseInt
flowRight
differenceBy
property
assign - radash aceita somente 2 objetos
- radashi e' maior seguranca de tipos

Not all Lodash functions are included. These were chosen based on NPM downloads of > 10,000

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment