1.2.3 • Published 5 months ago

is-check-mahmud v1.2.3

Weekly downloads
-
License
MIT
Repository
github
Last release
5 months ago

is-check-mahmud

A lightweight utility package for type checking in JavaScript & Node.js

npm
license
downloads


šŸ“Œ Features

āœ” Check data types (number, string, array, object, null, undefined, etc.)
āœ” Check if a value is odd/even
āœ” Check if a string is URL, binary, SVG, PNG, JPEG, MP3, MP4, WebP, etc.
āœ” Detect file type from a URL or file path
āœ” Works in both Node.js & Browser


šŸ“„ Installation

Using npm:

npm install is-check-mahmud

Using yarn:

yarn add  is-check-mahmud

šŸ“Œ Import The package

const isCheck = require("is-check-mahmud");

šŸ“Œ Check basic data types

console.log(isCheck.isNumber(123));      // true

console.log(check.isInteger(10)); // true
console.log(check.isFloat(10.5)); // true
console.log(check.isNaNValue(NaN)); // true
console.log(check.isFiniteNumber(100)); // true
console.log(check.isFiniteNumber(Infinity)); // false
console.log(check.isInfinity(Infinity)); // true
console.log(check.isInfinity(-Infinity)); // true
console.log(isCheck.isString("Hello"));  // true
console.log(isCheck.isArray([1, 2, 3])); // true
console.log(isCheck.isObject({ key: "value" })); // true
console.log(isCheck.isNull(null));       // true
console.log(isCheck.isUndefined(undefined)); // true

šŸ“Œ Check even/odd numbers

console.log(isCheck.isEven(10)); // true
console.log(isCheck.isOdd(7));   // true

šŸ“Œ Check URLS and File types

console.log(isCheck.isURL("https://example.com")); // true
console.log(isCheck.isBinary("1010101"));         // true
console.log(isCheck.isSVG("<svg></svg>"));         // true
console.log(isCheck.isPNG("image.png"));          // true
console.log(isCheck.isJPEG("image.jpeg"));        // true
console.log(isCheck.isMP3("audio.mp3"));          // true
console.log(isCheck.isMP4("video.mp4"));          // true
console.log(isCheck.isWebP("image.webp"));        // true

šŸ“Œ Check URLS and File types

console.log(isCheck.getFileType("https://example.com/image.png")); // "png"
console.log(isCheck.getFileType("C:/Users/user/music.mp3")); // "mp3"

API Methods

MethodDescriptionExample Usage
isNumber(value)Check if the value is a numberisCheck.isNumber(123) // true
isInteger(value)Check if the value is a integerisCheck.isInteger(123) // true
isFloat(value)Check if the value is a floating point numberisCheck.isFloat(10.5) // true
isNaNValue(value)Check if the value is a NaNisCheck.isNaNValue(NaN) // true
isFiniteNumber(value)Check if the value is a Infinite numberisCheck.isFiniteNumber(100) // true
isInfinity(value)Check if the value is a Infinity or -InfinityisCheck.isInfinity(Infinity) // true
isString(value)Check if the value is a stringisCheck.isString("Hello") // true
isArray(value)Check if the value is an arrayisCheck.isArray([1, 2, 3]) // true
isObject(value)Check if the value is an objectisCheck.isObject({key: "value"}) // true
isNull(value)Check if the value is nullisCheck.isNull(null) // true
isUndefined(value)Check if the value is undefinedisCheck.isUndefined(undefined) // true
isEven(number)Check if the number is evenisCheck.isEven(10) // true
isOdd(number)Check if the number is oddisCheck.isOdd(7) // true
isURL(value)Check if the value is a valid URLisCheck.isURL("https://example.com") // true
isBinary(value)Check if the value is binaryisCheck.isBinary("1010101") // true
isSVG(value)Check if the value is an SVGisCheck.isSVG("<svg></svg>") // true
isPNG(value)Check if the value is a PNG imageisCheck.isPNG("image.png") // true
isJPEG(value)Check if the value is a JPEG imageisCheck.isJPEG("image.jpeg") // true
isMP3(value)Check if the value is an MP3 fileisCheck.isMP3("audio.mp3") // true
isMP4(value)Check if the value is an MP4 videoisCheck.isMP4("video.mp4") // true
isWebP(value)Check if the value is a WebP imageisCheck.isWebP("image.webp") // true
getFileType(value)Get file type from URL or file pathisCheck.getFileType("https://example.com/image.png") // "png"