afridho-utils
TypeScript icon, indicating that this package has built-in type declarations

1.1.0 • Public • Published

afridho-utils

A lightweight utility library for JavaScript/TypeScript with handy functions like random number generation and currency formatting for Indonesian Rupiah (IDR).

Features

  • Generate random integers within a range
  • Format numbers as Indonesian Rupiah currency strings
  • Modular design with support for both CommonJS and ES Modules

Installation

npm install afridho-utils

Usage

Import entire package

import { getRandomNumber, toIdr } from "afridho-utils";

console.log(getRandomNumber(1, 100)); // e.g. 42
console.log(toIdr(1500000)); // Rp 1.500.000

Import specific modules (subpath imports)

import { toIdr } from "afridho-utils/currency";
const getRandomNumber = require("afridho-utils/number");

console.log(toIdr(50000)); // Rp 50.000
console.log(getRandomNumber(5, 10)); // e.g. 7

API

⁠getRandomNumber(min: number, max: number): number Generates a random integer between ⁠min and ⁠max (inclusive).

⁠toIdr(amount: number): string Formats a number as Indonesian Rupiah currency string. Returns ⁠'Invalid Amount.' if input is invalid.

Release (Developer)

How to set up standard-version

  1. Install as dev dependency: npm install --save-dev standard-version
  2. Add release script to ⁠package.json:
"scripts": {
  "release": "standard-version"
}
  1. Use Conventional Commits style in your commit messages, e.g.:
feat: add roundToDecimals function
fix: correct typo in toIdr function
  1. Run release:
npm run release
npm run publish

Readme

Keywords

none

Package Sidebar

Install

npm i afridho-utils

Weekly Downloads

1

Version

1.1.0

License

ISC

Unpacked Size

11.4 kB

Total Files

22

Last publish

Collaborators

  • afridhozega