Economizing Technology >

persist-unique-random - Unique Random Array Generator with Persist(saving to file) Feature + Command Line Tool


An Unique Random Array Generator with Persist(saving to file) Feature + Command Line Tool

PersistUniqueRandom=require('persist-unique-random');
rng=new PersistUniqueRandom({max:10});

for(var i=0;i<20;i++) console.log(rng.next());
//-> 7 5 6 2 3 8 9 1 4 0 7 5 6 ... (loop 7 5 6..)

rngShuffle=new PersistUniqueRandom({max:10,reshuffle:true});

for(var i=0;i<20;i++) console.log(rngShuffle.next());
//-> 7 5 6 2 3 8 9 1 4 0 8 2 1 ... (re-shuffle at loop point)

// * arrays are saved to $HOME/.persist-unique-random/persist-unique-random.json per 'id+min+max' pairs.

Index

  1. Module Reference
  2. Install(CLI command line tool)
  3. Command line
  4. Options
  5. Examples
  6. Change Log
  7. Idea
  8. Comments

Module Reference

constructor(options)

each seeds and index of unique random arrays are saved to a file to use next run of the process.

seed and index are saved per 'id+min+max' pair.

you can set persist:false to make this module as ordnary unique random array generator. index and arrays are not saved to file. this means random number will not be unique if you re-execute the process.

next()

returns random integer. index will be saved at this point.

reset()

reset current (id+min+max) random array.and save file.

resetAll()

reset all random array.and save file.

Install(CLI command line tool)

npm i -g persist-unique-random

Command line

unique-random [options]

Unique Random Array Generator with Persist(saving to file) Feature + Command Line Tool

Copyright (C) 2019-2019 @kssfilo(https://kanasys.com/gtech/)

Options

- h          show this help
- ?          
- d          debug mode
- r          reset specified random array. 
- R          reset all random arrays.
- i <id>     random array id. random arrays are saved per id+min+max pair. default('ID')
- x <max>    max value. e.g. 10 -> [0..9]. default:16
- n <min>    min value. default:0
- s          re-shuffle when random array loops. default:loops same array
- S <number> force override seed number. e.g. 12345. default:random number or saved seed.
- D <dir>    directory to save random array seeds. default:$HOME/.persist-unique-random
- f <file>   file name to save random array seeds. default:persist-unique-random
- N          don't save/load random arrays.(generates non-unique random number)

Examples

Change Log

Idea

Popular Articles from This Page

Economizing Technology >

Comments

Top Page

Economizing Technology > persist-unique-random - Unique Random Array Generator with Persist(saving to file) Feature + Command Line Tool