nl_tokens: Reduces the size of a data array such that it is < = maxPoints .
pl_tokens: function downsample ( data , maxPoints , startingIndex = 0 ) { // ensures that the downampling of data while zooming looks good. const dataLength = getLength ( data ) ; if ( dataLength > maxPoints ) { // limit k to powers of 2, e.g. 64, 128, 256 // so that the same points will be chosen reliably, reducing flicker on zoom const k = Math . pow ( 2 , Math . ceil ( Math . log2 ( dataLength / maxPoints ) ) ) ; return <mask> . filter ( // ensure modulo is always calculated from same reference: i + startingIndex ( d , i ) => ( i + startingIndex ) % k === 0 ) ; } return data ; }