xy
Type Aliases
XY
type XY<T> = [T, T];
Defined in: dom/src/xy.ts:5
A pair of per-axis values. The tuple elements are labelled, so editors show
[x: number, y: number] rather than a bare pair.
Type Parameters
| Type Parameter |
|---|
T |
XYInput
type XYInput<T> = [T] extends [readonly unknown[]] ? readonly [T, T] : T | readonly [T, T];
Defined in: dom/src/xy.ts:14
A setting that may be given once for both axes, or per axis.
A single value is told from a pair with Array.isArray, so the single form
is only offered while T cannot itself be an array. Where it can, the pair
is the only way to write it, since a lone array would be read as a pair.
Type Parameters
| Type Parameter |
|---|
T |
Functions
toXY()
function toXY<T>(value): XY<T>;
Defined in: dom/src/xy.ts:36
Spread a setting that may have been given as a single value.
The parameter is written out rather than taken as XYInput<T>: a
conditional type cannot be narrowed, so the constraint stays where it is
declared and this takes both forms.
The pair is copied rather than passed along, so that the result is a tuple the caller owns even when a readonly one was given.
Type Parameters
| Type Parameter |
|---|
T |
Parameters
| Parameter | Type |
|---|---|
value | T | readonly [T, T] |
Returns
XY<T>