44 lines
1.3 KiB
TypeScript
44 lines
1.3 KiB
TypeScript
import * as _ from "@preserves/core";
|
|
import * as _i_Actor from "../actor";
|
|
|
|
export const $BoxState = Symbol.for("BoxState");
|
|
export const $SetBox = Symbol.for("SetBox");
|
|
|
|
export const BoxState = _.Record.makeConstructor<{"_field0": number}, _ptr>()($BoxState, ["_field0"]);
|
|
|
|
export type BoxState = _.Record<(typeof $BoxState), [number], _ptr>;
|
|
|
|
export const SetBox = _.Record.makeConstructor<{"_field0": number}, _ptr>()($SetBox, ["_field0"]);
|
|
|
|
export type SetBox = _.Record<(typeof $SetBox), [number], _ptr>;
|
|
|
|
export type _ptr = _i_Actor.Ref;
|
|
|
|
export type _val = _.Value<_ptr>;
|
|
|
|
|
|
export function isBoxState(v: any): v is BoxState {
|
|
return (
|
|
_.Record.isRecord<_val, _.Tuple<_val>, _ptr>(v) &&
|
|
_.is(v.label, $BoxState) &&
|
|
((v.length === 1) && typeof v[0] === 'number')
|
|
);
|
|
}
|
|
|
|
export function asBoxState(v: any): BoxState {
|
|
if (!isBoxState(v)) {throw new TypeError(`Invalid BoxState: ${_.stringify(v)}`);} else {return v;};
|
|
}
|
|
|
|
export function isSetBox(v: any): v is SetBox {
|
|
return (
|
|
_.Record.isRecord<_val, _.Tuple<_val>, _ptr>(v) &&
|
|
_.is(v.label, $SetBox) &&
|
|
((v.length === 1) && typeof v[0] === 'number')
|
|
);
|
|
}
|
|
|
|
export function asSetBox(v: any): SetBox {
|
|
if (!isSetBox(v)) {throw new TypeError(`Invalid SetBox: ${_.stringify(v)}`);} else {return v;};
|
|
}
|
|
|