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
  1. Get a taste of Katxupa
  2. Usage
  3. Scope Functions
  4. Functions

letIt

letIt(it => { //do something here it })

  • The context object is available as an argument (it).

  • The return value is the lambda result.

letIt can be used to invoke one or more functions on results of call chains.

const data: Array<number> | null = await idsFromFile();

const str = data?.letIt(it => convertToString(it)) ?? "empty";

You can also use withIt to introduce a helper object whose properties or functions are used for calculating a value.

const numbers = mutableListOf<string>("one", "two", "three");

const firstAndLast = withIt(numbers, function () {
    return `The first element is ${this.first()}, the last element is ${this.last()}`
});
console.debug(firstAndLast);
PreviousFunctionsNextwithIt

Last updated 1 year ago

🍜
🍻