mirror of
https://github.com/excalidraw/excalidraw.git
synced 2025-05-03 10:00:07 -04:00
feat: store library to IndexedDB & support storage adapters (#7655)
This commit is contained in:
parent
480572f893
commit
2382fad4f6
14 changed files with 718 additions and 95 deletions
|
@ -14,7 +14,7 @@ import {
|
|||
UnsubscribeCallback,
|
||||
Zoom,
|
||||
} from "./types";
|
||||
import { ResolutionType } from "./utility-types";
|
||||
import { MaybePromise, ResolutionType } from "./utility-types";
|
||||
|
||||
let mockDateTime: string | null = null;
|
||||
|
||||
|
@ -538,7 +538,9 @@ export const isTransparent = (color: string) => {
|
|||
};
|
||||
|
||||
export type ResolvablePromise<T> = Promise<T> & {
|
||||
resolve: [T] extends [undefined] ? (value?: T) => void : (value: T) => void;
|
||||
resolve: [T] extends [undefined]
|
||||
? (value?: MaybePromise<Awaited<T>>) => void
|
||||
: (value: MaybePromise<Awaited<T>>) => void;
|
||||
reject: (error: Error) => void;
|
||||
};
|
||||
export const resolvablePromise = <T>() => {
|
||||
|
@ -1090,3 +1092,13 @@ export const toBrandedType = <BrandedType, CurrentType = BrandedType>(
|
|||
};
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
// Promise.try, adapted from https://github.com/sindresorhus/p-try
|
||||
export const promiseTry = async <TValue, TArgs extends unknown[]>(
|
||||
fn: (...args: TArgs) => PromiseLike<TValue> | TValue,
|
||||
...args: TArgs
|
||||
): Promise<TValue> => {
|
||||
return new Promise((resolve) => {
|
||||
resolve(fn(...args));
|
||||
});
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue