Skip to content

Stack

Since 1.4.0

Stack type (LIFO - Last In First Out).

Signature

typescript
type Stack<T> = T[]

Parameters

ParameterDescription
TValue type

Description

Represents a stack data structure with LIFO semantics.

Examples

Basic Usage

typescript
import type { Stack, Push, Pop } from 'uni-types'

type MyStack = Stack<number>
// number[]

type AfterPush = Push<[1, 2], 3>
// [1, 2, 3]

type AfterPop = Pop<[1, 2, 3]>
// { stack: [1, 2]; value: 3 }
  • Push - Push onto stack
  • Pop - Pop from stack
  • Queue - Queue type (FIFO)

Released under the MIT License.