Skip to content

A lightweight library that provides simple validation and conversion JavaScript functions to make your code more intuitive and readable.

License

Notifications You must be signed in to change notification settings

artembuslaev/readablefn

Repository files navigation

readablefn

Publish Package

A lightweight library that provides simple validation and conversion JavaScript functions to make your code more intuitive and readable.

Installation Guide

npm install readablefn - adds the library to your project.

Feel free to import the modules you need using import or require.

Usage Example

import { isNotNull } from 'readablefn/base';
import { Numbers } from 'readablefn';

const value = 5;

if (isNotNull(value)&& Numbers.isNumber(value) && Numbers.inRange(value, { start: 1, end: 10 })) {
  console.log('Value is a valid number in range!');
}

API Reference

Base

Function Description Example
isNull Checks if value is null or undefined isNull(null) -> true
isNull(1) -> false
isNotNull Checks if value is not null or undefined isNotNull(1) -> true
isNotNull(null) -> false
isUndefined Checks if value is undefined isUndefined(undefined) -> true
isUndefined(0) -> false
isNotUndefined Checks if value is not undefined isNotUndefined(1) -> true
isNotUndefined(undefined) -> false

Strings

Function Description Example
isString Checks if value is a string isString('abc') -> true
isString(123) -> false
isEmpty Checks if value is empty ('', null, undefined) isEmpty('') -> true
isEmpty('abc') -> false
isNotEmpty Checks if value is not empty isNotEmpty('abc') -> true
isNotEmpty('') -> false

Numbers

Function Description Example
isNumber Checks if value is a number (not NaN, not Infinity) isNumber(5) -> true
isNumber('5') -> false
isNotNumber Checks if value is not a number isNotNumber('abc') -> true
isNotNumber(5) -> false
inRange Checks if number is in the given range inRange(5, {start: 1, end: 10}) -> true
inRange(0, {start: 1, end: 10}) -> false

Contributing

You are welcome to contribute to this library.

Prerequisites

  • Node.js with NPM

Setup Guide

  • npm ci - install dependencies
  • npm test - run build and tests

NOTE: Please submit your PRs to the develop branch.

About

A lightweight library that provides simple validation and conversion JavaScript functions to make your code more intuitive and readable.

Topics

Resources

License

Stars

Watchers

Forks

Contributors 2

  •  
  •