Skip to content

Latest commit

 

History

History

javascript

README.md

randino

randino for JavaScript

license npm latest package npm downloads

The full documentation, with JavaScript picked in the sidebar. This README is the quick start.


randino generates random sample data in nine languages: person names, nicknames, words, sentences, real places, ages, genders, organizations, dates and phone numbers, and the operating system, hardware and files of a sample machine.

  • Written the way each language writes it. Names, nicknames and sentences follow the language's own script, word order and grammar: 김민준, Emma Clover, 여우가 사과를 먹는다.
  • Real only where it should be. Places and system values are real, such as 서울특별시 종로구 and Apple iPhone 15 Pro. Organizations are invented, and nicknames are never built from person names. Fictional names and places are made for a story's cast and map, and none is a real country or a famous character.
  • One options object per generator, every option optional, so randName() on its own works.
  • Seeded or secure. Every generator and decorator takes a random source: a seeded one for a fixture that must repeat, a secure one for a token nobody may predict.
  • No runtime dependencies. ESM, typed, and it runs in Node and in the browser alike.

This is the JavaScript package. The Dart package and the Python package generate from the same datasets under the same rules, and each versions independently.

Install

npm install randino

Requires Node.js 22 or newer, or any browser. The package ships ESM with type declarations and pulls nothing in behind it.

sideEffects: false is declared and every call made on import is marked /*#__PURE__*/, so a bundler drops the pools nothing reaches whether it reads the field or not — and the pools are nearly all of it. Minified and gzipped, randSuffix alone is 0.6 KB, randName 24 KB, randModifier 122 KB, randLocation 156 KB, randWord and randNickname 345 KB, and randSentence 524 KB; the getting-started page lists the rest. In a browser bundle that is worth knowing: the word pools are one object per language, so one theme costs what thirty-seven do.

Person names

import { randName } from 'randino';

randName();
// ['Emma Clover']

randName({ language: 'en', count: 3 });
// ['Christina Mills', 'Jack Reeves', 'Brian Wallace']

randName({ language: 'ko', script: 'roman' });
// ['Kim Minjun']

randName({ language: 'en', gender: 'female', includeMiddleName: true });
// ['Grace Amelia Bennett']

randName({ language: 'ja', count: 2, script: 'roman' });
// ['Murakami Hinata', 'Miura Eriko']

randName({ language: 'ko', output: 'detail' });
// [{ native: '여미주', roman: 'Yeo Miju', language: 'ko', gender: 'female' }]
Option Type Default
language 'all' or a language code 'all'
gender 'all' | 'male' | 'female' 'all'
count number 1
realism RandRealism 'real'
minLength / maxLength number language
includeSurname boolean true
includeMiddleName boolean false
script 'native' | 'roman' 'native'
output 'value' | 'detail' 'value'
startsWith string —
unique boolean false

Nicknames

import { randNickname } from 'randino';

randNickname({ language: 'en', count: 3 });
// ['FoggyHillside', 'CraneVoyage', 'TinyLeopardCloak']

randNickname({ language: 'en', theme: 'animal', count: 2 });
// ['FloatingFalcon', 'ChewyOtter']

randNickname({ language: 'en', slots: 'action', count: 2 });
// ['CountingHarmonics', 'HaulingBurrito']

randNickname({ language: 'en', output: 'detail' });
// [{
//   nickname: 'MistyOwl',
//   words: ['Misty', 'Owl'],
//   slots: ['adjective', 'noun'],
//   language: 'en',
//   theme: 'animal'
// }]
Option Type Default
language 'all' or a language code 'all'
theme 'all' or a theme name 'all'
slots WordSlotOption 'all'
count number 1
realism RandRealism 'real'
vocabulary RandVocabulary 'full'
minLength / maxLength number language
wordSeparator string language
startsWith string —
unique boolean false
output 'value' | 'detail' 'value'

Themes: animal, object, nature, plant, gem, concept, myth, monster, job, music, genre, place, building, food, ingredient, vegetable, fruit, sport, vehicle, product, beauty, color, finance, tech, weather, space, planet, time, emotion, body, clothing, tool, drink, toy, sound, person, furniture.

Words

The pools the nicknames are built from, on their own. Thirty-seven themes, nine languages, and a function per theme.

import { randAnimal, randFood, randWord, wordLengthRange } from 'randino';

randWord({ language: 'en', theme: 'animal', count: 3 });
// ['Otter', 'Falcon', 'Lynx']

randAnimal({ language: 'en', count: 2 }); // ['Turtle', 'Crane']
randFood({ language: 'en', count: 2 }); // ['Dumpling', 'Pretzel']

randWord({ language: 'en', theme: 'plant', output: 'detail' });
// [{ word: 'Cedar', language: 'en', theme: 'plant' }]

wordLengthRange('en'); // [3, 11]
Option Type Default
language 'all' or a language code 'all'
theme 'all' or a theme name 'all'
count number 1
realism RandRealism 'real'
vocabulary RandVocabulary 'full'
minLength / maxLength number pools
startsWith string —
unique boolean false
output 'value' | 'detail' 'value'

One function per theme: randAnimal, randObject, randNature, randPlant, randGem, randConcept, randMyth, randMonster, randJob, randMusic, randGenre, randPlace, randBuilding, randFood, randIngredient, randVegetable, randFruit, randSport, randVehicle, randProduct, randBeauty, randColor, randFinance, randTech, randWeather, randSpace, randPlanet, randTime, randEmotion, randBody, randClothing, randTool, randDrink, randToy, randSound, randPerson, randFurniture. Each is randWord with the theme already chosen.

Sentences

Whole statements, written the way the language writes them. The nouns are the same pools the words and nicknames come from, and what a sentence adds is the grammar: a verb that states what can do it and what it can be done to, and the shapes each language allows.

import { randSentence, sentenceLengthRange } from 'randino';

randSentence({ language: 'en', count: 3 });
// ['The brave lion runs quietly.', 'The otter swims in the cove.', 'The sky is blue.']

randSentence({ language: 'ko', count: 2 });
// ['검은 고양이가 숲에서 잠잔다.', '여우가 사과를 먹는다.']

randSentence({ language: 'en', shape: 'simple' }); // ['The gondola passes.']
randSentence({ language: 'en', include: ['brave', 'lion'] });
// ['The brave lion yawns quietly.']

randSentence({ language: 'ko', output: 'detail' });
// [{
//   sentence: '검은 고양이가 숲에서 잠잔다.',
//   phrases: ['검은 고양이', '숲', '잠잔다'],
//   slots: ['subject', 'place', 'verb'],
//   language: 'ko',
//   theme: 'animal'
// }]

sentenceLengthRange('en'); // [11, 117]
Option Type Default
language 'all' or a language code 'all'
theme 'all' or a theme name 'all'
shape 'all' | 'simple' | 'detailed' | 'complex' 'all'
slots 'all' | 'none' or one or more SentenceSlot 'all'
include string or string[] —
type 'all' or one or more SentenceType drawn
quote 'double' | 'single' —
style SentenceStyle drawn
sentences number 1
includeName boolean drawn
count number 1
realism RandRealism 'real'
vocabulary RandVocabulary 'common'
minLength / maxLength number language
startsWith string —
unique boolean false
output 'value' | 'detail' 'value'

slots names the parts a shape may carry beside its subject: object, place, time, manner, state, quantity, money, date, clock, or 'none' for a subject and its predicate alone. A language declares its own shapes, so German has no object and Russian no place, because both would mark those with a case their nouns have to change for. Asking for one falls back to the closest shape the language does have.

include puts words you name into every sentence. A word the pools hold goes in the phrase it belongs to, and a word from anywhere else is used as a noun.

type is what the sentence does: a statement, a question, an exclamation, a line that trails off, or one somebody says or thinks. style is the speech level, which Korean writes four of. sentences puts up to ten of them in one string, about one subject. includeName puts a generated person's name where a person can stand. Left out, the three of them are drawn per result.

Locations

Real places, written out from the country down the way the language writes one. Every division is one the country itself publishes, inside the one written beside it, and nothing goes below a Korean 읍·면·동 or a US city, so a result is never somebody's address. Korean and English only: a country is in when its list comes with no conditions a user of this package would inherit.

import { randCity, randDistrict, randLocation, randRegion } from 'randino';

randLocation({ language: 'ko', count: 2 });
// ['대한민국 경기도 양평군 단월면', '대한민국 충청북도 청주시 서원구 미평동']
randLocation({ language: 'en', level: 'city' });
// ['Gig Harbor, Washington, United States']

randRegion({ language: 'en', count: 3 }); // ['Idaho', 'Georgia', 'Vermont']
randCity({ language: 'ko', count: 3 }); // ['함안군', '영덕군', '여수시']
randDistrict({ count: 3 }); // ['가현동', '겸면', '행주외동']

randLocation({ language: 'ko', includeCountry: false, short: true });
// ['경기 양평 단월']
randRegion({ language: 'ko', short: true, count: 3 }); // ['세종', '울산', '충북']

randLocation({ language: 'ko', output: 'detail' });
// [{ location: '대한민국 전남광주통합특별시 서구 양동', language: 'ko', level: 'district',
//    country: '대한민국', region: '전남광주통합특별시', city: '서구', district: '양동' }]
Option Type Default
language 'all' | 'ko' | 'en' 'all'
level LocationLevel 'district'
includeCountry boolean true
short boolean false
count number 1
minLength / maxLength number —
startsWith string —
unique boolean false
output 'value' | 'detail' 'value'

level is how far down the location goes: country, region, city or district. A country without that level stops at the deepest one it has, so an English location ends at its city. includeCountry: false leaves the country out of the string, which is what a fixed language usually wants. short: true writes each division without its kind, the way it is said: 서울특별시 is 서울, 충청북도 is 충북 and 관악구 is 관악, while a name left one character long keeps its kind (중구) and English names stay as they are. randRegion, randCity and randDistrict take the same options minus level, and hand back that one division's name.

randCountry names any of the 249 ISO 3166-1 countries and territories, in any of the nine languages rather than only the two with divisions:

import { randCountry } from 'randino';

randCountry({ language: 'ko', count: 3 }); // ['아르헨티나', '방글라데시', '세인트키츠 네비스']
randCountry({ language: 'ja', output: 'detail' });
// [{ country: 'サウジアラビア', code: 'SA', language: 'ja' }]

Ages

Ages for sample people, in whole years. The draw follows a curve shaped like a population rather than an even spread: it peaks from 25 to 35, sits lower for children and falls away past seventy, so a third of the ages are in their twenties and thirties and about 2% are past eighty.

import { randAge } from 'randino';

randAge({ count: 5 }); // [27, 8, 41, 63, 30]
randAge({ minAge: 18, maxAge: 39, count: 3 }); // [22, 35, 31]
randAge({ group: ['teen', 'senior'], count: 3 }); // [15, 71, 66]
randAge({ distribution: 'uniform', count: 3 }); // [91, 4, 57]

randAge({ output: 'detail' }); // [{ age: 16, group: 'teen' }]
Option Type Default
minAge / maxAge number 0 / 100
group AgeGroupOption 'all'
distribution 'population' | 'uniform' 'population'
count number 1
unique boolean false
output 'value' | 'detail' 'value'

group is child (0 to 12), teen (13 to 19), adult (20 to 64) or senior (65 and up), or an array of them, and narrows the range rather than replacing it. An age has no language, so randAge takes none.

Genders

Genders for sample people, written the way a form in the language labels them. Male and female split evenly; includeUnknown adds a gender nobody stated, about one draw in eleven, and includeNonbinary a third gender, about one in a hundred. nonbinaryIdentity writes that third gender as the identity a person names themselves by (Genderqueer, Agender) rather than as the option a form offers.

import { randGender } from 'randino';

randGender({ language: 'ko', count: 3 }); // ['여성', '남성', '여성']
randGender({ language: 'en', includeUnknown: true, count: 3 }); // ['Male', 'Unknown', 'Female']
randGender({ language: 'de', includeNonbinary: true }); // ['Divers']
randGender({ language: 'de', includeNonbinary: true, nonbinaryIdentity: true }); // ['Genderfluid']

randGender({ language: 'ko', output: 'detail' });
// [{ gender: '여성', code: 'female', language: 'ko', identity: null }]
Option Type Default
language WordLanguageOption 'all'
includeUnknown boolean false
includeNonbinary boolean false
nonbinaryIdentity boolean false
count number 1
unique boolean false
output 'value' | 'detail' 'value'

The detail's code is male, female, nonbinary or unknown whatever the language, and the first two are the codes randName's gender takes. Its identity names the identity nonbinaryIdentity wrote, the same in every language, and is null otherwise.

Organizations

Companies, schools, government offices, public institutions and associations that do not exist, each written the way its language writes that kind of organization. A company may carry its legal form (Inc., (주), GmbH, ООО), and the stems are chosen to be nobody's brand.

import { randOrganization } from 'randino';

randOrganization({ language: 'ko', count: 3 }); // ['(주)가람에너지', '윤슬교육지원청', '새솔홀딩스']
randOrganization({ language: 'en', industry: 'logistics' }); // ['Greenbriar Logistics Corp.']
randOrganization({ language: 'de', type: ['school', 'public'], count: 2 });
// ['Gymnasium Eschenhain', 'Stadtbibliothek Tannenhof']

randOrganization({ language: 'ko', type: 'company', output: 'detail' });
// [{ organization: '(주)새솔테크', name: '새솔테크', legalForm: '(주)',
//    type: 'company', industry: 'tech', language: 'ko' }]
Option Type Default
language WordLanguageOption 'all'
type OrganizationTypeOption 'all'
industry OrganizationIndustryOption 'all'
includeLegalForm boolean drawn
count number 1
realism RandRealism 'real'
minLength / maxLength number —
startsWith string —
unique boolean false
output 'value' | 'detail' 'value'

type is company, nonprofit, school, government or public, or an array of them; left out, companies come up most often. industry is one of ten, written into a company's name as a word for its business, and naming one with type left out asks for companies. realism: 'invented' builds the stem from the language's own sounds, for a name nobody has.

Fictional names and places

