2022-08-27 17:46:43 +00:00
|
|
|
import * as RSModuleValue from "../rescript/ForTS/ForTS_SquiggleValue/ForTS_SquiggleValue_Module.gen";
|
2022-08-28 17:45:15 +00:00
|
|
|
import { SqModuleValue, wrapValue } from "./SqValue";
|
2022-08-29 21:51:44 +00:00
|
|
|
import { SqValueLocation } from "./SqValueLocation";
|
2022-08-27 17:46:43 +00:00
|
|
|
|
2022-08-28 16:19:44 +00:00
|
|
|
export class SqModule {
|
2022-08-29 21:51:44 +00:00
|
|
|
constructor(
|
|
|
|
private _value: RSModuleValue.squiggleValue_Module,
|
|
|
|
public location: SqValueLocation
|
|
|
|
) {}
|
2022-08-28 17:45:15 +00:00
|
|
|
|
|
|
|
entries() {
|
|
|
|
return RSModuleValue.getKeyValuePairs(this._value).map(
|
2022-08-29 21:51:44 +00:00
|
|
|
([k, v]) => [k, wrapValue(v, this.location.extend(k))] as const
|
2022-08-28 17:45:15 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
asValue() {
|
2022-08-29 21:51:44 +00:00
|
|
|
return new SqModuleValue(
|
|
|
|
RSModuleValue.toSquiggleValue(this._value),
|
|
|
|
this.location
|
|
|
|
);
|
2022-08-28 17:45:15 +00:00
|
|
|
}
|
2022-09-01 11:02:32 +00:00
|
|
|
|
|
|
|
get(k: string) {
|
|
|
|
const v = RSModuleValue.get(this._value, k);
|
|
|
|
return v === undefined || v === null
|
|
|
|
? undefined
|
|
|
|
: wrapValue(v, this.location.extend(k));
|
|
|
|
}
|
2022-08-27 17:46:43 +00:00
|
|
|
}
|