functype 0.8.67 → 0.8.69
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 +136 -6
- package/dist/Either-BfXNbTHo.d.ts +533 -0
- package/dist/Map-vivbm5n0.d.ts +65 -0
- package/dist/{Tuple-DfdXAbL_.d.ts → Valuable-CtuVEKTZ.d.ts} +17 -10
- package/dist/chunk-5DWCHDSA.mjs +39 -0
- package/dist/chunk-5DWCHDSA.mjs.map +1 -0
- package/dist/chunk-7PQA3W7W.mjs +2 -0
- package/dist/chunk-7PQA3W7W.mjs.map +1 -0
- package/dist/either/index.d.ts +2 -3
- package/dist/either/index.mjs +1 -1
- package/dist/fpromise/index.d.ts +373 -3
- package/dist/fpromise/index.mjs +1 -1
- package/dist/index.d.ts +533 -2
- package/dist/index.mjs +1 -1
- package/dist/list/index.d.ts +2 -3
- package/dist/list/index.mjs +1 -1
- package/dist/map/index.d.ts +4 -3
- package/dist/map/index.mjs +1 -1
- package/dist/option/index.d.ts +2 -987
- package/dist/option/index.mjs +1 -1
- package/dist/set/index.d.ts +2 -3
- package/dist/set/index.mjs +1 -1
- package/dist/try/index.d.ts +59 -3
- package/dist/try/index.mjs +1 -1
- package/dist/tuple/index.d.ts +12 -1
- package/dist/tuple/index.mjs +1 -1
- package/package.json +17 -16
- package/readme/BUNDLE_OPTIMIZATION.md +74 -0
- package/readme/FPromise-Assessment.md +43 -0
- package/readme/HKT.md +110 -0
- package/readme/ROADMAP.md +113 -0
- package/readme/TASK-IMPLEMENTATION.md +290 -0
- package/readme/TASK-TODO.md +40 -0
- package/readme/TASK-UPDATES.md +64 -0
- package/readme/TUPLE-EXAMPLES.md +79 -0
- package/readme/TaskMigration.md +129 -0
- package/readme/ai-guide.md +406 -0
- package/readme/examples.md +2093 -0
- package/readme/quick-reference.md +514 -0
- package/readme/task-cancellation-progress.md +258 -0
- package/readme/task-error-handling.md +128 -0
- package/readme/task-quick-reference.md +157 -0
- package/readme/tasks.md +205 -0
- package/readme/type-index.md +238 -0
- package/dist/chunk-NTL4HYMA.mjs +0 -18
- package/dist/chunk-NTL4HYMA.mjs.map +0 -1
- package/dist/chunk-PXFJPCM7.mjs +0 -2
- package/dist/chunk-PXFJPCM7.mjs.map +0 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,534 @@
|
|
|
1
|
-
export { c as AbstractFunctor, d as ArrayFunctor, A as AsyncFunctor, E as ExtractTag, F as Functor, b as Tuple, a as Type, T as Typeable, e as TypeableParams, i as isTypeable } from './Tuple-DfdXAbL_.js';
|
|
2
1
|
export { Brand, BrandedBoolean, BrandedNumber, BrandedString, ExtractBrand, Unbrand, createBrander, hasBrand, unbrand } from './branded/index.js';
|
|
3
|
-
|
|
2
|
+
import { E as Either, F as Foldable, O as Option, L as List, T as Traversable, S as Serializable, P as Pipe, M as Matchable } from './Either-BfXNbTHo.js';
|
|
3
|
+
export { a as Collection, C as Converters, I as IterableType, c as Left, h as MatchableUtils, N as None, k as OptionConstructor, R as Right, l as SerializationMethods, m as Set, j as Some, b as TestEither, f as TypeCheckLeft, e as TypeCheckRight, d as isLeft, i as isRight, t as tryCatch, g as tryCatchAsync } from './Either-BfXNbTHo.js';
|
|
4
|
+
import { T as Typeable, a as Type, F as Functor, V as Valuable } from './Valuable-CtuVEKTZ.js';
|
|
5
|
+
export { A as AbstractFunctor, c as ArrayFunctor, b as AsyncFunctor, E as ExtractTag, d as TypeableParams, e as ValuableParams, i as isTypeable } from './Valuable-CtuVEKTZ.js';
|
|
6
|
+
import { FPromise } from './fpromise/index.js';
|
|
7
|
+
export { ErrorContext, FPromiseCompanion } from './fpromise/index.js';
|
|
8
|
+
import { Try } from './try/index.js';
|
|
9
|
+
export { TypeNames } from './try/index.js';
|
|
10
|
+
export { a as ESMap, E as ESMapType, M as Map, S as SafeTraversable } from './Map-vivbm5n0.js';
|
|
11
|
+
export { Tuple } from './tuple/index.js';
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Creates a function-object hybrid similar to Scala's companion objects.
|
|
15
|
+
* This utility allows creating TypeScript function objects with attached methods,
|
|
16
|
+
* mimicking Scala's class + companion object pattern without using classes.
|
|
17
|
+
*
|
|
18
|
+
* @param object The main function that will be invoked when the object is called
|
|
19
|
+
* @param companion Additional static methods to attach to the function
|
|
20
|
+
* @returns A function with the attached methods
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* const greet = (name: string) => `Hello, ${name}!`;
|
|
24
|
+
* const methods = {
|
|
25
|
+
* formal: (name: string) => `Good day, ${name}.`,
|
|
26
|
+
* casual: (name: string) => `Hey ${name}!`
|
|
27
|
+
* };
|
|
28
|
+
* const Greeter = createCompanionObject(greet, methods);
|
|
29
|
+
*
|
|
30
|
+
* // Usage:
|
|
31
|
+
* Greeter("World"); // Hello, World!
|
|
32
|
+
* Greeter.formal("Sir"); // Good day, Sir.
|
|
33
|
+
* Greeter.casual("Friend"); // Hey Friend!
|
|
34
|
+
*/
|
|
35
|
+
declare function Companion<ObjectF extends object, CompanionF extends object>(object: ObjectF, companion: CompanionF): ObjectF & CompanionF;
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Base Object from which most other objects inherit
|
|
39
|
+
* @param type - The type name for the object
|
|
40
|
+
* @param body - The implementation body
|
|
41
|
+
*/
|
|
42
|
+
declare function Base<T>(type: string, body: T): T & {
|
|
43
|
+
toString(): string;
|
|
44
|
+
_tag: string;
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* The identifier name for Throwable type
|
|
49
|
+
*/
|
|
50
|
+
declare const NAME: "Throwable";
|
|
51
|
+
type ThrowableType = Error & Typeable<typeof NAME> & {
|
|
52
|
+
readonly data?: unknown;
|
|
53
|
+
readonly cause?: Error;
|
|
54
|
+
readonly taskInfo?: {
|
|
55
|
+
name: string;
|
|
56
|
+
description: string;
|
|
57
|
+
};
|
|
58
|
+
};
|
|
59
|
+
declare class Throwable extends Error implements ThrowableType {
|
|
60
|
+
readonly _tag: typeof NAME;
|
|
61
|
+
readonly data?: unknown;
|
|
62
|
+
readonly cause?: Error;
|
|
63
|
+
readonly taskInfo?: {
|
|
64
|
+
name: string;
|
|
65
|
+
description: string;
|
|
66
|
+
};
|
|
67
|
+
protected constructor(message: string, options?: {
|
|
68
|
+
data?: unknown | undefined;
|
|
69
|
+
cause?: Error | undefined;
|
|
70
|
+
stack?: string | undefined;
|
|
71
|
+
taskInfo?: {
|
|
72
|
+
name: string;
|
|
73
|
+
description: string;
|
|
74
|
+
} | undefined;
|
|
75
|
+
});
|
|
76
|
+
static apply(srcError: unknown, data?: unknown, taskInfo?: {
|
|
77
|
+
name: string;
|
|
78
|
+
description: string;
|
|
79
|
+
}): ThrowableType;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Type definition for errors with a _tag property that identifies them as Throwables
|
|
84
|
+
*/
|
|
85
|
+
type TaggedThrowable = Error & {
|
|
86
|
+
_tag: "Throwable";
|
|
87
|
+
cause?: Error;
|
|
88
|
+
taskInfo?: TaskInfo;
|
|
89
|
+
};
|
|
90
|
+
/**
|
|
91
|
+
* Type guard to check if an error is a TaggedThrowable
|
|
92
|
+
*/
|
|
93
|
+
declare function isTaggedThrowable(error: unknown): error is TaggedThrowable;
|
|
94
|
+
type TaskParams = {
|
|
95
|
+
name?: string;
|
|
96
|
+
description?: string;
|
|
97
|
+
};
|
|
98
|
+
type TaskInfo = {
|
|
99
|
+
_task: TaskParams;
|
|
100
|
+
name?: string;
|
|
101
|
+
description?: string;
|
|
102
|
+
};
|
|
103
|
+
type TaskException<T> = Either<Throwable, T> & TaskInfo;
|
|
104
|
+
/**
|
|
105
|
+
* TaskException factory function
|
|
106
|
+
* @param error - The error object
|
|
107
|
+
* @param data - Additional data related to the error
|
|
108
|
+
* @param _task - Task parameters
|
|
109
|
+
*/
|
|
110
|
+
declare const TaskException: <T>(error: unknown, data?: unknown, _task?: TaskParams) => TaskException<T>;
|
|
111
|
+
type TaskResult<T> = Either<Throwable, T> & TaskInfo;
|
|
112
|
+
declare const TaskResult: <T>(data: T, _task?: TaskParams) => TaskResult<T>;
|
|
113
|
+
/**
|
|
114
|
+
* The CancellationToken is a control structure that allows long-running tasks to be cancelled
|
|
115
|
+
* Cancellation is cooperative, meaning the task must check the token and respond to cancellation requests
|
|
116
|
+
*/
|
|
117
|
+
type CancellationToken = {
|
|
118
|
+
/** Whether the token has been cancelled */
|
|
119
|
+
readonly isCancelled: boolean;
|
|
120
|
+
/** Signal that can be used with fetch and other abortable APIs */
|
|
121
|
+
readonly signal: AbortSignal;
|
|
122
|
+
/** Register a callback to be called when cancellation occurs */
|
|
123
|
+
onCancel(callback: () => void): void;
|
|
124
|
+
};
|
|
125
|
+
/**
|
|
126
|
+
* Create a cancellation token and controller
|
|
127
|
+
* The controller can be used to cancel operations that use the token
|
|
128
|
+
*/
|
|
129
|
+
type CancellationTokenSource = {
|
|
130
|
+
/** The token to be passed to cancellable operations */
|
|
131
|
+
readonly token: CancellationToken;
|
|
132
|
+
/** Cancel all operations using this token */
|
|
133
|
+
cancel(): void;
|
|
134
|
+
};
|
|
135
|
+
/**
|
|
136
|
+
* Create a cancellation token source
|
|
137
|
+
* @returns A CancellationTokenSource that can be used to create and control cancellation tokens
|
|
138
|
+
*/
|
|
139
|
+
declare const createCancellationTokenSource: () => CancellationTokenSource;
|
|
140
|
+
type Sync<T> = Either<Throwable, T>;
|
|
141
|
+
type Async<T> = FPromise<Sync<T>>;
|
|
142
|
+
declare const Task: (<T = unknown>(params?: TaskParams) => {
|
|
143
|
+
_type: string;
|
|
144
|
+
/**
|
|
145
|
+
* Run an async operation with explicit try/catch/finally semantics
|
|
146
|
+
* Returns a raw Promise that can interact with traditional Promise-based code
|
|
147
|
+
*
|
|
148
|
+
* @param t - The main operation function that returns a value or Promise
|
|
149
|
+
* @param e - Optional error handler function
|
|
150
|
+
* @param f - Optional finally handler function
|
|
151
|
+
* @param cancellationToken - Optional token for cancellation support
|
|
152
|
+
*/
|
|
153
|
+
Async: <U = T>(t: () => U | Promise<U>, e?: (error: unknown) => unknown, f?: () => Promise<void> | void, cancellationToken?: CancellationToken) => FPromise<U>;
|
|
154
|
+
/**
|
|
155
|
+
* Run a synchronous operation with explicit try/catch/finally semantics
|
|
156
|
+
* Returns an Either for functional error handling
|
|
157
|
+
*
|
|
158
|
+
* @param t - The main operation function that returns a value
|
|
159
|
+
* @param e - Optional error handler function
|
|
160
|
+
* @param f - Optional finally handler function
|
|
161
|
+
*/
|
|
162
|
+
Sync: <U = T>(t: () => U, e?: (error: unknown) => unknown, f?: () => void) => Sync<U>;
|
|
163
|
+
/**
|
|
164
|
+
* Run an async operation with progress tracking capabilities
|
|
165
|
+
* Returns a Promise and provides progress updates via callback
|
|
166
|
+
*
|
|
167
|
+
* @param t - The main operation that receives a progress updater function
|
|
168
|
+
* @param onProgress - Callback that receives progress updates (0-100)
|
|
169
|
+
* @param e - Optional error handler function
|
|
170
|
+
* @param f - Optional finally handler function
|
|
171
|
+
* @param cancellationToken - Optional token for cancellation support
|
|
172
|
+
*/
|
|
173
|
+
AsyncWithProgress: <U = T>(t: (updateProgress: (percent: number) => void) => U | Promise<U>, onProgress: (percent: number) => void, e?: (error: unknown) => unknown, f?: () => Promise<void> | void, cancellationToken?: CancellationToken) => FPromise<U>;
|
|
174
|
+
toString(): string;
|
|
175
|
+
_tag: string;
|
|
176
|
+
}) & {
|
|
177
|
+
/**
|
|
178
|
+
* Create a successful Task result
|
|
179
|
+
*/
|
|
180
|
+
success: <T>(data: T, params?: TaskParams) => TaskResult<T>;
|
|
181
|
+
/**
|
|
182
|
+
* Create a failed Task result
|
|
183
|
+
*/
|
|
184
|
+
fail: <T>(error: unknown, data?: unknown, params?: TaskParams) => TaskException<T>;
|
|
185
|
+
/**
|
|
186
|
+
* Extract the error chain from a Throwable error
|
|
187
|
+
* Returns an array of errors from outermost to innermost
|
|
188
|
+
*
|
|
189
|
+
* @param error - The error to extract the chain from
|
|
190
|
+
* @returns An array of errors in the chain, from outermost to innermost
|
|
191
|
+
*/
|
|
192
|
+
getErrorChain: (error: Error | undefined) => Error[];
|
|
193
|
+
/**
|
|
194
|
+
* Format the error chain as a string with the option to include task details
|
|
195
|
+
*
|
|
196
|
+
* @param error - The error to format
|
|
197
|
+
* @param options - Formatting options
|
|
198
|
+
* @returns A formatted string representation of the error chain
|
|
199
|
+
*/
|
|
200
|
+
formatErrorChain: (error: Error | undefined, options?: {
|
|
201
|
+
includeTasks?: boolean;
|
|
202
|
+
separator?: string;
|
|
203
|
+
includeStackTrace?: boolean;
|
|
204
|
+
}) => string;
|
|
205
|
+
/**
|
|
206
|
+
* Convert a Promise-returning function to a Task-compatible function
|
|
207
|
+
*/
|
|
208
|
+
fromPromise: <U, Args extends unknown[]>(promiseFn: (...args: Args) => Promise<U>, params?: TaskParams) => ((...args: Args) => FPromise<U>);
|
|
209
|
+
/**
|
|
210
|
+
* Convert a Task result to a Promise
|
|
211
|
+
*/
|
|
212
|
+
toPromise: <U>(taskResult: TaskResult<U> | TaskException<U>) => Promise<U>;
|
|
213
|
+
/**
|
|
214
|
+
* Race multiple tasks and return the result of the first one to complete
|
|
215
|
+
* Optionally specify a timeout after which the race will fail
|
|
216
|
+
*
|
|
217
|
+
* @param tasks - Array of tasks to race (as FPromises)
|
|
218
|
+
* @param timeoutMs - Optional timeout in milliseconds
|
|
219
|
+
* @param params - Task parameters for the race operation
|
|
220
|
+
* @returns A promise that resolves with the first task to complete or rejects if all tasks fail
|
|
221
|
+
*/
|
|
222
|
+
race: <T>(tasks: Array<FPromise<T>>, timeoutMs?: number, params?: TaskParams) => FPromise<T>;
|
|
223
|
+
/**
|
|
224
|
+
* Convert a Node.js style callback function to a Task-compatible function
|
|
225
|
+
* Node.js callbacks typically have the signature (error, result) => void
|
|
226
|
+
*
|
|
227
|
+
* @param nodeFn - Function that accepts a Node.js style callback
|
|
228
|
+
* @param params - Task parameters
|
|
229
|
+
* @returns A function that returns an FPromise
|
|
230
|
+
*/
|
|
231
|
+
fromNodeCallback: <T, Args extends unknown[]>(nodeFn: (...args: [...Args, (error: unknown, result: T) => void]) => void, params?: TaskParams) => ((...args: Args) => FPromise<T>);
|
|
232
|
+
/**
|
|
233
|
+
* Create a cancellation token source
|
|
234
|
+
* @returns A cancellation token source that can be used to control task cancellation
|
|
235
|
+
*/
|
|
236
|
+
createCancellationTokenSource: () => CancellationTokenSource;
|
|
237
|
+
/**
|
|
238
|
+
* Create a task that can be cancelled
|
|
239
|
+
*
|
|
240
|
+
* @param task - The task function to make cancellable
|
|
241
|
+
* @param params - Task parameters
|
|
242
|
+
* @returns An object with the task and a function to cancel it
|
|
243
|
+
*/
|
|
244
|
+
cancellable: <T>(task: (token: CancellationToken) => Promise<T>, params?: TaskParams) => {
|
|
245
|
+
task: FPromise<T>;
|
|
246
|
+
cancel: () => void;
|
|
247
|
+
};
|
|
248
|
+
/**
|
|
249
|
+
* Creates a task with progress tracking
|
|
250
|
+
*
|
|
251
|
+
* @param task - The task function that accepts a progress updater
|
|
252
|
+
* @param onProgress - Callback function that receives progress updates
|
|
253
|
+
* @param params - Task parameters
|
|
254
|
+
* @returns An object with the task, cancel function, and current progress
|
|
255
|
+
*/
|
|
256
|
+
withProgress: <T>(task: (updateProgress: (percent: number) => void, token: CancellationToken) => Promise<T>, onProgress?: (percent: number) => void, params?: TaskParams) => {
|
|
257
|
+
task: FPromise<T>;
|
|
258
|
+
cancel: () => void;
|
|
259
|
+
currentProgress: () => number;
|
|
260
|
+
};
|
|
261
|
+
};
|
|
262
|
+
type Task = ReturnType<typeof Task>;
|
|
263
|
+
|
|
264
|
+
/**
|
|
265
|
+
* Type definition for task information that may be attached to errors
|
|
266
|
+
*/
|
|
267
|
+
type TaskErrorInfo = {
|
|
268
|
+
name?: string;
|
|
269
|
+
description?: string;
|
|
270
|
+
[key: string]: unknown;
|
|
271
|
+
};
|
|
272
|
+
/**
|
|
273
|
+
* Type definition for an error with potential task information
|
|
274
|
+
*/
|
|
275
|
+
type ErrorWithTaskInfo = Error & {
|
|
276
|
+
taskInfo?: TaskErrorInfo;
|
|
277
|
+
data?: unknown;
|
|
278
|
+
};
|
|
279
|
+
/**
|
|
280
|
+
* Type definition for a structured error chain element
|
|
281
|
+
*/
|
|
282
|
+
type ErrorChainElement = {
|
|
283
|
+
message?: string;
|
|
284
|
+
name?: string;
|
|
285
|
+
taskInfo?: TaskErrorInfo;
|
|
286
|
+
stack?: string;
|
|
287
|
+
[key: string]: unknown;
|
|
288
|
+
};
|
|
289
|
+
/**
|
|
290
|
+
* Options for formatting error chains
|
|
291
|
+
*/
|
|
292
|
+
type ErrorFormatterOptions = {
|
|
293
|
+
/** Include task names in the formatted output */
|
|
294
|
+
includeTasks?: boolean;
|
|
295
|
+
/** Include stack traces in the formatted output */
|
|
296
|
+
includeStackTrace?: boolean;
|
|
297
|
+
/** Separator between error lines (default: newline) */
|
|
298
|
+
separator?: string;
|
|
299
|
+
/** Include detailed error data in the output */
|
|
300
|
+
includeData?: boolean;
|
|
301
|
+
/** Maximum number of stack frames to include if stack trace is enabled */
|
|
302
|
+
maxStackFrames?: number;
|
|
303
|
+
/** Title to display at the start of the formatted error */
|
|
304
|
+
title?: string;
|
|
305
|
+
/** Format the output with colors for console display */
|
|
306
|
+
colors?: boolean;
|
|
307
|
+
};
|
|
308
|
+
/**
|
|
309
|
+
* Safely stringify data including BigInt values and circular references
|
|
310
|
+
*/
|
|
311
|
+
declare function safeStringify(obj: unknown): string;
|
|
312
|
+
/**
|
|
313
|
+
* Format a stack trace string for better readability
|
|
314
|
+
*/
|
|
315
|
+
declare function formatStackTrace(stack: string | undefined): string;
|
|
316
|
+
/**
|
|
317
|
+
* Create a formatted string representation of an error for better logging and display
|
|
318
|
+
*
|
|
319
|
+
* @example
|
|
320
|
+
* ```typescript
|
|
321
|
+
* const error = new Error("Something went wrong");
|
|
322
|
+
* console.error(formatError(error, { colors: true, includeData: true }));
|
|
323
|
+
* ```
|
|
324
|
+
*/
|
|
325
|
+
declare function formatError(error: unknown, options?: ErrorFormatterOptions): string;
|
|
326
|
+
/**
|
|
327
|
+
* Create a serializer function for Pino or other JSON loggers
|
|
328
|
+
* to better represent errors with their full context
|
|
329
|
+
*/
|
|
330
|
+
declare function createErrorSerializer(): (err: unknown) => unknown;
|
|
331
|
+
|
|
332
|
+
declare const ParseError: (message?: string) => Error & {
|
|
333
|
+
name: "ParseError";
|
|
334
|
+
};
|
|
335
|
+
type ParseError = Error & {
|
|
336
|
+
name: "ParseError";
|
|
337
|
+
};
|
|
338
|
+
|
|
339
|
+
/**
|
|
340
|
+
* Utility functions for working with Foldable data structures
|
|
341
|
+
*/
|
|
342
|
+
declare const FoldableUtils: {
|
|
343
|
+
/**
|
|
344
|
+
* Converts a Foldable to an Option
|
|
345
|
+
*
|
|
346
|
+
* @param foldable - The foldable structure to convert
|
|
347
|
+
* @returns An Option containing the value, or None if empty
|
|
348
|
+
*/
|
|
349
|
+
toOption: <A extends Type>(foldable: Foldable<A>) => Option<A>;
|
|
350
|
+
/**
|
|
351
|
+
* Converts a Foldable to a List
|
|
352
|
+
*
|
|
353
|
+
* @param foldable - The foldable structure to convert
|
|
354
|
+
* @returns A List containing the value(s), or empty List if empty
|
|
355
|
+
*/
|
|
356
|
+
toList: <A extends Type>(foldable: Foldable<A>) => List<A>;
|
|
357
|
+
/**
|
|
358
|
+
* Converts a Foldable to an Either
|
|
359
|
+
*
|
|
360
|
+
* @param foldable - The foldable structure to convert
|
|
361
|
+
* @param left - The value to use for Left if empty
|
|
362
|
+
* @returns Either.Right with the value if non-empty, or Either.Left with left if empty
|
|
363
|
+
*/
|
|
364
|
+
toEither: <A extends Type, E>(foldable: Foldable<A>, left: E) => Either<E, A>;
|
|
365
|
+
/**
|
|
366
|
+
* Checks if the Foldable is empty
|
|
367
|
+
*
|
|
368
|
+
* @param foldable - The foldable structure to check
|
|
369
|
+
* @returns true if empty, false otherwise
|
|
370
|
+
*/
|
|
371
|
+
isEmpty: <A extends Type>(foldable: Foldable<A>) => boolean;
|
|
372
|
+
/**
|
|
373
|
+
* Calculates the size of the Foldable
|
|
374
|
+
*
|
|
375
|
+
* @param foldable - The foldable structure to measure
|
|
376
|
+
* @returns The size (number of elements)
|
|
377
|
+
*/
|
|
378
|
+
size: <A extends Type>(foldable: Foldable<A>) => number;
|
|
379
|
+
};
|
|
380
|
+
|
|
381
|
+
/**
|
|
382
|
+
* Type function for representing higher-kinded types
|
|
383
|
+
*/
|
|
384
|
+
type Kind<F, A> = F extends (arg: infer T) => infer R ? R : never;
|
|
385
|
+
/**
|
|
386
|
+
* Type constructors for common Functype data types
|
|
387
|
+
*/
|
|
388
|
+
type OptionKind = <A>(a: A) => Option<A>;
|
|
389
|
+
type ListKind = <A>(a: A) => List<A>;
|
|
390
|
+
type EitherKind<E> = <A>(a: A) => Either<E, A>;
|
|
391
|
+
type TryKind = <A>(a: A) => Try<A>;
|
|
392
|
+
/**
|
|
393
|
+
* Generic container types for type-safe operations
|
|
394
|
+
*/
|
|
395
|
+
type Mappable<T> = {
|
|
396
|
+
map<U>(f: (value: T) => U): unknown;
|
|
397
|
+
};
|
|
398
|
+
type Flattenable = {
|
|
399
|
+
flatten(): unknown;
|
|
400
|
+
};
|
|
401
|
+
type FlatMappable<T> = {
|
|
402
|
+
flatMap<U>(f: (value: T) => unknown): unknown;
|
|
403
|
+
};
|
|
404
|
+
/**
|
|
405
|
+
* Universal type that includes all potential return types from the HKT functions
|
|
406
|
+
* Used to avoid 'any' usage which the linter prohibits
|
|
407
|
+
*/
|
|
408
|
+
type UniversalContainer = Option<unknown> | List<unknown> | Either<unknown, unknown> | Try<unknown>;
|
|
409
|
+
/**
|
|
410
|
+
* HKT provides utilities for working with higher-kinded types
|
|
411
|
+
* This allows writing generic code that works across different
|
|
412
|
+
* container types like Option, List, Either, etc.
|
|
413
|
+
*/
|
|
414
|
+
declare const HKT: {
|
|
415
|
+
(): {
|
|
416
|
+
_type: string;
|
|
417
|
+
map: <F, A, B>(fa: unknown, f: (a: A) => B) => unknown;
|
|
418
|
+
flatten: <F, A>(ffa: unknown) => unknown;
|
|
419
|
+
flatMap: <F, A, B>(fa: unknown, f: (a: A) => unknown) => unknown;
|
|
420
|
+
ap: <F, A, B>(ff: unknown, fa: unknown) => unknown;
|
|
421
|
+
sequence: <F, G, A>(fga: unknown) => unknown;
|
|
422
|
+
traverse: <F, G, A, B>(fa: unknown, f: (a: A) => unknown) => unknown;
|
|
423
|
+
toString(): string;
|
|
424
|
+
_tag: string;
|
|
425
|
+
};
|
|
426
|
+
map<F = unknown, A = unknown, B = unknown>(fa: unknown, f: (a: A) => B): unknown;
|
|
427
|
+
flatten<F = unknown, A = unknown>(ffa: unknown): unknown;
|
|
428
|
+
flatMap<F = unknown, A = unknown, B = unknown>(fa: unknown, f: (a: A) => unknown): unknown;
|
|
429
|
+
ap<F = unknown, A = unknown, B = unknown>(ff: unknown, fa: unknown): unknown;
|
|
430
|
+
sequence<F = unknown, G = unknown, A = unknown>(fga: unknown): unknown;
|
|
431
|
+
traverse<F = unknown, G = unknown, A = unknown, B = unknown>(fa: unknown, f: (a: A) => unknown): unknown;
|
|
432
|
+
isOption: <T extends Type>(value: unknown) => value is Option<T> & Mappable<T> & FlatMappable<T>;
|
|
433
|
+
isList: <T extends Type>(value: unknown) => value is List<T> & Mappable<T> & Flattenable & FlatMappable<T>;
|
|
434
|
+
isEither: <E extends Type, A extends Type>(value: unknown) => value is Either<E, A> & Mappable<A> & FlatMappable<A>;
|
|
435
|
+
isTry: <T extends Type>(value: unknown) => value is Try<T> & Mappable<T> & FlatMappable<T>;
|
|
436
|
+
};
|
|
437
|
+
|
|
438
|
+
type Identity<T> = {
|
|
439
|
+
id: T;
|
|
440
|
+
isSame?: (other: Identity<T>) => boolean;
|
|
441
|
+
};
|
|
442
|
+
declare function Identity<T>(value: T): Identity<T>;
|
|
443
|
+
|
|
444
|
+
/**
|
|
445
|
+
* Stack data structure - Last In, First Out (LIFO)
|
|
446
|
+
* Implements the Traversable interface for working with ordered collections
|
|
447
|
+
*/
|
|
448
|
+
type Stack<A extends Type> = {
|
|
449
|
+
/**
|
|
450
|
+
* Push a value onto the top of the stack
|
|
451
|
+
* @param value - The value to push
|
|
452
|
+
* @returns A new Stack with the value added
|
|
453
|
+
*/
|
|
454
|
+
push(value: A): Stack<A>;
|
|
455
|
+
/**
|
|
456
|
+
* Remove and return the top value from the stack
|
|
457
|
+
* @returns A tuple containing the new Stack and the value
|
|
458
|
+
*/
|
|
459
|
+
pop(): [Stack<A>, Option<A>];
|
|
460
|
+
/**
|
|
461
|
+
* Return the top value without removing it
|
|
462
|
+
* @returns The top value wrapped in an Option
|
|
463
|
+
*/
|
|
464
|
+
peek(): Option<A>;
|
|
465
|
+
/**
|
|
466
|
+
* Transforms each element in the stack using the provided function
|
|
467
|
+
* @param f - The mapping function
|
|
468
|
+
* @returns A new Stack with transformed elements
|
|
469
|
+
*/
|
|
470
|
+
map<B extends Type>(f: (a: A) => B): Stack<B>;
|
|
471
|
+
/**
|
|
472
|
+
* Maps each element to a Stack and flattens the result
|
|
473
|
+
* @param f - The mapping function returning a Stack
|
|
474
|
+
* @returns A new flattened Stack
|
|
475
|
+
*/
|
|
476
|
+
flatMap<B extends Type>(f: (a: A) => Stack<B>): Stack<B>;
|
|
477
|
+
/**
|
|
478
|
+
* Convert the stack to a List
|
|
479
|
+
* @returns A List containing all elements
|
|
480
|
+
*/
|
|
481
|
+
toList(): List<A>;
|
|
482
|
+
/**
|
|
483
|
+
* Convert the stack to an array
|
|
484
|
+
* @returns An array of all elements
|
|
485
|
+
*/
|
|
486
|
+
toArray(): A[];
|
|
487
|
+
/**
|
|
488
|
+
* Returns a string representation of the stack
|
|
489
|
+
* @returns A string representation
|
|
490
|
+
*/
|
|
491
|
+
toString(): string;
|
|
492
|
+
/**
|
|
493
|
+
* Pattern matches over the Stack, applying a handler function based on whether it's empty
|
|
494
|
+
* @param patterns - Object with handler functions for Empty and NonEmpty variants
|
|
495
|
+
* @returns The result of applying the matching handler function
|
|
496
|
+
*/
|
|
497
|
+
match<R>(patterns: {
|
|
498
|
+
Empty: () => R;
|
|
499
|
+
NonEmpty: (values: A[]) => R;
|
|
500
|
+
}): R;
|
|
501
|
+
} & Traversable<A> & Functor<A> & Typeable<"Stack"> & Valuable<"Stack", A[]> & Serializable<A> & Pipe<A[]> & Foldable<A> & Matchable<A[], "Empty" | "NonEmpty">;
|
|
502
|
+
declare const Stack: (<A extends Type>(values?: A[]) => Stack<A>) & {
|
|
503
|
+
/**
|
|
504
|
+
* Creates an empty stack
|
|
505
|
+
* @returns An empty Stack instance
|
|
506
|
+
*/
|
|
507
|
+
empty: <A extends Type>() => Stack<A>;
|
|
508
|
+
/**
|
|
509
|
+
* Creates a Stack from a single value
|
|
510
|
+
* @param value - The value to create a stack with
|
|
511
|
+
* @returns A Stack with a single value
|
|
512
|
+
*/
|
|
513
|
+
of: <A extends Type>(value: A) => Stack<A>;
|
|
514
|
+
/**
|
|
515
|
+
* Creates a Stack from JSON string
|
|
516
|
+
* @param json - The JSON string
|
|
517
|
+
* @returns Stack instance
|
|
518
|
+
*/
|
|
519
|
+
fromJSON: <A>(json: string) => Stack<A>;
|
|
520
|
+
/**
|
|
521
|
+
* Creates a Stack from YAML string
|
|
522
|
+
* @param yaml - The YAML string
|
|
523
|
+
* @returns Stack instance
|
|
524
|
+
*/
|
|
525
|
+
fromYAML: <A>(yaml: string) => Stack<A>;
|
|
526
|
+
/**
|
|
527
|
+
* Creates a Stack from binary string
|
|
528
|
+
* @param binary - The binary string
|
|
529
|
+
* @returns Stack instance
|
|
530
|
+
*/
|
|
531
|
+
fromBinary: <A>(binary: string) => Stack<A>;
|
|
532
|
+
};
|
|
533
|
+
|
|
534
|
+
export { type Async, Base, type CancellationToken, type CancellationTokenSource, Companion, Either, type EitherKind, type ErrorChainElement, type ErrorFormatterOptions, type ErrorWithTaskInfo, FPromise, Foldable, FoldableUtils, Functor, HKT, Identity, type Kind, List, type ListKind, Matchable, NAME, Option, type OptionKind, ParseError, Pipe, Serializable, Stack, type Sync, type TaggedThrowable, Task, type TaskErrorInfo, TaskException, type TaskInfo, type TaskParams, TaskResult, Throwable, type ThrowableType, Traversable, Try, type TryKind, Type, Typeable, type UniversalContainer, Valuable, createCancellationTokenSource, createErrorSerializer, formatError, formatStackTrace, isTaggedThrowable, safeStringify };
|
package/dist/index.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export{
|
|
1
|
+
export{h as Base,a as Companion,J as ESMap,s as Either,u as FPromise,t as FPromiseCompanion,F as FoldableUtils,H as HKT,I as Identity,l as Left,g as List,K as Map,L as MatchableUtils,i as NAME,c as None,e as Option,d as OptionConstructor,E as ParseError,k as Right,f as Set,b as Some,M as Stack,z as Task,w as TaskException,x as TaskResult,j as Throwable,G as Try,q as TypeCheckLeft,p as TypeCheckRight,y as createCancellationTokenSource,D as createErrorSerializer,C as formatError,B as formatStackTrace,n as isLeft,m as isRight,v as isTaggedThrowable,A as safeStringify,o as tryCatch,r as tryCatchAsync}from'./chunk-5DWCHDSA.mjs';export{d as Tuple,a as Typeable,c as Valuable,b as isTypeable}from'./chunk-7PQA3W7W.mjs';export{a as Brand,g as BrandedBoolean,f as BrandedNumber,e as BrandedString,d as createBrander,c as hasBrand,b as unbrand}from'./chunk-TQJDL6YW.mjs';//# sourceMappingURL=index.mjs.map
|
|
2
2
|
//# sourceMappingURL=index.mjs.map
|
package/dist/list/index.d.ts
CHANGED
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
import '../branded/index.js';
|
|
1
|
+
export { L as List } from '../Either-BfXNbTHo.js';
|
|
2
|
+
import '../Valuable-CtuVEKTZ.js';
|
package/dist/list/index.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export{
|
|
1
|
+
export{g as List}from'../chunk-5DWCHDSA.mjs';import'../chunk-7PQA3W7W.mjs';import'../chunk-TQJDL6YW.mjs';//# sourceMappingURL=index.mjs.map
|
|
2
2
|
//# sourceMappingURL=index.mjs.map
|
package/dist/map/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
import '../
|
|
3
|
-
|
|
1
|
+
import '../Either-BfXNbTHo.js';
|
|
2
|
+
import '../Valuable-CtuVEKTZ.js';
|
|
3
|
+
export { M as Map, S as SafeTraversable } from '../Map-vivbm5n0.js';
|
|
4
|
+
import '../tuple/index.js';
|
package/dist/map/index.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export{
|
|
1
|
+
export{K as Map}from'../chunk-5DWCHDSA.mjs';import'../chunk-7PQA3W7W.mjs';import'../chunk-TQJDL6YW.mjs';//# sourceMappingURL=index.mjs.map
|
|
2
2
|
//# sourceMappingURL=index.mjs.map
|