Names for the characters of a story or a game, and the countries, regions, cities and districts of its map. A name is spelled in Latin letters first, English and British names among them, and written by its sound in every other language: Artemis is 아르테미스 and アルテミス. A list of languages returns each result in every one of them, keyed by code, for a game that shows one character to every player in the player's own language.

import { randFictionalCountry, randFictionalDistrict, randFictionalName } from 'randino';

randFictionalName({ language: 'en', count: 3 }); // ['Alice', 'Arsis', 'Emily']
randFictionalName({ language: 'ko', includeSurname: true }); // ['엘라라 블랙우드']
randFictionalCountry({ language: 'ko', count: 3 }); // ['에들린 왕국', '글래시아', '카스타비아 제국']
randFictionalDistrict({ language: 'ko', count: 2 }); // ['그루거 파크', '이블린 베이']

randFictionalName({ language: ['ko', 'en', 'ja'] });
// [{ ko: '아르테미스', en: 'Artemis', ja: 'アルテミス' }]
randFictionalDistrict({ language: ['ko', 'en'], includeKind: true });
// [{ ko: '이블린 베이', en: 'Evelyn Bay' }]

randFictionalRegion and randFictionalCity fill in the levels between. Every place function takes the same options:

Option Type Default
language FictionalLanguageOption 'all'
includeKind boolean drawn
kindStyle FictionalKindStyle by level
count number 1
realism RandRealism 'real'
minLength / maxLength number —
startsWith string —
unique boolean false
output 'value' | 'detail' 'value'

randFictionalName takes gender and includeSurname (default false) in place of the two kind options. With a list of languages, a result is drawn in the first, which is the one startsWith and the length range read. The kind is written in each language's words: a country's or a region's is translated (에들린 왕국) and a city's or a district's keeps the English word (그루거 파크); kindStyle: 'borrowed' or 'translated' writes every kind one way (에들린 킹덤). realism: 'invented' builds names out of syllables and English halves, tens of thousands of them, none of which is a real country or a famous character or place.

Dates

Dates drawn evenly from a range and written out in UTC. The range defaults to the years 1900 to 2099 and the format to ISO 8601. A string bound names a span, so maxDate: '2024-12-31' reaches the last millisecond of that day.

import { randDate } from 'randino';

randDate(); // ['1987-06-21T08:14:51.302Z']
randDate({ minDate: '2024-01-01', maxDate: '2024-12-31', format: 'YYYY-MM-DD', count: 3 });
// ['2024-07-09', '2024-02-27', '2024-11-30']
randDate({ format: 'YYYY년 M월 D일 HH:mm' }); // ['2031년 3월 4일 19:40']

randDate({ unit: 'minute', count: 5 }); // [37, 4, 52, 19, 0]
randDate({ output: 'detail' });
// [{ date: '1987-06-21T08:14:51.302Z', timestamp: 551261691302, year: 1987, month: 6,
//    day: 21, hour: 8, minute: 14, second: 51, millisecond: 302 }]
Option Type Default
minDate / maxDate string | Date | number '1900' / '2099'
format string YYYY-MM-DDTHH:mm:ss.SSSZ
language WordLanguageOption 'en'
utcOffset string | number UTC
unit DateUnit —
count number 1
unique boolean false
output 'value' | 'detail' 'value'

format replaces YYYY, YY, MMMM, MMM, MM, M, DD, D, dddd, ddd, HH, H, hh, h, mm, m, ss, s, SSS, A, a, Z and ZZ, and writes text inside [ ] as it is. MMMM, MMM, dddd, ddd, A and a write words, in language: English unless another of the nine is named. utcOffset writes the dates at a fixed offset, '+09:00' or 540 minutes, and Z writes it. unit is year, month, day, hour, minute, second or millisecond, read off a date drawn from the range, so a minute is 0 to 59 and a year keeps inside the range.

Phone numbers

Phone numbers written the way their country writes them, for the United States, Korea, Japan, China, Vietnam, Spain, Italy, Germany and Russia. Each opens on a mobile block or a city's area code that the country really gives out, and the digits after it are random — so a number can by chance belong to somebody. Use them as sample data, and never call or text one. The examples below write the last four digits as #; a call returns every digit.

import { randPhone } from 'randino';

randPhone({ country: 'KR', count: 2 }); // ['010-4821-####', '010-7302-####']
randPhone({ country: 'US', type: 'landline' }); // ['(212) 846-####']
randPhone({ country: 'KR', includeCountryCode: true }); // ['+82 10-4821-####']
randPhone({ country: 'KR', includeCountryCode: true, separator: '' }); // ['+82104821####']

randPhone({ country: 'JP', output: 'detail' });
// [{ phone: '090-3718-####', e164: '+81903718####', country: 'JP', callingCode: '81', type: 'mobile' }]
Option Type Default
country PhoneCountryOption 'all'
type PhoneTypeOption 'mobile'
includeCountryCode boolean false
separator string country
fictional boolean false
count number 1
unique boolean false
output 'value' | 'detail' 'value'

