JSPM

@trailhead/core

3.0.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 286
  • Score
    100M100P100Q87272F
  • License MIT

Foundation package for Trailhead System - CoreError interface, Result types, and functional programming utilities

Package Exports

  • @trailhead/core
  • @trailhead/core/errors
  • @trailhead/core/functional
  • @trailhead/core/testing
  • @trailhead/core/utils

Readme

@trailhead/core

Foundation package providing unified Result types, enhanced error handling, and performance-optimized utilities

TypeScript Node License

Foundation package for the Trailhead ecosystem providing unified Result types, enhanced error handling, and performance-optimized type guards.

Installation

npm install @trailhead/core

Quick Example

import { ok, err, type Result } from '@trailhead/core'

const divide = (a: number, b: number): Result<number, Error> => {
  if (b === 0) {
    return err(new Error('Division by zero'))
  }
  return ok(a / b)
}

const result = divide(10, 2)
if (result.isOk()) {
  console.log('Result:', result.value) // 5
} else {
  console.error('Error:', result.error.message)
}

Key Features

  • Unified Result types - Single source of truth for Result operations across the ecosystem
  • Enhanced error context - Rich debugging with operation context, timestamps, and severity
  • Performance-optimized type guards - Zero-overhead validation for critical paths
  • Functional utilities - Composition helpers and Result-based patterns

Documentation

License

MIT © esteban-url