Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

knuth-shuffle-seeded

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

knuth-shuffle-seeded - npm Package Compare versions

Comparing version 1.0.5 to 1.0.6

.travis.yml

4

bower.json
{
"name": "knuth-shuffle-seeded",
"version": "1.0.5",
"main": "shuffle.js",
"version": "1.0.6",
"main": "browser.js",
"dependencies": {},
"devDependencies": {}
}

@@ -1,2 +0,2 @@

// Node.js demo
// This is a demo of using knuth-shuffle-seeded with Node.js.

@@ -6,22 +6,33 @@ 'use strict'

var shuffle = require('./')
, a = [2,11,37,42]
, assert = require('assert')
, a = [ 2, 11, 37, 42 ]
// The shuffle modifies the original array
// calling a.slice(0) creates a copy, which is assigned to b
var b = shuffle(a.slice(0))
console.log(b)
// shuffle() modifies the original array as well.
// Calling a.slice(0) creates a copy, which is then assigned to b
var copy = a.slice(0)
var b = shuffle(copy)
console.log(copy, b)
// Seed the following two functions the same way. The output should be the
// same.
var c = shuffle(a.slice(0), 2)
console.log(c)
var d = shuffle(a.slice(0), 2)
console.log(d)
console.log(c, d)
// seed can be a string too:
// The seed can be a string too:
var e = shuffle(a.slice(0), 'str')
console.log(e)
var f = shuffle(a.slice(0), 'str')
console.log(f)
console.log(e, f)
var g = shuffle(a.slice(0), '\ns\0t\rr\uD834')
console.log(g)
// It can even be an object or array, although it is not recommended to do so:
var h = shuffle(a.slice(0), { obj: true })
var i = shuffle(a.slice(0), new Date(0))
var j = shuffle(a.slice(0), a)
console.log(h, i, j)
// But it can't be undefined or null. If it is, then the "seed" is discarded
// and a random one will be used.

@@ -17,2 +17,3 @@ /*

*/
'use strict'

@@ -19,0 +20,0 @@

{
"name": "knuth-shuffle-seeded",
"version": "1.0.5",
"version": "1.0.6",
"description": "The Fisher-Yates (aka Knuth) shuffle for Node.js, with seeding support",
"main": "index.js",
"scripts": {
"test": "node example.js",
"prepublish": "browserify -s shuffle -g uglifyify -o shuffle.js index.js"
"test": "mocha",
"browserify": "browserify -s shuffle -g uglifyify -o browser.js index.js",
"prepublish": "npm run browserify",
"coverage": "istanbul cover node_modules/mocha/bin/_mocha",
"codecov": "npm run coverage && cat ./coverage/lcov.info | codecov"
},

@@ -42,4 +45,7 @@ "homepage": "https://github.com/TimothyGu/knuth-shuffle-seeded",

"browserify": "~8.1.1",
"codecov.io": "~0.0.8",
"istanbul": "~0.3.5",
"mocha": "~2.1.0",
"uglifyify": "~3.0.1"
}
}

@@ -1,5 +0,8 @@

knuth-shuffle-seeded
====================
# knuth-shuffle-seeded
[![npm](https://img.shields.io/npm/v/knuth-shuffle-seeded.svg?style=flat)](https://www.npmjs.com/package/knuth-shuffle-seeded)
[![Build Status](https://img.shields.io/travis/TimothyGu/knuth-shuffle-seeded/gh-pages.svg?style=flat)](https://travis-ci.org/TimothyGu/knuth-shuffle-seeded)
[![Dependencies](https://img.shields.io/david/TimothyGu/knuth-shuffle-seeded.svg?style=flat)](https://david-dm.org/TimothyGu/knuth-shuffle-seeded#info=dependencies)
[![devDependencies](https://img.shields.io/david/dev/TimothyGu/knuth-shuffle-seeded.svg?style=flat)](https://david-dm.org/TimothyGu/knuth-shuffle-seeded#info=devDependencies)
[![Code Coverage](https://img.shields.io/codecov/c/github/TimothyGu/knuth-shuffle-seeded.svg?style=flat)](https://codecov.io/github/TimothyGu/knuth-shuffle-seeded?branch=gh-pages)

@@ -9,27 +12,37 @@ The Fisher-Yates (aka Knuth) shuffle for the browser and Node.js, with seeds

This project is initially forked from [coolaj86/knuth-shuffle]
(https://github.com/coolaj86/knuth-shuffle), but extended so that it is
possible to specify a seed to use in the shuffling, to ensure test
reproducability.
This project is initially forked from
[coolaj86/knuth-shuffle](https://github.com/coolaj86/knuth-shuffle), but is
extended so that it is possible to specify a seed to use in the shuffling, to
ensure test reproducability.
Demo: https://timothygu.github.io/knuth-shuffle-seeded/
Online demo: https://timothygu.github.io/knuth-shuffle-seeded/
Getting Started
---------------
## Getting Started
### Node.js
npm install knuth-shuffle-seeded
Installing:
Then look at example.js.
```sh
npm install knuth-shuffle-seeded
```
### The Browser
Put shuffle.js into your `js/`. Then look at index.html.
Put browser.js into your directory for JavaScripts. Then take a look at
index.html.
You can also visit the page at http://timothygu.github.io/knuth-shuffle-seeded/.
You can also visit the page at
https://timothygu.github.io/knuth-shuffle-seeded/.
Why not contribute to the original repo?
----------------------------------------
### API
```js
shuffle(inputArray[, seed])
```
See example.js for more examples.
## Why not contribute to the original repo?
I have considered that, but the introduction of an npm dependency makes it

@@ -39,4 +52,3 @@ necessary to use Browserify to generate a browser-compatible JavaScript file,

Authors
-------
## Authors

@@ -46,6 +58,6 @@ - AJ O'Neal (@coolaj86) -- initial author

License
-------
## License
Copyright 2013 AJ O'Neal
Copyright 2015 Tiancheng "Timothy" Gu

@@ -52,0 +64,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc