Gathering detailed insights and metrics for onetime-rnd
Gathering detailed insights and metrics for onetime-rnd
npm install onetime-rnd
Typescript
Module System
Node Version
NPM Version
70.8
Supply Chain
98.8
Quality
75.2
Maintenance
100
Vulnerability
100
License
Cumulative downloads
Total Downloads
Last day
0%
1
Compared to previous day
Last week
-40%
3
Compared to previous week
Last month
-33.3%
10
Compared to previous month
Last year
-4.5%
128
Compared to previous year
4
Generate unique random number
$ npm i onetime-rnd
or
1<script src="https://unpkg.com/onetime-rnd@1.0.2/dist/index.js"></script>
By default if you don't pass any arguments it will generate number between 0 and 100 inclusive.
1const OneTimeRnd = require("onetime-rnd"); 2 3const rnd = new OneTimeRnd({ from: 1, to: 3 }); 4 5console.log(rnd.next()); //1 6console.log(rnd.next()); //3 7console.log(rnd.next()); //2 8console.log(rnd.next()); //undefined
Generate float number. Here in this case you will generate 3 float for each number so you have 3 numbers * 3 floats = 9 numbers
1const rnd = new OneTimeRnd({ from: 1, to: 3, float: 3 }); 2 3console.log(rnd.next()); //1.156449849 4console.log(rnd.next()); //3.416419571 5console.log(rnd.next()); //2.711771777 6console.log(rnd.next()); //2.525252524 7console.log(rnd.next()); //3.272727227 8console.log(rnd.next()); //2.525228282
Will generate new numbers at the end of the first iteration (exclusive will not generate float numbers for 1).
1const rnd = new OneTimeRnd({ 2 from: 0, 3 to: 1, 4 float: 2, 5 exclusive: true, 6 autoRefresh: true, 7}); 8 9console.log(rnd.next()); //0.1564498495 10console.log(rnd.next()); //0.4481797174 11console.log(rnd.next()); //0.5252772721 12console.log(rnd.next()); //0.7971117657 13console.log(rnd.next()); //0.7171617261 14console.log(rnd.next()); //0.7167197129
When all the number are done it will return the same sequence in the same order.
1const rnd = new OneTimeRnd({ from: 1, to: 3, repeat: true }); 2 3console.log(rnd.next()); //1 4console.log(rnd.next()); //3 5console.log(rnd.next()); //2 6console.log(rnd.next()); //1 7console.log(rnd.next()); //3 8console.log(rnd.next()); //2
Will display the same numbers but in a different order.
1const rnd = new OneTimeRnd({ 2 from: 1, 3 to: 3, 4 repeat: true, 5 shuffleOnRepeat: true, 6}); 7 8console.log(rnd.next()); //1 9console.log(rnd.next()); //3 10console.log(rnd.next()); //2 11console.log(rnd.next()); //2 12console.log(rnd.next()); //1 13console.log(rnd.next()); //3
Refresh the list by generating new numbers (for float) and making a new shuffle.
1const rnd = new OneTimeRnd({ 2 from: 1, 3 to: 3, 4}); 5 6console.log(rnd.next()); //1 7console.log(rnd.next()); //3 8console.log(rnd.next()); //2 9rnd.refresh(); 10console.log(rnd.next()); //2 11console.log(rnd.next()); //1 12console.log(rnd.next()); //3
Shuffle the numbers.
1const rnd = new OneTimeRnd({ 2 from: 1, 3 to: 3, 4}); 5 6rnd.shuffle(); 7 8console.log(rnd.next()); //1 9console.log(rnd.next()); //3 10console.log(rnd.next()); //2
Start the function passed as argument when all the numbers are done.
1const rnd = new OneTimeRnd({ 2 from: 1, 3 to: 3, 4}); 5 6rnd.onEnd(function () { 7 console.log("Done !"); 8}); 9 10console.log(rnd.next()); //1 11console.log(rnd.next()); //3 12console.log(rnd.next()); //2 13rnd.next(); // Done !
No vulnerabilities found.
No security vulnerabilities found.