@hazae41/glacier
Advanced tools
Comparing version 2.0.3 to 2.0.4
@@ -1,3 +0,3 @@ | ||
type Promiseable<T> = T | Promise<T> | PromiseLike<T>; | ||
type Awaitable<T> = T | Promise<T> | PromiseLike<T>; | ||
export type { Promiseable }; | ||
export type { Awaitable }; |
@@ -5,3 +5,3 @@ import { Mutex } from '@hazae41/mutex'; | ||
import { Result } from '@hazae41/result'; | ||
import { Promiseable } from '../../libs/promises/promises.js'; | ||
import { Awaitable } from '../../libs/promises/promises.js'; | ||
import { FetchedInit, Fetched } from '../fetched/fetched.js'; | ||
@@ -108,3 +108,3 @@ import { Mutator, Setter } from '../types/mutator.js'; | ||
deoptimize(cacheKey: string, uuid: string): Promise<void>; | ||
runWithTimeout<T>(callback: (signal: AbortSignal) => Promiseable<T>, aborter: AbortController, delay?: number): Promise<T>; | ||
runWithTimeout<T>(callback: (signal: AbortSignal) => Awaitable<T>, aborter: AbortController, delay?: number): Promise<T>; | ||
/** | ||
@@ -111,0 +111,0 @@ * Transform children into refs but do not normalize them |
import { Ok } from '@hazae41/result'; | ||
import { Promiseable } from '../../libs/promises/promises.js'; | ||
import { Awaitable } from '../../libs/promises/promises.js'; | ||
import { TimesInit, Times } from './times.js'; | ||
@@ -28,3 +28,3 @@ | ||
setTimes(times?: TimesInit): Data<T>; | ||
map<U>(mapper: (data: T) => Promiseable<U>): Promise<Data<U>>; | ||
map<U>(mapper: (data: T) => Awaitable<U>): Promise<Data<U>>; | ||
mapSync<U>(mapper: (data: T) => U): Data<U>; | ||
@@ -31,0 +31,0 @@ /** |
import { Err } from '@hazae41/result'; | ||
import { Promiseable } from '../../libs/promises/promises.js'; | ||
import { Awaitable } from '../../libs/promises/promises.js'; | ||
import { TimesInit, Times } from './times.js'; | ||
@@ -28,3 +28,3 @@ | ||
setTimes(times?: TimesInit): Fail<T>; | ||
mapErr<U>(mapper: (data: T) => Promiseable<U>): Promise<Fail<U>>; | ||
mapErr<U>(mapper: (data: T) => Awaitable<U>): Promise<Fail<U>>; | ||
mapErrSync<U>(mapper: (data: T) => U): Fail<U>; | ||
@@ -31,0 +31,0 @@ /** |
@@ -1,2 +0,3 @@ | ||
import { Ok, Err, Result } from '@hazae41/result'; | ||
import { Ok, Err, Result, Catched } from '@hazae41/result'; | ||
import { Awaitable } from '../../libs/promises/promises.js'; | ||
import { DataInit, Data } from './data.js'; | ||
@@ -20,4 +21,52 @@ import { FailInit, Fail } from './fail.js'; | ||
function rewrap<T extends Result.Infer<T>>(result: Timed<T>, times?: TimesInit): Fetched<Ok.Inner<T>, Err.Inner<T>>; | ||
/** | ||
* Run a callback and wrap any returned value in Ok<T> and any thrown error in Err<unknown> | ||
* @param callback | ||
* @returns | ||
*/ | ||
function runAndWrap<T>(callback: () => Awaitable<T>, times?: TimesInit): Promise<Fetched<T, unknown>>; | ||
/** | ||
* Run a callback and wrap any returned value in Ok<T> and any thrown error in Err<unknown> | ||
* @param callback | ||
* @returns | ||
*/ | ||
function runAndWrapSync<T>(callback: () => T, times?: TimesInit): Fetched<T, unknown>; | ||
/** | ||
* Run a callback and wrap any returned value in Ok<T> and any thrown error in Err<Catched> | ||
* @param callback | ||
* @returns | ||
*/ | ||
function runAndDoubleWrap<T>(callback: () => Awaitable<T>, times?: TimesInit): Promise<Fetched<T, Catched>>; | ||
/** | ||
* Run a callback and wrap any returned value in Ok<T> and any thrown error in Err<Catched> | ||
* @param callback | ||
* @returns | ||
*/ | ||
function runAndDoubleWrapSync<T>(callback: () => T, times?: TimesInit): Fetched<T, Catched>; | ||
/** | ||
* Run a callback and wrap any thrown error in Err<unknown> | ||
* @param callback | ||
* @returns | ||
*/ | ||
function runOrWrap<F extends Fetched.Infer<F>>(callback: () => Awaitable<F>, times?: TimesInit): Promise<F | Fail<unknown>>; | ||
/** | ||
* Run a callback and wrap any thrown error in Err<unknown> | ||
* @param callback | ||
* @returns | ||
*/ | ||
function runOrWrapSync<F extends Fetched.Infer<F>>(callback: () => F, times?: TimesInit): F | Fail<unknown>; | ||
/** | ||
* Run a callback and wrap any thrown error in Err<unknown> | ||
* @param callback | ||
* @returns | ||
*/ | ||
function runOrDoubleWrap<F extends Fetched.Infer<F>>(callback: () => Awaitable<F>, times?: TimesInit): Promise<F | Fail<Catched>>; | ||
/** | ||
* Run a callback and wrap any thrown error in Err<unknown> | ||
* @param callback | ||
* @returns | ||
*/ | ||
function runOrDoubleWrapSync<F extends Result.Infer<F>>(callback: () => F, times?: TimesInit): F | Fail<Catched>; | ||
} | ||
export { Fetched, FetchedInit }; |
@@ -1,2 +0,2 @@ | ||
import { Promiseable } from '../../libs/promises/promises.js'; | ||
import { Awaitable } from '../../libs/promises/promises.js'; | ||
import { RawState } from '../types/state.js'; | ||
@@ -11,3 +11,3 @@ | ||
*/ | ||
getOrThrow?(cacheKey: string): Promiseable<RawState>; | ||
getOrThrow?(cacheKey: string): Awaitable<RawState>; | ||
/** | ||
@@ -20,5 +20,5 @@ * Set the given data to the given key | ||
*/ | ||
setOrThrow?(cacheKey: string, value: RawState): Promiseable<void>; | ||
setOrThrow?(cacheKey: string, value: RawState): Awaitable<void>; | ||
} | ||
export type { Storage }; |
@@ -1,5 +0,5 @@ | ||
import { Promiseable } from '../../libs/promises/promises.js'; | ||
import { Awaitable } from '../../libs/promises/promises.js'; | ||
import { FetchedInit } from '../fetched/fetched.js'; | ||
type Fetcher<K, D, F> = (key: K, more: FetcherMore) => Promiseable<FetchedInit<D, F>>; | ||
type Fetcher<K, D, F> = (key: K, more: FetcherMore) => Awaitable<FetchedInit<D, F>>; | ||
interface FetcherMore { | ||
@@ -6,0 +6,0 @@ readonly signal?: AbortSignal; |
import { Option, Nullable } from '@hazae41/option'; | ||
import { Promiseable } from '../../libs/promises/promises.js'; | ||
import { Awaitable } from '../../libs/promises/promises.js'; | ||
import { FetchedInit } from '../fetched/fetched.js'; | ||
import { State } from './state.js'; | ||
type Mutator<D, F> = (previous: State<D, F>) => Promiseable<Option<Nullable<FetchedInit<D, F>>>>; | ||
type Setter<D, F> = (previous: State<D, F>) => Promiseable<State<D, F>>; | ||
type Mutator<D, F> = (previous: State<D, F>) => Awaitable<Option<Nullable<FetchedInit<D, F>>>>; | ||
type Setter<D, F> = (previous: State<D, F>) => Awaitable<State<D, F>>; | ||
export type { Mutator, Setter }; |
{ | ||
"type": "module", | ||
"name": "@hazae41/glacier", | ||
"version": "2.0.3", | ||
"version": "2.0.4", | ||
"author": "hazae41", | ||
@@ -6,0 +6,0 @@ "license": "MIT", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
597118
6466