oramics/dsp-kit

View on GitHub
packages/signal/lib/buffer.js

Summary

Maintainability
A
0 mins
Test Coverage
/**
 * @module signal/buffer
 */

/**
 * @name data
 * @function
 */
export const data = (data) => () => data

export function loop (data) {
  const len = data.length
  let index = 0
  return function () {
    const val = data[index]
    index = (index + 1) % len
    return val
  }
}

export const peek = (data, index, opts) => {
  return () => {
    const val = data[index]
    index++
    return val
  }
}