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.2.4
  • 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: unknown) => value is number

and

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

array

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

at

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

below

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

either

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

has

const hasFoo = has('foo') // (value: unknown) => value is { 'foo': unknown }

instance

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

literal

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

max

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

min

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

noneable

const isNoneableString = noneable(isString) // (value: unknown) => value is string | null | undefined

nullable

const isNullableString = nullable(isString) // (value: unknown) => value is string | null

object

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

optional

const isOptionalString = optional(isString) // (value: unknown) => value is string | undefined

or

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

record

const isEnum = record(isString, isNumber) // (value: unknown) => value is Record<string, number>

Note: record is limited to string and symbol type keys.

shape

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

test

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

tuple

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

Predicates

isAny

isAny(value) // value is any

isArray

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

isArrayLike

isArrayLike(value) // value is Record<number, unknown>

isBigInt

isBigInt(value) // value is bigint

isBoolean

isBoolean(value) // value is boolean

isDate

isDate(value) // value is Date

isDictionary

isDictionary(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

Serializable // SerializableArray | SerializableObject | SerializablePrimitive

SerializableArray

SerializableArray // Array<Serializable>

SerializableObject

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

SerializablePrimitive

SerializableObject // null | boolean | number | string

Some

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

Static

Static<Predicate<T>> // T

FAQs

Package last updated on 16 Dec 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