Katxupa
  • 👋Welcome to Katxupa Extension Library
  • Why Katxupa?
    • 🍻What makes Katxupa special?
    • ✨Key Features
  • Get a taste of Katxupa
    • 🍲Installation
    • 🍜Usage
      • 🍻Scope Functions
        • Function Selection
        • Distinctions
        • Functions
          • letIt
          • withIt
          • runIt
          • applyIt
          • alsoIt
          • takeIf and takeUnless
      • 😎Null Safety
        • TypeScript Null-Safety
        • Optional Chaining for JavaScript
      • ⏰Duration
      • ➖Reducer
      • 📏Range
      • 🏃‍♂️Result
      • 🤼Either
      • 🟰Compare
      • ⚔️Global Utility Functions
    • 🤌Dip Dive
      • Optional
      • Range
      • Duration
      • Reducer
      • Collections
        • Array
        • Set
  • 🙏Support
    • Source Code
    • ESLint Config
    • TypeScript Docs
    • Manuel Santos Linkedin
Powered by GitBook
On this page
  • Functions
  • rangeTo
  • rangeUntil
  • inRange
  1. Get a taste of Katxupa
  2. Dip Dive

Range

The Range class provides utility methods for working with numeric ranges. It allows you to generate a range of numbers, check if a value is within a specified range, and create aliases for the range methods.

Example Usage
rangeTo(0,10,3)
    .forEach(it => console.log(`Index: ${it}`));
// Output:
//    Index: 0
//    Index: 3
//    Index: 6
//    Index: 9

Functions

rangeTo

Creates an array representing a range of numbers from start to end (inclusive) with an optional step.

const numericRange = rangeTo(1, 5, 2);
console.log(numericRange); // Output: [1, 3, 5]

rangeUntil

Creates an array representing a range of numbers from start to (end - 1) with an optional step.

const numericRange = rangeUntil(1, 5, 2);
console.log(numericRange); // Output: [1, 3]

inRange

Checks if a value is within the specified numeric range.

const isInRange = inRange(3, 1, 5);
console.log(isInRange); // Output: true
PreviousOptionalNextDuration

Last updated 1 year ago

🤌