novy-syndicate/src/gen/worker.ts

43 lines
1.4 KiB
TypeScript

import * as _ from "@preserves/core";
import * as _i_Actor from "../runtime/actor";
export const $Instance = Symbol.for("Instance");
export type _ptr = _i_Actor.Ref;
export type _val = _.Value<_ptr>;
export type Instance = {"name": string, "argument": _val};
export const _toPtr = (v: _val) => {let result: undefined | _ptr; result = _i_Actor.toRef(v); return result;};
export function Instance({name, argument}: {name: string, argument: _val}): Instance {return {"name": name, "argument": argument};}
export function asInstance(v: _val): Instance {
let result = toInstance(v);
if (result === void 0) throw new TypeError(`Invalid Instance: ${_.stringify(v)}`);
return result;
}
export function toInstance(v: _val): undefined | Instance {
let result: undefined | Instance;
if (_.Record.isRecord<_val, _.Tuple<_val>, _ptr>(v)) {
let _tmp0: (null) | undefined;
_tmp0 = _.is(v.label, $Instance) ? null : void 0;
if (_tmp0 !== void 0) {
let _tmp1: (string) | undefined;
_tmp1 = typeof v[0] === 'string' ? v[0] : void 0;
if (_tmp1 !== void 0) {
let _tmp2: (_val) | undefined;
_tmp2 = v[1];
if (_tmp2 !== void 0) {result = {"name": _tmp1, "argument": _tmp2};};
};
};
};
return result;
}
export function fromInstance(_v: Instance): _val {return _.Record($Instance, [_v["name"], _v["argument"]]);}