@febin52/shuffle-array-fast 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/LICENSE ADDED
@@ -0,0 +1 @@
1
+ MIT License
package/README.md ADDED
@@ -0,0 +1,8 @@
1
+ # 🔀 @febin52/shuffle-array-fast
2
+
3
+ > Fisher-Yates array randomizer.
4
+
5
+ ```ts
6
+ import { shuffle } from '@febin52/shuffle-array-fast';
7
+ shuffle([1, 2, 3, 4, 5]);
8
+ ```
package/dist/index.cjs ADDED
@@ -0,0 +1 @@
1
+ (function(e,n){typeof exports=="object"&&typeof module<"u"?n(exports):typeof define=="function"&&define.amd?define(["exports"],n):(e=typeof globalThis<"u"?globalThis:e||self,n(e.Pkg={}))})(this,function(e){"use strict";function n(i){const t=i.slice();for(let o=t.length-1;o>0;o--){const f=Math.floor(Math.random()*(o+1));[t[o],t[f]]=[t[f],t[o]]}return t}e.shuffle=n,Object.defineProperty(e,Symbol.toStringTag,{value:"Module"})});
@@ -0,0 +1,3 @@
1
+ export declare function shuffle<T>(arr: T[]): T[];
2
+
3
+ export { }
package/dist/index.js ADDED
@@ -0,0 +1,11 @@
1
+ function r(n) {
2
+ const t = n.slice();
3
+ for (let o = t.length - 1; o > 0; o--) {
4
+ const e = Math.floor(Math.random() * (o + 1));
5
+ [t[o], t[e]] = [t[e], t[o]];
6
+ }
7
+ return t;
8
+ }
9
+ export {
10
+ r as shuffle
11
+ };
package/package.json ADDED
@@ -0,0 +1,41 @@
1
+ {
2
+ "name": "@febin52/shuffle-array-fast",
3
+ "version": "1.0.0",
4
+ "description": "Fisher-Yates random array shuffle algorithm.",
5
+ "main": "./dist/index.cjs",
6
+ "module": "./dist/index.js",
7
+ "types": "./dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "import": "./dist/index.js",
12
+ "require": "./dist/index.cjs"
13
+ }
14
+ },
15
+ "files": [
16
+ "dist",
17
+ "README.md",
18
+ "LICENSE"
19
+ ],
20
+ "scripts": {
21
+ "build": "tsc && vite build",
22
+ "test": "vitest run"
23
+ },
24
+ "keywords": [
25
+ "shuffle",
26
+ "array",
27
+ "randomize",
28
+ "fisher-yates",
29
+ "random"
30
+ ],
31
+ "author": "Febin Francis",
32
+ "license": "MIT",
33
+ "repository": {
34
+ "type": "git",
35
+ "url": "git+https://github.com/febin52/shuffle-array-fast.git"
36
+ },
37
+ "bugs": {
38
+ "url": "https://github.com/febin52/shuffle-array-fast/issues"
39
+ },
40
+ "homepage": "https://github.com/febin52/shuffle-array-fast#readme"
41
+ }