@@ -17,9 +17,11 @@ export function valueof(data, value, type) {
17
17
? map ( data , constant ( value ) , type )
18
18
: typeof value ?. transform === "function"
19
19
? maybeTypedArrayify ( value . transform ( data ) , type )
20
- : value && data ?. reindex
21
- ? maybeTypedMap ( data . reindex , ( i ) => value [ i ] , type )
22
- : maybeTypedArrayify ( value , type ) ;
20
+ : maybeTake ( maybeTypedArrayify ( value , type ) , data ?. reindex ) ;
21
+ }
22
+
23
+ function maybeTake ( values , index ) {
24
+ return index ? take ( values , index ) : values ;
23
25
}
24
26
25
27
function maybeTypedMap ( data , f , type ) {
@@ -172,6 +174,7 @@ export function isScaleOptions(option) {
172
174
173
175
// Disambiguates an options object (e.g., {y: "x2"}) from a channel value
174
176
// definition expressed as a channel transform (e.g., {transform: …}).
177
+ // TODO Check typeof option[Symbol.iterator] !== "function"?
175
178
export function isOptions ( option ) {
176
179
return isObject ( option ) && typeof option . transform !== "function" ;
177
180
}
@@ -225,7 +228,7 @@ export function where(data, test) {
225
228
226
229
// Returns an array [values[index[0]], values[index[1]], …].
227
230
export function take ( values , index ) {
228
- return map ( index , ( i ) => values [ i ] ) ;
231
+ return map ( index , ( i ) => values [ i ] , values . constructor ) ;
229
232
}
230
233
231
234
// If f does not take exactly one argument, wraps it in a function that uses take.
0 commit comments