Skip to content

Conversation

@Fil
Copy link
Contributor

@Fil Fil commented Jun 2, 2023

Our types don't guarantee the presence of the third argument to valueof—it depends on whether some type conversion happens, which is an arbitrary implementation choice.

this PR normalizes the calls to valueof to three arguments: element, index, and data

previously data was present in some cases (when going through the arraytype.map code path) but not others (e.g. when doing type conversion)

Addresses this comment in #1665 (comment), guaranteeing that you can use a function filter(d, i, data) { return i < data.length-1 } to select any value but the last.

This seems a bit more robust and I don't expect any performance impact (the wrapper is invoked only when necessary). That said I'm not sure we should do this, or go the other way and ban the third argument—or ignore the issue altogether.

…*, and *data*

previously *data* was present in some cases (when going through the *arraytype*.map code path) but not others (e.g. when doing type conversion)

Addresses this comment in #1665 (comment)
@Fil Fil requested a review from mbostock June 2, 2023 11:44
@Fil Fil marked this pull request as draft June 26, 2023 17:04
@Fil
Copy link
Contributor Author

Fil commented Sep 13, 2023

closing as it doesn't seem necessary

@Fil Fil closed this Sep 13, 2023
@Fil Fil deleted the fil/valueof-pass-data branch August 5, 2024 17:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants