How to use array-shuffle - 2 common examples

To help you get started, we’ve selected a few array-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 mattdesl / svg-mesh-3d / demo / index.js View on Github external
import randomVec3 from 'gl-vec3/random'
import triangleCentroid from 'triangle-centroid'
import reindex from 'mesh-reindex'
import unindex from 'unindex-mesh'
import shuffle from 'array-shuffle'
import svgMesh3d from '../'

const createGeom = require('three-simplicial-complex')(THREE)
const fs = require('fs')

const tweenr = Tweenr({ defaultEase: 'expoOut' })
const vertShader = fs.readFileSync(__dirname + '/vert.glsl', 'utf8')
const fragShader = fs.readFileSync(__dirname + '/frag.glsl', 'utf8')
let files = fs.readdirSync(__dirname + '/svg/entypo-social')
  .filter(file => /\.svg$/.test(file))
files = shuffle(files)

document.querySelector('.count').innerText = files.length

const canvas = document.querySelector('canvas')
canvas.addEventListener('touchstart', (ev) => ev.preventDefault())
canvas.addEventListener('contextmenu', (ev) => ev.preventDefault())

const renderer = new THREE.WebGLRenderer({
  canvas: canvas,
  antialias: true,
  devicePixelRatio: window.devicePixelRatio
})
renderer.setClearColor(0x97c2c5, 1)

const scene = new THREE.Scene()
const camera = new THREE.PerspectiveCamera(50, 1, 0.01, 100)
github Wildhoney / Keo / example / js / components / question.js View on Github external
const render = compose(({ props, dispatch }) => {

    const countries = shuffle([ ...props.countries ]);
    const answers = [ props.country.capital, ...countries.filter(x => x.name !== props.country.name).slice(0, MAXIMUM_CHOICES - 1).map(x => x.capital) ];
    const sendAnswer = compose(() => dispatch(fetchCountry()), name => dispatch(setAnswer(name)));

    return (
        <section>

            { props.country.name &amp;&amp; `What is the capital of ${props.country.name}?` }

            <ul>

                {answers.map(name =&gt; {

                    return (
                        <li name=""> sendAnswer(name)}&gt;
                            {name}
                        </li></ul></section>

array-shuffle

Randomize the order of items in an array

MIT
Latest version published 3 years ago

Package Health Score

53 / 100
Full package analysis

Popular array-shuffle functions