dakini
v1.0.7
Published
utils for node.js
Readme
Dakini
Utility functions for Node.js (≥22) - random numbers, file system helpers, time formatting, and cross-platform directory paths.
Installation
npm install dakiniAPI
Random & Probability
random(n, isFloating)- Random number [0, n)range(min, max, isFloating)- Random number [min, max)flipCoin()- Random boolean (50/50)chance(chance, range)- Random boolean with probabilityshuffle(arr)- Shuffle array in place
Math
factorial(num)- Calculate factorial
Time
formatTimeRange(seconds)- Format time range as {days, hours, minutes, seconds}
File System
ensureDir(dir)- Create directory recursivelyreadFromFile(file)- Read file contents
System
getUsername()- Get current usernamegetConfigDir(app)- Get app config directory (XDG-compliant)getDataDir(app)- Get app data directorygetStateDir(app)- Get app state directorygetCacheDir(app)- Get app cache directory
Utilities
sleep(milliseconds)- Async delaygetCounter()- Returns incrementing counter function
License
GNU