country is an ISO 3166-1 alpha-2 code, read regardless of case. includeCountryCode drops the trunk prefix the country dials at home, and separator replaces the country's own punctuation: '' writes the digits alone, which with the country code is E.164. fictional keeps to the numbers a country sets aside for films and books, which nobody is given: 555-0100 to 555-0199 in the United States and the drama numbers in Germany; the other seven countries reserve none and return nothing.

System

Values that describe a sample machine. They are real products rather than invented ones, written by the names they were released under, so none of them takes a language.

Operating systems

Windows, macOS, Ubuntu, Debian and Fedora on the desktop, Android, iOS and iPadOS on mobile, every release from the first to the ones out by October 2026, written the way each release is known.

import { randOs } from 'randino';

randOs({ count: 3 }); // ['Windows 10', 'macOS Sonoma 14', 'Android 9 Pie']
randOs({ platform: 'mobile' }); // ['iOS 17']
randOs({ family: ['macos', 'ubuntu'] }); // ['Ubuntu 22.04 LTS']
randOs({ includeBuild: true, includeEdition: true }); // ['Windows 11 Pro 23H2 (Build 22631)']
randOs({ platform: 'desktop', maxYear: 2010 }); // ['Mac OS X Snow Leopard 10.6']

randOs({ includeBuild: true, output: 'detail' });
// [{ os: 'Android 14 (API 34)', name: 'Android', version: '14', build: '(API 34)',
//    edition: null, family: 'android', platform: 'mobile', year: 2023 }]
Option Type Default
platform SystemPlatformOption 'all'
family OsFamilyOption 'all'
minYear number —
maxYear number —
includeVersion boolean true
includeBuild boolean false
includeEdition boolean false
count number 1
unique boolean false
output 'value' | 'detail' 'value'

A draw picks the line first — Windows is about two desktops in three, Android about three phones in five — and a release inside it second. family keeps to the lines named (windows, macos, ubuntu, fedora, debian, android, ios, ipados), still drawn by how common each is, and a line that does not run on the platform asked for returns nothing. minYear and maxYear read the year a release came out, or with includeBuild the year of the build written, and a range nothing came out in returns nothing.

Devices

Real phones, tablets and laptops, by the names their makers gave them, from the first iPhone to the devices on sale by October 2026. A desktop PC is left out: it is built from parts and has no model name of its own.

import { randDevice } from 'randino';

randDevice({ count: 2 }); // ['Samsung Galaxy S24 Ultra', 'Apple iPad (10th generation)']
randDevice({ type: 'laptop' }); // ['Lenovo ThinkPad X1 Carbon Gen 11']
randDevice({ type: ['phone', 'tablet'], maxYear: 2012 }); // ['Apple iPhone 4']
randDevice({ type: 'phone', includeVendor: false }); // ['Pixel 8 Pro']
randDevice({ vendor: ['Samsung', 'Google'] }); // ['Samsung Galaxy Z Fold8']

randDevice({ output: 'detail' });
// [{ device: 'Google Pixel 8', vendor: 'Google', model: 'Pixel 8', type: 'phone', year: 2023 }]
Option Type Default
type DeviceTypeOption 'all'
minYear number —
maxYear number —
vendor DeviceVendorOption 'all'
includeVendor boolean true
count number 1
unique boolean false
output 'value' | 'detail' 'value'

type is phone, tablet or laptop, or an array of them, and vendor one maker or several, named the way the catalog writes them (DEVICE_VENDORS). A model is written the way its maker writes it, generation and all, and one whose name already opens on its maker's (Xiaomi 14) is never written with the maker twice.

Processors

Real processors, by the names their makers gave them: Intel, AMD, Apple and Qualcomm parts for desktops and laptops, and the chips of phones and tablets from Apple, Qualcomm, Samsung, MediaTek, Google and HiSilicon, from the Pentium 4 to the parts on sale by October 2026.

import { randCpu } from 'randino';

randCpu({ count: 2 }); // ['Intel Core i7-13700K', 'Apple A17 Pro']
randCpu({ platform: 'desktop', maxYear: 2012 }); // ['AMD Phenom II X4 940']
randCpu({ platform: 'mobile', includeVendor: false }); // ['Snapdragon 8 Gen 3']
randCpu({ vendor: ['AMD', 'Apple'] }); // ['AMD Ryzen 5 5600X']

randCpu({ output: 'detail' });
// [{ cpu: 'Apple M3 Pro', vendor: 'Apple', model: 'M3 Pro', platform: 'desktop', year: 2023 }]
Option Type Default
platform SystemPlatformOption 'all'
minYear number —
maxYear number —
vendor CpuVendorOption 'all'
includeVendor boolean true
count number 1
unique boolean false
output 'value' | 'detail' 'value'

