@mui/toolpad-utils
Advanced tools
Comparing version 0.1.17 to 0.1.18
@@ -13,7 +13,5 @@ declare global { | ||
} | ||
export declare function serializeError(error: Error & { | ||
code?: unknown; | ||
}): SerializedError; | ||
export declare function serializeError(error: Error): SerializedError; | ||
/** | ||
* Creates a javascript `Error` from an unkown value if it's not already an error. | ||
* Creates a javascript `Error` from an unknown value if it's not already an error. | ||
* Does a best effort at inferring a message. Intended to be used typically in `catch` | ||
@@ -27,3 +25,3 @@ * blocks, as there is no way to enforce only `Error` objects being thrown. | ||
* const error = errorFrom(rawError); | ||
* console.assert(error instancof Error); | ||
* console.assert(error instanceof Error); | ||
* } | ||
@@ -30,0 +28,0 @@ * ``` |
import { | ||
errorFrom, | ||
serializeError | ||
} from "./chunk-22SQFP4C.js"; | ||
} from "./chunk-EWC6WHDG.js"; | ||
import "./chunk-DP5G656E.js"; | ||
@@ -6,0 +6,0 @@ import "./chunk-KHQ5PB5A.js"; |
export type EventName = string | symbol; | ||
export type EventHandler<T = unknown> = (event: T) => void; | ||
export type AllEventsHandler<T extends Record<EventName, unknown>, K extends keyof T = keyof T> = (type: keyof T, event: T[K]) => void; | ||
export type EventHandlers = Record<EventName, unknown>; | ||
export type EventHandler<T extends EventHandlers, K extends keyof T = keyof T> = (event: T[K]) => void; | ||
export type AllEventsHandler<T extends EventHandlers, K extends keyof T = keyof T> = (type: K, event: T[K]) => void; | ||
/** | ||
* Lightweight event emitter | ||
*/ | ||
export declare class Emitter<T extends Record<EventName, unknown> = {}> { | ||
export declare class Emitter<T extends EventHandlers = {}> { | ||
private handlers; | ||
@@ -13,15 +14,15 @@ /** | ||
on(name: '*', handler: AllEventsHandler<T>): void; | ||
on<K extends keyof T>(name: K, handler: EventHandler<T[K]>): void; | ||
on<K extends keyof T>(name: K, handler: EventHandler<T, K>): void; | ||
/** | ||
* Remove a listener from an event | ||
*/ | ||
off<K extends keyof T>(name: K, handler: EventHandler<T[K]>): void; | ||
off<K extends keyof T>(name: K, handler: EventHandler<T, K>): void; | ||
/** | ||
* Subscribe to an event and return an unsubscribe function. | ||
*/ | ||
subscribe<K extends keyof T>(name: K, handler: EventHandler<T[K]>): () => void; | ||
subscribe<K extends keyof T>(name: K, handler: EventHandler<T, K>): () => void; | ||
/** | ||
* Emit an event. | ||
*/ | ||
emit<K extends keyof T>(name: K, event: T[K] extends undefined ? void | undefined : T[K]): void; | ||
emit<K extends keyof T>(name: K, event: T[K]): void; | ||
} |
import { | ||
Emitter | ||
} from "./chunk-P4EBKAZE.js"; | ||
} from "./chunk-WJUTEAU5.js"; | ||
export { | ||
@@ -5,0 +5,0 @@ Emitter |
@@ -9,3 +9,3 @@ /// <reference types="node" /> | ||
*/ | ||
export declare function readJsonFile(filePath: string, reviver?: Reviver): Promise<any>; | ||
export declare function readJsonFile(filePath: string, reviver?: Reviver): Promise<unknown>; | ||
export declare function readMaybeFile(filePath: string): Promise<string | null>; | ||
@@ -12,0 +12,0 @@ export declare function readMaybeDir(dirPath: string): Promise<Dirent[] | null>; |
import { | ||
errorFrom | ||
} from "./chunk-22SQFP4C.js"; | ||
} from "./chunk-EWC6WHDG.js"; | ||
import "./chunk-DP5G656E.js"; | ||
@@ -5,0 +5,0 @@ import "./chunk-KHQ5PB5A.js"; |
import { | ||
Emitter | ||
} from "./chunk-P4EBKAZE.js"; | ||
} from "./chunk-WJUTEAU5.js"; | ||
@@ -5,0 +5,0 @@ // src/react.tsx |
{ | ||
"name": "@mui/toolpad-utils", | ||
"version": "0.1.17", | ||
"version": "0.1.18", | ||
"description": "Build MUI apps quickly", | ||
@@ -61,5 +61,5 @@ "author": "MUI Toolpad team", | ||
"devDependencies": { | ||
"@types/react-is": "18.2.0" | ||
"@types/react-is": "18.2.1" | ||
}, | ||
"gitHead": "c8b22003698070cd85b6fc336c05f5645f45da24" | ||
"gitHead": "08fb1bad6e60086d1b775f377101b88b3d1a9e5d" | ||
} |
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
137067
1610