@hazae41/glacier
Advanced tools
Comparing version 2.1.4 to 2.2.0
@@ -7,7 +7,6 @@ import * as index from './mods/index.js'; | ||
export { AsyncStorageError, CooldownError, Core, MissingFetcherError, MissingKeyError, TimeoutError, core } from './mods/core/core.js'; | ||
export { Equalsable } from './mods/equals/equals.js'; | ||
export { Data, DataInit } from './mods/fetched/data.js'; | ||
export { Fail, FailInit } from './mods/fetched/fail.js'; | ||
export { Fetched, FetchedInit } from './mods/fetched/fetched.js'; | ||
export { DelaysInit, Times, TimesInit } from './mods/fetched/times.js'; | ||
export { Cached, CachedInit, Timed, TimedInit } from './mods/fetched/times.js'; | ||
export { ScrollError, Scrollable } from './mods/queries/scroll/helper.js'; | ||
@@ -30,2 +29,3 @@ export { ScrollableFetcherfulQuery, ScrollableFetcherlessQuery, ScrollableQuery, createScrollableQuery } from './mods/queries/scroll/query.js'; | ||
export { FetcherfulReactQuery, FetcherlessReactQuery, ReactQuery, ReactQueryLike, SkeletonReactQuery } from './mods/react/types/query.js'; | ||
export { JsonRequest, JsonRequestInit, TextRequest, TextRequestInit } from './mods/requests/index.js'; | ||
export { Collected, Collector, KeyValueCoders, SeracQueryStorage, SeracQueryStorageParams, useSeracStorage } from './mods/storages/serac/index.js'; | ||
@@ -32,0 +32,0 @@ export { QueryStorage } from './mods/storages/storage.js'; |
@@ -1,7 +0,6 @@ | ||
import { Nullable } from '@hazae41/option'; | ||
import { Ok } from '@hazae41/result'; | ||
import { Awaitable } from '../../libs/promises/promises.js'; | ||
import { TimesInit, Times } from './times.js'; | ||
import { TimedInit, CachedInit, Timed, Cached } from './times.js'; | ||
interface DataInit<T> extends TimesInit { | ||
interface DataInit<T> extends TimedInit, CachedInit { | ||
readonly data: T; | ||
@@ -17,8 +16,8 @@ } | ||
} | ||
declare class Data<T> extends Ok<T> implements DataInit<T>, Times { | ||
declare class Data<T> extends Ok<T> implements DataInit<T>, Timed, Cached { | ||
readonly data: T; | ||
readonly time: number; | ||
readonly cooldown?: Nullable<number>; | ||
readonly expiration?: Nullable<number>; | ||
constructor(data: T, times?: TimesInit); | ||
readonly cooldown?: number; | ||
readonly expiration?: number; | ||
constructor(data: T, init?: TimedInit & CachedInit); | ||
static from<T>(init: DataInit<T>): Data<T>; | ||
@@ -29,3 +28,3 @@ isData(): this is Data<T>; | ||
setErr(inner: unknown): this; | ||
setTimes(times?: TimesInit): Data<T>; | ||
setInit(init?: TimedInit & CachedInit): Data<T>; | ||
map<U>(mapper: (data: T) => Awaitable<U>): Promise<Data<U>>; | ||
@@ -32,0 +31,0 @@ mapSync<U>(mapper: (data: T) => U): Data<U>; |
@@ -1,7 +0,6 @@ | ||
import { Nullable } from '@hazae41/option'; | ||
import { Err } from '@hazae41/result'; | ||
import { Awaitable } from '../../libs/promises/promises.js'; | ||
import { TimesInit, Times } from './times.js'; | ||
import { TimedInit, CachedInit, Timed, Cached } from './times.js'; | ||
interface FailInit<T> extends TimesInit { | ||
interface FailInit<T> extends TimedInit, CachedInit { | ||
readonly error: T; | ||
@@ -17,8 +16,8 @@ } | ||
} | ||
declare class Fail<T> extends Err<T> implements FailInit<T>, Times { | ||
declare class Fail<T> extends Err<T> implements FailInit<T>, Timed, Cached { | ||
readonly error: T; | ||
readonly time: number; | ||
readonly cooldown?: Nullable<number>; | ||
readonly expiration?: Nullable<number>; | ||
constructor(error: T, times?: TimesInit); | ||
readonly cooldown?: number; | ||
readonly expiration?: number; | ||
constructor(error: T, init?: TimedInit & CachedInit); | ||
static from<T>(init: FailInit<T>): Fail<T>; | ||
@@ -29,3 +28,3 @@ isData(): false; | ||
setErr<U>(inner: U): Fail<U>; | ||
setTimes(times?: TimesInit): Fail<T>; | ||
setInit(init?: TimedInit & CachedInit): Fail<T>; | ||
mapErr<U>(mapper: (data: T) => Awaitable<U>): Promise<Fail<U>>; | ||
@@ -32,0 +31,0 @@ mapErrSync<U>(mapper: (data: T) => U): Fail<U>; |
@@ -5,3 +5,3 @@ import { Ok, Err, Result } from '@hazae41/result'; | ||
import { FailInit, Fail } from './fail.js'; | ||
import { Times, TimesInit } from './times.js'; | ||
import { Timed, Cached, TimedInit, CachedInit } from './times.js'; | ||
@@ -16,8 +16,5 @@ type FetchedInit<D, F> = DataInit<D> | FailInit<F>; | ||
function from<T extends FetchedInit.Infer<T>>(init: T): Fetched<DataInit.Inner<T>, FailInit.Inner<T>>; | ||
interface Timed { | ||
readonly times?: Times; | ||
} | ||
function rewrap<T extends Ok.Infer<T>>(result: T & Timed, times?: TimesInit): Data<Ok.Inner<T>>; | ||
function rewrap<T extends Err.Infer<T>>(result: T & Timed, times?: TimesInit): Fail<Err.Inner<T>>; | ||
function rewrap<T extends Result.Infer<T>>(result: T & Timed, times?: TimesInit): Fetched<Ok.Inner<T>, Err.Inner<T>>; | ||
function rewrap<T extends Ok.Infer<T>>(result: T & Timed & Cached, init?: TimedInit & CachedInit): Data<Ok.Inner<T>>; | ||
function rewrap<T extends Err.Infer<T>>(result: T & Timed & Cached, init?: TimedInit & CachedInit): Fail<Err.Inner<T>>; | ||
function rewrap<T extends Result.Infer<T>>(result: T & Timed & Cached, init?: TimedInit & CachedInit): Fetched<Ok.Inner<T>, Err.Inner<T>>; | ||
/** | ||
@@ -28,3 +25,3 @@ * Run a callback and wrap any returned value in Ok<T> and any thrown error in Err<unknown> | ||
*/ | ||
function runAndWrap<T>(callback: () => Awaitable<T>, times?: TimesInit): Promise<Fetched<T, unknown>>; | ||
function runAndWrap<T>(callback: () => Awaitable<T>, init?: TimedInit & CachedInit): Promise<Fetched<T, unknown>>; | ||
/** | ||
@@ -35,3 +32,3 @@ * Run a callback and wrap any returned value in Ok<T> and any thrown error in Err<unknown> | ||
*/ | ||
function runAndWrapSync<T>(callback: () => T, times?: TimesInit): Fetched<T, unknown>; | ||
function runAndWrapSync<T>(callback: () => T, init?: TimedInit & CachedInit): Fetched<T, unknown>; | ||
/** | ||
@@ -42,3 +39,3 @@ * Run a callback and wrap any returned value in Ok<T> and any thrown error in Err<Catched> | ||
*/ | ||
function runAndDoubleWrap<T>(callback: () => Awaitable<T>, times?: TimesInit): Promise<Fetched<T, Error>>; | ||
function runAndDoubleWrap<T>(callback: () => Awaitable<T>, init?: TimedInit & CachedInit): Promise<Fetched<T, Error>>; | ||
/** | ||
@@ -49,3 +46,3 @@ * Run a callback and wrap any returned value in Ok<T> and any thrown error in Err<Catched> | ||
*/ | ||
function runAndDoubleWrapSync<T>(callback: () => T, times?: TimesInit): Fetched<T, Error>; | ||
function runAndDoubleWrapSync<T>(callback: () => T, init?: TimedInit & CachedInit): Fetched<T, Error>; | ||
/** | ||
@@ -56,3 +53,3 @@ * Run a callback and wrap any thrown error in Err<unknown> | ||
*/ | ||
function runOrWrap<F extends Fetched.Infer<F>>(callback: () => Awaitable<F>, times?: TimesInit): Promise<F | Fail<unknown>>; | ||
function runOrWrap<F extends Fetched.Infer<F>>(callback: () => Awaitable<F>, init?: TimedInit & CachedInit): Promise<F | Fail<unknown>>; | ||
/** | ||
@@ -63,3 +60,3 @@ * Run a callback and wrap any thrown error in Err<unknown> | ||
*/ | ||
function runOrWrapSync<F extends Fetched.Infer<F>>(callback: () => F, times?: TimesInit): F | Fail<unknown>; | ||
function runOrWrapSync<F extends Fetched.Infer<F>>(callback: () => F, init?: TimedInit & CachedInit): F | Fail<unknown>; | ||
/** | ||
@@ -70,3 +67,3 @@ * Run a callback and wrap any thrown error in Err<unknown> | ||
*/ | ||
function runOrDoubleWrap<F extends Fetched.Infer<F>>(callback: () => Awaitable<F>, times?: TimesInit): Promise<F | Fail<Error>>; | ||
function runOrDoubleWrap<F extends Fetched.Infer<F>>(callback: () => Awaitable<F>, init?: TimedInit & CachedInit): Promise<F | Fail<Error>>; | ||
/** | ||
@@ -77,5 +74,5 @@ * Run a callback and wrap any thrown error in Err<unknown> | ||
*/ | ||
function runOrDoubleWrapSync<F extends Result.Infer<F>>(callback: () => F, times?: TimesInit): F | Fail<Error>; | ||
function runOrDoubleWrapSync<F extends Result.Infer<F>>(callback: () => F, init: TimedInit & CachedInit): F | Fail<Error>; | ||
} | ||
export { Fetched, FetchedInit }; |
@@ -1,21 +0,16 @@ | ||
import { Nullable } from '@hazae41/option'; | ||
interface Times { | ||
interface Timed { | ||
readonly time: number; | ||
readonly cooldown?: Nullable<number>; | ||
readonly expiration?: Nullable<number>; | ||
} | ||
interface DelaysInit { | ||
readonly cooldown?: Nullable<number>; | ||
readonly expiration?: Nullable<number>; | ||
interface TimedInit { | ||
readonly time?: number; | ||
} | ||
interface TimesInit { | ||
readonly time?: Nullable<number>; | ||
readonly cooldown?: Nullable<number>; | ||
readonly expiration?: Nullable<number>; | ||
interface Cached { | ||
readonly cooldown?: number; | ||
readonly expiration?: number; | ||
} | ||
declare namespace TimesInit { | ||
function merge(times: TimesInit, delays?: DelaysInit): TimesInit; | ||
interface CachedInit { | ||
readonly cooldown?: number; | ||
readonly expiration?: number; | ||
} | ||
export { type DelaysInit, type Times, TimesInit }; | ||
export type { Cached, CachedInit, Timed, TimedInit }; |
@@ -5,7 +5,6 @@ export { AsyncBicoder, AsyncEncoder, AsyncPipeBicoder, AsyncPipeEncoder, Bicoder, Encoder, Identity, Jsoned, SyncBicoder, SyncEncoder, SyncPipeBicoder, SyncPipeEncoder } from './coders/coder.js'; | ||
export { AsyncStorageError, CooldownError, Core, MissingFetcherError, MissingKeyError, TimeoutError, core } from './core/core.js'; | ||
export { Equalsable } from './equals/equals.js'; | ||
export { Data, DataInit } from './fetched/data.js'; | ||
export { Fail, FailInit } from './fetched/fail.js'; | ||
export { Fetched, FetchedInit } from './fetched/fetched.js'; | ||
export { DelaysInit, Times, TimesInit } from './fetched/times.js'; | ||
export { Cached, CachedInit, Timed, TimedInit } from './fetched/times.js'; | ||
export { ScrollError, Scrollable } from './queries/scroll/helper.js'; | ||
@@ -28,2 +27,3 @@ export { ScrollableFetcherfulQuery, ScrollableFetcherlessQuery, ScrollableQuery, createScrollableQuery } from './queries/scroll/query.js'; | ||
export { FetcherfulReactQuery, FetcherlessReactQuery, ReactQuery, ReactQueryLike, SkeletonReactQuery } from './react/types/query.js'; | ||
export { JsonRequest, JsonRequestInit, TextRequest, TextRequestInit } from './requests/index.js'; | ||
export { Collected, Collector, KeyValueCoders, SeracQueryStorage, SeracQueryStorageParams, useSeracStorage } from './storages/serac/index.js'; | ||
@@ -30,0 +30,0 @@ export { QueryStorage } from './storages/storage.js'; |
@@ -21,3 +21,3 @@ import { ScrollableFetcherfulQuerySettings } from '../../types/settings.js'; | ||
*/ | ||
function fetchOrThrow<K, D, F>(cacheKey: string, presignal: AbortSignal, settings: ScrollableFetcherfulQuerySettings<K, D, F>): Promise<State<D[], F>>; | ||
function fetchOrThrow<K, D, F>(cacheKey: string, signal: AbortSignal, settings: ScrollableFetcherfulQuerySettings<K, D, F>): Promise<State<D[], F>>; | ||
/** | ||
@@ -33,5 +33,5 @@ * Scroll to the next page | ||
*/ | ||
function scrollOrThrow<K, D, F>(cacheKey: string, presignal: AbortSignal, settings: ScrollableFetcherfulQuerySettings<K, D, F>): Promise<State<D[], F>>; | ||
function scrollOrThrow<K, D, F>(cacheKey: string, signal: AbortSignal, settings: ScrollableFetcherfulQuerySettings<K, D, F>): Promise<State<D[], F>>; | ||
} | ||
export { ScrollError, Scrollable }; |
@@ -7,3 +7,3 @@ import { FetcherfulQuerySettings } from '../../types/settings.js'; | ||
function getCacheKey<K>(key: K): string; | ||
function fetchOrThrow<K, D, F>(cacheKey: string, presignal: AbortSignal, settings: FetcherfulQuerySettings<K, D, F>): Promise<State<D, F>>; | ||
function fetchOrThrow<K, D, F>(cacheKey: string, signal: AbortSignal, settings: FetcherfulQuerySettings<K, D, F>): Promise<State<D, F>>; | ||
/** | ||
@@ -19,5 +19,5 @@ * Optimistic update | ||
*/ | ||
function updateOrThrow<K, D, F>(cacheKey: string, updater: Updater<K, D, F>, presignal: AbortSignal, settings: FetcherfulQuerySettings<K, D, F>): Promise<State<D, F>>; | ||
function updateOrThrow<K, D, F>(cacheKey: string, updater: Updater<K, D, F>, signal: AbortSignal, settings: FetcherfulQuerySettings<K, D, F>): Promise<State<D, F>>; | ||
} | ||
export { Simple }; |
@@ -16,5 +16,2 @@ import { Nullable } from '@hazae41/option'; | ||
readonly key?: K; | ||
readonly timeout?: number; | ||
readonly cooldown?: number; | ||
readonly expiration?: number; | ||
readonly fetcher?: Fetcher<K, D, F>; | ||
@@ -21,0 +18,0 @@ readonly normalizer?: Normalizer<D, F>; |
@@ -14,5 +14,2 @@ import { QueryStorage } from '../storages/storage.js'; | ||
readonly key?: K; | ||
readonly timeout?: number; | ||
readonly cooldown?: number; | ||
readonly expiration?: number; | ||
readonly fetcher?: Fetcher<K, D, F>; | ||
@@ -28,5 +25,2 @@ readonly normalizer?: Normalizer<D, F>; | ||
readonly key: K; | ||
readonly timeout?: number; | ||
readonly cooldown?: number; | ||
readonly expiration?: number; | ||
readonly fetcher: Fetcher<K, D, F>; | ||
@@ -42,5 +36,2 @@ readonly normalizer?: Normalizer<D, F>; | ||
readonly key: K; | ||
readonly timeout?: number; | ||
readonly cooldown?: number; | ||
readonly expiration?: number; | ||
readonly fetcher?: undefined; | ||
@@ -47,0 +38,0 @@ readonly normalizer?: Normalizer<D, F>; |
@@ -1,2 +0,1 @@ | ||
import { Nullable } from '@hazae41/option'; | ||
import { DataInit, Data } from '../fetched/data.js'; | ||
@@ -11,4 +10,4 @@ import { FailInit, Fail } from '../fetched/fail.js'; | ||
readonly time: number; | ||
readonly cooldown?: Nullable<number>; | ||
readonly expiration?: Nullable<number>; | ||
readonly cooldown?: number; | ||
readonly expiration?: number; | ||
} | ||
@@ -20,4 +19,4 @@ interface RawState2<D = unknown, F = unknown> { | ||
readonly time: number; | ||
readonly cooldown?: Nullable<number>; | ||
readonly expiration?: Nullable<number>; | ||
readonly cooldown?: number; | ||
readonly expiration?: number; | ||
} | ||
@@ -30,4 +29,4 @@ interface RawState3<K = unknown, D = unknown, F = unknown> { | ||
readonly time: number; | ||
readonly cooldown?: Nullable<number>; | ||
readonly expiration?: Nullable<number>; | ||
readonly cooldown?: number; | ||
readonly expiration?: number; | ||
} | ||
@@ -34,0 +33,0 @@ interface StateAndAborter<D, F> { |
{ | ||
"type": "module", | ||
"name": "@hazae41/glacier", | ||
"version": "2.1.4", | ||
"version": "2.2.0", | ||
"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
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
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
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
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
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
646574
6369