Graphics

Real graphics processors, by the names their makers gave them: NVIDIA, AMD and Intel cards, laptop GPUs and integrated graphics for desktops and laptops, and the GPUs of phones and tablets from Qualcomm, Arm and Samsung, from the GeForce 8800 GTX to the parts on sale by October 2026. A Radeon from before the end of 2010 is written as ATI sold it.

import { randGpu } from 'randino';

randGpu({ count: 2 }); // ['NVIDIA GeForce RTX 3060', 'Qualcomm Adreno 740']
randGpu({ platform: 'desktop', maxYear: 2010 }); // ['ATI Radeon HD 4870']

randGpu({ output: 'detail' });
// [{ gpu: 'Intel Arc A770', vendor: 'Intel', model: 'Arc A770', platform: 'desktop', year: 2022 }]

It takes randCpu's options: platform, minYear, maxYear, vendor and includeVendor.

Architectures

Processor architectures, by the names a download page most often lists them under: x86_64 and arm64 nearly every time, the 32-bit x86 and armv7 the rest. A desktop is mostly x86_64 and a phone nearly always arm64. includeRare adds RISC-V, POWER, IBM Z, MIPS, LoongArch and SPARC, about one desktop draw in twenty together.

import { randArchitecture } from 'randino';

randArchitecture({ count: 3 }); // ['x86_64', 'arm64', 'x86_64']
randArchitecture({ platform: 'mobile' }); // ['arm64']
randArchitecture({ naming: 'debian', count: 2 }); // ['amd64', 'armhf']
randArchitecture({ includeRare: true, count: 3 }); // ['arm64', 'riscv64', 'x86_64']

randArchitecture({ output: 'detail' });
// [{ architecture: 'x86_64', code: 'x86_64', aliases: ['amd64', 'x64'], bits: 64,
//    family: 'x86', rare: false, platform: 'desktop' }]
Option Type Default
platform SystemPlatformOption 'all'
includeRare boolean false
naming ArchitectureNaming 'common'
count number 1
unique boolean false
output 'value' | 'detail' 'value'

naming writes Debian's package architectures (amd64, armhf), Go's GOARCH (amd64, 386, arm) or the kernel's machine names (aarch64, armv7l) instead. The detail's code is the common name whatever the naming, and its aliases every other name, Windows' and Node's x64 included.

Memory

Amounts of memory a machine is really sold with, from 512 MB to a terabyte, drawn by how common each one is: 8 and 16 GB are most of a sample, and a phone's stop at 24 GB. A size is only written in a unit it is a whole number of, so nothing carries a decimal point; a gigabyte is 1024 megabytes, the way an operating system counts. Each size comes with the kind of memory it was sold as on its platform and in its years: DDR to DDR5 in a desktop or a laptop, LPDDR to LPDDR5X in a phone or a tablet.

import { randRam } from 'randino';

randRam({ count: 3 }); // ['8 GB', '16 GB', '4 GB']
randRam({ unit: 'MB' }); // ['8192 MB']
randRam({ minSize: 16, maxSize: 64 }); // ['32 GB']
randRam({ includeUnit: false }); // ['16']
randRam({ platform: 'mobile', includeType: true }); // ['12 GB LPDDR5X']
randRam({ platform: 'desktop', maxYear: 2010, includeType: true }); // ['4 GB DDR3']

randRam({ output: 'detail' });
// [{ ram: '16 GB', value: 16, unit: 'GB', bytes: 17179869184, type: 'DDR5', platform: 'desktop' }]
Option Type Default
platform SystemPlatformOption 'all'
minYear number —
maxYear number —
unit RamUnitOption 'auto'
includeUnit boolean true
minSize number —
maxSize number —
includeType boolean false
count number 1
unique boolean false
output 'value' | 'detail' 'value'

unit: 'auto' writes each size in the largest unit it is whole in; 'GB' or 'MB' keeps to the sizes whole in that unit. minSize and maxSize are in unit, or in gigabytes for 'auto', and a range no real size is inside returns nothing. minYear and maxYear keep to the kinds of memory machines were sold with in those years, and the sizes they came in; includeType writes the kind after the size, and leaves it out of a bare number with includeUnit: false.

Storage

The kind of storage a machine has, by the platform it is drawn for: an SSD or a hard disk on a desktop or a laptop, UFS or eMMC on a phone or a tablet.

import { randDiskType } from 'randino';

randDiskType({ platform: 'desktop', count: 3 }); // ['SSD', 'HDD', 'SSD']
randDiskType({ platform: 'mobile' }); // ['UFS']

randDiskType({ output: 'detail' });
// [{ diskType: 'SSD', code: 'ssd', name: 'Solid State Drive', platform: 'desktop' }]
Option Type Default
platform SystemPlatformOption 'all'
count number 1
unique boolean false
output 'value' | 'detail' 'value'

