Creates a moving window
// Create a moving window of 3 samplesconst window = movingWindow(3);window(1); // [ 1 ]window(2); // [ 1, 2 ]window(3); // [ 1, 2, 3 ]window(4); // [ 2, 3, 4 ] Copy
// Create a moving window of 3 samplesconst window = movingWindow(3);window(1); // [ 1 ]window(2); // [ 1, 2 ]window(3); // [ 1, 2, 3 ]window(4); // [ 2, 3, 4 ]
'reject' option allows values to be discarded:
// Reject all NaN valuesconst window = movingWindow({ samples: 3, reject: (v) => Number.isNaN(v) }); Copy
// Reject all NaN valuesconst window = movingWindow({ samples: 3, reject: (v) => Number.isNaN(v) });
'allow' is similar, but is applied after 'reject' (if provided). Instead, values must pass true
If a reject/disallow is triggered, the current state of the queue is returned.
Creates a moving window
'reject' option allows values to be discarded:
'allow' is similar, but is applied after 'reject' (if provided). Instead, values must pass true
If a reject/disallow is triggered, the current state of the queue is returned.