knuth-shuffle-seeded
Advanced tools
Comparing version 1.0.1 to 1.0.2
{ | ||
"name": "knuth-shuffle-seeded", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"main": "shuffle.js", | ||
@@ -5,0 +5,0 @@ "dependencies": {}, |
@@ -21,5 +21,7 @@ // Node.js demo | ||
// seed can be a string too: | ||
var e = shuffle(a.slice(0), 'string') | ||
console.log(c) | ||
var f = shuffle(a.slice(0), 'string') | ||
console.log(d) | ||
var e = shuffle(a.slice(0), 'str') | ||
console.log(e) | ||
var f = shuffle(a.slice(0), 'str') | ||
console.log(f) | ||
var g = shuffle(a.slice(0), '\ns\0t\rr\uD834') | ||
console.log(g) |
@@ -49,3 +49,5 @@ /* | ||
, randomIndex | ||
, rand = randGen(seed || Math.random()) | ||
, rand | ||
if (arguments.length < 2) rand = randGen() | ||
else rand = randGen(seed) | ||
@@ -58,3 +60,3 @@ if (array.constructor !== Array) throw new Error('Input is not an array') | ||
// Pick a remaining element... | ||
randomIndex = Math.floor(rand() * currentIndex --) | ||
randomIndex = Math.floor(rand() * (currentIndex --)) | ||
@@ -61,0 +63,0 @@ // And swap it with the current element. |
{ | ||
"name": "knuth-shuffle-seeded", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"description": "The Fisher-Yates (aka Knuth) shuffle for Node.js, with seeding support", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var f;"undefined"!=typeof window?f=window:"undefined"!=typeof global?f=global:"undefined"!=typeof self&&(f=self),f.shuffle=e()}}(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){ | ||
"use strict";var randGen=require("seed-random");module.exports=function(r,n){var o,t,a,e=randGen(n||Math.random());if(r.constructor!==Array)throw new Error("Input is not an array");for(o=r.length;0!==o;)a=Math.floor(e()*o--),t=r[o],r[o]=r[a],r[a]=t;return r}; | ||
"use strict";var randGen=require("seed-random");module.exports=function(r,n){var e,t,a,o;if(o=arguments.length<2?randGen():randGen(n),r.constructor!==Array)throw new Error("Input is not an array");for(e=r.length;0!==e;)a=Math.floor(o()*e--),t=r[e],r[e]=r[a],r[a]=t;return r}; | ||
},{"seed-random":2}],2:[function(require,module,exports){ | ||
@@ -4,0 +4,0 @@ (function (global){ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1048092
692