Files
languageservices/expressions/src/idxHelper.ts
T

24 lines
505 B
TypeScript
Raw Normal View History

2023-01-09 19:02:19 -05:00
import {ExpressionData} from "./data";
export class idxHelper {
public readonly str: string | undefined;
public readonly int: number | undefined;
constructor(public readonly star: boolean, idx: ExpressionData | undefined) {
2023-03-16 18:08:51 -04:00
if (!idx) {
return;
}
if (!star) {
2023-03-16 18:08:51 -04:00
if (idx.primitive) {
this.str = idx.coerceString();
}
2023-03-16 18:08:51 -04:00
let f = idx.number();
if (!isNaN(f) && isFinite(f) && f >= 0) {
f = Math.floor(f);
this.int = f;
}
}
}
}