jarvis-f
v0.1.8
Published
Helper Functions for daily lifes
Downloads
3
Maintainers
Readme
Getting Started with helpers
Installation
npm install --save jarvis-f
Usage
import {
splitName,
extractOnlyCharacters,
extractOnlyNumbers,
removeEmptyFields,
getLengthOfObj,
validateEmail,
getTheRoundOffValue,
removeEmptyKeys,
isNumber,
isInt,
isFloat,
isEven,
isOdd,
isPrime,
getRandom,
sortArrayOfStrings,
sortArrayOfObj,
} from 'jarvis-f';
let name = splitName('sathish krish'); // { firstName: "sathish", lastName: "krish", middleName: "" }
let characters = extractOnlyCharacters('sathish krish123213123'); // "sathishkrish"
let numbers = extractOnlyNumbers('sathish krish123213123'); // "123213123"
let nonEmptyFields = removeEmptyFields({
firstName: '',
lastName: 'sathish',
}); // { totalLength: 2, fields: { lastName: "sathish" }, fieldsLength: 1 }
let objectLength = getLengthOfObj({
firstName: '',
lastName: 'sathish',
}); // 2
let isValidEmail = validateEmail('[email protected]'); // true
let value = getTheRoundOffValue(12.4); // { value: 12, remain: 0.4, type: "round" }
let keys = removeEmptyKeys({
firstName: '',
lastName: 'sathish',
}); // { lastName: "sathish" }
let isNumberT = isNumber(12); // true
let isIntT = isInt(12); // true
let isFloatT = isFloat(12.4); // true
let isEvenT = isEven(12); // true
let isOddT = isOdd(12); // false
let isPrimeT = isPrime(12); // true
let getRandomT = getRandom(1, 10); // 5
let arrayOfStrings = ['ryan', 'corbin', 'dan', 'steven', 'bob'];
let arrayToBeChecked = ['dan', 'ryan', 'bob', 'steven', 'corbin'];
let arrayOfObjects = [{ name: 'bob' }, { name: 'ryan' }];
let arrayToBeCheckedOb = [{ name: 'dan' }, { name: 'steven' }, { name: 'ryan' }, { name: 'bob' }, { name: 'corbin' }];
let arrayStrings = sortArrayOfStrings(arrayToBeChecked, arrayOfStrings); // ['dan', 'ryan', 'bob', 'steven', 'corbin']
let arrayObjects = sortArrayOfObj(arrayToBeCheckedOb, arrayOfObjects, key); // [{name: 'ryan'}, {name: 'bob'}]