ixfx
    Preparing search index...

    Function movingWindow

    • Creates a moving window

      // Create a moving window of 3 samples
      const 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 values
      const 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.

      Type Parameters

      • T

      Parameters

      Returns (value: T) => T[]