@alwatr/random 5.1.28 → 5.1.29

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/CHANGELOG.md CHANGED
@@ -3,6 +3,10 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [5.1.29](https://github.com/Alwatr/nanolib/compare/@alwatr/random@5.1.28...@alwatr/random@5.1.29) (2026-02-18)
7
+
8
+ **Note:** Version bump only for package @alwatr/random
9
+
6
10
  ## [5.1.28](https://github.com/Alwatr/nanolib/compare/@alwatr/random@5.1.27...@alwatr/random@5.1.28) (2025-12-23)
7
11
 
8
12
  **Note:** Version bump only for package @alwatr/random
package/dist/main.cjs CHANGED
@@ -1,4 +1,4 @@
1
- /** 📦 @alwatr/random v5.1.28 */
2
- __dev_mode__: console.debug("📦 @alwatr/random v5.1.28");
1
+ /** 📦 @alwatr/random v5.1.29 */
2
+ __dev_mode__: console.debug("📦 @alwatr/random v5.1.29");
3
3
  "use strict";var __defProp=Object.defineProperty;var __getOwnPropDesc=Object.getOwnPropertyDescriptor;var __getOwnPropNames=Object.getOwnPropertyNames;var __hasOwnProp=Object.prototype.hasOwnProperty;var __export=(target,all)=>{for(var name in all)__defProp(target,name,{get:all[name],enumerable:true})};var __copyProps=(to,from,except,desc)=>{if(from&&typeof from==="object"||typeof from==="function"){for(let key of __getOwnPropNames(from))if(!__hasOwnProp.call(to,key)&&key!==except)__defProp(to,key,{get:()=>from[key],enumerable:!(desc=__getOwnPropDesc(from,key))||desc.enumerable})}return to};var __toCommonJS=mod=>__copyProps(__defProp({},"__esModule",{value:true}),mod);var main_exports={};__export(main_exports,{bytesToHex:()=>bytesToHex,randArray:()=>randArray,randBoolean:()=>randBoolean,randColor:()=>randColor,randFloat:()=>randFloat,randInteger:()=>randInteger,randNumber:()=>randNumber,randPick:()=>randPick,randShuffle:()=>randShuffle,randStep:()=>randStep,randString:()=>randString,randUuid:()=>randUuid});module.exports=__toCommonJS(main_exports);var import_global_this=require("@alwatr/global-this");var globalThis=(0,import_global_this.getGlobalThis)();var hasCrypto=(()=>typeof globalThis.crypto!=="undefined")();function bytesToHex(bytes){let result="";for(const byte of bytes){const hex=byte.toString(16);result+=hex.length===1?"0"+hex:hex}return result}function randNumber(){return Math.random()}function randFloat(min,max){return Math.random()*(max-min)+min}function randInteger(min,max){return Math.floor(randFloat(min,max+1))}function randString(minLength,maxLength=minLength,chars="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"){const length=maxLength===minLength?minLength:randInteger(minLength,maxLength);if(length<=0)return"";const charsLength=chars.length;let result="";if(length<=10){for(let i=0;i<length;i++){result+=chars.charAt(Math.floor(Math.random()*charsLength))}return result}const resultArray=new Array(length);for(let i=0;i<length;i++){resultArray[i]=chars.charAt(Math.floor(Math.random()*charsLength))}return resultArray.join("")}function randStep(min,max,step){if(step===0){return min}const steps=Math.floor((max-min)/step);return min+randInteger(0,steps)*step}function randShuffle(array){for(let i=array.length-1;i>0;i--){const j=randInteger(0,i);[array[i],array[j]]=[array[j],array[i]]}return array}function randPick(array){if(array.length===0)throw new Error("Cannot pick from empty array");return array[randInteger(0,array.length-1)]}function randArray(array,min=0,max=255){for(let i=array.length-1;i>=0;i--){array[i]=randInteger(min,max)}return array}function randUuid(){if(hasCrypto&&globalThis.crypto?.randomUUID){return globalThis.crypto.randomUUID()}const bytes=randArray(new Uint8Array(16));bytes[6]=bytes[6]&15|64;bytes[8]=bytes[8]&191|128;return`${bytesToHex(bytes.subarray(0,4))}-${bytesToHex(bytes.subarray(4,6))}-${bytesToHex(bytes.subarray(6,8))}-${bytesToHex(bytes.subarray(8,10))}-${bytesToHex(bytes.subarray(10,16))}`}function randBoolean(probability=.5){return Math.random()<probability}function randColor(){const bytes=randArray(new Array(3));return`#${bytesToHex(bytes)}`}0&&(module.exports={bytesToHex,randArray,randBoolean,randColor,randFloat,randInteger,randNumber,randPick,randShuffle,randStep,randString,randUuid});
4
4
  //# sourceMappingURL=main.cjs.map
package/dist/main.mjs CHANGED
@@ -1,4 +1,4 @@
1
- /** 📦 @alwatr/random v5.1.28 */
2
- __dev_mode__: console.debug("📦 @alwatr/random v5.1.28");
1
+ /** 📦 @alwatr/random v5.1.29 */
2
+ __dev_mode__: console.debug("📦 @alwatr/random v5.1.29");
3
3
  import{getGlobalThis}from"@alwatr/global-this";var globalThis=getGlobalThis();var hasCrypto=(()=>typeof globalThis.crypto!=="undefined")();function bytesToHex(bytes){let result="";for(const byte of bytes){const hex=byte.toString(16);result+=hex.length===1?"0"+hex:hex}return result}function randNumber(){return Math.random()}function randFloat(min,max){return Math.random()*(max-min)+min}function randInteger(min,max){return Math.floor(randFloat(min,max+1))}function randString(minLength,maxLength=minLength,chars="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"){const length=maxLength===minLength?minLength:randInteger(minLength,maxLength);if(length<=0)return"";const charsLength=chars.length;let result="";if(length<=10){for(let i=0;i<length;i++){result+=chars.charAt(Math.floor(Math.random()*charsLength))}return result}const resultArray=new Array(length);for(let i=0;i<length;i++){resultArray[i]=chars.charAt(Math.floor(Math.random()*charsLength))}return resultArray.join("")}function randStep(min,max,step){if(step===0){return min}const steps=Math.floor((max-min)/step);return min+randInteger(0,steps)*step}function randShuffle(array){for(let i=array.length-1;i>0;i--){const j=randInteger(0,i);[array[i],array[j]]=[array[j],array[i]]}return array}function randPick(array){if(array.length===0)throw new Error("Cannot pick from empty array");return array[randInteger(0,array.length-1)]}function randArray(array,min=0,max=255){for(let i=array.length-1;i>=0;i--){array[i]=randInteger(min,max)}return array}function randUuid(){if(hasCrypto&&globalThis.crypto?.randomUUID){return globalThis.crypto.randomUUID()}const bytes=randArray(new Uint8Array(16));bytes[6]=bytes[6]&15|64;bytes[8]=bytes[8]&191|128;return`${bytesToHex(bytes.subarray(0,4))}-${bytesToHex(bytes.subarray(4,6))}-${bytesToHex(bytes.subarray(6,8))}-${bytesToHex(bytes.subarray(8,10))}-${bytesToHex(bytes.subarray(10,16))}`}function randBoolean(probability=.5){return Math.random()<probability}function randColor(){const bytes=randArray(new Array(3));return`#${bytesToHex(bytes)}`}export{bytesToHex,randArray,randBoolean,randColor,randFloat,randInteger,randNumber,randPick,randShuffle,randStep,randString,randUuid};
4
4
  //# sourceMappingURL=main.mjs.map
package/package.json CHANGED
@@ -1,15 +1,15 @@
1
1
  {
2
2
  "name": "@alwatr/random",
3
3
  "description": "A lightweight utility library for generating random numbers, strings, UUIDs and more",
4
- "version": "5.1.28",
4
+ "version": "5.1.29",
5
5
  "author": "S. Ali Mihandoost <ali.mihandoost@gmail.com>",
6
6
  "bugs": "https://github.com/Alwatr/nanolib/issues",
7
7
  "dependencies": {
8
- "@alwatr/global-this": "5.6.8"
8
+ "@alwatr/global-this": "5.6.9"
9
9
  },
10
10
  "devDependencies": {
11
- "@alwatr/nano-build": "6.4.0",
12
- "@alwatr/prettier-config": "6.0.1",
11
+ "@alwatr/nano-build": "6.4.1",
12
+ "@alwatr/prettier-config": "6.0.2",
13
13
  "@alwatr/tsconfig-base": "6.0.4",
14
14
  "jest": "^30.2.0",
15
15
  "typescript": "^5.9.3"
@@ -89,5 +89,5 @@
89
89
  "sideEffects": false,
90
90
  "type": "module",
91
91
  "types": "./dist/main.d.ts",
92
- "gitHead": "35950cd5ceb1ae5a8ba4ac73852d286b7b3cd45f"
92
+ "gitHead": "f9f9ba54b319ce8ccc6968059b222e89f4b5d149"
93
93
  }