Rando.js: The world's easiest, most powerful random function.

栏目: IT技术 · 发布时间: 4年前

内容简介:The world's easiest, most powerful random function.

Rando.js: The world's easiest, most powerful random function.

Rando.js

The world's easiest, most powerful random function.

Rando.js: The world's easiest, most powerful random function.

Rando.js: The world's easiest, most powerful random function. Rando.js: The world's easiest, most powerful random function.

:hear_no_evil: What's all the hullabaloo?

Rando.js helps JavaScript developers code randomness more simply, readably, and securely. Whether you need to find a random int/float between two numbers, pick a random value from an array, choose a random element from your jQuery object, grab a character from a string, toss a coin, or do anything of the like while even preventing repetitions, we've got you covered at a cryptographically strong level. The best part? Our library is extremely lightweight and developer friendly- which means it won't take a toll on your project, and it's uber-simple to implement.

:zap: Fast implementation

Step 1:Paste the following script tag into the head of your HTML document:

<script src="https://randojs.com/2.0.0.js"></script>

Or, use npm:

//Install:
npm i @nastyox/rando.js@2.0.0

//Then, paste this at the top of your JavaScript file:
const randojs = require('@nastyox/rando.js'), rando = randojs.rando, randoSequence = randojs.randoSequence;

Step 2:Use any of the commands explained at https://randojs.com/ however you like.

:tada: Examples

rando()                       //a floating-point number between 0 and 1 (could be exactly 0, but never exactly 1)  
 rando(5)                      //an integer between 0 and 5 (could be 0 or 5)  
 rando(5, 10)                  //a random integer between 5 and 10 (could be 5 or 10)  
 rando(5, "float")             //a floating-point number between 0 and 5 (could be exactly 0, but never exactly 5)  
 rando(5, 10, "float")         //a floating-point number between 5 and 10 (could be exactly 5, but never exactly 10)  
 rando(true, false)            //either true or false  
 rando(["a", "b"])             //{index:..., value:...} object representing a value of the provided array OR false if array is empty  
 rando({a: 1, b: 2})           //{key:..., value:...} object representing a property of the provided object OR false if object has no properties  
 rando($("div"))               //{index:..., value:...} object representing a jQuery element from the provided jQuery element set OR false if the provided jQuery element set does not contain any elements  
 rando("Gee willikers!")       //a character from the provided string OR false if the string is empty. Reoccurring characters will naturally form a more likely return value  
 rando(null)                   //ANY invalid arguments return false  

⇢ Prevent repetitions by grabbing a sequence and looping through it

randoSequence(5)              //an array of integers from 0 through 5 in random order  
 randoSequence(5, 10)          //an array of integers from 5 through 10 in random order  
 randoSequence(["a", "b"])     //an array of {index:..., value:...} objects representing the values of the provided array in random order  
 randoSequence({a: 1, b: 2})   //an array of {key:..., value:...} objects representing the properties of the provided object in random order  
 randoSequence($("div"))       //an array of {index:..., value:...} objects representing all jQuery elements from the provided jQuery element set in random order  
 randoSequence("Good gravy!")  //an array of the characters of the provided string in random order  
 randoSequence(null)           //ANY invalid arguments return false

Rando.js: The world's easiest, most powerful random function.

Rando.js: The world's easiest, most powerful random function.


以上就是本文的全部内容,希望本文的内容对大家的学习或者工作能带来一定的帮助,也希望大家多多支持 码农网

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

个体与交互

个体与交互

Ken Howard、Barry Rogers / 贾永娜、张凯峰 / 机械工业出版社华章公司 / 2012-3-20 / 45.00元

对敏捷软件开发的关注重点,通常都集中在“机制”方面,即过程和工具。“敏捷宣言”认为,个体与交互的价值要高于过程和工具,但这一点很容易被遗忘。在敏捷开发中,如果你重新将注意力放在人的方面,将会收获巨大利益。 本书展示了如何解决敏捷团队在实际项目中遭遇的问题。同时,本书也是很有实用价值的敏捷用户指南,其中包含的故事、最佳实践方法、经验以及技巧均可应用到实际项目当中。通过逐步实践,你将学会如何让团......一起来看看 《个体与交互》 这本书的介绍吧!

RGB转16进制工具
RGB转16进制工具

RGB HEX 互转工具

Base64 编码/解码
Base64 编码/解码

Base64 编码/解码

SHA 加密
SHA 加密

SHA 加密工具