Rename folder
[poolifier.git] / src / utility-types.ts
... / ...
CommitLineData
1/**
2 * Make all properties in T non-readonly
3 */
4export type Draft<T> = { -readonly [P in keyof T]?: T[P] }
5
6/**
7 * Serializable primitive JSON value.
8 */
9export type JSONPrimitive = number | boolean | string | null
10/**
11 * Serializable JSON value.
12 */
13// eslint-disable-next-line no-use-before-define
14export type JSONValue = JSONPrimitive | JSONArray | JSONObject
15/**
16 * Serializable JSON object.
17 */
18export type JSONObject = { [k: string]: JSONValue }
19/**
20 * Serializable JSON array.
21 */
22export type JSONArray = Array<JSONValue>
23
24/**
25 * Message object that is passed between worker and main worker.
26 */
27export interface MessageValue<Data = unknown> {
28 /**
29 * Input data that will be passed to the worker.
30 */
31 readonly data?: Data
32 /**
33 * ID of the message.
34 */
35 readonly id?: number
36 /**
37 * Kill code.
38 */
39 readonly kill?: number
40 /**
41 * Error.
42 */
43 readonly error?: string
44 /**
45 * Reference to main worker.
46 *
47 * _Only for internal use_
48 */
49 readonly parent?: MessagePort
50}