secure-shuffle
Shuffle an array using secure-random-uniform as the RNG
Last updated 6 months ago by emilbayes .
ISC · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install secure-shuffle 
SYNC missed versions from official npm registry.

secure-shuffle

Shuffle an array using secure-random-uniform as the RNG

Install

npm install secure-shuffle

Usage

Note that this module mutates the passed array, as you can always .slice(0) to get a "cheap" copy:

const sshuffle = require('secure-shuffle')

const arr = [1, 2, 3, 4, 5, 6, 7, 8, 9]

const sarr = sshuffle(arr.slice(0)) // sarr is now a shuffled copy of arr

sshuffle(arr) // arr is now shuffled

API

###secureShuffle(arr)

Takes an array-like structure (eg. Buffer) and shuffles it. Note that the original will be mutated for performance reasons. You might want to copy the structure before passing it, depending on your use-case.

As a convenience, the passed structure will be returned.

License

ISC

Current Tags

  • 2.0.0                                ...           latest (6 months ago)

4 Versions

  • 2.0.0                                ...           6 months ago
  • 1.2.0                                ...           3 years ago
  • 1.1.0                                ...           4 years ago
  • 1.0.0                                ...           4 years ago
Maintainers (2)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 1
Dependencies (1)
Dev Dependencies (1)

Copyright 2014 - 2016 © taobao.org |