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