Changelog
All notable changes to this project will be documented in this file.
The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.
1.2.0 - 2025-12-08
Added
-
taphelper function: Executes side-effects in functional pipelines without altering data flow.- Generic utility that works with any type (monads, primitives, objects, arrays).
- Useful for debugging, logging, metrics, and error tracking.
- Example:
1 2 3 4 5
pipe( just(42), tap(x => console.log('Value:', x)), map(x => x * 2) );
-
inspecthelper function: Logs values with optional labels for debugging.- Specialized version of
tapthat automatically usesconsole.log. - Convenient for quick debugging with optional label prefixes.
- Example:
1 2 3 4 5 6
pipe( just(42), inspect('After init'), // Logs: "After init: Just(42)" map(x => x * 2), inspect('Final result') );
- Specialized version of
-
allcombinator forMaybe,Result, andEither: Combines an array of monads into a single monad containing an array of values.Maybe: ReturnsJustwith all values if all areJust, orNothingif any isNothing.Result/Either: Collects all errors if any fail.- Heterogeneous tuple support: Preserves different types in arrays using advanced TypeScript type inference.
- Example:
1 2 3
all([just(1), just(2), just(3)]).unwrapOr([]); // [1, 2, 3] all([ok(1), err('e1'), err('e2')]); // Err(['e1', 'e2']) all([just(42), just("hello"), just(true)]); // Just<[number, string, boolean]>
-
sequencecombinator forResultandEither: Combines an array of monads with fail-fast behavior.- Stops at the first error instead of collecting all errors.
- Returns single error type instead of array.
- Heterogeneous tuple support: Preserves different types in arrays.
- Example:
1sequence([ok(1), err('e1'), err('e2')]); // Err('e1') - stops at first!
-
partitionfunction forResultandEither: Separates an array of monads into successes and failures.- Returns a plain object with two arrays (not a monad).
- Always processes all items.
- Heterogeneous tuple support: Preserves different types in returned arrays.
- Example:
1 2
partition([ok(1), err('e1'), ok(2), err('e2')]); // { oks: [1, 2], errs: ['e1', 'e2'] }
-
Common Patterns documentation: Added comprehensive documentation section with practical recipes for:
- Validation pipelines with multiple checks
- Form validation with error collection
- Concurrent operations handling
- Async error handling patterns
- Data transformation pipelines
[1.1.0] - 2025-11-30
Added
-
filtermethod forMaybe: Validates values with a predicate, convertingJusttoNothingwhen the predicate fails.- Added
filter(predicate: (value: T) => boolean): Maybe<T>method toMaybeinterface. - Added curried
filterfunction for use withpipe. - Example:
1 2
just(25).filter(x => x >= 18).unwrapOr(0); // 25 just(15).filter(x => x >= 18).unwrapOr(0); // 0
- Added
-
validatemethod forResultandEither: Validates values with custom error messages.- Added
validate(predicate: (value: T) => boolean, error: E): Result<T, E>toResult. - Added
validate(predicate: (value: R) => boolean, leftValue: L): Either<L, R>toEither. - Added curried
validatefunctions for use withpipe. - Example:
1 2
ok(25).validate(x => x >= 18, 'Must be 18+').unwrapOr(0); // 25 ok(15).validate(x => x >= 18, 'Must be 18+').isErr(); // true
- Added
[1.0.0] - 2025-06-25
Added
- First stable release of
holo-fnwith core monads:Maybe,Either, andResult. Maybemonad:Just,Nothing, and helper functions likefromNullable.- Added methods like
map,chain,unwrapOr,match, andequals.
Eithermonad:Left, 'Right', and helper functions liketryCatch,fromPromise,fromAsync.- Added methods like
map,chain,unwrapOr,match, andequals.
Resultmonad:Ok,Err, and helper functions likefromThrowable,fromPromise,fromAsync.- Added methods like
map,chain,unwrapOr,match, andequals.
- Introduced
curried functionsformap,chain,unwrapOr, andmatchfor each monad:map,chain,unwrapOr, andmatchforEither,MaybeandResult.
Export restructuring:- Now, monads are imported from their specific files, instead of a global import.
- Example:
1 2 3 4
import { M, E, R } from "holo-fn"; import { fromNullable } from 'holo-fn/maybe'; import { tryCatch } from 'holo-fn/either'; import { fromThrowable } from 'holo-fn/result';
Changed
Migration to Bun: The library is now compatible withBunruntime, offering better performance and faster execution.- Reorganized the imports for better modularization and performance.
- Now, to use specific monads and functions, you must import from their respective files.
Fixed
- Fixed
bugrelated to circular imports. - Optimized the library for faster loading and reduced bundle size.
[0.3.0] - 2025-05-10
Added
- New helpers functions:
- Maybe:
- just(value: T): Maybe
: Creates a Justvalue representing the presence of a value. - nothing
(): Maybe : Creates a Nothingvalue representing the absence of a value.
- just(value: T): Maybe
- Either:
- left
(value: L): Either : Creates a Leftvalue representing a failure or error. - right
(value: R): Either : Creates a Rightvalue representing a success.
- left
- Result:
- ok
(value: T): Result : Creates an Okvalue representing the success of an operation with a value. - err
(error: E): Result : Creates an Errvalue representing a failure of an operation with an error.
- ok
- Maybe:
[0.2.0] - 2025-04-26
Added
- Introduced the
equalsmethod for Maybe, Either, and Result types to compare instances of these types based on their internal values. - Added curried functions for
equalsto allow for easier composition and usage:equalsMfor Maybe.equalsEfor Either.equalsRfor Result.
- New helper functions for easy comparison between monadic values.
Changed
- Refined the API for better type inference and consistency across all functional types (
Maybe,Either,Result). - Improved type safety for curried functions in all monads.
[0.1.0] - 2025-04-23
Added
- Initial release of holo-fn with core monads:
Maybe,Either, andResult. Maybemonad:Just,Nothing, and helper functions likefromNullable.Eithermonad:Left,Right,tryCatch,fromPromise,fromAsync.Resultmonad:Ok,Err,fromThrowable,fromPromise,fromAsync.- Added curried handlers for
map,chain,unwrapOr, andmatchfor better composition and functional pipelines:mapE,chainE,unwrapOrE, andmatchEforEither.mapM,chainM,unwrapOrM, andmatchMforMaybe.mapR,chainR,unwrapOrR, andmatchRforResult.