time-to-botec

Benchmark sampling in different programming languages
Log | Files | Refs | README

calculator.js (1490B)


      1 import { makeDefinition } from "../library/registry/fnDefinition.js";
      2 import { frDict, frLambda, frArray, frString, frOptional, frInput, frBool, frNumber, } from "../library/registry/frTypes.js";
      3 import { FnFactory } from "../library/registry/helpers.js";
      4 import { vCalculator } from "../value/index.js";
      5 const maker = new FnFactory({
      6     nameSpace: "Calculator",
      7     requiresNamespace: true,
      8 });
      9 export const library = [
     10     maker.make({
     11         name: "make",
     12         output: "Calculator",
     13         examples: [],
     14         definitions: [
     15             makeDefinition([
     16                 frDict(["fn", frLambda], ["title", frOptional(frString)], ["description", frOptional(frString)], ["inputs", frArray(frInput)], ["autorun", frOptional(frBool)], ["sampleCount", frOptional(frNumber)]),
     17             ], ([{ fn, title, description, inputs, autorun, sampleCount }]) => {
     18                 const calc = vCalculator({
     19                     fn,
     20                     title: title || undefined,
     21                     description: description || undefined,
     22                     inputs: inputs,
     23                     autorun: autorun == null ? true : autorun,
     24                     sampleCount: sampleCount || undefined,
     25                 });
     26                 const error = calc.getError();
     27                 if (error) {
     28                     throw error;
     29                 }
     30                 else {
     31                     return calc;
     32                 }
     33             }),
     34         ],
     35     }),
     36 ];
     37 //# sourceMappingURL=calculator.js.map