@idb-orm/core 1.0.8 → 1.0.9

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.
@@ -0,0 +1,46 @@
1
+ /**
2
+ * Extracts the string keys of an object
3
+ */
4
+ export type Keyof<T extends Record<any, any>> = Extract<keyof T, string>;
5
+ export type Arrayable<T> = T | T[];
6
+ export type IsNever<T> = [T] extends [never] ? true : false;
7
+ export type Promisable<T> = T | Promise<T>;
8
+ export type NoUndefined<T> = Exclude<T, undefined>;
9
+ export type Extends<T, K> = T extends K ? true : false;
10
+ export type And<T, K> = T extends true ? K extends true ? true : false : false;
11
+ export type Or<T, K> = T extends true ? true : K extends true ? true : false;
12
+ export type MakeOptional<B extends boolean, T> = B extends true ? T | undefined : T;
13
+ export type MakeRequired<B extends boolean, T> = B extends true ? NonNullable<T> : T;
14
+ export type Simplify<T> = {
15
+ [K in keyof T]: T[K];
16
+ } & {};
17
+ export type MakeArray<B extends boolean, T> = B extends true ? T[] : T;
18
+ export type MakeArrayable<B extends boolean, T> = B extends true ? Arrayable<T> : T;
19
+ export type If<Type extends boolean, IfBranch, ElseBranch> = IsNever<Type> extends true ? ElseBranch : Type extends true ? IfBranch : ElseBranch;
20
+ export type RemoveNeverValues<T extends object> = {
21
+ [K in keyof T as T[K] extends never ? never : K]: T[K];
22
+ };
23
+ /**
24
+ * A type representing a dictionary from string to some type
25
+ */
26
+ export type Dict<T = unknown> = Record<string, T>;
27
+ type UndefinedKeys<T extends Dict> = {
28
+ [K in Keyof<T>]: undefined extends T[K] ? K : never;
29
+ }[Keyof<T>];
30
+ type Optional<T extends Dict> = Partial<Pick<T, UndefinedKeys<T>>>;
31
+ type Required<T extends Dict> = Omit<T, UndefinedKeys<T>>;
32
+ export type PartialOnUndefined<T extends Dict> = Required<T> & Optional<T>;
33
+ /**
34
+ * Types that can be resolved to specific boolean values
35
+ */
36
+ export type BooleanLike = boolean | undefined | null | 0;
37
+ export type Literable = string | number | bigint | boolean | null | undefined;
38
+ export type SinglularKey<T extends Record<string, any>> = {
39
+ [K in keyof T]: {
40
+ [P in K]: T[P];
41
+ } & {
42
+ [Q in Exclude<keyof T, K>]?: never;
43
+ };
44
+ }[keyof T];
45
+ export type Ctor<T> = new (...args: any[]) => T;
46
+ export {};
@@ -0,0 +1,18 @@
1
+ import { Arrayable, Keyof } from './util-types';
2
+ import { Transaction } from './transaction.js';
3
+ export declare function handleRequest<T>(req: IDBRequest<T>, tx?: Transaction<any, any>): Promise<T>;
4
+ export declare function getKeys<T extends object>(obj: T): Keyof<T>[];
5
+ export declare function addToSet<T>(set: Set<T>, items: T[]): Set<T>;
6
+ export declare function toArray<T>(value: Arrayable<T>): T[];
7
+ export declare function uuid(): `${string}-${string}-${string}-${string}-${string}`;
8
+ export declare function getDate(): Date;
9
+ /**
10
+ * Identity Function, it returns the first argument it is given, all others are ignored
11
+ * @param value Value
12
+ * @returns Same Value
13
+ */
14
+ export declare function identity<T>(value: T): T;
15
+ /**
16
+ * Performs a union over `set1` and `set2`, modifying `set1` to be union of the two sets
17
+ */
18
+ export declare function unionSets<T>(set: Set<T>, other: Set<T>): Set<T>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@idb-orm/core",
3
- "version": "1.0.8",
3
+ "version": "1.0.9",
4
4
  "description": "",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",