feat: Add Map support to flattenObject function Fixes #1388 #1389
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.
Add Map support to flattenObject function
Fixes #1388
Summary
This PR adds Map support to the
flattenObject
function as requested in issue #1388, allowing users to flatten objects directly into Map instances for improved performance and cleaner syntax.However, during implementation, we discovered that simply adding Map support would break the existing delimiter customization feature. To maintain feature parity and ensure users don't lose functionality, we implemented an enhanced solution that supports both Map targets and custom delimiters simultaneously.
Changes
🆕 New Features
🔧 Implementation Details
FlattenObjectMapOptions
interface for Map-specific optionsflattenObjectIntoMap
function for direct Map operationsUsage Examples
The
flattenObject
function now supports 4 different usage patterns:1. Original Object Return (unchanged)
2. Object with Custom Delimiter (unchanged)
3. Map Target (new - addresses #1388)
4. Map with Custom Delimiter (new - enhancement)
Performance Benchmarks
Comprehensive performance testing shows significant improvements:
Why is it faster?
Legacy approach (3 steps):
New approach (1 step):
The new approach eliminates intermediate object and array creation, resulting in significant memory and CPU savings.
Testing
Commit History
flattenObject
intoMap
object #1388) - Core Map functionality한국어 요약
이슈 #1388 요구사항대로
flattenObject
함수에 Map 지원 기능을 추가했습니다. 7ac4f06그러나 구현 중 기존 delimiter 커스터마이징 기능이 누락되는 문제를 발견하여, Map 지원과 delimiter 지정을 모두 가능하도록 코드를 보완하였습니다. eba49df
주요 개선사항: