@dami_deleon/rikudo 1.0.1-alpha.2 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +0 -6
- package/dist/utils/either.js +38 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -15,12 +15,6 @@ Inspirado en el Sabio de los Seis Caminos, Rikudo utiliza seis módulos especial
|
|
|
15
15
|
5. **Camino Naraka (Cache):** Memoria persistente basada en hashes de Git para optimizar tokens.
|
|
16
16
|
6. **Camino Asura (Rate Limiter):** Gestión de poder para respetar los límites de las APIs.
|
|
17
17
|
|
|
18
|
-
¡Claro que sí! Aquí tienes una versión profesional, estructurada y atractiva para tu `README.md`.
|
|
19
|
-
|
|
20
|
-
He destacado las características clave que mencionaste (Multi-AI, Templates y Diagnóstico) y he añadido secciones útiles como instalación y configuración.
|
|
21
|
-
|
|
22
|
-
Copia y pega el siguiente contenido en tu archivo `README.md`:
|
|
23
|
-
|
|
24
18
|
|
|
25
19
|
## ✨ Características Principales
|
|
26
20
|
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
export const Either = {
|
|
2
|
+
right: (value) => createEither(undefined, value),
|
|
3
|
+
left: (value) => createEither(value, undefined),
|
|
4
|
+
};
|
|
5
|
+
function createEither(l, r) {
|
|
6
|
+
return {
|
|
7
|
+
left: l,
|
|
8
|
+
right: r,
|
|
9
|
+
// --- Métodos anteriores ---
|
|
10
|
+
getOrElse: (defaultValue) => r ?? defaultValue,
|
|
11
|
+
getOrNull: () => r ?? null,
|
|
12
|
+
getOrThrow: (error) => {
|
|
13
|
+
if (r === undefined)
|
|
14
|
+
throw new Error(error, { cause: l });
|
|
15
|
+
return r;
|
|
16
|
+
},
|
|
17
|
+
// --- Nuevos métodos funcionales ---
|
|
18
|
+
/**
|
|
19
|
+
* Transforma el valor si es 'Right'. Si es 'Left', no hace nada.
|
|
20
|
+
*/
|
|
21
|
+
map(fn) {
|
|
22
|
+
if (r !== undefined) {
|
|
23
|
+
return Either.right(fn(r));
|
|
24
|
+
}
|
|
25
|
+
return Either.left(l);
|
|
26
|
+
},
|
|
27
|
+
/**
|
|
28
|
+
* Transforma el valor devolviendo un nuevo Either.
|
|
29
|
+
* Ideal para encadenar operaciones que también pueden fallar.
|
|
30
|
+
*/
|
|
31
|
+
flatMap(fn) {
|
|
32
|
+
if (r !== undefined) {
|
|
33
|
+
return fn(r);
|
|
34
|
+
}
|
|
35
|
+
return Either.left(l);
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
}
|