Isntnt is a collection of composable JavaScript runtime type predicates with TypeScript type guard declarations. Supports generics including union and intersection types.
Generics
above
const isAboveZero = above(0)
and
const isBetween0And21 = and(above(0), below(21))
array
const isAnyArray = array(isAny)
at
const isAnyAtFoo = at('foo', isAny)
below
const isBelow21 = below(21)
either
const isFooOrBar = either('foo', 'bar')
instance
const isInstanceofString = instance(String)
literal
const is42 = literal(42)
max
const isMax255 = max(255)
min
const isMin18 = min(18)
object
const isEnum = object(isNumber)
or
const isStringOrNumber = or(isString, isNumber)
shape
const isPosition = shape({ x: isNumber, y: isNumber })
test
const isSlug = test(/^[\w-]+$/)
tuple
const isEntry = tuple(isNumber, isNumber)
Predicates
isAny
isAny(value)
isArray
isArray(value)
isBigInt
isBigInt(value)
isBoolean
isBoolean(value)
isDate
isDate(value)
isDictionary
isDicionary(value)
isFalse
isFalse(value)
isFunction
isFunction(value)
isInt
isInt(value)
isInt8
isInt8(value)
isInt16
isInt16(value)
isInt32
isInt32(value)
isLength
isLength(value)
isMap
isMap(value)
isNegative
isNegative(value)
isNever
isNever(value)
isNone
isNone(value)
isNull
isNull(value)
isNumber
isNumber(value)
isObject
isObject(value)
isObjectLike
isObjectLike(value)
isPositive
isPositive(value)
isPrimitive
isPrimitive(value)
isRegExp
isRegExp(value)
isSerializable
isSerializable(value)
isSerializableArray
isSerializableArray(value)
isSerializableNumber
isSerializableNumber(value)
isSerializableObject
isSerializableObject(value)
isSerializablePrimitive
isSerializablePrimitive(value)
isSet
isSet(value)
isSome
isSome(value)
isString
isString(value)
isSymbol
isSymbol(value)
isTrue
isTrue(value)
isUint
isUint(value)
isUint8
isUint8(value)
isUint16
isUint16(value)
isUint32
isUint32(value)
isUndefined
isUndefined(value)
isWeakMap
isWeakMap(value)
isWithLength
isWithLength(value)
Types
Intersect
Intersect<A | B>
None
None
Predicate
Predicate<T>
Primitive
Primitive
Serializable
Primitive
SerializableArray
SerializableArray<any>
SerializableObject
SerializableObject
SerializablePrimitive
SerializableObject
Some
Some
Static
Static<Predicate<T>>