time-to-botec

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

SqScale.js (2134B)


      1 import { vScale, SCALE_SYMLOG_DEFAULT_CONSTANT, SCALE_POWER_DEFAULT_CONSTANT, } from "../../value/index.js";
      2 export const wrapScale = (value) => {
      3     switch (value.type) {
      4         case "linear":
      5             return SqLinearScale.create(value);
      6         case "log":
      7             return SqLogScale.create(value);
      8         case "symlog":
      9             return SqSymlogScale.create(value);
     10         case "power":
     11             return SqPowerScale.create(value);
     12     }
     13 };
     14 class SqAbstractScale {
     15     constructor(_value) {
     16         this._value = _value;
     17     }
     18     toString() {
     19         return vScale(this._value).toString();
     20     }
     21     get min() {
     22         return this._value.min;
     23     }
     24     get max() {
     25         return this._value.max;
     26     }
     27     get tickFormat() {
     28         return this._value.tickFormat;
     29     }
     30     get title() {
     31         return this._value.title;
     32     }
     33 }
     34 export class SqLinearScale extends SqAbstractScale {
     35     constructor() {
     36         super(...arguments);
     37         this.tag = "linear";
     38     }
     39     static create(args = {}) {
     40         return new SqLinearScale({ type: "linear", ...args });
     41     }
     42 }
     43 export class SqLogScale extends SqAbstractScale {
     44     constructor() {
     45         super(...arguments);
     46         this.tag = "log";
     47     }
     48     static create(args = {}) {
     49         return new SqLogScale({ type: "log", ...args });
     50     }
     51 }
     52 export class SqSymlogScale extends SqAbstractScale {
     53     constructor(args) {
     54         super({
     55             type: "symlog",
     56             ...args,
     57         });
     58         this.tag = "symlog";
     59         this._constant = args.constant ?? SCALE_SYMLOG_DEFAULT_CONSTANT;
     60     }
     61     static create(args) {
     62         return new SqSymlogScale(args);
     63     }
     64     get constant() {
     65         return this._constant;
     66     }
     67 }
     68 export class SqPowerScale extends SqAbstractScale {
     69     constructor(args) {
     70         super({
     71             type: "power",
     72             ...args,
     73         });
     74         this.tag = "power";
     75         this._exponent = args.exponent ?? SCALE_POWER_DEFAULT_CONSTANT;
     76     }
     77     static create(args) {
     78         return new SqPowerScale(args);
     79     }
     80     get exponent() {
     81         return this._exponent;
     82     }
     83 }
     84 //# sourceMappingURL=SqScale.js.map