fix(defaults): handle undefined and null sources in compat/defaults#1233
Merged
fix(defaults): handle undefined and null sources in compat/defaults#1233
undefined and null sources in compat/defaults#1233Conversation
…tion * `defaults` 함수에서 `undefined` 및 `null` 소스를 처리하도록 수정 * 관련 테스트 케이스 추가
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1233 +/- ##
=======================================
Coverage 99.88% 99.88%
=======================================
Files 468 468
Lines 4451 4453 +2
Branches 1310 1311 +1
=======================================
+ Hits 4446 4448 +2
Misses 5 5 🚀 New features to boost your workflow:
|
undefined and null sources in compat/defaultsundefined and null sources in compat/defaults
Contributor
Author
|
@dayongkr |
NotIvny
added a commit
to NotIvny/Yunzai
that referenced
this pull request
Sep 3, 2025
似乎没修 toss/es-toolkit#1223 toss/es-toolkit#1233 我做了点改动: const source = sources[i] != null ? sources[i] : [];
TimeRainStarSky
pushed a commit
to TimeRainStarSky/Yunzai
that referenced
this pull request
Sep 3, 2025
似乎没修 toss/es-toolkit#1223 toss/es-toolkit#1233 我做了点改动: const source = sources[i] != null ? sources[i] : [];
TimeRainStarSky
pushed a commit
to TimeRainStarSky/Yunzai
that referenced
this pull request
Sep 3, 2025
似乎没修 toss/es-toolkit#1223 toss/es-toolkit#1233 我做了点改动: const source = sources[i] != null ? sources[i] : [];
raon0211
previously approved these changes
Oct 24, 2025
Collaborator
raon0211
left a comment
There was a problem hiding this comment.
Sorry for the late review. Really appreciate your work!
raon0211
approved these changes
Oct 24, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Before, the
sourcesparameter had a strict type, so unless a user intentionally hacked around the type system,nullorundefinedvalues were never passed.Later, while making the type compatible with Lodash, it became possible to pass nil (
nullorundefined) values.When this happened,
compat/defaultswould throw an error, while Lodash’sdefaultswould simply ignore those values without a problem.This change fixes that issue by making
compat/defaultshandle nil values the same way as Lodash — safely skipping them without errors.Before Change
The following code would throw an error when a null or undefined source parameter is provided:
After Change
The defaults function has been updated to safely ignore null or undefined sources.
If a nil (null/undefined) source is passed, it will simply be skipped without throwing an error.
Testing
Coverage