@bbn/bbn 1.0.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/dist/fn/shuffle.d.ts +7 -0
- package/dist/fn/shuffle.js +20 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +7 -0
- package/package.json +29 -0
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
*
|
|
3
|
+
* @param {Array} array
|
|
4
|
+
* @returns Array
|
|
5
|
+
*/
|
|
6
|
+
const shuffle = function (array) {
|
|
7
|
+
let currentIndex = array.length, randomIndex;
|
|
8
|
+
// While there remain elements to shuffle.
|
|
9
|
+
while (currentIndex != 0) {
|
|
10
|
+
// Pick a remaining element.
|
|
11
|
+
randomIndex = Math.floor(Math.random() * currentIndex);
|
|
12
|
+
currentIndex--;
|
|
13
|
+
// And swap it with the current element.
|
|
14
|
+
[array[currentIndex], array[randomIndex]] = [
|
|
15
|
+
array[randomIndex], array[currentIndex]
|
|
16
|
+
];
|
|
17
|
+
}
|
|
18
|
+
return array;
|
|
19
|
+
};
|
|
20
|
+
export { shuffle };
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@bbn/bbn",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Javascript toolkit",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"files": [
|
|
8
|
+
"/dist"
|
|
9
|
+
],
|
|
10
|
+
"scripts": {
|
|
11
|
+
"test": "echo \"Error: no test specified\" && exit 1"
|
|
12
|
+
},
|
|
13
|
+
"keywords": [
|
|
14
|
+
"toolkit"
|
|
15
|
+
],
|
|
16
|
+
"author": "Thomas Nabet <thomas.nabet@gmail.com>",
|
|
17
|
+
"license": "ISC",
|
|
18
|
+
"devDependencies": {
|
|
19
|
+
"typescript": "^5.2.2"
|
|
20
|
+
},
|
|
21
|
+
"repository": {
|
|
22
|
+
"type": "git",
|
|
23
|
+
"url": "git+https://github.com/nabab/bbn-js.git"
|
|
24
|
+
},
|
|
25
|
+
"bugs": {
|
|
26
|
+
"url": "https://github.com/nabab/bbn-js/issues"
|
|
27
|
+
},
|
|
28
|
+
"homepage": "https://github.com/nabab/bbn-js#readme"
|
|
29
|
+
}
|