g45t345rt / minifaker

A lightweight alternative to faker.js

Home Page:https://www.npmjs.com/package/minifaker

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Hexadecimal

IanVS opened this issue · comments

Hi there!

After faker.js was deleted, I came across this library and love that it's small and ESM based, and am in the process of migrating to it. I don't have much usage of faker, but I do find that I'm missing a hexadecimal generator here. Do you have any recommendations of how to generate a random hex value of a particular length, or is that something you'd consider adding to minifaker?

Thanks!

I've added the missing hex function.

minifaker/src/index.ts

Lines 226 to 230 in a866428

export const hex = (count: number = 1) => {
let hexString = ''
array(count, () => hexString += number({ max: 15 }).toString(16))
return `0x${hexString}` // 0x is the prefix used to denote hexadecimal
}