Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

isntnt

Package Overview
Dependencies
Maintainers
1
Versions
33
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

isntnt

A collection of composable JavaScript runtime type predicates with TypeScript type guard declarations

  • 1.0.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
762
decreased by-26.23%
Maintainers
1
Weekly downloads
 
Created
Source

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) // (value: any) => value is number

and

const isBetween0And21 = and(above(0), below(21)) // (value: any) => value is number

array

const isAnyArray = array(isAny) // (value: any) => value is Array<any>

at

const isAnyAtFoo = at('foo', isAny) // (value: any) => value is { foo: any }

below

const isBelow21 = below(21) // (value: any) => value is { foo: any }

either

const isFooOrBar = either('foo', 'bar') // (value: any) => value is 'foo' | 'bar'

instance

const isInstanceofString = instance(String) // (value: any) => value is String

literal

const is42 = literal(42) // (value: any) => value is 42

max

const isMax255 = max(255) // (value: any) => value is number

min

const isMin18 = min(18) // (value: any) => value is number

object

const isEnum = object(isNumber) // (value: any) => value is ObjectOf<number>

or

const isStringOrNumber = or(isString, isNumber) // (value: any) => value is string | number

shape

const isPosition = shape({ x: isNumber, y: isNumber }) // (value: any) => value is { x: number, y: number }

test

const isSlug = test(/^[\w-]+$/) // (value: any) => value is string

tuple

const isEntry = tuple(isNumber, isNumber) // (value: any) => value is [number, number]

Predicates

isAny

isAny(value) // value is any

isArray

isArray(value) // value is Array<unknown>

isBigInt

isBigInt(value) // value is bigint

isBoolean

isBoolean(value) // value is boolean

isDate

isDate(value) // value is Date

isDictionary

isDicionary(value) // value is ObjectOf<string>

isFalse

isFalse(value) // value is false

isFunction

isFunction(value) // value is Function

isInt

isInt(value) // value is number

isInt8

isInt8(value) // value is number

isInt16

isInt16(value) // value is number

isInt32

isInt32(value) // value is number

isLength

isLength(value) // value is number

isMap

isMap(value) // value is Map<any, unknown>

isNegative

isNegative(value) // value is number

isNever

isNever(value) // value is never

isNone

isNone(value) // value is null | undefined

isNull

isNull(value) // value is null

isNumber

isNumber(value) // value is number

isObject

isObject(value) // value is object

isObjectLike

isObjectLike(value) // value is ObjectLike

isPositive

isPositive(value) // value is number

isPrimitive

isPrimitive(value) // value is Primitive

isRegExp

isRegExp(value) // value is RegExp

isSerializable

isSerializable(value) // value is Serializable

isSerializableArray

isSerializableArray(value) // value is Array<Serializable>

isSerializableNumber

isSerializableNumber(value) // value is number

isSerializableObject

isSerializableObject(value) // value is Record<string, Serializable>

isSerializablePrimitive

isSerializablePrimitive(value) // value is SerializablePrimitive

isSet

isSet(value) // value is Set<unknown>

isSome

isSome(value) // value is Some

isString

isString(value) // value is string

isSymbol

isSymbol(value) // value is symbol

isTrue

isTrue(value) // value is true

isUint

isUint(value) // value is number

isUint8

isUint8(value) // value is number

isUint16

isUint16(value) // value is number

isUint32

isUint32(value) // value is number

isUndefined

isUndefined(value) // value is undefined

isWeakMap

isWeakMap(value) // value is WeakMap<any, unknown>

isWithLength

isWithLength(value) // value is { length: number }

Types

Intersect

Intersect<A | B> // A & B

None

None // null | undefined

Predicate

Predicate<T> // (value: unknown, ...rest: Array<unknown>) => value is T

Primitive

Primitive // null | undefined | boolean | number | string | symbol | bigint

Serializable

Primitive // SerializableArray<any> | SerializableObject | SerializablePrimitive

SerializableArray

SerializableArray<any> // Serializable

SerializableObject

SerializableObject // { [key: string]: Serializable }

SerializablePrimitive

SerializableObject // null | boolean | number | string

Some

Some // Function | boolean | bigin | number | string | symbol | object

Static

Static<Predicate<T>> // T

FAQs

Package last updated on 30 Aug 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc