1.0.7 • Published 2 years ago

useless-info v1.0.7

Weekly downloads
-
License
ISC
Repository
github
Last release
2 years ago

U-FO (useless-info)

Useful JavaScript library to manage easily types and classes in your application

What is it

This library offer:

  • Some informative functions about your values
  • A bundle of useful functions to check conditions and handle consistency.

How it works

After you have imported the package:

import * as UFO from "useless-info";

You can call the functions you need, for example:

let myArray = [objClassA,objClassB,objClassA,objClassA];
UFO.isArrayClassConsistent(myArray);
// Expected result : false

let myArray = [34,{},'hello',4.6];
UFO.getElementsFromArrayWithType(myArray,'float');
// Expected result : [4.6]

You can also import only some functions, for example:

import { isArray, isFloat } from "useless-info";

List of Functions

This library provides also a bunch of functions to check your types and your classes. Here some of them:

FunctionsDescriptionPropertiesReturn
isObjectCheck whatever is an objectvalueboolean
isFunctionCheck whatever is a functionvalueboolean
isStringCheck whatever is a stringvalueboolean
isCharCheck whatever is a charvalueboolean
isNumberCheck whatever is a numbervalueboolean
isIntegerCheck whatever is an integer numbervalueboolean
isFloatCheck whatever is a floatvalueboolean
isArrayCheck whatever is an arrayvalueboolean
clearObjectClear an object removing all values and setting their default valuesobjectobject
isArrayTypeConsistentCheck if all the values in the array have the same typearray, type (optional)boolean
getElementsFromArrayWithTypeCheck if all the values in the array have the same typearray, elementsWithTypearray
isArrayClassConsistentCheck if all the values in the array have the same classarray, myClass (optional)boolean
getElementsFromArrayWithClassIterate your array and return only elements that matches your typearray, objectWithClassarray

Other

No peerDependences are required. Feel free to share your advice to improve this library.