randDiskSize writes how much it holds, the way randRam writes memory: a size a drive is sold with, drawn by how common it is, in a unit it is whole in. A terabyte is 1000 gigabytes, the way the box counts. Each kind of storage is sold in sizes of its own, so an eMMC chip stops at 128 GB and only a hard disk goes past 8 TB.

randDiskSize({ count: 3 }); // ['1 TB', '256 GB', '2 TB']
randDiskSize({ unit: 'GB' }); // ['1000 GB']
randDiskSize({ unit: 'TB', minSize: 8 }); // ['12 TB']
randDiskSize({ type: 'emmc' }); // ['64 GB']

randDiskSize({ output: 'detail' });
// [{ size: '1 TB', value: 1, unit: 'TB', bytes: 1000000000000, type: 'ssd', platform: 'desktop' }]

It takes randRam's unit, includeUnit, minSize and maxSize, with unit a DiskUnitOption: 'MB', 'GB', 'TB' or 'auto'. type keeps to the kinds named, one or an array of them, and platform to the kinds a desktop or a phone uses, a kind the platform does not use returning nothing.

Resolutions

Screen resolutions, the way a browser reports them, with the common ones most often: 1920x1080 is about a quarter of the desktops, and a phone is written portrait, its width first. A scaled display is the size the system lays things out at, so a 1920x1080 laptop at 125% is 1536x864.

import { randResolution } from 'randino';

randResolution({ platform: 'desktop', count: 3 }); // ['1920x1080', '2560x1440', '1366x768']
randResolution({ platform: 'mobile' }); // ['390x844']
randResolution({ separator: '×' }); // ['1920×1080']

randResolution({ output: 'detail' });
// [{ resolution: '1920x1080', width: 1920, height: 1080, platform: 'desktop' }]
Option Type Default
platform SystemPlatformOption 'all'
separator string 'x'
count number 1
unique boolean false
output 'value' | 'detail' 'value'

Versions

Software version numbers, in one of three formats: semver (2.14.3), calver, counted from a year (2024.3.1, 24.04, 2024.03.15), or number, a version that is one number (42). Every part is drawn with the small numbers most often, so 0.x and x.y.0 come up the way they do in a registry.

import { randVersion } from 'randino';

randVersion({ count: 3 }); // ['2.14.3', '0.4.0', '1.0.2']
randVersion({ format: 'calver', minYear: 2022 }); // ['2024.3.1']
randVersion({ format: 'all', prefix: 'v', count: 3 }); // ['v1.4.0', 'v24.04', 'v42']
randVersion({ includePrerelease: true, count: 2 }); // ['3.0.0-rc.1', '0.12.2']

randVersion({ output: 'detail' });
// [{ version: '2.14.3', format: 'semver', scheme: 'MAJOR.MINOR.PATCH', parts: [2, 14, 3], prerelease: null, year: null }]
Option Type Default
format VersionFormatOption 'semver'
prefix string ''
includePrerelease boolean false
minYear number 2010
maxYear number 2026
count number 1
unique boolean false
output 'value' | 'detail' 'value'

App stores

Real app stores, by the name each is known by, its company in front where the store is called by one: Google Play Store, Apple App Store, Samsung Galaxy Store, Steam. Google Play and Apple's App Store are most of the phones, and the Microsoft Store, Steam and the Mac App Store most of the desktops. Google Play is never a desktop's.

import { randAppStore } from 'randino';

randAppStore({ platform: 'mobile', count: 3 }); // ['Google Play Store', 'Apple App Store', 'Huawei AppGallery']
randAppStore({ platform: 'desktop', count: 2 }); // ['Steam', 'Microsoft Store']
randAppStore({ includeCompany: false }); // ['Galaxy Store']

randAppStore({ output: 'detail' });
// [{ store: 'Apple App Store', name: 'App Store', company: 'Apple', platform: 'mobile' }]
Option Type Default
platform SystemPlatformOption 'all'
includeCompany boolean true
count number 1
unique boolean false
output 'value' | 'detail' 'value'

File extensions

File extensions files are really saved with, from fourteen kinds of file: .pdf, .png, .mp4, .zip, .js. The extensions nearly everybody meets come up most often, and the ones only a few programs write rarely.

import { randFileExtension } from 'randino';

randFileExtension({ count: 3 }); // ['.pdf', '.png', '.mp4']
randFileExtension({ category: 'image', count: 2 }); // ['.jpg', '.webp']
randFileExtension({ category: ['code', 'data'], includeDot: false }); // ['json']

randFileExtension({ output: 'detail' });
// [{ extension: '.png', name: 'png', category: 'image', mimeType: 'image/png' }]

randMimeType draws the MIME types those extensions are served as, once each, by the part in front of the slash:

import { randMimeType } from 'randino';

