squiggle/packages/squiggle-lang/src/js/SqRecord.ts

16 lines
479 B
TypeScript
Raw Normal View History

2022-08-27 17:46:43 +00:00
import * as RSRecord from "../rescript/ForTS/ForTS_SquiggleValue/ForTS_SquiggleValue_Record.gen";
2022-08-28 16:19:44 +00:00
import { wrapValue } from "./SqValue";
import { SqValueLocation } from "./SqValueLocation";
2022-08-27 17:46:43 +00:00
type T = RSRecord.squiggleValue_Record;
2022-08-28 16:19:44 +00:00
export class SqRecord {
constructor(private _value: T, public location: SqValueLocation) {}
2022-08-27 17:46:43 +00:00
entries() {
return RSRecord.getKeyValuePairs(this._value).map(
([k, v]) => [k, wrapValue(v, this.location.extend(k))] as const
2022-08-27 17:46:43 +00:00
);
}
}