diff --git a/README.md b/README.md
index bb1d397..e24201a 100644
--- a/README.md
+++ b/README.md
@@ -1,261 +1,4 @@
# Katxupa
**Delicious Dish for Typescript and JavaScript projects.**
-In [Cape Verde](https://en.wikipedia.org/wiki/Cape_Verde) we have a saying:
-
-"_Put a person to work in the field and serve them anything other than [Katxupa](https://www.crumbsnatched.com/cachupa-traditional-dish-of-cape-verde/)
-for breakfast, and you'll notice a decline in productivity and motivation. Therefore, give them Katxupa and spice it up on the side._"
-
-Just as "_Katxupa_" is an essential part of Cape Verdean culture, this library brings _functional_ elements to enhance your
-productivity and developer happiness. So, consume (use) it!
-
-> **Katxupa**, Cape Verde’s national dish, is a flavorful stew consisting of hominy, beans, seasoned meats, and vegetables.
-> Each family has its unique version, leading to delightful variations.
-> One undeniable fact: there is no Cape Verdean who doesn't appreciate Katxupa ("Cachupa") — whether for breakfast, lunch, dinner, or any time, anywhere.
-
-## Why Katxupa
-For starters, the "_K_" in **Katxupa** stands for [Kotlin](https://kotlinlang.org/), which was the primary inspiration for this library. Drawing from the
-functional programming paradigm of Kotlin and its concise yet expressive syntax, Katxupa aims to bring similar benefits
-to Typescript and JavaScript developers.
-
-### What Makes Katxupa Special?
-* **Functional Delight**: _Katxupa_ introduces functional programming concepts to enhance your code's expressiveness and clarity.
-
-* **Kotlin-Inspired Goodness**: Leveraging lessons learned from Kotlin, _Katxupa_ provides utilities and extensions that streamline your workflow.
-
-* **Boosted Productivity**: Enjoy a more productive development experience with _Katxupa_'s utility classes, sequences, durations, and more.
-
-* **Developer Happiness**: Inspired by the joy of coding in Kotlin, Katxupa seeks to bring happiness to your TypeScript and JavaScript projects.
-
-### Key Features
-* **Scope Functions**: _Kotlin-like_ scope functions, provides a set of functions to execute a block of code in the context of a given object: _letIt_, _runIt_, _withIt_, _apply_, and _also_.
-
-* **Collections Functions**: _Kotlin-like_ functions for Arrays, Maps, and Sets: Apply concise and expressive operations on collections.
-
-* **Sequences**: Lazy sequences with a _Kotlin-esque_ feel, providing a convenient way to work with iterable data.
-
-* **Duration**: A flexible and comprehensive time duration class with support for various units, offering better time handling.
-
-* **Optional**: A type that represents an optional value, helping to avoid null or undefined-related issues.
-
-* **Result and Either**: Functional constructs to handle success, errors, and alternate paths in a more expressive manner.
-
-* **Inspired by Cape Verde**: Infused with the spirit of [Cape Verde](https://en.wikipedia.org/wiki/Cape_Verde) and its cherished dish **Katxupa**, this library aims to add flavor to your coding experience.
-
-### Get a Taste of Katxupa
-Explore the documentation and see how Katxupa can bring a delightful touch to your TypeScript and JavaScript projects.
-From functional programming utilities to time handling and result handling, **Katxupa** is here to make your coding journey _more enjoyable_.
-
-## Installation
-This package is build up with simplicity in mind, brings no additional dependencies, and it's published in NPM https://www.npmjs.com/package/katxupa.
-
-It can be installed using your preferred package manager.
-
-### NPM
-```shell
-npm install katxupa
-```
-
-### PNPM
-```shell
-pnpm install katxupa
-```
-
-### YARN
-```shell
-yarn add katxupa
-```
-
-## Usage
-### Scope Functions
-Simply call any value with **_letIt_**, **_runIt_**, **_alsoIt_** or **_applyIt_**, and it'll be passed as the argument or the context of a scope function.
-
-```ts
-const person = {name: "Manuel", email: "ney.br.santos@gmail.com", age: 35};
-
-person.letIt(it => {
- console.log(`${it.name},`);
- it.age < 30 ? console.log("A Young Man") : console.log("An Old Man");
- return it.age;
-}).alsoIt(it => {
- console.log(`Actual Age is ${it}`);
-});
-// Output:
-// Manuel,
-// An Old Man
-// Actual Age is 35
-```
-
-It also supports the use of the new [Optional Chaining Operator](https://github.com/tc39/proposal-optional-chaining),
-bringing the logic of [Kotlin's Null Safe Calls](https://kotlinlang.org/docs/reference/null-safety.html) to the JavaScript world.
-
-```ts
- const user = await this.userRepository.findOneBy({
- id: userId,
-});
-
-user?.runIt(function() {
- this.emailService.send(this.email, `${this.name} welcome to the Katxupa library`);
-});
-```
-
-You can execute a block of code only if a value is neither null nor undefined:
-```ts
-const data: string | null = await getData();
-
-data?.alsoIt(it => console.log(`Already initialized: ${it}`)) ?? console.log("Still not initialized");
-```
-The above code is equivalent to:
-```ts
-if (data != null && data != undefined)
- console.log(`Already initialized: ${str!}`);
-else
- console.log("Still not initialized");
-```
-
-The usage of **_takeIf_** & **_takeUnless_** is a bit different. You can call any value with **_takeIf_** and it will
-return the caller instance if the predicate is true, or undefined if it's false (and vice versa when using **_takeUnless_**).
-```ts
-const account = await accountService.getAccount(id);
-
-account.takeIf(it => {
- return addressBook.has(it.email);
-})?.alsoIt(it => {
- emailService.send(it.email, "You are entitled for crypto airdrop")
-}) ?? console.log(`Account with ${id} not found in the system`);
-```
-
-### Null Safety
-* Null-safety through [Optional Chaining Operator](https://github.com/tc39/proposal-optional-chaining) for scope functions:
-```ts
-// Only run the code block if "numberOrUndefined" is defined
-const numberOrUndefinedOrNull = await bitcoinService.getPrice();
-numberOrUndefinedOrNull?.letIt((it) => {
- it++;
- it = it * 100;
- return it;
-});
-
-// Actually, there is no need to declare a variable
-(await bitcoinService.getPrice())
- ?.letIt((it) => {
- it++;
- it = it * 100;
- return it;
- });
-```
-* **_Optional_** wrapper for general purpose:
-```ts
-// Example 1
-// Get Usecase:
-// 1- Validate if user exists
-// 2- Through an HttpError if not
-// 3- Return the user object
-return optionalOf(user)
- .orElseThrow(() => new NotFoundError("User doesn't exist"))
- .get();
-
-// Example 2
-// Delete Usecase:
-// 1- Validate if user exists
-// 2- Through an HttpError if not
-// 3- Delete the user from the database asynchronously and await for the result
-await Optional.of(user)
- .orElseThrow(() => new HttpError(409, "User doesn't exist"))
- .runAsync(() => this.userRepository.delete({id: userId}));
-
-// Example 3
-// Update usecase:
-// 1- Validate if user exists
-// 2- Through an HttpError if not
-// 3- If exists, merge the existing one with additional userData
-// 4- Call the user repository and save the updated user asyncronously, returning a promise
-//
-return optionalOf(user)
- .orElseThrow(() => new HttpError(409, "User doesn't exist"))
- .map(user => {
- return {
- ...user,
- userData,
- };
- })
- .runAsync(user => this.userRepository.save(user));
-```
-
-### Duration
-An easy, expressive and functional way of declaring a duration of time with support for various units (nanoseconds,
-microseconds, milliseconds, seconds, minutes, hours, and days).
-
-```ts
-// Example 1
-durationOf(1000)
- .inWholeSeconds()
- .letIt(it => {
- console.log(`1000 milliseconds are the same as ${it} seconds`);
- });
-
-// Example 2
-const oneYearInMinutes = (1).years().inWholeMinutes();
-console.log(`1 year is ${oneYearInMinutes} minutes.`);
-
-// Example 3
-const duration = (1).years().add((6).months()).toString();
-console.log(duration); // Output: 548d 0h 0m 0s 0ns
-```
-
-### Range
-The `Range` class provides utility methods for working with numeric ranges.
-
-```ts
-// Example 1: Creating a Numeric Range
-const numericRange = Range.rangeTo(1, 5, 2);
-console.log(numericRange); // Output: [1, 3, 5]
-
-// Example 2: Creating a Numeric Range (Exclusive)
-const numericRangeAlias = rangeUntil(1, 5, 2);
-console.log(numericRangeAlias); // Output: [1, 3, 5]
-
-// Example 3: Checking if a Value is in Range
-const isInRange = Range.inRange(3, 1, 5);
-console.log(isInRange); // Output: true
-
-// Example 4: Range with chaining Operations
-rangeTo(1, 5, 2)
- .runIt(function () {
- console.log(`multiplying the following range of numbers: ${this}`);
- this.map(it => it * 2)
- .forEach(it => console.log(it));
- });
-```
-
-### Global Utility Functions
-Global functions are the unsung heroes that transcend the boundaries of specific data types, providing a universal
-toolkit for developers. These functions, residing in the global scope, are the go-to tools when you need versatile
-and expressive solutions that operate seamlessly across various data structures.
-
-#### Meet some Ingredients
-* **runIt()**: The maestro orchestrating the symphony of functions, _runIt_ calls a specified function block and presents its harmonious result.
-* **withIt()**: The chameleon of functions, _withIt_ transforms any object into the star of the show, letting it shine in a function block tailored just for them.
-* **listOf()**: Assemble an immutable list of elements effortlessly with _listOf_. It's your go-to for creating collections in a concise and readable manner.
-* **mutableListOf()**: When you need a dynamic collection that can evolve with your needs, turn to _mutableListOf_ to create mutable lists with ease.
-* **optionalOf()**: Embrace the power of optionals with _optionalOf_, a function that lets you gracefully handle scenarios with potentially absent values.
-* **durationOf()**: Time is of the essence, and _durationOf_ allows you to craft time durations with precision, making time manipulation a breeze.
-* **sequenceOf()**: Elevate your iteration game with _sequenceOf_, creating lazy sequences that conserve resources and provide on-the-fly transformation capabilities.
-* **reducerOf()**: Transform your data with _reducerOf_, a function designed for building reducers that streamline complex state transformations in a functional paradigm.
-* **rangeTo()**: Define ranges effortlessly with _rangeTo_, a function simplifying the creation of numeric ranges for iteration or data selection.
-* **ok()**: Indicate success with confidence using _ok_. This function constructs an "ok" result, signaling that a task or operation was completed successfully.
-* **error()**: Handle errors gracefully with _error_. This function constructs an error result, encapsulating details about the failure and allowing for structured error handling.
-
-These are just a smell of the utility this library brings to the table. Please, check the complete list in the [Global Functions]() section.
-
-### Type Extension Functions
-In JavaScript, where each data type carries its own set of behaviors, type extension functions emerge as the virtuosos of customization.
-These functions enrich your interactions with core data types, injecting them with new capabilities, being functional
-or utilities, and streamlining common operations.
-
-| Type | Utilities |
-|------------------------|---------------------------------------------------------------------------------------------------------------------------------------|
-| [Object Extensions]() | Extensions redefine how you interact with objects, enabling fluid and expressive operations tailored to your needs. |
-| [Number Extensions]() | Brings a consistent, functional and powerful approach to numeric operations |
-| [String Extensions]() | Give your strings a makeover with extensions that redefine the way you manipulate text. |
-| [Boolean Extensions]() | Functions like letIt, also, runIt, apply, takeIf, and takeUnless introduce a consistent and expressive way to handle boolean values. |
+# Documentation
diff --git a/docs/array.md b/docs/array.md
deleted file mode 100644
index ff0a540..0000000
--- a/docs/array.md
+++ /dev/null
@@ -1,539 +0,0 @@
-
-```markdown
----
-id: array
-title: Array Component
-sidebar_label: Array
----
-
-## Introduction
-
-The Array component in the Katxupa library provides additional utility functions for working with arrays.
-
-### Installation
-
-To use the Array component, you can include it in your project:
-
-```bash
-npm install katxupa
-```
-
-### Usage
-
-#### listOf
-
-Creates an immutable list from the provided elements.
-
-```javascript
-const list = listOf(1, 2, 3);
-// list is [1, 2, 3]
-```
-
-#### mutableListOf
-
-Creates a mutable list from the provided elements.
-
-```javascript
-const mutableList = mutableListOf(1, 2, 3);
-// mutableList is [1, 2, 3]
-```
-
-#### emptyList
-
-Creates an empty list.
-
-```javascript
-const empty = emptyList();
-// empty is []
-```
-
-#### associateWith
-
-Associates each element with a key-value pair based on the provided selectors.
-
-```javascript
-const elements = [
- { id: 1, value: 'a' },
- { id: 2, value: 'b' },
-];
-const keyValuePairs = elements.associateWith(
- (element) => element.id,
- (element) => element.value
-);
-// keyValuePairs is { '1': 'a', '2': 'b' }
-```
-
-#### mapIndexed
-
-Maps each element to a new value using the provided transformation function.
-
-```javascript
-const numbers = [1, 2, 3];
-const squaredNumbers = numbers.mapIndexed((num, index) => num * num + index);
-// squaredNumbers is [1, 5, 11]
-```
-
-#### sortDescending
-
-Sorts the collection in descending order.
-
-```javascript
-const numbers = [3, 1, 4, 1, 5, 9, 2];
-const sortedNumbers = numbers.sortDescending();
-// sortedNumbers is [9, 5, 4, 3, 2, 1, 1]
-```
-
-#### sortBy
-
-Sorts the collection using the provided comparator function.
-
-```javascript
-const users = [
- { name: 'John', age: 30 },
- { name: 'Alice', age: 25 },
- { name: 'Bob', age: 35 },
-];
-const sortedUsers = users.sortBy((a, b) => a.age - b.age);
-// sortedUsers is [{ name: 'Alice', age: 25 }, { name: 'John', age: 30 }, { name: 'Bob', age: 35 }]
-```
-
-#### plus
-
-Concatenates the collection with another array.
-
-```javascript
-const collection = [1, 2, 3];
-const otherArray = [4, 5, 6];
-const result = collection.plus(otherArray);
-// result is [1, 2, 3, 4, 5, 6]
-```
-
-#### minus
-
-Removes elements from the collection that are present in another array.
-
-```javascript
-const collection = [1, 2, 3, 4, 5];
-const elementsToRemove = [3, 5];
-const result = collection.minus(elementsToRemove);
-// result is [1, 2, 4]
-```
-
-#### minusAssign
-
-Removes elements from the collection that are present in another array (mutates the collection).
-
-```javascript
-const collection = [1, 2, 3, 4, 5];
-const elementsToRemove = [3, 5];
-collection.minusAssign(elementsToRemove);
-// collection is now [1, 2, 4]
-```
-
-#### plusAssign
-
-Appends elements from another array to the collection (mutates the collection).
-
-```javascript
-const collection = [1, 2, 3];
-const additionalElements = [4, 5, 6];
-collection.plusAssign(additionalElements);
-// collection is now [1, 2, 3, 4, 5, 6]
-```
-
-#### count
-
-Returns the number of elements in the collection.
-
-```javascript
-const collection = [1, 2, 3, 4, 5];
-const count = collection.count();
-// count is 5
-```
-
-#### removeAll
-
-Removes elements from the collection based on a predicate or a collection of elements.
-
-```javascript
-const collection = [1, 2, 3, 4, 5];
-const elementsToRemove = [3, 5];
-const result = collection.removeAll(elementsToRemove);
-// result is [1, 2, 4]
-```
-
-#### retainAll
-
-Retains only the elements in the collection that are present in another array.
-
-```javascript
-const collection = [1, 2, 3, 4, 5];
-const elementsToRetain = [3, 5];
-const result = collection.retainAll(elementsToRetain);
-// result is [3, 5]
-```
-
-#### last
-
-Returns the last element in the collection.
-
-```javascript
-const collection = [1, 2, 3];
-const lastElement = collection.last();
-// lastElement is 3
-```
-
-#### getOrElse
-
-Gets the element at the specified index or provides a default value if the index is out of bounds.
-
-```javascript
-const collection = [1, 2, 3, 4, 5];
-const element = collection.getOrElse(2, () => 10);
-// element is 3
-```
-
-#### getOrEmpty
-
-Gets an optional containing the element at the specified index.
-
-```javascript
-const collection = [1, 2, 3, 4, 5];
-const optionalElement = collection.getOrEmpty(2);
-// optionalElement contains the value Optional.of(3)
-```
-
-#### shuffle
-
-Shuffles the elements in the collection randomly.
-
-```javascript
-const collection = [1, 2, 3, 4, 5];
-collection.shuffle();
-// collection is now shuffled randomly, e.g., [3, 1, 5, 2, 4]
-```
-
-## API Reference
-
-### Methods
-
-- [associateWith](#associateWith)
-- [mapIndexed](#mapIndexed)
-- [sortDescending](#sortDescending)
-- [sortBy](#sortBy)
-- [plus](#plus)
-- [minus](#minus)
-- [minusAssign](#minusAssign)
-- [plusAssign](#plusAssign)
-- [count](#count)
-- [removeAll](#removeAll)
-- [retainAll](#retainAll)
-- [last](#last)
-- [getOrElse](#getOrElse)
-- [getOrEmpty](#getOrEmpty)
-- [shuffle](#shuffle)
-
-### associateWith
-
-Associates each element with a key-value pair based on the provided selectors.
-
-#### Parameters
-
-- `keySelector: (element: T) => K` - The function to extract keys from elements.
-- `valueSelector: (element: T) => V` - The function to extract values from elements.
-
-#### Returns
-
-A record associating keys with their corresponding values.
-
-#### Example
-
-```javascript
-const elements = [
- { id: 1, value: 'a' },
- { id: 2, value: 'b' },
-];
-const keyValuePairs = elements.associateWith(
- (element) => element.id,
- (element) => element.value
-);
-// keyValuePairs is { '1': 'a', '2': 'b' }
-```
-
-### mapIndexed
-
-Maps each element to a new value using the provided transformation function.
-
-#### Parameters
-
-- `transform: (element: T, index: number) => U` - The function to transform each element.
-
-#### Returns
-
-A readonly array containing the transformed elements.
-
-#### Example
-
-```javascript
-const numbers = [1, 2, 3];
-const squaredNumbers = numbers.mapIndexed((num, index) => num * num + index);
-// squaredNumbers is [1, 5, 11]
-```
-
-### sortDescending
-
-Sorts the collection in descending order.
-
-#### Returns
-
-A reference to the sorted array.
-
-#### Example
-
-```javascript
-const numbers = [3, 1, 4, 1, 5, 9, 2];
-numbers.sortDescending();
-// numbers is now [9, 5, 4, 3, 2, 1, 1]
-```
-
-### sortBy
-
-Sorts the collection using the provided comparator function.
-
-#### Parameters
-
-- `comparator: (a: T, b: T) => number` - The function to compare elements.
-
-#### Returns
-
-A reference to the sorted array.
-
-#### Example
-
-```javascript
-const users = [
- { name: 'John', age: 30 },
- { name: 'Alice', age: 25 },
- { name: 'Bob', age: 35 },
-];
-users.sortBy((a, b) => a.age - b.age);
-// users is now sorted by age: [{ name: 'Alice', age: 25 }, { name: 'John', age: 30 }, { name: 'Bob', age: 35 }]
-```
-
-### plus
-
-Concatenates the collection with another array.
-
-#### Parameters
-
-- `other: T[]` - The array to concatenate with the current collection.
-
-#### Returns
-
-A new array containing elements from both the current collection and the provided array.
-
-#### Example
-
-```javascript
-const collection = [1, 2, 3];
-const otherArray = [4, 5, 6];
-const result = collection.plus(otherArray);
-// result is [1, 2, 3, 4, 5, 6]
-```
-
-### minus
-
-Removes elements from the collection that are present in another array.
-
-#### Parameters
-
-- `other: T[]` - The array containing elements to be removed from the current collection.
-
-#### Returns
-
-A new array with elements not present in the provided array.
-
-#### Example
-
-```javascript
-const collection = [1, 2, 3, 4, 5];
-const elementsToRemove = [3, 5];
-const result = collection.minus(elementsToRemove);
-// result is [1, 2, 4]
-```
-
-### minusAssign
-
-Removes elements from the collection that are present in another array (mutates the collection).
-
-#### Parameters
-
-- `collection: T[]` - The array containing elements to be removed from the current collection.
-
-#### Returns
-
-A reference to the affected array.
-
-#### Example
-
-```javascript
-const collection = [1, 2, 3, 4, 5];
-const elementsToRemove = [3, 5];
-collection.minusAssign(elementsToRemove);
-// collection is now [1, 2, 4]
-```
-
-### plusAssign
-
-Appends elements from another array to the collection (mutates the collection).
-
-#### Parameters
-
-- `other: T[]` - The array containing elements to be added to the current collection.
-
-#### Returns
-
-A reference to the affected array.
-
-#### Example
-
-```javascript
-const collection = [1, 2, 3];
-const additionalElements = [4, 5, 6];
-collection.plusAssign(additionalElements);
-// collection is now [1, 2, 3, 4, 5, 6]
-```
-
-### count
-
-Returns the number of elements in the collection.
-
-#### Returns
-
-The number of elements in the collection.
-
-#### Example
-
-```javascript
-const collection = [1, 2, 3, 4, 5];
-const count = collection.count();
-// count is 5
-```
-
-### removeAll
-
-Removes elements from the collection based on a predicate or a collection of elements.
-
-#### Parameters
-
-- `predicate: ((item: T) => boolean) | T[]` - The predicate function or collection of elements to remove.
-
-#### Returns
-
-A new array with elements removed based on the provided predicate or collection.
-
-#### Example
-
-```javascript
-const collection = [1, 2, 3, 4, 5];
-const elementsToRemove = [3, 5];
-const result = collection.removeAll(elementsToRemove);
-// result is [1, 2, 4]
-```
-
-### retainAll
-
-Retains only the elements in the collection that are present in another array.
-
-#### Parameters
-
-- `predicate: ((item: T) => boolean) | T[]` - The predicate function or collection of elements to retain.
-
-#### Returns
-
-A new array containing only the elements that satisfy the provided predicate or are present in the provided collection.
-
-#### Example
-
-```javascript
-const collection = [1, 2, 3, 4, 5];
-const elementsToRetain = [3, 5];
-const result = collection.retainAll(elementsToRetain);
-// result is [3, 5]
-```
-
-### last
-
-Returns the last element in the collection.
-
-#### Returns
-
-The last element in the collection.
-
-#### Throws
-
-- `NoSuchElementError` - If the collection is empty.
-
-#### Example
-
-```javascript
-const collection = [1, 2, 3];
-const lastElement = collection.last();
-// lastElement is 3
-```
-
-### getOrElse
-
-Gets the element at the specified index or provides a default value if the index is out of bounds.
-
-#### Parameters
-
-- `index: number` - The index of the element to retrieve.
-- `defaultValueProvider: () => T` - A function providing the default value.
-
-#### Returns
-
-The element at the specified index or the default value if the index is out of bounds.
-
-#### Example
-
-```javascript
-const collection = [1, 2, 3, 4, 5];
-const element = collection.getOrElse(2, () => 10);
-// element is 3
-```
-
-### getOrEmpty
-
-Gets an optional containing the element at the specified index.
-
-#### Parameters
-
-- `index: number` - The index of the element.
-
-#### Returns
-
-An optional containing the element if it exists, otherwise an empty optional.
-
-#### Example
-
-```javascript
-const collection = [1, 2, 3, 4, 5];
-const optionalElement = collection.getOrEmpty(2);
-// optionalElement contains the value Optional.of(3)
-```
-
-### shuffle
-
-Shuffles the elements in the collection randomly.
-
-#### Returns
-
-A reference to the affected array.
-
-#### Example
-
-```javascript
-const collection = [1, 2, 3, 4, 5];
-collection.shuffle();
-// collection is now shuffled randomly, e.g., [3, 1, 5, 2, 4]
diff --git a/docs/assets/docs-home.png b/docs/assets/docs-home.png
new file mode 100644
index 0000000..1aa9175
Binary files /dev/null and b/docs/assets/docs-home.png differ
diff --git a/docs/index.md b/docs/index.md
deleted file mode 100644
index 9343001..0000000
--- a/docs/index.md
+++ /dev/null
@@ -1,261 +0,0 @@
-# Katxupa
-**Delicious Dish for Typescript and JavaScript projects.**
-
-In [Cape Verde](https://en.wikipedia.org/wiki/Cape_Verde) we have a saying:
-
-"_Put a person to work in the field and serve them anything other than [Katxupa](https://www.crumbsnatched.com/cachupa-traditional-dish-of-cape-verde/)
-for breakfast, and you'll notice a decline in productivity and motivation. Therefore, give them Katxupa and spice it up on the side._"
-
-Just as "_Katxupa_" is an essential part of Cape Verdean culture, this library brings _functional_ elements to enhance your
-productivity and developer happiness. So, consume (use) it!
-
-> **Katxupa**, Cape Verde’s national dish, is a flavorful stew consisting of hominy, beans, seasoned meats, and vegetables.
-> Each family has its unique version, leading to delightful variations.
-> One undeniable fact: there is no Cape Verdean who doesn't appreciate Katxupa ("Cachupa") — whether for breakfast, lunch, dinner, or any time, anywhere.
-
-## Why Katxupa
-For starters, the "_K_" in **Katxupa** stands for [Kotlin](https://kotlinlang.org/), which was the primary inspiration for this library. Drawing from the
-functional programming paradigm of Kotlin and its concise yet expressive syntax, Katxupa aims to bring similar benefits
-to Typescript and JavaScript developers.
-
-### What Makes Katxupa Special?
-* **Functional Delight**: _Katxupa_ introduces functional programming concepts to enhance your code's expressiveness and clarity.
-
-* **Kotlin-Inspired Goodness**: Leveraging lessons learned from Kotlin, _Katxupa_ provides utilities and extensions that streamline your workflow.
-
-* **Boosted Productivity**: Enjoy a more productive development experience with _Katxupa_'s utility classes, sequences, durations, and more.
-
-* **Developer Happiness**: Inspired by the joy of coding in Kotlin, Katxupa seeks to bring happiness to your TypeScript and JavaScript projects.
-
-### Key Features
-* **Scope Functions**: _Kotlin-like_ scope functions, provides a set of functions to execute a block of code in the context of a given object: _letIt_, _runIt_, _withIt_, _apply_, and _also_.
-
-* **Collections Functions**: _Kotlin-like_ functions for Arrays, Maps, and Sets: Apply concise and expressive operations on collections.
-
-* **Sequences**: Lazy sequences with a _Kotlin-esque_ feel, providing a convenient way to work with iterable data.
-
-* **Duration**: A flexible and comprehensive time duration class with support for various units, offering better time handling.
-
-* **Optional**: A type that represents an optional value, helping to avoid null or undefined-related issues.
-
-* **Result and Either**: Functional constructs to handle success, errors, and alternate paths in a more expressive manner.
-
-* **Inspired by Cape Verde**: Infused with the spirit of [Cape Verde](https://en.wikipedia.org/wiki/Cape_Verde) and its cherished dish **Katxupa**, this library aims to add flavor to your coding experience.
-
-### Get a Taste of Katxupa
-Explore the documentation and see how Katxupa can bring a delightful touch to your TypeScript and JavaScript projects.
-From functional programming utilities to time handling and result handling, **Katxupa** is here to make your coding journey _more enjoyable_.
-
-## Installation
-This package is build up with simplicity in mind, brings no additional dependencies, and it's published in NPM https://www.npmjs.com/package/katxupa.
-
-It can be installed using your preferred package manager.
-
-### NPM
-```shell
-npm install katxupa
-```
-
-### PNPM
-```shell
-pnpm install katxupa
-```
-
-### YARN
-```shell
-yarn add katxupa
-```
-
-## Usage
-### Scope Functions
-Simply call any value with **_letIt_**, **_runIt_**, **_also_** or **_apply_**, and it'll be passed as the argument or the context of a scope function.
-
-```ts linenums="1"
-const person = {name: "Manuel", email: "ney.br.santos@gmail.com", age: 35};
-
-person.letIt(it => {
- console.log(`${it.name},`);
- it.age < 30 ? console.log("A Young Man") : console.log("An Old Man");
- return it.age;
-}).also(it => {
- console.log(`Actual Age is ${it}`);
-});
-// Output:
-// Manuel,
-// An Old Man
-// Actual Age is 35
-```
-
-It also supports the use of the new [Optional Chaining Operator](https://github.com/tc39/proposal-optional-chaining),
-bringing the logic of [Kotlin's Null Safe Calls](https://kotlinlang.org/docs/reference/null-safety.html) to the JavaScript world.
-
-```ts linenums="1"
- const user = await this.userRepository.findOneBy({
- id: userId,
-});
-
-user?.runIt(function() {
- this.emailService.send(this.email, `${this.name} welcome to the Katxupa library`);
-});
-```
-
-You can execute a block of code only if a value is neither null nor undefined:
-```ts linenums="1"
-const data: string | null = await getData();
-
-data?.also(it => console.log(`Already initialized: ${it}`)) ?? console.log("Still not initialized");
-```
-The above code is equivalent to:
-```ts linenums="1"
-if (data != null && data != undefined)
- console.log(`Already initialized: ${str!}`);
-else
- console.log("Still not initialized");
-```
-
-The usage of **_takeIf_** & **_takeUnless_** is a bit different. You can call any value with **_takeIf_** and it will
-return the caller instance if the predicate is true, or undefined if it's false (and vice versa when using **_takeUnless_**).
-```ts linenums="1"
-const account = await accountService.getAccount(id);
-
-account.takeIf(it => {
- return addressBook.has(it.email);
-})?.also(it => {
- emailService.send(it.email, "You are entitled for crypto airdrop")
-}) ?? console.log(`Account with ${id} not found in the system`);
-```
-
-### Null Safety
-* Null-safety through [Optional Chaining Operator](https://github.com/tc39/proposal-optional-chaining) for scope functions:
-```ts linenums="1"
-// Only run the code block if "numberOrUndefined" is defined
-const numberOrUndefinedOrNull = await bitcoinService.getPrice();
-numberOrUndefinedOrNull?.letIt((it) => {
- it++;
- it = it * 100;
- return it;
-});
-
-// Actually, there is no need to declare a variable
-(await bitcoinService.getPrice())
- ?.letIt((it) => {
- it++;
- it = it * 100;
- return it;
- });
-```
-* **_Optional_** wrapper for general purpose:
-```ts linenums="1"
-// Example 1
-// Get Usecase:
-// 1- Validate if user exists
-// 2- Through an HttpError if not
-// 3- Return the user object
-return optionalOf(user)
- .orElseThrow(() => new NotFoundError("User doesn't exist"))
- .get();
-
-// Example 2
-// Delete Usecase:
-// 1- Validate if user exists
-// 2- Through an HttpError if not
-// 3- Delete the user from the database asynchronously and await for the result
-await Optional.of(user)
- .orElseThrow(() => new HttpError(409, "User doesn't exist"))
- .runAsync(() => this.userRepository.delete({id: userId}));
-
-// Example 3
-// Update usecase:
-// 1- Validate if user exists
-// 2- Through an HttpError if not
-// 3- If exists, merge the existing one with additional userData
-// 4- Call the user repository and save the updated user asyncronously, returning a promise
-//
-return optionalOf(user)
- .orElseThrow(() => new HttpError(409, "User doesn't exist"))
- .map(user => {
- return {
- ...user,
- userData,
- };
- })
- .runAsync(user => this.userRepository.save(user));
-```
-
-### Duration
-An easy, expressive and functional way of declaring a duration of time with support for various units (nanoseconds,
-microseconds, milliseconds, seconds, minutes, hours, and days).
-
-```ts linenums="1"
-// Example 1
-durationOf(1000)
- .toSeconds()
- .letIt(it => {
- console.log(`1000 milliseconds are the same as ${it} seconds`);
- });
-
-// Example 2
-const oneYearInMinutes = (1).years().toHours().toMinutes();
-console.log(`1 year is approximately ${oneYearInMinutes} minutes.`);
-
-// Example 3
-const duration = (1).years().add((6).months()).toString();
-console.log(duration); // Output: 548d 0h 0m 0s 0ns
-```
-
-### Range
-The `Range` class provides utility methods for working with numeric ranges.
-
-```ts linenums="1"
-// Example 1: Creating a Numeric Range
-const numericRange = Range.rangeTo(1, 5, 2);
-console.log(numericRange); // Output: [1, 3, 5]
-
-// Example 2: Creating a Numeric Range (Exclusive)
-const numericRangeAlias = rangeUntil(1, 5, 2);
-console.log(numericRangeAlias); // Output: [1, 3, 5]
-
-// Example 3: Checking if a Value is in Range
-const isInRange = Range.inRange(3, 1, 5);
-console.log(isInRange); // Output: true
-
-// Example 4: Range with chaining Operations
-rangeTo(1, 5, 2)
- .runIt(function () {
- console.log(`multiplying the following range of numbers: ${this}`);
- this.map(it => it * 2)
- .forEach(it => console.log(it));
- });
-```
-
-### Global Utility Functions
-Global functions are the unsung heroes that transcend the boundaries of specific data types, providing a universal
-toolkit for developers. These functions, residing in the global scope, are the go-to tools when you need versatile
-and expressive solutions that operate seamlessly across various data structures.
-
-#### Meet some Ingredients
-* **runIt()**: The maestro orchestrating the symphony of functions, _runIt_ calls a specified function block and presents its harmonious result.
-* **withIt()**: The chameleon of functions, _withIt_ transforms any object into the star of the show, letting it shine in a function block tailored just for them.
-* **listOf()**: Assemble an immutable list of elements effortlessly with _listOf_. It's your go-to for creating collections in a concise and readable manner.
-* **mutableListOf()**: When you need a dynamic collection that can evolve with your needs, turn to _mutableListOf_ to create mutable lists with ease.
-* **optionalOf()**: Embrace the power of optionals with _optionalOf_, a function that lets you gracefully handle scenarios with potentially absent values.
-* **durationOf()**: Time is of the essence, and _durationOf_ allows you to craft time durations with precision, making time manipulation a breeze.
-* **sequenceOf()**: Elevate your iteration game with _sequenceOf_, creating lazy sequences that conserve resources and provide on-the-fly transformation capabilities.
-* **reducerOf()**: Transform your data with _reducerOf_, a function designed for building reducers that streamline complex state transformations in a functional paradigm.
-* **rangeTo()**: Define ranges effortlessly with _rangeTo_, a function simplifying the creation of numeric ranges for iteration or data selection.
-* **ok()**: Indicate success with confidence using _ok_. This function constructs an "ok" result, signaling that a task or operation was completed successfully.
-* **error()**: Handle errors gracefully with _error_. This function constructs an error result, encapsulating details about the failure and allowing for structured error handling.
-
-These are just a smell of the utility this library brings to the table. Please, check the complete list in the [Global Functions]() section.
-
-### Type Extension Functions
-In JavaScript, where each data type carries its own set of behaviors, type extension functions emerge as the virtuosos of customization.
-These functions enrich your interactions with core data types, injecting them with new capabilities, being functional
-or utilities, and streamlining common operations.
-
-| Type | Utilities |
-|------------------------|---------------------------------------------------------------------------------------------------------------------------------------|
-| [Object Extensions]() | Extensions redefine how you interact with objects, enabling fluid and expressive operations tailored to your needs. |
-| [Number Extensions]() | Brings a consistent, functional and powerful approach to numeric operations |
-| [String Extensions]() | Give your strings a makeover with extensions that redefine the way you manipulate text. |
-| [Boolean Extensions]() | Functions like letIt, also, runIt, apply, takeIf, and takeUnless introduce a consistent and expressive way to handle boolean values. |
diff --git a/docs/index2.md b/docs/index2.md
deleted file mode 100644
index fb8a6f3..0000000
--- a/docs/index2.md
+++ /dev/null
@@ -1,47 +0,0 @@
-# Katxupa
-**Delicious Dish for Typescript and JavaScript projects.**
-
-In [Cape Verde](https://en.wikipedia.org/wiki/Cape_Verde) we have a saying:
-
-"_Put a person to work in the field and serve them anything other than [Katxupa](https://www.crumbsnatched.com/cachupa-traditional-dish-of-cape-verde/)
-for breakfast, and you'll notice a decline in productivity and motivation. Therefore, give them Katxupa and spice it up on the side._"
-
-Just as "_Katxupa_" is an essential part of Cape Verdean culture, this library brings _functional_ elements to enhance your
-productivity and developer happiness. So, consume (use) it!
-
-> **Katxupa**, Cape Verde’s national dish, is a flavorful stew consisting of hominy, beans, seasoned meats, and vegetables.
-> Each family has its unique version, leading to delightful variations.
-> One undeniable fact: there is no Cape Verdean who doesn't appreciate Katxupa ("Cachupa") — whether for breakfast, lunch, dinner, or any time, anywhere.
-
-## Why Katxupa
-For starters, the "_K_" in **Katxupa** stands for [Kotlin](https://kotlinlang.org/), which was the primary inspiration for this library. Drawing from the
-functional programming paradigm of Kotlin and its concise yet expressive syntax, Katxupa aims to bring similar benefits
-to Typescript and JavaScript developers.
-
-### What Makes Katxupa Special?
-* **Functional Delight**: _Katxupa_ introduces functional programming concepts to enhance your code's expressiveness and clarity.
-
-* **Kotlin-Inspired Goodness**: Leveraging lessons learned from Kotlin, _Katxupa_ provides utilities and extensions that streamline your workflow.
-
-* **Boosted Productivity**: Enjoy a more productive development experience with _Katxupa_'s utility classes, sequences, durations, and more.
-
-* **Developer Happiness**: Inspired by the joy of coding in Kotlin, Katxupa seeks to bring happiness to your TypeScript and JavaScript projects.
-
-### Key Features
-* **Scope Functions**: _Kotlin-like_ scope functions, provides a set of functions to execute a block of code in the context of a given object: _letIt_, _runIt_, _withIt_, _apply_, and _also_.
-
-* **Collections Functions**: _Kotlin-like_ functions for Arrays, Maps, and Sets: Apply concise and expressive operations on collections.
-
-* **Sequences**: Lazy sequences with a _Kotlin-esque_ feel, providing a convenient way to work with iterable data.
-
-* **Duration**: A flexible and comprehensive time duration class with support for various units, offering better time handling.
-
-* **Optional**: A type that represents an optional value, helping to avoid null or undefined-related issues.
-
-* **Result and Either**: Functional constructs to handle success, errors, and alternate paths in a more expressive manner.
-
-* **Inspired by Cape Verde**: Infused with the spirit of [Cape Verde](https://en.wikipedia.org/wiki/Cape_Verde) and its cherished dish **Katxupa**, this library aims to add flavor to your coding experience.
-
-### Get a Taste of Katxupa
-Explore the documentation and see how Katxupa can bring a delightful touch to your TypeScript and JavaScript projects.
-From functional programming utilities to time handling and result handling, **Katxupa** is here to make your coding journey _more enjoyable_.
diff --git a/docs/scope.md b/docs/scope.md
deleted file mode 100644
index cbd2afb..0000000
--- a/docs/scope.md
+++ /dev/null
@@ -1,270 +0,0 @@
-## Scope Functions
-The Katxupa library contains several functions whose sole purpose is to execute a block of code within the context of an object.
-When you call such a function on an object with a lambda expression provided, it forms a temporary scope. In this scope,
-you can access the object through _**it**_ or in some cases _**this**_. Such functions are called scope functions.
-
-There are five of them: **_letIt_**, **_runIt_**, **_withIt_**, **_applyIt_**, and **_alsoIt_**.
-
-Basically, these functions all perform the same action: execute a block of code on an object. What's different is how this
-object becomes available inside the block and what the result of the whole expression is.
-
-Here's a typical example of how to use a scope function:
-```ts
-({name: "Manuel", age: 36})
- .letIt(it => {
- console.log(it);
- it.age++;
- console.log(it);
- });
-```
-If you write the same without letIt, you'll have to introduce a new variable and repeat its name whenever you use it.
-```ts
-const user = {name: "Manuel", age: 36};
-console.log(user);
-user.age++;
-console.log(user);
-```
-
-Scope functions don't introduce any new technical capabilities, but they can make your code more concise and readable.
-
-Due to the many similarities between scope functions, choosing the right one for your use case can be tricky.
-The choice mainly depends on your intent and the consistency of use in your project. Below, we provide detailed descriptions
-of the differences between scope functions and their conventions.
-
-### Function selection
-To help you choose the right scope function for your purpose, we provide this table that summarizes the key differences between them.
-
-| Function | Object Reference | Return Value | Is extension function |
-|----------|------------------|----------------|----------------------------------------------|
-| letIt | it | Lambda Result | Yes |
-| runIt | this | Lambda Result | Yes |
-| runIt | - | Lambda Result | No: called without the context object |
-| withIt | this | Lambda Result | No: takes the context object as an argument. |
-| applyIt | this | Context Object | Yes |
-| alsoIt | it | Context Object | Yes |
-
-> Note that **letIt** & **alsoIt** can be called with standard lambda/arrow functions, but because JavaScript arrow functions don't
-> have an own this context, **runIt** & **applyIt** have to be called with standard functions.
-
-Detailed information about these functions is provided in the dedicated sections below.
-
-Here is a short guide for choosing scope functions depending on the intended purpose:
-* Executing a lambda on non-nullable objects: **letIt**
-* Introducing an expression as a variable in local scope: **letIt**
-* Object configuration: **applyIt**
-* Object configuration and computing the result: **runIt**
-* Running statements where an expression is required: non-extension **runIt**
-* Additional effects: **alsoIt**
-* Grouping function calls on an object: **withIt**
-
-The use cases of different scope functions overlap, so you can choose which functions to use based on the specific
-conventions used in your project or team.
-
-Although scope functions can make your code more concise, avoid overusing them: it can make your code hard to read and
-lead to errors. We also recommend that you avoid nesting scope functions and be careful when chaining them because it's
-easy to get confused about the current context object and value of this or it.
-
-### Distinctions
-Because scope functions are similar in nature, it's important to understand the differences between them. There are two
-main differences between each scope function:
-
-* The way they refer to the context object.
-* Their return value.
-
-#### Context object: this or it
-Inside the lambda passed to a scope function, the context object is available by a short reference instead of its actual name.
-Each scope function uses one of two ways to reference the context object: as a function receiver (_this_) or as a lambda argument (_it_).
-Both provide the same capabilities, so we describe the pros and cons of each for different use cases and provide recommendations for their use.
-
-```ts
-function main() {
- const str = "Hello"
- // this
- str.runIt(function () {
- console.log(`The string's length: ${this.length}`)
- } );
-
- // it
- str.letIt(it => {
- console.log(`The string's length: ${it.length}`)
- })
-}
-```
-### Functions
-To help you choose the right scope function for your use case, we describe them in detail and provide recommendations for use.
-Technically, scope functions are interchangeable in many cases, so the examples show conventions for using them.
-
-#### letIt
-* **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.
-```ts
-const data: Array Creates an immutable list from the provided elements. Creates a mutable list from the provided elements. Creates an empty list. Associates each element with a key-value pair based on the provided selectors. Maps each element to a new value using the provided transformation function. Sorts the collection in descending order. Sorts the collection using the provided comparator function. Concatenates the collection with another array. Removes elements from the collection that are present in another array. Removes elements from the collection that are present in another array (mutates the collection). Appends elements from another array to the collection (mutates the collection). Returns the number of elements in the collection. Removes elements from the collection based on a predicate or a collection of elements. Retains only the elements in the collection that are present in another array. Returns the last element in the collection. Gets the element at the specified index or provides a default value if the index is out of bounds. Gets an optional containing the element at the specified index. Shuffles the elements in the collection randomly. Associates each element with a key-value pair based on the provided selectors. A record associating keys with their corresponding values. Maps each element to a new value using the provided transformation function. A readonly array containing the transformed elements. Sorts the collection in descending order. A reference to the sorted array. Sorts the collection using the provided comparator function. A reference to the sorted array. Concatenates the collection with another array. A new array containing elements from both the current collection and the provided array. Removes elements from the collection that are present in another array. A new array with elements not present in the provided array. Removes elements from the collection that are present in another array (mutates the collection). A reference to the affected array. Appends elements from another array to the collection (mutates the collection). A reference to the affected array. Returns the number of elements in the collection. The number of elements in the collection. Removes elements from the collection based on a predicate or a collection of elements. A new array with elements removed based on the provided predicate or collection. Retains only the elements in the collection that are present in another array. A new array containing only the elements that satisfy the provided predicate or are present in the provided collection. Returns the last element in the collection. The last element in the collection. Gets the element at the specified index or provides a default value if the index is out of bounds. The element at the specified index or the default value if the index is out of bounds. Gets an optional containing the element at the specified index. An optional containing the element if it exists, otherwise an empty optional. Shuffles the elements in the collection randomly. A reference to the affected array. ```javascript
-const collection = [1, 2, 3, 4, 5];
-collection.shuffle();
-// collection is now shuffled randomly, e.g., [3, 1, 5, 2, 4] Delicious Dish for Typescript and JavaScript projects. In Cape Verde we have a saying: "Put a person to work in the field and serve them anything other than Katxupa
-for breakfast, and you'll notice a decline in productivity and motivation. Therefore, give them Katxupa and spice it up on the side." Just as "Katxupa" is an essential part of Cape Verdean culture, this library brings functional elements to enhance your
-productivity and developer happiness. So, consume (use) it! Katxupa, Cape Verde’s national dish, is a flavorful stew consisting of hominy, beans, seasoned meats, and vegetables.
-Each family has its unique version, leading to delightful variations.
-One undeniable fact: there is no Cape Verdean who doesn't appreciate Katxupa ("Cachupa") — whether for breakfast, lunch, dinner, or any time, anywhere. For starters, the "K" in Katxupa stands for Kotlin, which was the primary inspiration for this library. Drawing from the
-functional programming paradigm of Kotlin and its concise yet expressive syntax, Katxupa aims to bring similar benefits
-to Typescript and JavaScript developers. Functional Delight: Katxupa introduces functional programming concepts to enhance your code's expressiveness and clarity. Kotlin-Inspired Goodness: Leveraging lessons learned from Kotlin, Katxupa provides utilities and extensions that streamline your workflow. Boosted Productivity: Enjoy a more productive development experience with Katxupa's utility classes, sequences, durations, and more. Developer Happiness: Inspired by the joy of coding in Kotlin, Katxupa seeks to bring happiness to your TypeScript and JavaScript projects. Scope Functions: Kotlin-like scope functions, provides a set of functions to execute a block of code in the context of a given object: letIt, runIt, withIt, apply, and also. Collections Functions: Kotlin-like functions for Arrays, Maps, and Sets: Apply concise and expressive operations on collections. Sequences: Lazy sequences with a Kotlin-esque feel, providing a convenient way to work with iterable data. Duration: A flexible and comprehensive time duration class with support for various units, offering better time handling. Optional: A type that represents an optional value, helping to avoid null or undefined-related issues. Result and Either: Functional constructs to handle success, errors, and alternate paths in a more expressive manner. Inspired by Cape Verde: Infused with the spirit of Cape Verde and its cherished dish Katxupa, this library aims to add flavor to your coding experience. Explore the documentation and see how Katxupa can bring a delightful touch to your TypeScript and JavaScript projects.
-From functional programming utilities to time handling and result handling, Katxupa is here to make your coding journey more enjoyable. This package is build up with simplicity in mind, brings no additional dependencies, and it's published in NPM https://www.npmjs.com/package/katxupa. It can be installed using your preferred package manager. Simply call any value with letIt, runIt, also or apply, and it'll be passed as the argument or the context of a scope function. It also supports the use of the new Optional Chaining Operator,
-bringing the logic of Kotlin's Null Safe Calls to the JavaScript world. You can execute a block of code only if a value is neither null nor undefined:
- The usage of takeIf & takeUnless is a bit different. You can call any value with takeIf and it will
-return the caller instance if the predicate is true, or undefined if it's false (and vice versa when using takeUnless).
- An easy, expressive and functional way of declaring a duration of time with support for various units (nanoseconds,
-microseconds, milliseconds, seconds, minutes, hours, and days). The Global functions are the unsung heroes that transcend the boundaries of specific data types, providing a universal
-toolkit for developers. These functions, residing in the global scope, are the go-to tools when you need versatile
-and expressive solutions that operate seamlessly across various data structures. These are just a smell of the utility this library brings to the table. Please, check the complete list in the Global Functions section. In JavaScript, where each data type carries its own set of behaviors, type extension functions emerge as the virtuosos of customization.
-These functions enrich your interactions with core data types, injecting them with new capabilities, being functional
-or utilities, and streamlining common operations. Delicious Dish for Typescript and JavaScript projects. In Cape Verde we have a saying: "Put a person to work in the field and serve them anything other than Katxupa
-for breakfast, and you'll notice a decline in productivity and motivation. Therefore, give them Katxupa and spice it up on the side." Just as "Katxupa" is an essential part of Cape Verdean culture, this library brings functional elements to enhance your
-productivity and developer happiness. So, consume (use) it! Katxupa, Cape Verde’s national dish, is a flavorful stew consisting of hominy, beans, seasoned meats, and vegetables.
-Each family has its unique version, leading to delightful variations.
-One undeniable fact: there is no Cape Verdean who doesn't appreciate Katxupa ("Cachupa") — whether for breakfast, lunch, dinner, or any time, anywhere. For starters, the "K" in Katxupa stands for Kotlin, which was the primary inspiration for this library. Drawing from the
-functional programming paradigm of Kotlin and its concise yet expressive syntax, Katxupa aims to bring similar benefits
-to Typescript and JavaScript developers. Functional Delight: Katxupa introduces functional programming concepts to enhance your code's expressiveness and clarity. Kotlin-Inspired Goodness: Leveraging lessons learned from Kotlin, Katxupa provides utilities and extensions that streamline your workflow. Boosted Productivity: Enjoy a more productive development experience with Katxupa's utility classes, sequences, durations, and more. Developer Happiness: Inspired by the joy of coding in Kotlin, Katxupa seeks to bring happiness to your TypeScript and JavaScript projects. Scope Functions: Kotlin-like scope functions, provides a set of functions to execute a block of code in the context of a given object: letIt, runIt, withIt, apply, and also. Collections Functions: Kotlin-like functions for Arrays, Maps, and Sets: Apply concise and expressive operations on collections. Sequences: Lazy sequences with a Kotlin-esque feel, providing a convenient way to work with iterable data. Duration: A flexible and comprehensive time duration class with support for various units, offering better time handling. Optional: A type that represents an optional value, helping to avoid null or undefined-related issues. Result and Either: Functional constructs to handle success, errors, and alternate paths in a more expressive manner. Inspired by Cape Verde: Infused with the spirit of Cape Verde and its cherished dish Katxupa, this library aims to add flavor to your coding experience. Explore the documentation and see how Katxupa can bring a delightful touch to your TypeScript and JavaScript projects.
-From functional programming utilities to time handling and result handling, Katxupa is here to make your coding journey more enjoyable. The Katxupa library contains several functions whose sole purpose is to execute a block of code within the context of an object.
-When you call such a function on an object with a lambda expression provided, it forms a temporary scope. In this scope,
-you can access the object through it or in some cases this. Such functions are called scope functions. There are five of them: letIt, runIt, withIt, applyIt, and alsoIt. Basically, these functions all perform the same action: execute a block of code on an object. What's different is how this
-object becomes available inside the block and what the result of the whole expression is. Here's a typical example of how to use a scope function:
- Scope functions don't introduce any new technical capabilities, but they can make your code more concise and readable. Due to the many similarities between scope functions, choosing the right one for your use case can be tricky.
-The choice mainly depends on your intent and the consistency of use in your project. Below, we provide detailed descriptions
-of the differences between scope functions and their conventions. To help you choose the right scope function for your purpose, we provide this table that summarizes the key differences between them. Note that letIt & alsoIt can be called with standard lambda/arrow functions, but because JavaScript arrow functions don't
-have an own this context, runIt & applyIt have to be called with standard functions. Detailed information about these functions is provided in the dedicated sections below. Here is a short guide for choosing scope functions depending on the intended purpose:
-* Executing a lambda on non-nullable objects: letIt
-* Introducing an expression as a variable in local scope: letIt
-* Object configuration: applyIt
-* Object configuration and computing the result: runIt
-* Running statements where an expression is required: non-extension runIt
-* Additional effects: alsoIt
-* Grouping function calls on an object: withIt The use cases of different scope functions overlap, so you can choose which functions to use based on the specific
-conventions used in your project or team. Although scope functions can make your code more concise, avoid overusing them: it can make your code hard to read and
-lead to errors. We also recommend that you avoid nesting scope functions and be careful when chaining them because it's
-easy to get confused about the current context object and value of this or it. Because scope functions are similar in nature, it's important to understand the differences between them. There are two
-main differences between each scope function: Inside the lambda passed to a scope function, the context object is available by a short reference instead of its actual name.
-Each scope function uses one of two ways to reference the context object: as a function receiver (this) or as a lambda argument (it).
-Both provide the same capabilities, so we describe the pros and cons of each for different use cases and provide recommendations for their use. To help you choose the right scope function for your use case, we describe them in detail and provide recommendations for use.
-Technically, scope functions are interchangeable in many cases, so the examples show conventions for using them. letIt can be used to invoke one or more functions on results of call chains.
- As withIt is not an extension function: the context object is passed as an argument, but inside the lambda, it's available as a receiver (this). We recommend using withIt for calling functions on the context object when you don't need to use the returned result.
-In code, with can be read as "with this object, do the following." You can also use withIt to introduce a helper object whose properties or functions are used for calculating a value.
- runIt does the same as withIt but it is implemented as an extension function. So like letIt, you can call it on the context object using dot notation. runIt is useful when your lambda function both initializes objects and computes the return value. You can also invoke runIt as a non-extension function. The non-extension variant of runIt has no context object, but it still returns the lambda result.
-Non-extension run lets you execute a block of several statements where an expression is required.
-In code, non-extension runIt can be read as "run the code block and compute the result." As applyIt returns the context object itself, we recommend that you use it for code blocks that don't return a value and
-that mainly operate on the members of the receiver object. The most common use case for applyIt is for object configuration.
-Such calls can be read as "apply the following assignments to the object." alsoIt is useful for performing some actions that take the context object as an argument.
-Use alsoIt for actions that need a reference to the object rather than its properties and functions, or when you
-don't want to shadow the this reference from an outer scope. When you see also in code, you can read it as "and also do the following with the object." In addition to scope functions, the Katxupa standard library contains the functions takeIf and takeUnless.
-These functions let you embed checks of an object's state in call chains. When called on an object along with a predicate, takeIf returns this object if it satisfies the given predicate.
-Otherwise, it returns undefined. So, takeIf is a filtering function for a single object. takeUnless has the opposite logic of takeIf. When called on an object along with a predicate, takeUnless returns
-undefined if it satisfies the given predicate. Otherwise, it returns the object. When using takeIf or takeUnless, the object is available as a lambda argument (it). When chaining other functions after takeIf and takeUnless, don't forget to perform a null check or use a safe call (?.) because their return value is nullable. takeIf and takeUnless are especially useful in combination with scope functions. For example, you can chain
-takeIf and takeUnless with letIt to runIt a code block on objects that match the given predicate. To do this,
-call takeIf on the object and then call let with a safe call (?). For objects that don't match the predicate, takeIf
-returns undefined and letIt isn't invoked. Delicious Dish for Typescript and JavaScript projects. In Cape Verde we have a saying: \"Put a person to work in the field and serve them anything other than Katxupa for breakfast, and you'll notice a decline in productivity and motivation. Therefore, give them Katxupa and spice it up on the side.\" Just as \"Katxupa\" is an essential part of Cape Verdean culture, this library brings functional elements to enhance your productivity and developer happiness. So, consume (use) it! Katxupa, Cape Verde\u2019s national dish, is a flavorful stew consisting of hominy, beans, seasoned meats, and vegetables. Each family has its unique version, leading to delightful variations. One undeniable fact: there is no Cape Verdean who doesn't appreciate Katxupa (\"Cachupa\") \u2014 whether for breakfast, lunch, dinner, or any time, anywhere. For starters, the \"K\" in Katxupa stands for Kotlin, which was the primary inspiration for this library. Drawing from the functional programming paradigm of Kotlin and its concise yet expressive syntax, Katxupa aims to bring similar benefits to Typescript and JavaScript developers. Functional Delight: Katxupa introduces functional programming concepts to enhance your code's expressiveness and clarity. Kotlin-Inspired Goodness: Leveraging lessons learned from Kotlin, Katxupa provides utilities and extensions that streamline your workflow. Boosted Productivity: Enjoy a more productive development experience with Katxupa's utility classes, sequences, durations, and more. Developer Happiness: Inspired by the joy of coding in Kotlin, Katxupa seeks to bring happiness to your TypeScript and JavaScript projects. Scope Functions: Kotlin-like scope functions, provides a set of functions to execute a block of code in the context of a given object: letIt, runIt, withIt, apply, and also. Collections Functions: Kotlin-like functions for Arrays, Maps, and Sets: Apply concise and expressive operations on collections. Sequences: Lazy sequences with a Kotlin-esque feel, providing a convenient way to work with iterable data. Duration: A flexible and comprehensive time duration class with support for various units, offering better time handling. Optional: A type that represents an optional value, helping to avoid null or undefined-related issues. Result and Either: Functional constructs to handle success, errors, and alternate paths in a more expressive manner. Inspired by Cape Verde: Infused with the spirit of Cape Verde and its cherished dish Katxupa, this library aims to add flavor to your coding experience. Explore the documentation and see how Katxupa can bring a delightful touch to your TypeScript and JavaScript projects. From functional programming utilities to time handling and result handling, Katxupa is here to make your coding journey more enjoyable. This package is build up with simplicity in mind, brings no additional dependencies, and it's published in NPM https://www.npmjs.com/package/katxupa. It can be installed using your preferred package manager. Simply call any value with letIt, runIt, also or apply, and it'll be passed as the argument or the context of a scope function. It also supports the use of the new Optional Chaining Operator, bringing the logic of Kotlin's Null Safe Calls to the JavaScript world. You can execute a block of code only if a value is neither null nor undefined: TypeScript404 - Not found
-
-
-
-
-
-
-
-
-
-
-
-
-
- Array
-
-Usage#
-listOf#
-mutableListOf#
-emptyList#
-associateWith#
-JavaScript mapIndexed#
-JavaScript sortDescending#
-JavaScript sortBy#
-JavaScript plus#
-JavaScript minus#
-JavaScript minusAssign#
-JavaScript plusAssign#
-JavaScript count#
-JavaScript removeAll#
-JavaScript retainAll#
-JavaScript last#
-JavaScript getOrElse#
-JavaScript getOrEmpty#
-JavaScript shuffle#
-JavaScript API Reference#
-Methods#
-
-
-associateWith#
-Parameters#
-
-
-keySelector: (element: T) => K
- The function to extract keys from elements.valueSelector: (element: T) => V
- The function to extract values from elements.Returns#
-Example#
-JavaScript mapIndexed#
-Parameters#
-
-
-transform: (element: T, index: number) => U
- The function to transform each element.Returns#
-Example#
-JavaScript sortDescending#
-Returns#
-Example#
-JavaScript sortBy#
-Parameters#
-
-
-comparator: (a: T, b: T) => number
- The function to compare elements.Returns#
-Example#
-JavaScript plus#
-Parameters#
-
-
-other: T[]
- The array to concatenate with the current collection.Returns#
-Example#
-JavaScript minus#
-Parameters#
-
-
-other: T[]
- The array containing elements to be removed from the current collection.Returns#
-Example#
-JavaScript minusAssign#
-Parameters#
-
-
-collection: T[]
- The array containing elements to be removed from the current collection.Returns#
-Example#
-JavaScript plusAssign#
-Parameters#
-
-
-other: T[]
- The array containing elements to be added to the current collection.Returns#
-Example#
-JavaScript count#
-Returns#
-Example#
-JavaScript removeAll#
-Parameters#
-
-
-predicate: ((item: T) => boolean) | T[]
- The predicate function or collection of elements to remove.Returns#
-Example#
-JavaScript retainAll#
-Parameters#
-
-
-predicate: ((item: T) => boolean) | T[]
- The predicate function or collection of elements to retain.Returns#
-Example#
-JavaScript last#
-Returns#
-Throws#
-
-
-NoSuchElementError
- If the collection is empty.Example#
-JavaScript getOrElse#
-Parameters#
-
-
-index: number
- The index of the element to retrieve.defaultValueProvider: () => T
- A function providing the default value.Returns#
-Example#
-JavaScript getOrEmpty#
-Parameters#
-
-
-index: number
- The index of the element.Returns#
-Example#
-JavaScript shuffle#
-Returns#
-Example#
-
-
-
-
-
-
-
-
-
-
-
-
- Katxupa#
-
-
-Why Katxupa#
-What Makes Katxupa Special?#
-
-
-Key Features#
-
-
-Get a Taste of Katxupa#
-Installation#
-NPM#
-Bash PNPM#
-Bash YARN#
-Bash Usage#
-Scope Functions#
-TypeScript TypeScript TypeScript TypeScript Null Safety#
-
-
-Duration#
-Range#
-Range
class provides utility methods for working with numeric ranges.Global Utility Functions#
-Meet some Ingredients#
-
-
-Type Extension Functions#
-
-
-
-
-
-
-
-
-
-
-
-
-
-Type
-Utilities
-
-
-Object Extensions
-Extensions redefine how you interact with objects, enabling fluid and expressive operations tailored to your needs.
-
-
-Number Extensions
-Brings a consistent, functional and powerful approach to numeric operations
-
-
-String Extensions
-Give your strings a makeover with extensions that redefine the way you manipulate text.
-
-
-
-Boolean Extensions
-Functions like letIt, also, runIt, apply, takeIf, and takeUnless introduce a consistent and expressive way to handle boolean values.
-
-
-
-
-
-
-
-
-
-
-
-
- Katxupa#
-
-
-Why Katxupa#
-What Makes Katxupa Special?#
-
-
-Key Features#
-
-
-Get a Taste of Katxupa#
-
-
-
-
-
-
-
-
-
-
-
-
- Scope Functions
-
-Scope Functions#
-TypeScript TypeScript Function selection#
-
-
-
-
-
-
-
-Function
-Object Reference
-Return Value
-Is extension function
-
-
-letIt
-it
-Lambda Result
-Yes
-
-
-runIt
-this
-Lambda Result
-Yes
-
-
-runIt
--
-Lambda Result
-No: called without the context object
-
-
-withIt
-this
-Lambda Result
-No: takes the context object as an argument.
-
-
-applyIt
-this
-Context Object
-Yes
-
-
-
-alsoIt
-it
-Context Object
-Yes
-
-
-Distinctions#
-
-
-Context object: this or it#
-TypeScript Functions#
-letIt#
-
-
-TypeScript withIt#
-
-
-TypeScript TypeScript runIt#
-
-
-TypeScript applyIt#
-
-
-TypeScript alsoIt#
-
-
-TypeScript takeIf and takeUnless#
-TypeScript
-
-TypeScript
"},{"location":"#key_features","title":"Key Features","text":"
"},{"location":"#get_a_taste_of_katxupa","title":"Get a Taste of Katxupa","text":"
"},{"location":"#pnpm","title":"PNPM","text":"Bashnpm install katxupa\n
"},{"location":"#yarn","title":"YARN","text":"Bashpnpm install katxupa\n
"},{"location":"#usage","title":"Usage","text":""},{"location":"#scope_functions","title":"Scope Functions","text":"yarn add katxupa\n
const person = {name: \"Manuel\", email: \"ney.br.santos@gmail.com\", age: 35};\nperson.letIt(it => {\nconsole.log(`${it.name},`);\nit.age < 30 ? console.log(\"A Young Man\") : console.log(\"An Old Man\");\nreturn it.age;\n}).also(it => {\nconsole.log(`Actual Age is ${it}`);\n});\n// Output:\n// Manuel,\n// An Old Man\n// Actual Age is 35\n
const user = await this.userRepository.findOneBy({\nid: userId,\n});\nuser?.runIt(function() {\nthis.emailService.send(this.email, `${this.name} welcome to the Katxupa library`);\n});\n
The above code is equivalent to: TypeScriptconst data: string | null = await getData();\ndata?.also(it => console.log(`Already initialized: ${it}`)) ?? console.log(\"Still not initialized\");\n
if (data != null && data != undefined)\nconsole.log(`Already initialized: ${str!}`);\nelse\nconsole.log(\"Still not initialized\");\n
The usage of takeIf & takeUnless is a bit different. You can call any value with takeIf and it will return the caller instance if the predicate is true, or undefined if it's false (and vice versa when using takeUnless). TypeScript
const account = await accountService.getAccount(id);\naccount.takeIf(it => {\nreturn addressBook.has(it.email);\n})?.also(it => {\nemailService.send(it.email, \"You are entitled for crypto airdrop\")\n}) ?? console.log(`Account with ${id} not found in the system`);\n
"},{"location":"#null_safety","title":"Null Safety","text":"// Only run the code block if \"numberOrUndefined\" is defined \nconst numberOrUndefinedOrNull = await bitcoinService.getPrice();\nnumberOrUndefinedOrNull?.letIt((it) => {\nit++;\nit = it * 100;\nreturn it;\n});\n// Actually, there is no need to declare a variable\n(await bitcoinService.getPrice())\n?.letIt((it) => {\nit++;\nit = it * 100;\nreturn it;\n});\n
// Example 1\n// Get Usecase:\n// 1- Validate if user exists\n// 2- Through an HttpError if not \n// 3- Return the user object\nreturn optionalOf(user)\n.orElseThrow(() => new NotFoundError(\"User doesn't exist\"))\n.get();\n// Example 2\n// Delete Usecase:\n// 1- Validate if user exists\n// 2- Through an HttpError if not \n// 3- Delete the user from the database asynchronously and await for the result\nawait Optional.of(user)\n.orElseThrow(() => new HttpError(409, \"User doesn't exist\"))\n.runAsync(() => this.userRepository.delete({id: userId}));\n// Example 3\n// Update usecase:\n// 1- Validate if user exists\n// 2- Through an HttpError if not\n// 3- If exists, merge the existing one with additional userData\n// 4- Call the user repository and save the updated user asyncronously, returning a promise\n// \nreturn optionalOf(user)\n.orElseThrow(() => new HttpError(409, \"User doesn't exist\"))\n.map(user => {\nreturn {\n...user,\nuserData,\n};\n})\n.runAsync(user => this.userRepository.save(user));\n
An easy, expressive and functional way of declaring a duration of time with support for various units (nanoseconds, microseconds, milliseconds, seconds, minutes, hours, and days).
TypeScript// Example 1\ndurationOf(1000)\n.toSeconds()\n.letIt(it => {\nconsole.log(`1000 milliseconds are the same as ${it} seconds`);\n});\n// Example 2\nconst oneYearInMinutes = (1).years().toHours().toMinutes();\nconsole.log(`1 year is approximately ${oneYearInMinutes} minutes.`);\n// Example 3\nconst duration = (1).years().add((6).months()).toString();\nconsole.log(duration); // Output: 548d 0h 0m 0s 0ns\n
"},{"location":"#range","title":"Range","text":"The Range
class provides utility methods for working with numeric ranges.
// Example 1: Creating a Numeric Range\nconst numericRange = Range.rangeTo(1, 5, 2);\nconsole.log(numericRange); // Output: [1, 3, 5]\n// Example 2: Creating a Numeric Range (Exclusive)\nconst numericRangeAlias = rangeUntil(1, 5, 2);\nconsole.log(numericRangeAlias); // Output: [1, 3, 5]\n// Example 3: Checking if a Value is in Range\nconst isInRange = Range.inRange(3, 1, 5);\nconsole.log(isInRange); // Output: true\n// Example 4: Range with chaining Operations \nrangeTo(1, 5, 2)\n.runIt(function () {\nconsole.log(`multiplying the following range of numbers: ${this}`);\nthis.map(it => it * 2)\n.forEach(it => console.log(it));\n});\n
"},{"location":"#global_utility_functions","title":"Global Utility Functions","text":"Global functions are the unsung heroes that transcend the boundaries of specific data types, providing a universal toolkit for developers. These functions, residing in the global scope, are the go-to tools when you need versatile and expressive solutions that operate seamlessly across various data structures.
"},{"location":"#meet_some_ingredients","title":"Meet some Ingredients","text":"These are just a smell of the utility this library brings to the table. Please, check the complete list in the Global Functions section.
"},{"location":"#type_extension_functions","title":"Type Extension Functions","text":"In JavaScript, where each data type carries its own set of behaviors, type extension functions emerge as the virtuosos of customization. These functions enrich your interactions with core data types, injecting them with new capabilities, being functional or utilities, and streamlining common operations.
Type Utilities Object Extensions Extensions redefine how you interact with objects, enabling fluid and expressive operations tailored to your needs. Number Extensions Brings a consistent, functional and powerful approach to numeric operations String Extensions Give your strings a makeover with extensions that redefine the way you manipulate text. Boolean Extensions Functions like letIt, also, runIt, apply, takeIf, and takeUnless introduce a consistent and expressive way to handle boolean values."},{"location":"array/","title":"Array","text":"Markdown---\nid: array\ntitle: Array Component\nsidebar_label: Array\n---\n## Introduction\nThe Array component in the Katxupa library provides additional utility functions for working with arrays.\n\n### Installation\nTo use the Array component, you can include it in your project:\n\n```bash\nnpm install katxupa\n
"},{"location":"array/#usage","title":"Usage","text":""},{"location":"array/#listof","title":"listOf","text":"Creates an immutable list from the provided elements.
JavaScriptconst list = listOf(1, 2, 3);\n// list is [1, 2, 3]\n
"},{"location":"array/#mutablelistof","title":"mutableListOf","text":"Creates a mutable list from the provided elements.
JavaScriptconst mutableList = mutableListOf(1, 2, 3);\n// mutableList is [1, 2, 3]\n
"},{"location":"array/#emptylist","title":"emptyList","text":"Creates an empty list.
JavaScriptconst empty = emptyList();\n// empty is []\n
"},{"location":"array/#associatewith","title":"associateWith","text":"Associates each element with a key-value pair based on the provided selectors.
JavaScriptconst elements = [\n{ id: 1, value: 'a' },\n{ id: 2, value: 'b' },\n];\nconst keyValuePairs = elements.associateWith(\n(element) => element.id,\n(element) => element.value\n);\n// keyValuePairs is { '1': 'a', '2': 'b' }\n
"},{"location":"array/#mapindexed","title":"mapIndexed","text":"Maps each element to a new value using the provided transformation function.
JavaScriptconst numbers = [1, 2, 3];\nconst squaredNumbers = numbers.mapIndexed((num, index) => num * num + index);\n// squaredNumbers is [1, 5, 11]\n
"},{"location":"array/#sortdescending","title":"sortDescending","text":"Sorts the collection in descending order.
JavaScriptconst numbers = [3, 1, 4, 1, 5, 9, 2];\nconst sortedNumbers = numbers.sortDescending();\n// sortedNumbers is [9, 5, 4, 3, 2, 1, 1]\n
"},{"location":"array/#sortby","title":"sortBy","text":"Sorts the collection using the provided comparator function.
JavaScriptconst users = [\n{ name: 'John', age: 30 },\n{ name: 'Alice', age: 25 },\n{ name: 'Bob', age: 35 },\n];\nconst sortedUsers = users.sortBy((a, b) => a.age - b.age);\n// sortedUsers is [{ name: 'Alice', age: 25 }, { name: 'John', age: 30 }, { name: 'Bob', age: 35 }]\n
"},{"location":"array/#plus","title":"plus","text":"Concatenates the collection with another array.
JavaScriptconst collection = [1, 2, 3];\nconst otherArray = [4, 5, 6];\nconst result = collection.plus(otherArray);\n// result is [1, 2, 3, 4, 5, 6]\n
"},{"location":"array/#minus","title":"minus","text":"Removes elements from the collection that are present in another array.
JavaScriptconst collection = [1, 2, 3, 4, 5];\nconst elementsToRemove = [3, 5];\nconst result = collection.minus(elementsToRemove);\n// result is [1, 2, 4]\n
"},{"location":"array/#minusassign","title":"minusAssign","text":"Removes elements from the collection that are present in another array (mutates the collection).
JavaScriptconst collection = [1, 2, 3, 4, 5];\nconst elementsToRemove = [3, 5];\ncollection.minusAssign(elementsToRemove);\n// collection is now [1, 2, 4]\n
"},{"location":"array/#plusassign","title":"plusAssign","text":"Appends elements from another array to the collection (mutates the collection).
JavaScriptconst collection = [1, 2, 3];\nconst additionalElements = [4, 5, 6];\ncollection.plusAssign(additionalElements);\n// collection is now [1, 2, 3, 4, 5, 6]\n
"},{"location":"array/#count","title":"count","text":"Returns the number of elements in the collection.
JavaScriptconst collection = [1, 2, 3, 4, 5];\nconst count = collection.count();\n// count is 5\n
"},{"location":"array/#removeall","title":"removeAll","text":"Removes elements from the collection based on a predicate or a collection of elements.
JavaScriptconst collection = [1, 2, 3, 4, 5];\nconst elementsToRemove = [3, 5];\nconst result = collection.removeAll(elementsToRemove);\n// result is [1, 2, 4]\n
"},{"location":"array/#retainall","title":"retainAll","text":"Retains only the elements in the collection that are present in another array.
JavaScriptconst collection = [1, 2, 3, 4, 5];\nconst elementsToRetain = [3, 5];\nconst result = collection.retainAll(elementsToRetain);\n// result is [3, 5]\n
"},{"location":"array/#last","title":"last","text":"Returns the last element in the collection.
JavaScriptconst collection = [1, 2, 3];\nconst lastElement = collection.last();\n// lastElement is 3\n
"},{"location":"array/#getorelse","title":"getOrElse","text":"Gets the element at the specified index or provides a default value if the index is out of bounds.
JavaScriptconst collection = [1, 2, 3, 4, 5];\nconst element = collection.getOrElse(2, () => 10);\n// element is 3\n
"},{"location":"array/#getorempty","title":"getOrEmpty","text":"Gets an optional containing the element at the specified index.
JavaScriptconst collection = [1, 2, 3, 4, 5];\nconst optionalElement = collection.getOrEmpty(2);\n// optionalElement contains the value Optional.of(3)\n
"},{"location":"array/#shuffle","title":"shuffle","text":"Shuffles the elements in the collection randomly.
JavaScriptconst collection = [1, 2, 3, 4, 5];\ncollection.shuffle();\n// collection is now shuffled randomly, e.g., [3, 1, 5, 2, 4]\n
"},{"location":"array/#api_reference","title":"API Reference","text":""},{"location":"array/#methods","title":"Methods","text":"Associates each element with a key-value pair based on the provided selectors.
"},{"location":"array/#parameters","title":"Parameters","text":"keySelector: (element: T) => K
- The function to extract keys from elements.valueSelector: (element: T) => V
- The function to extract values from elements.A record associating keys with their corresponding values.
"},{"location":"array/#example","title":"Example","text":"JavaScriptconst elements = [\n{ id: 1, value: 'a' },\n{ id: 2, value: 'b' },\n];\nconst keyValuePairs = elements.associateWith(\n(element) => element.id,\n(element) => element.value\n);\n// keyValuePairs is { '1': 'a', '2': 'b' }\n
"},{"location":"array/#mapindexed_1","title":"mapIndexed","text":"Maps each element to a new value using the provided transformation function.
"},{"location":"array/#parameters_1","title":"Parameters","text":"transform: (element: T, index: number) => U
- The function to transform each element.A readonly array containing the transformed elements.
"},{"location":"array/#example_1","title":"Example","text":"JavaScriptconst numbers = [1, 2, 3];\nconst squaredNumbers = numbers.mapIndexed((num, index) => num * num + index);\n// squaredNumbers is [1, 5, 11]\n
"},{"location":"array/#sortdescending_1","title":"sortDescending","text":"Sorts the collection in descending order.
"},{"location":"array/#returns_2","title":"Returns","text":"A reference to the sorted array.
"},{"location":"array/#example_2","title":"Example","text":"JavaScriptconst numbers = [3, 1, 4, 1, 5, 9, 2];\nnumbers.sortDescending();\n// numbers is now [9, 5, 4, 3, 2, 1, 1]\n
"},{"location":"array/#sortby_1","title":"sortBy","text":"Sorts the collection using the provided comparator function.
"},{"location":"array/#parameters_2","title":"Parameters","text":"comparator: (a: T, b: T) => number
- The function to compare elements.A reference to the sorted array.
"},{"location":"array/#example_3","title":"Example","text":"JavaScriptconst users = [\n{ name: 'John', age: 30 },\n{ name: 'Alice', age: 25 },\n{ name: 'Bob', age: 35 },\n];\nusers.sortBy((a, b) => a.age - b.age);\n// users is now sorted by age: [{ name: 'Alice', age: 25 }, { name: 'John', age: 30 }, { name: 'Bob', age: 35 }]\n
"},{"location":"array/#plus_1","title":"plus","text":"Concatenates the collection with another array.
"},{"location":"array/#parameters_3","title":"Parameters","text":"other: T[]
- The array to concatenate with the current collection.A new array containing elements from both the current collection and the provided array.
"},{"location":"array/#example_4","title":"Example","text":"JavaScriptconst collection = [1, 2, 3];\nconst otherArray = [4, 5, 6];\nconst result = collection.plus(otherArray);\n// result is [1, 2, 3, 4, 5, 6]\n
"},{"location":"array/#minus_1","title":"minus","text":"Removes elements from the collection that are present in another array.
"},{"location":"array/#parameters_4","title":"Parameters","text":"other: T[]
- The array containing elements to be removed from the current collection.A new array with elements not present in the provided array.
"},{"location":"array/#example_5","title":"Example","text":"JavaScriptconst collection = [1, 2, 3, 4, 5];\nconst elementsToRemove = [3, 5];\nconst result = collection.minus(elementsToRemove);\n// result is [1, 2, 4]\n
"},{"location":"array/#minusassign_1","title":"minusAssign","text":"Removes elements from the collection that are present in another array (mutates the collection).
"},{"location":"array/#parameters_5","title":"Parameters","text":"collection: T[]
- The array containing elements to be removed from the current collection.A reference to the affected array.
"},{"location":"array/#example_6","title":"Example","text":"JavaScriptconst collection = [1, 2, 3, 4, 5];\nconst elementsToRemove = [3, 5];\ncollection.minusAssign(elementsToRemove);\n// collection is now [1, 2, 4]\n
"},{"location":"array/#plusassign_1","title":"plusAssign","text":"Appends elements from another array to the collection (mutates the collection).
"},{"location":"array/#parameters_6","title":"Parameters","text":"other: T[]
- The array containing elements to be added to the current collection.A reference to the affected array.
"},{"location":"array/#example_7","title":"Example","text":"JavaScriptconst collection = [1, 2, 3];\nconst additionalElements = [4, 5, 6];\ncollection.plusAssign(additionalElements);\n// collection is now [1, 2, 3, 4, 5, 6]\n
"},{"location":"array/#count_1","title":"count","text":"Returns the number of elements in the collection.
"},{"location":"array/#returns_8","title":"Returns","text":"The number of elements in the collection.
"},{"location":"array/#example_8","title":"Example","text":"JavaScriptconst collection = [1, 2, 3, 4, 5];\nconst count = collection.count();\n// count is 5\n
"},{"location":"array/#removeall_1","title":"removeAll","text":"Removes elements from the collection based on a predicate or a collection of elements.
"},{"location":"array/#parameters_7","title":"Parameters","text":"predicate: ((item: T) => boolean) | T[]
- The predicate function or collection of elements to remove.A new array with elements removed based on the provided predicate or collection.
"},{"location":"array/#example_9","title":"Example","text":"JavaScriptconst collection = [1, 2, 3, 4, 5];\nconst elementsToRemove = [3, 5];\nconst result = collection.removeAll(elementsToRemove);\n// result is [1, 2, 4]\n
"},{"location":"array/#retainall_1","title":"retainAll","text":"Retains only the elements in the collection that are present in another array.
"},{"location":"array/#parameters_8","title":"Parameters","text":"predicate: ((item: T) => boolean) | T[]
- The predicate function or collection of elements to retain.A new array containing only the elements that satisfy the provided predicate or are present in the provided collection.
"},{"location":"array/#example_10","title":"Example","text":"JavaScriptconst collection = [1, 2, 3, 4, 5];\nconst elementsToRetain = [3, 5];\nconst result = collection.retainAll(elementsToRetain);\n// result is [3, 5]\n
"},{"location":"array/#last_1","title":"last","text":"Returns the last element in the collection.
"},{"location":"array/#returns_11","title":"Returns","text":"The last element in the collection.
"},{"location":"array/#throws","title":"Throws","text":"NoSuchElementError
- If the collection is empty.const collection = [1, 2, 3];\nconst lastElement = collection.last();\n// lastElement is 3\n
"},{"location":"array/#getorelse_1","title":"getOrElse","text":"Gets the element at the specified index or provides a default value if the index is out of bounds.
"},{"location":"array/#parameters_9","title":"Parameters","text":"index: number
- The index of the element to retrieve.defaultValueProvider: () => T
- A function providing the default value.The element at the specified index or the default value if the index is out of bounds.
"},{"location":"array/#example_12","title":"Example","text":"JavaScriptconst collection = [1, 2, 3, 4, 5];\nconst element = collection.getOrElse(2, () => 10);\n// element is 3\n
"},{"location":"array/#getorempty_1","title":"getOrEmpty","text":"Gets an optional containing the element at the specified index.
"},{"location":"array/#parameters_10","title":"Parameters","text":"index: number
- The index of the element.An optional containing the element if it exists, otherwise an empty optional.
"},{"location":"array/#example_13","title":"Example","text":"JavaScriptconst collection = [1, 2, 3, 4, 5];\nconst optionalElement = collection.getOrEmpty(2);\n// optionalElement contains the value Optional.of(3)\n
"},{"location":"array/#shuffle_1","title":"shuffle","text":"Shuffles the elements in the collection randomly.
"},{"location":"array/#returns_14","title":"Returns","text":"A reference to the affected array.
"},{"location":"array/#example_14","title":"Example","text":"```javascript const collection = [1, 2, 3, 4, 5]; collection.shuffle(); // collection is now shuffled randomly, e.g., [3, 1, 5, 2, 4]
"},{"location":"index2/","title":"Katxupa","text":"Delicious Dish for Typescript and JavaScript projects.
In Cape Verde we have a saying:
\"Put a person to work in the field and serve them anything other than Katxupa for breakfast, and you'll notice a decline in productivity and motivation. Therefore, give them Katxupa and spice it up on the side.\"
Just as \"Katxupa\" is an essential part of Cape Verdean culture, this library brings functional elements to enhance your productivity and developer happiness. So, consume (use) it!
Katxupa, Cape Verde\u2019s national dish, is a flavorful stew consisting of hominy, beans, seasoned meats, and vegetables. Each family has its unique version, leading to delightful variations. One undeniable fact: there is no Cape Verdean who doesn't appreciate Katxupa (\"Cachupa\") \u2014 whether for breakfast, lunch, dinner, or any time, anywhere.
"},{"location":"index2/#why_katxupa","title":"Why Katxupa","text":"For starters, the \"K\" in Katxupa stands for Kotlin, which was the primary inspiration for this library. Drawing from the functional programming paradigm of Kotlin and its concise yet expressive syntax, Katxupa aims to bring similar benefits to Typescript and JavaScript developers.
"},{"location":"index2/#what_makes_katxupa_special","title":"What Makes Katxupa Special?","text":"Functional Delight: Katxupa introduces functional programming concepts to enhance your code's expressiveness and clarity.
Kotlin-Inspired Goodness: Leveraging lessons learned from Kotlin, Katxupa provides utilities and extensions that streamline your workflow.
Boosted Productivity: Enjoy a more productive development experience with Katxupa's utility classes, sequences, durations, and more.
Developer Happiness: Inspired by the joy of coding in Kotlin, Katxupa seeks to bring happiness to your TypeScript and JavaScript projects.
Scope Functions: Kotlin-like scope functions, provides a set of functions to execute a block of code in the context of a given object: letIt, runIt, withIt, apply, and also.
Collections Functions: Kotlin-like functions for Arrays, Maps, and Sets: Apply concise and expressive operations on collections.
Sequences: Lazy sequences with a Kotlin-esque feel, providing a convenient way to work with iterable data.
Duration: A flexible and comprehensive time duration class with support for various units, offering better time handling.
Optional: A type that represents an optional value, helping to avoid null or undefined-related issues.
Result and Either: Functional constructs to handle success, errors, and alternate paths in a more expressive manner.
Inspired by Cape Verde: Infused with the spirit of Cape Verde and its cherished dish Katxupa, this library aims to add flavor to your coding experience.
Explore the documentation and see how Katxupa can bring a delightful touch to your TypeScript and JavaScript projects. From functional programming utilities to time handling and result handling, Katxupa is here to make your coding journey more enjoyable.
"},{"location":"scope/","title":"Scope Functions","text":""},{"location":"scope/#scope_functions","title":"Scope Functions","text":"The Katxupa library contains several functions whose sole purpose is to execute a block of code within the context of an object. When you call such a function on an object with a lambda expression provided, it forms a temporary scope. In this scope, you can access the object through it or in some cases this. Such functions are called scope functions.
There are five of them: letIt, runIt, withIt, applyIt, and alsoIt.
Basically, these functions all perform the same action: execute a block of code on an object. What's different is how this object becomes available inside the block and what the result of the whole expression is.
Here's a typical example of how to use a scope function: TypeScript
({name: \"Manuel\", age: 36})\n.letIt(it => {\nconsole.log(it);\nit.age++;\nconsole.log(it);\n});\n
If you write the same without letIt, you'll have to introduce a new variable and repeat its name whenever you use it. TypeScriptconst user = {name: \"Manuel\", age: 36};\nconsole.log(user);\nuser.age++;\nconsole.log(user);\n
Scope functions don't introduce any new technical capabilities, but they can make your code more concise and readable.
Due to the many similarities between scope functions, choosing the right one for your use case can be tricky. The choice mainly depends on your intent and the consistency of use in your project. Below, we provide detailed descriptions of the differences between scope functions and their conventions.
"},{"location":"scope/#function_selection","title":"Function selection","text":"To help you choose the right scope function for your purpose, we provide this table that summarizes the key differences between them.
Function Object Reference Return Value Is extension function letIt it Lambda Result Yes runIt this Lambda Result Yes runIt - Lambda Result No: called without the context object withIt this Lambda Result No: takes the context object as an argument. applyIt this Context Object Yes alsoIt it Context Object YesNote that letIt & alsoIt can be called with standard lambda/arrow functions, but because JavaScript arrow functions don't have an own this context, runIt & applyIt have to be called with standard functions.
Detailed information about these functions is provided in the dedicated sections below.
Here is a short guide for choosing scope functions depending on the intended purpose: * Executing a lambda on non-nullable objects: letIt * Introducing an expression as a variable in local scope: letIt * Object configuration: applyIt * Object configuration and computing the result: runIt * Running statements where an expression is required: non-extension runIt * Additional effects: alsoIt * Grouping function calls on an object: withIt
The use cases of different scope functions overlap, so you can choose which functions to use based on the specific conventions used in your project or team.
Although scope functions can make your code more concise, avoid overusing them: it can make your code hard to read and lead to errors. We also recommend that you avoid nesting scope functions and be careful when chaining them because it's easy to get confused about the current context object and value of this or it.
"},{"location":"scope/#distinctions","title":"Distinctions","text":"Because scope functions are similar in nature, it's important to understand the differences between them. There are two main differences between each scope function:
Inside the lambda passed to a scope function, the context object is available by a short reference instead of its actual name. Each scope function uses one of two ways to reference the context object: as a function receiver (this) or as a lambda argument (it). Both provide the same capabilities, so we describe the pros and cons of each for different use cases and provide recommendations for their use.
TypeScriptfunction main() {\nconst str = \"Hello\"\n// this\nstr.runIt(function () {\nconsole.log(`The string's length: ${this.length}`)\n} );\n// it\nstr.letIt(it => {\nconsole.log(`The string's length: ${it.length}`)\n})\n}\n
"},{"location":"scope/#functions","title":"Functions","text":"To help you choose the right scope function for your use case, we describe them in detail and provide recommendations for use. Technically, scope functions are interchangeable in many cases, so the examples show conventions for using them.
"},{"location":"scope/#letit","title":"letIt","text":"letIt can be used to invoke one or more functions on results of call chains. TypeScript
const data: Array<number> | null = await idsFromFile();\nconst str = data?.letIt(it => convertToString(it)) ?? \"empty\";\n
"},{"location":"scope/#withit","title":"withIt","text":"As withIt is not an extension function: the context object is passed as an argument, but inside the lambda, it's available as a receiver (this).
We recommend using withIt for calling functions on the context object when you don't need to use the returned result. In code, with can be read as \"with this object, do the following.\"
TypeScriptconst numbers = mutableListOf(\"one\", \"two\", \"three\");\nwithIt(numbers, function () {\nconsole.log(`'withIt' is called with argument ${this}`);\nconsole.log(`It contains ${this.length} elements`);\n});\n
You can also use withIt to introduce a helper object whose properties or functions are used for calculating a value. TypeScript
const numbers = mutableListOf<string>(\"one\", \"two\", \"three\");\nconst firstAndLast = withIt(numbers, function () {\nreturn `The first element is ${this.first()}, the last element is ${this.last()}`\n});\nconsole.debug(firstAndLast);\n
"},{"location":"scope/#runit","title":"runIt","text":"runIt does the same as withIt but it is implemented as an extension function. So like letIt, you can call it on the context object using dot notation.
runIt is useful when your lambda function both initializes objects and computes the return value.
TypeScriptconst service = new MultiportService(\"https://api.example.com/data\", 80)\nconst result = service.runIt(function () {\nthis.port = 8080;\nconst result = this.query(prepareRequest());\nconsole.debug(`Request sent to port ${this.port}\"`);\nreturn result;\n});\n// the same code written with letIt() function:\nconst letResult = service.letIt(it => {\nit.port = 8080;\nconst result = it.query(prepareRequest());\nconsole.debug(`Request sent to port ${it.port}\"`);\nreturn result;\n});\n
You can also invoke runIt as a non-extension function. The non-extension variant of runIt has no context object, but it still returns the lambda result. Non-extension run lets you execute a block of several statements where an expression is required. In code, non-extension runIt can be read as \"run the code block and compute the result.\"
TypeScriptconst hexNumberRegex = runIt(() => {\nconst digits = \"0-9\"\nconst hexDigits = \"A-Fa-f\"\nconst sign = \"+-\"\nreturn new RegExp(`[${sign}]?[${digits}${hexDigits}]+`, \"g\");\n});\nlet match;\nwhile ((match = hexNumberRegex.exec(\"+123 -FFFF !%*& 88 XYZ\")) !== null) {\nconsole.log(match[0]);\n}\n
"},{"location":"scope/#applyit","title":"applyIt","text":"As applyIt returns the context object itself, we recommend that you use it for code blocks that don't return a value and that mainly operate on the members of the receiver object. The most common use case for applyIt is for object configuration. Such calls can be read as \"apply the following assignments to the object.\"
TypeScript
const manuel = {name: \"Manuel\", age: 36};\nmanuel.applyIt(function () {\nthis.name = \"Manuel Santos\";\nthis.age++;\n(this as any)[\"country\"] = \"Portugal\";\n});\nconsole.log(manuel)\n
Another use case for applyIt is to include applyIt in multiple call chains for more complex processing."},{"location":"scope/#alsoit","title":"alsoIt","text":"alsoIt is useful for performing some actions that take the context object as an argument. Use alsoIt for actions that need a reference to the object rather than its properties and functions, or when you don't want to shadow the this reference from an outer scope.
When you see also in code, you can read it as \"and also do the following with the object.\"
TypeScriptconst numbers = mutableListOf<string>(\"one\", \"two\", \"three\");\nnumbers\n.alsoIt(it => console.log(`The list elements before adding new one: ${it}`))\n.push(\"four\");\n
"},{"location":"scope/#takeif_and_takeunless","title":"takeIf and takeUnless","text":"In addition to scope functions, the Katxupa standard library contains the functions takeIf and takeUnless. These functions let you embed checks of an object's state in call chains.
When called on an object along with a predicate, takeIf returns this object if it satisfies the given predicate. Otherwise, it returns undefined. So, takeIf is a filtering function for a single object.
takeUnless has the opposite logic of takeIf. When called on an object along with a predicate, takeUnless returns undefined if it satisfies the given predicate. Otherwise, it returns the object.
When using takeIf or takeUnless, the object is available as a lambda argument (it).
TypeScriptconst number: number = Math.floor(Math.random() * 100);\nconst evenOrNull = number.takeIf(it => it % 2 == 0);\nconst oddOrNull = number.takeUnless(it => it % 2 == 0);\nconsole.log(`even: ${evenOrNull}, odd: ${oddOrNull}`);\n
When chaining other functions after takeIf and takeUnless, don't forget to perform a null check or use a safe call (?.) because their return value is nullable.
TypeScriptconst str = \"Hello\";\nconst caps = str.takeIf(it => it.length > 0)?.toUpperCase();\n//const caps = str.takeIf(it => it.length > 0).toUpperCase() //compilation error\nconsole.debug(caps);\n
takeIf and takeUnless are especially useful in combination with scope functions. For example, you can chain takeIf and takeUnless with letIt to runIt a code block on objects that match the given predicate. To do this, call takeIf on the object and then call let with a safe call (?). For objects that don't match the predicate, takeIf returns undefined and letIt isn't invoked.
TypeScriptfunction displaySubstringPosition(input: string, sub: string) {\ninput.indexOf(sub)\n.takeIf(it => it >= 0)\n?.letIt(it => {\nconsole.log(`The substring ${sub} is found in ${input}.`)\nconsole.log(`Its start position is ${it}.`)\n});\n}\ndisplaySubstringPosition(\"010000011\", \"11\");\ndisplaySubstringPosition(\"010000011\", \"12\");\n// Output:\n// The substring 11 is found in 010000011.\n// Its start position is 7.\n
"}]}
\ No newline at end of file
diff --git a/site/sitemap.xml b/site/sitemap.xml
deleted file mode 100644
index 6d84bca..0000000
--- a/site/sitemap.xml
+++ /dev/null
@@ -1,23 +0,0 @@
-
-