@gent-js/gent
Version:
template-based data generator.
18 lines (17 loc) • 542 B
JavaScript
import { stampDocument, } from "../../document/index.js";
import { AbstractJsonable } from "../abstractJsonable.js";
export class NumberJsonable extends AbstractJsonable {
content;
type = "number";
constructor(content, probability, weight) {
super(probability, weight);
this.content = content;
}
toJSONImpl(keyOrIndex, context) {
const output = Number(stampDocument(this.content, context));
if (Number.isNaN(output)) {
return undefined;
}
return output;
}
}