1.1.0 • Published 2 years ago

@pbbbl/is v1.1.0

Weekly downloads
-
License
MIT
Repository
-
Last release
2 years ago

@pbbbl/is

A rewritten module/fork of is

Rewritten for Typescript, ES6 and beyond. Working on tree-shakable imports (future).

Key Differences

Tree Shakable-ish

This is a work in progress as my es skills are growing.

Typed (Typescript)

Rewritten in Typescript.

Improved Types

I realize a strongly-typed application shouldn't need is, but it is needed in some edge-cases. .. @types/is has out-of-date types, or types not found by Typescript. Using is.nil (the non-deprecated replacement for is.null) will throw an error in ts files.

  • The same issue is present with other now-deprecated methods ()

Using "submethods" ( is.[method].[sub-method] ) like is.array.empty in a .ts file will throw errors.

ES6+, CJS, TS compatible

Again, a work in progress due to my underwhelming TS skills.

Example of Syntax Differences

Take this example where will would check if const checkNull=null; is a null value...

With is

// In CJS
const is = require('is');
// In ES, TS modules
// import is from 'is';

const checkNull:boolean = is.nil(null); // checkNull=true
With @pbbbl/is
// In CJS
const {isNull} = require('@pbbbl/is');
// In ES, TS modules
// import {isNull} from '@pbbbl/is';

const checkNull:boolean = isNull(null); // checkNull=true

Methods

isActualNaN (value:any):boolean;
// check if value is type
isType(value:any, type:string):boolean;

// Same as isType. Replaces is.a which is the non-deprecated version of `is.type`
isA(value:any, type:string):boolean;
isDefined (value:any):boolean;
isEmpty(value:any):boolean;
isEmptyString(value:any, trimmed:boolean):boolean;
isEqual(value:any, other:any):boolean;
isHosted (value:any, host:any):boolean;
isInstance (value:any, constructor:any):boolean;
isInstanceOf (value:any, constructor:any):boolean;
isNull (value:any):boolean;
isNil (value:any):boolean;
isUndefined (value:any):boolean;
isUndef (value:any):boolean;
isArguments (value:any):boolean;
isArray(value:any):boolean;
isArgumentsEmpty (value:any):boolean;
isEmptyArguments (value:any):boolean;
isEmptyArray(value:any):boolean;
isArrayEmpty(value:any):boolean;
isArrayLike (value:any):boolean;
isBool (value:any):boolean;
isBoolean (value:any):boolean;
isFalse(value:any):boolean;
isTrue(value:any):boolean;
isDate(value:any):boolean;
isDateValid(value:any):boolean;
isValidDate(value:any):boolean;
isElement (value:any):boolean;
isError (value:any):boolean;
isFunction (value:any):boolean;
isFn (value:any):boolean;
isNumber (value:any):boolean;
isInfinite (value:any):boolean;
isDecimal (value:any):boolean;
isDivisibleBy (value:any, n:number):boolean;
isInt (value:any):boolean;
isInteger (value:any):boolean;
isMaximum (value:any, others:any[]):boolean;
isMinimum (value:any, others:any[]):boolean;
isNaN (value:any):boolean;
isEven(value:any) ;
isOdd (value:any):boolean;
isGe (value:any,other:any):boolean;
isGt (value:any,other:any):boolean;
isLe(value:any,other:any):boolean;
isLt (value:any,other:any):boolean;
isWithin (value:number, start:number, finish:number):boolean;
isObject(value:any):boolean;
isEmptyObject(value:any):boolean;
isPrimitive(value:any):boolean;
isHash(value:any):boolean;
isRegexp (value:any):boolean;
isString (value:any):boolean;
isStringEmpty(value:any):boolean;
isBase64 (value:any):boolean;
isHex(value:any):boolean;
isSymbol (value:any):boolean;
isBigInt (value:any):boolean;
isJSON (value:any):boolean;