This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Get a random integer. | |
* @author mebtte<mebtte@gamil.com> | |
* @param {Number} [min] Minimum integer, default `0`. | |
* @param {Number} [max] Maximum integer, default `1`. | |
* @return {Number} A random integer between `min` and `max` that include `min` but do not include `max`. | |
*/ | |
function getRandomInteger(min = 0, max = 1) { | |
return Math.floor(min + Math.random() * (max - min)); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# node.js & npm & yarn | |
node_modules/ | |
package-lock.json | |
yarn.lock | |
# macOS | |
.DS_Store | |
# Windows |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Get a random string. | |
* @author mebtte<mebtte@gamil.com> | |
* @param {String} [length] The length of string, detault `10`. | |
* @return {String} A random string. | |
*/ | |
function getRandomString(length = 10) { | |
const randomChars = [ | |
"0", | |
"1", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Get the type of value. | |
* @author mebtte<mebtte@gmail.com> | |
* @param {Any} [value] value | |
* @return {String} enum(Undefined, Null, Boolean, Number, String, Symbol, Object, Function, Array, Set, WeakSet, Map, WeakMap, NodeList) | |
*/ | |
function typeOf(value) { | |
return Object.prototype.toString.call(value).match(/\[object (\S*)\]/)[1]; | |
} |