index.d.ts (7324B)
1 import { BaseDist } from "../dist/BaseDist.js"; 2 import { REOther } from "../errors/messages.js"; 3 import { Lambda } from "../reducer/lambda.js"; 4 import { ImmutableMap } from "../utility/immutableMap.js"; 5 import { Domain } from "./domain.js"; 6 export type ValueMap = ImmutableMap<string, Value>; 7 type Indexable = { 8 get(key: Value): Value; 9 }; 10 declare abstract class BaseValue { 11 abstract type: string; 12 abstract publicName: string; 13 clone(): any; 14 abstract toString(): string; 15 } 16 declare class VArray extends BaseValue implements Indexable { 17 value: Value[]; 18 readonly type = "Array"; 19 readonly publicName = "List"; 20 constructor(value: Value[]); 21 toString(): string; 22 get(key: Value): Value; 23 flatten(): VArray; 24 shuffle(): VArray; 25 isEqual(other: VArray): boolean; 26 } 27 export declare const vArray: (v: Value[]) => VArray; 28 declare class VBool extends BaseValue { 29 value: boolean; 30 readonly type = "Bool"; 31 readonly publicName = "Boolean"; 32 constructor(value: boolean); 33 toString(): string; 34 isEqual(other: VBool): boolean; 35 } 36 export declare const vBool: (v: boolean) => VBool; 37 declare class VDate extends BaseValue { 38 value: Date; 39 readonly type = "Date"; 40 readonly publicName = "Date"; 41 constructor(value: Date); 42 toString(): string; 43 isEqual(other: VDate): boolean; 44 } 45 export declare const vDate: (v: Date) => VDate; 46 declare class VDist extends BaseValue { 47 value: BaseDist; 48 readonly type = "Dist"; 49 readonly publicName = "Distribution"; 50 constructor(value: BaseDist); 51 toString(): string; 52 isEqual(other: VDist): boolean; 53 } 54 export declare const vDist: (v: BaseDist) => VDist; 55 declare class VLambda extends BaseValue implements Indexable { 56 value: Lambda; 57 readonly type = "Lambda"; 58 readonly publicName = "Function"; 59 constructor(value: Lambda); 60 toString(): string; 61 get(key: Value): VArray; 62 } 63 export declare const vLambda: (v: Lambda) => VLambda; 64 declare class VNumber extends BaseValue { 65 value: number; 66 readonly type = "Number"; 67 readonly publicName = "Number"; 68 constructor(value: number); 69 toString(): string; 70 isEqual(other: VNumber): boolean; 71 } 72 export declare const vNumber: (v: number) => VNumber; 73 declare class VString extends BaseValue { 74 value: string; 75 readonly type = "String"; 76 readonly publicName = "String"; 77 constructor(value: string); 78 toString(): string; 79 isEqual(other: VString): boolean; 80 } 81 export declare const vString: (v: string) => VString; 82 declare class VDict extends BaseValue implements Indexable { 83 value: ValueMap; 84 readonly type = "Dict"; 85 readonly publicName = "Dictionary"; 86 constructor(value: ValueMap); 87 toString(): string; 88 get(key: Value): Value; 89 isEqual(other: VDict): boolean; 90 } 91 export declare const vDict: (v: ValueMap) => VDict; 92 declare class VTimeDuration extends BaseValue { 93 value: number; 94 readonly type = "TimeDuration"; 95 readonly publicName = "Time Duration"; 96 constructor(value: number); 97 toString(): string; 98 isEqual(other: VTimeDuration): boolean; 99 } 100 export declare const vTimeDuration: (v: number) => VTimeDuration; 101 export type CommonScaleArgs = { 102 min?: number; 103 max?: number; 104 tickFormat?: string; 105 title?: string; 106 }; 107 export type Scale = CommonScaleArgs & ({ 108 type: "linear"; 109 } | { 110 type: "log"; 111 } | { 112 type: "symlog"; 113 constant?: number; 114 } | { 115 type: "power"; 116 exponent?: number; 117 }); 118 export declare const SCALE_SYMLOG_DEFAULT_CONSTANT = 0.0001; 119 export declare const SCALE_POWER_DEFAULT_CONSTANT = 0.1; 120 declare class VScale extends BaseValue { 121 value: Scale; 122 readonly type = "Scale"; 123 readonly publicName = "Scale"; 124 constructor(value: Scale); 125 toString(): string; 126 isEqual(other: VScale): boolean; 127 } 128 export declare const vScale: (scale: Scale) => VScale; 129 export type CommonInputArgs = { 130 name: string; 131 description?: string; 132 }; 133 export type Input = CommonInputArgs & ({ 134 type: "text"; 135 default?: string; 136 } | { 137 type: "textArea"; 138 default?: string; 139 } | { 140 type: "checkbox"; 141 default?: boolean; 142 } | { 143 type: "select"; 144 default?: string; 145 options: string[]; 146 }); 147 declare class VInput extends BaseValue { 148 value: Input; 149 readonly type = "Input"; 150 readonly publicName = "Input"; 151 constructor(value: Input); 152 toString(): string; 153 isEqual(other: VInput): boolean; 154 } 155 export declare const vInput: (input: Input) => VInput; 156 export type LabeledDistribution = { 157 name?: string; 158 distribution: BaseDist; 159 }; 160 export type CommonPlotArgs = { 161 title?: string; 162 }; 163 export type Plot = CommonPlotArgs & ({ 164 type: "distributions"; 165 distributions: LabeledDistribution[]; 166 xScale: Scale; 167 yScale: Scale; 168 showSummary: boolean; 169 } | { 170 type: "numericFn"; 171 fn: Lambda; 172 xScale: Scale; 173 yScale: Scale; 174 points?: number; 175 } | { 176 type: "distFn"; 177 fn: Lambda; 178 xScale: Scale; 179 yScale: Scale; 180 distXScale: Scale; 181 points?: number; 182 } | { 183 type: "scatter"; 184 xDist: BaseDist; 185 yDist: BaseDist; 186 xScale: Scale; 187 yScale: Scale; 188 } | { 189 type: "relativeValues"; 190 fn: Lambda; 191 ids: string[]; 192 }); 193 export type TableChart = { 194 data: Value[]; 195 title?: string; 196 columns: { 197 fn: Lambda; 198 name: string | undefined; 199 }[]; 200 }; 201 declare class VTableChart extends BaseValue { 202 value: TableChart; 203 readonly type = "TableChart"; 204 readonly publicName = "Table Chart"; 205 constructor(value: TableChart); 206 toString(): string; 207 } 208 export declare const vTableChart: (v: TableChart) => VTableChart; 209 export type Calculator = { 210 fn: Lambda; 211 inputs: Input[]; 212 autorun: boolean; 213 description?: string; 214 title?: string; 215 sampleCount?: number; 216 }; 217 declare class VCalculator extends BaseValue { 218 value: Calculator; 219 readonly type = "Calculator"; 220 readonly publicName = "Calculator"; 221 private error; 222 constructor(value: Calculator); 223 private setError; 224 getError(): REOther | null; 225 toString(): string; 226 } 227 export declare const vCalculator: (v: Calculator) => VCalculator; 228 declare class VPlot extends BaseValue implements Indexable { 229 value: Plot; 230 readonly type = "Plot"; 231 readonly publicName = "Plot"; 232 constructor(value: Plot); 233 toString(): string; 234 get(key: Value): VLambda; 235 } 236 export declare const vPlot: (plot: Plot) => VPlot; 237 export declare class VDomain extends BaseValue implements Indexable { 238 value: Domain; 239 readonly type = "Domain"; 240 readonly publicName = "Domain"; 241 constructor(value: Domain); 242 toString(): string; 243 get(key: Value): VNumber; 244 isEqual(other: VDomain): boolean; 245 } 246 export declare const vDomain: (domain: Domain) => VDomain; 247 declare class VVoid extends BaseValue { 248 readonly type = "Void"; 249 readonly publicName = "Void"; 250 constructor(); 251 toString(): string; 252 } 253 export declare const vVoid: () => VVoid; 254 export type Value = VArray | VBool | VDate | VDist | VLambda | VNumber | VString | VDict | VTimeDuration | VPlot | VTableChart | VCalculator | VScale | VInput | VDomain | VVoid; 255 export declare function isEqual(a: Value, b: Value): boolean; 256 export declare function uniq(array: Value[]): Value[]; 257 export declare function uniqBy(array: Value[], fn: (e: Value) => Value): Value[]; 258 export {}; 259 //# sourceMappingURL=index.d.ts.map