randMimeType({ count: 2 }); // ['application/pdf', 'image/png']
randMimeType({ type: ['audio', 'video'] }); // ['video/mp4']

randMimeType({ output: 'detail' });
// [{ mimeType: 'image/jpeg', type: 'image', subtype: 'jpeg', extensions: ['jpg', 'jpeg'] }]
Option Type Default
category FileCategoryOption 'all'
includeDot boolean true
count number 1
unique boolean false
output 'value' | 'detail' 'value'

Decorators

randSuffix, randPrefix and randModifier attach something to a string you already have, rather than generating one. They take anything, not just this library's output, which is why none of them is an option on a generator. Each of them also works with no value at all, handing back the thing it would have attached.

import { randNickname, randPrefix, randSuffix } from 'randino';

randSuffix('MistyOwl'); // 'MistyOwl_nVtRC'
randSuffix(randNickname({ language: 'en', count: 2 }));
// ['RoundSeason_RVBnC', 'RowdyDusk_dwtu5']

randPrefix('order-4021', { length: 4, separator: '-' }); // 'k3Rm-order-4021'
randSuffix('MistyOwl', { length: 8, charset: '0123456789' }); // 'MistyOwl_40218836'
randSuffix(); // 'nVtRC' — the token on its own
Option Type Default
length number 5
separator string '_'
charset string built-in

A fresh token per value, never one for the batch. The default charset leaves out 0O1lI, because these end up in names people read aloud and type back in.

randModifier attaches a word instead of a token, in front of any string:

import { randAnimal, randModifier } from 'randino';

randModifier('Owl'); // 'MistyOwl'
randModifier('Owl', { separator: ' ' }); // 'Misty Owl'
randModifier('Owl', { kind: 'action' }); // 'CountingOwl'
randModifier(); // 'Misty'

randModifier(randAnimal({ language: 'en', count: 2 }));
// ['TwinklingLynx', 'OnyxCrane']
Option Type Default
language WordLanguageOption script
realism RandRealism 'real'
kind ModifierKind | 'all' 'all'
separator string language

With no language, the script of the value picks one, so '고양이' is never handed an English modifier.

Helpers and constants

import {
	nameLengthRange,
	nameSupportsMiddleName,
	nameSupportsRoman,
	nicknameLengthRange,
	sentenceLengthRange,
	wordLengthRange,
	NAME_LANGUAGES,
	WORD_THEMES
} from 'randino';

nameLengthRange('ko'); // [2, 3]
nameLengthRange('en', true, true); // [11, 32]
nameSupportsMiddleName('ko'); // false
nameSupportsRoman('en'); // false
nicknameLengthRange('ko'); // [1, 13]
sentenceLengthRange('ko'); // [5, 53]
wordLengthRange('ko'); // [1, 4]

seededRandom(seed) is a seeded source for the random option, since the standard library has none: randName({ count: 3, random: seededRandom(42) }) writes the same three names every run.

NAME_LANGUAGES, WORD_LANGUAGES, WORD_THEMES, LOCATION_LANGUAGES, LOCATION_LEVELS, AGE_GROUPS, ORGANIZATION_TYPES, ORGANIZATION_INDUSTRIES, DATE_UNITS, PHONE_COUNTRIES, PHONE_TYPES, SYSTEM_PLATFORMS, OS_FAMILY_CODES, DEVICE_TYPES, DEVICE_VENDORS, RAM_UNITS, RAM_TYPES, DISK_TYPES, DISK_UNITS, ARCHITECTURES, ARCHITECTURE_NAMINGS, VERSION_FORMATS, FILE_CATEGORIES, MIME_TOP_LEVELS, CPU_VENDORS and GPU_VENDORS list what the generators accept; RAND_COUNT_MAX, RAND_LENGTH_MIN / _MAX, RAND_SENTENCE_LENGTH_MAX, RAND_SENTENCE_COUNT_MAX, RAND_LOCATION_LENGTH_MAX, RAND_AGE_MAX, RAND_ORGANIZATION_LENGTH_MAX, AFFIX_LENGTH_DEFAULT / _MAX, AFFIX_SEPARATOR_DEFAULT and AFFIX_CHARSET are the bounds and defaults every option is clamped to.

Development

npm install
npm run test      # tsc, then node --test over test/**
npm run build     # format, tsc, minify
npm run lint

The tests import from dist/, so they need a build. npm run test does that first.

Disclaimer

randino draws its values at random, so some will match real things by chance: a person's name, a company, a phone number in service, a nickname already taken. Any such match is a coincidence, and no value refers to a real person or organization. Product names belong to their owners, and randino is not affiliated with any of them. Use the values as sample data, never to impersonate or deceive anyone or to contact a drawn phone number. The software and its output come without warranty, and nobody involved in randino is liable for any use of them. The full disclaimer has the details.

License

MIT © CDGet