Skip to content

Instantly share code, notes, and snippets.

@EmilienD
Created April 29, 2021 09:15
Show Gist options
  • Select an option

  • Save EmilienD/377a12bc672ad4503db70371319da61e to your computer and use it in GitHub Desktop.

Select an option

Save EmilienD/377a12bc672ad4503db70371319da61e to your computer and use it in GitHub Desktop.
One liner to use arrays as fifo cache without mutating the array
const fifo = limit => array => item => array.length === limit ? array.slice(1).concat(item) : array.concat(item)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment