unwrapped 0.1.4 → 0.1.5

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.
Files changed (3) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/README.md +25 -16
  3. package/package.json +1 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # unwrapped
2
2
 
3
+ ## 0.1.5
4
+
5
+ ### Patch Changes
6
+
7
+ - 50d5178: Improved beginning of docs
8
+
3
9
  ## 0.1.4
4
10
 
5
11
  ### Patch Changes
package/README.md CHANGED
@@ -1,10 +1,19 @@
1
1
  # Unwrapped
2
2
 
3
- A TypeScript library for elegant error handling and asynchronous state management, inspired by Rust's `Result` type and designed with Vue 3 integration in mind.
3
+ A TypeScript library for handling more gracefully synchronous and asynchronous operations that can fail via Result types. Provides also utilities for caching and binding for popular web frameworks.
4
4
 
5
5
  ## Overview
6
6
 
7
- **Unwrapped** provides a robust alternative to `try/catch` blocks and promise chains, making error handling explicit, type-safe, and composable. It consists of two main parts:
7
+ Error handling in TypeScript is fundamentally built around throwing exceptions and catching them with try/catch blocks. This works fine for simple scripts where an unexpected error should crash the program, but modern applications—especially frontends—need to handle errors gracefully without crashing the entire app.
8
+
9
+ **Unwrapped** provides a different approach by providing Result types, with variants for both synchronous and asynchronous operations.
10
+ While their primary and most basic use are for describing the result of operations that may fail, they can be chained to describe chains of operations, with build-in short-circuiting when encoutering an error. These chains can be described either by successively calling methods like `.chain()`, or by using a generator syntax inspired by Effect (although much simplified).
11
+
12
+ Without **Unwrapped**, the traditional approach leads to scattered state management: separate variables for loading, error, and data, manual state transitions, and the ever-present risk of forgetting to set loading = false in a finally block. Error types are unknown, forcing type assertions everywhere. Chaining multiple async operations that can each fail becomes a mess of nested try/catch blocks or promise chains with multiple .catch() handlers.
13
+
14
+ On the contrary, **Unwrapped**'s AsyncResult type wraps loading, error, and success states in one type allowing for a much leaner and less error prone way of writing. Unsettled asynchronous operations will always give you an AsyncResult in a loading state, and when this work finishes, the AsyncResult will always be in a settled state, being either error or success.
15
+
16
+ **Unwrapped** is composed of multiple sub-modules :
8
17
 
9
18
  - **Core**: Framework-agnostic utilities for managing results and async operations
10
19
  - **Vue**: Vue 3 composables and components for reactive async state management
@@ -19,6 +28,20 @@ A brief comparison with other libraries can be found at the "Why Unwrapped ?" se
19
28
  npm install unwrapped
20
29
  ```
21
30
 
31
+ ## API Reference
32
+
33
+ ### Core Module (`unwrapped/core`)
34
+
35
+ - **`Result<T, E>`**: Synchronous result type
36
+ - **`AsyncResult<T, E>`**: Asynchronous result with state tracking
37
+ - **`ErrorBase`**: Base error class with structured logging
38
+ - **`KeyedAsyncCache<P, V, E>`**: Cache for async operations
39
+
40
+ ### Vue Module (`unwrapped/vue`)
41
+
42
+ - **Composables**: `useAsyncResultRef`, `useAction`, `useLazyAction`, `useReactiveChain`, `useGenerator`, `useLazyGenerator`, `useReactiveGenerator`
43
+ - **Components**: `AsyncResultLoader`, `buildCustomAsyncResultLoader`
44
+
22
45
 
23
46
  ## Core Concepts
24
47
 
@@ -825,20 +848,6 @@ Unwrapped is in very active development and a lot of features are still planned,
825
848
  - Debounce on relevant utilities
826
849
 
827
850
 
828
- ## API Reference
829
-
830
- ### Core Module (`unwrapped/core`)
831
-
832
- - **`Result<T, E>`**: Synchronous result type
833
- - **`AsyncResult<T, E>`**: Asynchronous result with state tracking
834
- - **`ErrorBase`**: Base error class with structured logging
835
- - **`KeyedAsyncCache<P, V, E>`**: Cache for async operations
836
-
837
- ### Vue Module (`unwrapped/vue`)
838
-
839
- - **Composables**: `useAsyncResultRef`, `useAction`, `useLazyAction`, `useReactiveChain`, `useGenerator`, `useLazyGenerator`, `useReactiveGenerator`
840
- - **Components**: `AsyncResultLoader`, `buildCustomAsyncResultLoader`
841
-
842
851
  ## License
843
852
 
844
853
  LGPL-3.0-or-later
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "unwrapped",
3
- "version": "0.1.4",
3
+ "version": "0.1.5",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },