npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

persist-unique-random

v0.1.2

Published

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

Downloads

1

Readme

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.

Module Reference

constructor(options)

  • min: default=0
  • max: default=16, range is 0-max-1 . i.e. default is 0-15 integer
  • persist: set false if you dont wan't to save array file. default=true
  • id: array id. this module keeps each seeds(random arrays) per 'id+min+max' pair. default='ID'
  • fileDir: string of directory path of array file. default='$HOME/.persist-unique-random/'
  • fileName: string of array file. default='persist-unique-random.json'
  • reshuffle: set true is you want to re-shuffle random array at loop point. default=false
  • forceSeed: number. force set random seed.

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

  • 0.1.x: beta release

Idea