Closed tophtucker closed 3 years ago
This will make d3.autoType slower for its intended use case (converting strings into non-strings), so I think this is probably undesirable. What is the situation where you have partially converted some string values but not others?
Related? https://github.com/d3/d3-dsv/pull/54
OK I'm convinced! There wasn't really a situation where I had partially converted some string values but not others; there was only a situation where I wanted to charitably accept either converted or unconverted arrays, so the user didn't have to think about it. But I guess that's better handled by checking for unconverted values first.
I understand that d3.autoType is somewhat dangerous and only meant to be used in narrow circumstances. But I have still found myself wanting to use it outside the context of d3-dsv, and thus without the guarantee that values will come in as strings. I was happy when
data.map(d3.autoType)
worked (in a case that happened to be all strings), and then surprised when another time it didn't. (I only came across this thanks to @enjalot!)(Then again, I also actually initially guessed it'd be part of d3-array, and maybe that oughta be warning to me that this is out of scope; maybe if you were writing a more general-purpose autoType, many things would be different.)