How to use fast-shuffle - 3 common examples

To help you get started, we’ve selected a few fast-shuffle examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github DefinitelyTyped / DefinitelyTyped / types / fast-shuffle / fast-shuffle-tests.ts View on Github external
import shuffle from 'fast-shuffle';

{
    const d1 = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H'];
    const d2: string[] = shuffle(d1);
    const d3: string[] = shuffle(d1, () => 0.42);
}

{
  const d1 = [
    { name: 'Alice', money: 10 },
    { name: 'Betty', money: 20 },
    { name: 'Cindy', money: 15 }
  ];
  const d2: Array<{ name: string, money: number }> = shuffle(d1);
  const d3: Array<{ name: string, money: number }> = shuffle(d1, () => 0.42);
}
github DefinitelyTyped / DefinitelyTyped / types / fast-shuffle / fast-shuffle-tests.ts View on Github external
import shuffle from 'fast-shuffle';

{
    const d1 = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H'];
    const d2: string[] = shuffle(d1);
    const d3: string[] = shuffle(d1, () => 0.42);
}

{
  const d1 = [
    { name: 'Alice', money: 10 },
    { name: 'Betty', money: 20 },
    { name: 'Cindy', money: 15 }
  ];
  const d2: Array<{ name: string, money: number }> = shuffle(d1);
  const d3: Array<{ name: string, money: number }> = shuffle(d1, () => 0.42);
}
github ESWAT / voidview / src / renderer / index.js View on Github external
function shuffleFiles () {
  const shuffleList = document.querySelectorAll('.js-item')
  files = shuffle(files)

  shuffleList.forEach((item, index) => {
    const durations = [0.2, 0.35, 0.5]

    item.style['animation-duration'] = `${durations[Math.floor(Math.random() * 3)]}s`
    item.classList.add('shuffling')
  })

  setTimeout(() => {
    renderFiles()
    document.querySelector('#app').scrollTop = 0
  }, 500)
}

fast-shuffle

A fast implementation of a fisher-yates shuffle that does not mutate the source array.

MIT
Latest version published 5 months ago

Package Health Score

71 / 100
Full package analysis

Popular fast-shuffle functions