randomcryp 2.1.2 → 2.2.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/index.js +1 -1
- package/dist/lib/shuffle.d.ts +1 -0
- package/package.json +15 -6
- package/bunfig.toml +0 -5
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var
|
|
1
|
+
var N=Math.pow(2,37),R=Math.pow(2,21),D=Math.pow(2,5),L=()=>{let[z,B,H,J]=crypto.getRandomValues(new Uint16Array(4));return z*N+B*R+H*D+(J&D-1)};var Q=()=>L()%2===0;var S=Math.pow(2,53),C=()=>L()/S;var V=(z)=>{if(z.length===0)return;return z[Math.floor(C()*z.length)]};var U=(z=8,B=!1)=>{let H=crypto.getRandomValues(new Uint8Array(Math.ceil(z/2))),J=Array(H.length);for(let K=0,$=0;K<z;K++,$=Math.floor(K/2))if(K%2===0)J[K]="0123456789abcdef"[H[$]>>4];else J[K]="0123456789abcdef"[H[$]&15];if(B)return"0x"+J.join("");return J.join("")};var I=Math.pow(2,37),O=Math.pow(2,21),q=Math.pow(2,5),Z=()=>{let[z,B,H,J]=crypto.getRandomValues(new Uint16Array(4));return((J&q)<1?1:-1)*(z*I+B*O+H*q+(J&q-1))};var X=()=>Z()/Number.MAX_SAFE_INTEGER;var F=(z)=>{if(z<0||z>100)throw RangeError(`${z} is not in range [0, 100]`);return C()*100<z};var M=(z)=>{if(z<0||z>1)throw RangeError(`${z} is not in range [0, 1]`);return C()<z};var Y=(z,B)=>{if(z>B)throw RangeError("min must be less than or equal to max");return z+Math.floor(C()*(B-z+1))};var j=(z,B)=>{if(z>B)throw RangeError("min must be less than or equal to max");return z+C()*(B-z)};function T(z){let B=Array.from(z);for(let H=B.length-1;H>0;H--){let J=Math.floor(C()*(H+1)),K=B[H];B[H]=B[J],B[J]=K}return B}function k(z){if(typeof z==="string")return T(z).join("");else return T(z)}var Mz={bool:Q,boolean:Q,choice:V,float:C,hex:U,ifloat:X,percentage:F,probability:M,pick:V,randInt:Y,random:C,range:j,rangeInt:Y,safeInt:Z,shuffle:k,uSafeInt:L};export{L as uSafeInt,k as shuffle,Z as safeInt,Y as rangeInt,j as range,C as random,Y as randInt,M as probability,V as pick,F as percentage,X as ifloat,U as hex,C as float,Mz as default,V as choice,Q as boolean,Q as bool};
|
package/dist/lib/shuffle.d.ts
CHANGED
|
@@ -6,4 +6,5 @@ declare function shuffle(input: string): string;
|
|
|
6
6
|
* Returns a new array containing the elements of the input array in a shuffled order.
|
|
7
7
|
*/
|
|
8
8
|
declare function shuffle<E>(input: E[]): E[];
|
|
9
|
+
declare function shuffle<E>(input: ArrayLike<E> | Iterable<E>): E[];
|
|
9
10
|
export { shuffle };
|
package/package.json
CHANGED
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "randomcryp",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.2.0",
|
|
4
4
|
"license": "BSD-3-Clause",
|
|
5
5
|
"description": "A cryptographically secure, feature rich, zero dependency and browser friendly random number generator library.",
|
|
6
6
|
"author": {
|
|
7
7
|
"name": "Md. Touhidur Rahman",
|
|
8
8
|
"email": "touhidurrr@pm.me"
|
|
9
9
|
},
|
|
10
|
-
"repository":
|
|
10
|
+
"repository": {
|
|
11
|
+
"type": "git",
|
|
12
|
+
"url": "git+https://github.com/touhidurrr/randomcryp.git"
|
|
13
|
+
},
|
|
11
14
|
"homepage": "https://github.com/touhidurrr/randomcryp",
|
|
12
15
|
"bugs": "https://github.com/touhidurrr/randomcryp/issues",
|
|
13
16
|
"funding": "https://buymeacoffee.com/touhidurrr",
|
|
@@ -17,12 +20,18 @@
|
|
|
17
20
|
"types": "dist/index.d.ts",
|
|
18
21
|
"scripts": {
|
|
19
22
|
"format": "prettier --write .",
|
|
20
|
-
"build": "bun scripts/build.ts"
|
|
23
|
+
"build": "bun scripts/build.ts",
|
|
24
|
+
"lint": "eslint .",
|
|
25
|
+
"test": "bun test"
|
|
21
26
|
},
|
|
22
27
|
"devDependencies": {
|
|
23
|
-
"@
|
|
24
|
-
"
|
|
25
|
-
"
|
|
28
|
+
"@eslint/js": "^10.0.1",
|
|
29
|
+
"@types/bun": "^1.3.9",
|
|
30
|
+
"eslint": "^10.0.1",
|
|
31
|
+
"globals": "^17.3.0",
|
|
32
|
+
"prettier": "^3.8.1",
|
|
33
|
+
"typescript": "^5.9.3",
|
|
34
|
+
"typescript-eslint": "^8.56.0"
|
|
26
35
|
},
|
|
27
36
|
"keywords": [
|
|
28
37
|
"cryptographically-secure",
|