Skip to main content Link Search Menu Expand Document (external link)

TypesCategory overview

Enum classifying JavaScript values into ten runtime categories, plus a {@link fromValue} constructor and per-category predicates.

Mental model

  • Type has 10 cases: String, Number, Bigint, Boolean, Symbol, Null, Undefined, Record, Array, Function.
  • Record is the computer-science meaning (a string-keyed object), not the TypeScript Record<K, V> utility — arrays and functions get their own categories despite being objects at the JS level.
  • {@link fromValue} normalizes any JavaScript value to one of these categories; {@link isPrimitive} / {@link isNonPrimitive} group the categories accordingly.

Common tasks

  • Classify a value: {@link fromValue}
  • Group test: {@link isPrimitive}, {@link isNonPrimitive}
  • Per-category test: {@link isString}, {@link isNumber}, {@link isBigint}, {@link isBoolean}, {@link isSymbol}, {@link isNull}, {@link isUndefined}, {@link isFunction}, {@link isArray}, {@link isRecord}

Quickstart

Example (Classify and dispatch on category)

import * as MTypesCategory from "@parischap/effect-lib/types/TypesCategory"

console.log(MTypesCategory.fromValue("hi") === MTypesCategory.Type.String) // true
console.log(MTypesCategory.isNonPrimitive(MTypesCategory.fromValue([1, 2]))) // true

Table of contents


Constructors

fromValue

Builds the category of u.

  • Returns the matching {@link Type} variant for any JavaScript value.
  • null and arrays each get their own category, even though typeof reports them as 'object'.

Signature

export declare const fromValue: (u: unknown) => Type

Predicates

isArray

Returns true if self represents an array. false otherwise

Signature

export declare const isArray: Predicate.Predicate<Type>

isBigint

Returns true if self represents a bigint. false otherwise

Signature

export declare const isBigint: Predicate.Predicate<Type>

isBoolean

Returns true if self represents a boolean. false otherwise

Signature

export declare const isBoolean: Predicate.Predicate<Type>

isFunction

Returns true if self represents a function. false otherwise

Signature

export declare const isFunction: Predicate.Predicate<Type>

isNonPrimitive

Returns true if self represents a non-primitive. false otherwise

Signature

export declare const isNonPrimitive: Predicate.Predicate<Type>

isNull

Returns true if self is null. false otherwise

Signature

export declare const isNull: Predicate.Predicate<Type>

isNumber

Returns true if self represents a number. false otherwise

Signature

export declare const isNumber: Predicate.Predicate<Type>

isPrimitive

Returns true if self represents a primitive. false otherwise

Signature

export declare const isPrimitive: Predicate.Predicate<Type>

isRecord

Returns true if self represents a record. false otherwise

Signature

export declare const isRecord: Predicate.Predicate<Type>

isString

Returns true if self represents a string. false otherwise

Signature

export declare const isString: Predicate.Predicate<Type>

isSymbol

Returns true if self represents a symbol. false otherwise

Signature

export declare const isSymbol: Predicate.Predicate<Type>

isUndefined

Returns true if self is undefined. false otherwise

Signature

export declare const isUndefined: Predicate.Predicate<Type>