npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

ranrator

v1.0.1

Published

lightweight JavaScript library for generating random names that are unique, and high customizable

Readme

Ranrator.js Documentation

Lightweight JS library for generating random names that are unique, and customizable. Dev by masarisgk.

Table of Contents


Cara Pemasangan

Sertakan file library di halaman HTML/PHP Anda:

<script src="assets/js/ranrator.js"></script>

Opsi Penggunaan Lengkap

Library ini sangat fleksibel dan dapat dipanggil dengan berbagai cara:

A. Mendapatkan String (Tanpa Input)

Gunakan jika Anda hanya ingin mendapatkan teks hasil generate untuk disimpan di variabel atau diproses lebih lanjut.

// Mendapatkan string hostname
const text = ranrator({ tokenLength: 6 });

// Mendapatkan string password
const pass = ranrator.password({ complex: false });

B. Integrasi DOM (Mengisi Elemen Otomatis)

Anda dapat mengirimkan satu atau lebih elemen HTML (seperti <input>, <div>, atau <span>) sebagai argumen. Library akan otomatis mengisi nilai atau teks elemen tersebut dengan tambahan efek animasi.

Mengisi Satu Elemen

const input = document.getElementById('myInput');
ranrator(input, { tokenLength: 4 });

Mengisi Banyak Elemen Sekaligus (Synchronized)

Anda bisa mengirimkan banyak elemen sebagai argumen terpisah. Library akan men-generate satu nilai yang sama dan menerapkannya ke semua elemen tersebut secara sinkron.

const input = document.getElementById('myInput');
const display = document.getElementById('textDisplay');

// Menghasilkan satu nilai yang sama untuk kedua elemen
ranrator.password(input, display, { complex: false });

C. Penggunaan Berulang (Stateful)

Gunakan jika Anda ingin menyimpan konfigurasi tertentu untuk digunakan di banyak tempat.

const myRan = new Ranrator({ 
    prefix: 'idweb-', 
    transform: 'capitalize',
    delimiter: '.' 
});

// Panggil berkali-kali dengan konfigurasi yang sama
const user1 = myRan.generate(); // idweb-Ancient.Water.1234
const user2 = myRan.generate(); // idweb-Bold.Sky.5678

Opsi Konfigurasi

Semua opsi ini dapat dikirimkan melalui objek konfigurasi pada fungsi ranrator() atau Ranrator.generate().

| Opsi | Tipe | Default | Deskripsi | | :--- | :--- | :--- | :--- | | delimiter | string | "-" | Karakter pemisah antar bagian kata. | | tokenLength | number | 4 | Panjang karakter acak/angka di bagian akhir. | | tokenHex | boolean | false | Jika true, token akan menggunakan karakter hex (0-f). | | tokenChars | string | "0123...9" | Kumpulan karakter kustom untuk token. | | transform | string | "lower" | Pilihan: 'lower', 'upper', atau 'capitalize'. | | prefix | string | "" | Teks statis di awal hasil. | | suffix | string | "" | Teks statis di akhir hasil. | | parts | array | ['adj','noun','token'] | Susunan komponen: 'adj', 'noun', 'token'. | | animate | boolean | true | Aktifkan/matikan animasi saat integrasi DOM. | | animationType | string | "fade" | Pilihan: 'fade' atau 'scramble'. | | animationDuration | number | 300 | Durasi ms (untuk fade) atau iterasi (untuk scramble). | | adjectives | array | (Internal) | Daftar kata sifat kustom. | | nouns | array | (Internal) | Daftar kata benda kustom. |


Generator Password

Fungsi ranrator.password() khusus dioptimalkan untuk pembuatan kredensial.

Opsi Khusus Password

| Opsi | Default | Deskripsi | | :--- | :--- | :--- | | complex | true | true: Karakter acak kompleks. false: Passphrase (kata). | | length | 12 | Panjang password jika mode complex: true. |

Contoh Penggunaan Password

// Password Kompleks 16 Karakter
ranrator.password(16); 

// Passphrase Kustom
ranrator.password({
    complex: false,
    delimiter: '_',
    tokenLength: 6,
    parts: ['adj', 'token']
});

Contoh Kasus Spesifik

Hostname Tanpa Angka

ranrator({ parts: ['adj', 'noun'] }); 

Kode Token Saja (Hexadecimal)

ranrator({ parts: ['token'], tokenLength: 8, tokenHex: true, transform: 'upper' });

Format Folder/Path

ranrator({ delimiter: '/', transform: 'capitalize' });

API Reference

Global Functions

  • ranrator(elementOrOptions, options): Fungsi utama untuk generate name.
  • ranrator.password(elementOrOptions, options): Fungsi khusus untuk password.

Class Ranrator

  • new Ranrator(options): Membuat instance baru.
  • instance.generate(overrideOptions): Menghasilkan string berdasarkan instance.
  • Ranrator.generate(options): Shortcut statis untuk generate.
  • Ranrator.password(options): Shortcut statis untuk password.
  • Ranrator.apply(element, options): Menerapkan hasil ke elemen DOM.

Copyright (c) 2026 masarisgk