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

TypesCategory.ts overview

Enum classifying JavaScript values into ten runtime categories, plus a 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.
  • fromValue normalizes any JavaScript value to one of these categories; isPrimitive / isNonPrimitive group the categories accordingly.

Common tasks

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

Quickstart

Example (Classify and dispatch on category)

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

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

Exports Grouped by Category


Constructors

fromValue

Builds the category of u.

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

Signature

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

Source

Predicates

isArray

Returns true if self represents an array. false otherwise

Signature

declare const isArray: Predicate.Predicate<Type>

Source

isBigint

Returns true if self represents a bigint. false otherwise

Signature

declare const isBigint: Predicate.Predicate<Type>

Source

isBoolean

Returns true if self represents a boolean. false otherwise

Signature

declare const isBoolean: Predicate.Predicate<Type>

Source

isFunction

Returns true if self represents a function. false otherwise

Signature

declare const isFunction: Predicate.Predicate<Type>

Source

isNonPrimitive

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

Signature

declare const isNonPrimitive: Predicate.Predicate<Type>

Source

isNull

Returns true if self is null. false otherwise

Signature

declare const isNull: Predicate.Predicate<Type>

Source

isNumber

Returns true if self represents a number. false otherwise

Signature

declare const isNumber: Predicate.Predicate<Type>

Source

isPrimitive

Returns true if self represents a primitive. false otherwise

Signature

declare const isPrimitive: Predicate.Predicate<Type>

Source

isRecord

Returns true if self represents a record. false otherwise

Signature

declare const isRecord: Predicate.Predicate<Type>

Source

isString

Returns true if self represents a string. false otherwise

Signature

declare const isString: Predicate.Predicate<Type>

Source

isSymbol

Returns true if self represents a symbol. false otherwise

Signature

declare const isSymbol: Predicate.Predicate<Type>

Source

isUndefined

Returns true if self is undefined. false otherwise

Signature

declare const isUndefined: Predicate.Predicate<Type>

Source