Everything you constantly need for development (and probably still copy-pasting from other projects)
The promise:
- ✅ 1 package: say goodbye to lodash, faker, this and that and the other package.
- ⭕ 0 dependencies: keep it simple and lightweight.
- 🏆 Pick the best: the code is minimal and uses the best current practices and is optimized for max performance.
- 👪🏼 Typescript: use it, support it and export it.
- 🌊 Intuitive: favour always the most intuitive API and common usage, never throw errors unless asked.
- 🙈 Semantic: use simple function names that are easy to remember, no complicated options.
Contributions always welcome!
Validators
isArray()
isBoolean()
isBrowser()
to detect if you are on the browserisClient()
to detect if you are ont the browser/clientisEmail()
this is a relaxed check, use your own validation if you need to be strict- ⭐
isEmpty()
to check for empty object, empty array, empty string, null or undefined
isEmptyString()
trims the string and checks if something is leftisEmptyArray()
isEmptyObject()
isFunction()
isJsDate()
if it's a valid javascript's DateisKey()
isNumber()
if the arg is number, and also usable (no infinity)
isInt()
isEven()
isOdd()
isPositive()
isNegative()
isNumeric()
- ⭐
isObject()
if it's a js plain Object isPromise()
isPWA()
isReactElement()
isRegExp()
isServer()
if you are on the serverisString()
isStringDate()
also checks if the string passed is a valid date
isURL()
isUUID()
Helpers
array()
create an arbitrary array based on a functioncapitalize()
word => Wordfirst()
get the first element of an arraygetKeys()
get the keys of an object, includes symbolslast()
get the last element of an array- ⭐
merge()
deep merge objects moveToFirst()
move array element to firstmoveToLast()
move array element to last- ⭐
parseDate()
pass anything Date-Like, and get a JS Date back
Random data generators
These functions are optimized for low entropy random data generation useful for Unit Testing, Storybook, Pass real validations, Reverse hacking, Penetration testing...
randomAddress()
randomAlphaNumericCode()
- ⭐
randomArrayItem()
randomBool()
- ⭐
randomCoords()
randomDate()
a safe range in decade
randomMaxDate()
a range in the Max dates allowed by JSrandomFutureDate()
randomPastDate()
randomDateRange()
=> { startDate, endDate }
randomEmail()
randomEmoji()
randomEnumKey()
enum FRUIT { APPLE, PEAR } => APPLErandomEnumValue()
enum FRUIT { APPLE = 1, PEAR = 3 } => 3randomFile()
randomFloat()
randomHandle()
useful for social identifiers, or slugsrandomHexColor()
randomHexValue()
randomHtmlColorName()
randomIBAN()
randomInt()
randomPositiveInt()
> 0randomNegativeInt()
< 0randomMaxSafeInt()
Range of very BIG integers, which are still safe to use thorandomMaxInt()
Range within the Maximum integer supported by js
randomIP()
randomName()
randomFirstName()
randomLastName()
randomFullName()
randomNumericCode()
randomNumericId()
autoincremental process-unique idrandomParagraph()
randomPassword()
randomUUID()
lightweight uuid generation, passing UUID validationrandomWord()
TypeScript Helpers
Coords
DateLike
Maybe
MaybePromise
MaybePromiseOrValue
MaybePromiseOrValueArray
NonUndefined
ObjectValues
PlainObject
Point
Development
After changes, run
pnpm changeset
then
pnpm changeset version
To bump the version. CI will take care of publishing the package when merged.