-
Notifications
You must be signed in to change notification settings - Fork 76
Open
Description
Hi there - mostly curious but what's the reason for autoType
mutating the object in-place?
This caused a bug in my app since the function is not idempotent - passing the same object twice succeeds on the first time with a numeric value, and fails on the second due to the object[key].trim()
line. The value is a string the first time around, and a number after it is parsed.
The fix is to always clone the result first (i.e. arr.map(r => d3.autoType({ ...r }))
) but given how most d3 utility functions are pure I'm surprised to see this. It's clearly intentional given the explicit test for the behavior but am I missing a use case? Or is it just in the interest of speed / it's expected that the happy path is d3.csv(url, d3.autoType)
?
Metadata
Metadata
Assignees
Labels
No labels