@onurege3467/zerohelper 1.3.0 → 1.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/functions/functions.js +10 -0
- package/package.json +1 -1
- package/readme.md +1 -0
package/functions/functions.js
CHANGED
|
@@ -67,6 +67,15 @@ function isUUID(str, version) {
|
|
|
67
67
|
|
|
68
68
|
return (pattern && pattern.test(str)) || false;
|
|
69
69
|
}
|
|
70
|
+
function shuffleArray(array) {
|
|
71
|
+
let currentIndex = array.length;
|
|
72
|
+
while (currentIndex != 0) {
|
|
73
|
+
let randomIndex = Math.floor(Math.random() * currentIndex);
|
|
74
|
+
currentIndex--;
|
|
75
|
+
[array[currentIndex], array[randomIndex]] = [
|
|
76
|
+
array[randomIndex], array[currentIndex]];
|
|
77
|
+
}
|
|
78
|
+
}
|
|
70
79
|
module.exports = {
|
|
71
80
|
makeUniqueId,
|
|
72
81
|
randomArray,
|
|
@@ -78,4 +87,5 @@ module.exports = {
|
|
|
78
87
|
uuid,
|
|
79
88
|
isUUID,
|
|
80
89
|
},
|
|
90
|
+
shuffleArray
|
|
81
91
|
};
|
package/package.json
CHANGED
package/readme.md
CHANGED
|
@@ -17,6 +17,7 @@ console.log(functions.randomEmoji()) // returns a random emoji
|
|
|
17
17
|
console.log(functions.randomHex()) // returns a random hex code
|
|
18
18
|
console.log(functions.randomNumber()) // returns random number
|
|
19
19
|
console.log(functions.randomText()) // returns random text
|
|
20
|
+
console.log(functions.shuffleArray([1,2,3,4,5,6,7,8,9,0])) // returns shuffled array like [3,5,2,1,7,6,8,9,0]
|
|
20
21
|
```
|
|
21
22
|
## Using ZeroHelper As Database
|
|
22
23
|
ZeroHelper's database is divided into 3 parts.
|