sec-edgar-api
Version:
Fetch and parse SEC earnings reports and other filings. Useful for financial analysis.
51 lines (50 loc) • 1.77 kB
TypeScript
import type { CalculationMapCalculation, CalculationMap } from '../../types/calculation-map.type';
interface GetCalculatedFromGroupResult {
missingKeys: string[] | null;
isMissingRequiredKey: boolean;
hasAtLeastOneKey: boolean;
value: number | null;
}
interface GetCalculatedFromGroupParams {
group: CalculationMapCalculation;
breakIfMissingRequiredKey?: boolean;
}
export default class ReportResolvable {
readonly report: Record<string, string | number | null | boolean>;
private readonly calculationMap;
private readonly keyStack;
private readonly calculatedValues;
private readonly usedGroupIndexesByKey;
private depth;
constructor(args: {
report: Record<string, string | number | null | boolean>;
calculationMap?: CalculationMap;
});
getMap(): CalculationMap;
clearCache(): void;
/**
* Used when testing to remove groups that are not being used.
*/
getUsedGroupIndexesByKey(): Record<string, number[]>;
/**
* Gets value from report, or calculates it using calculationMap.
*/
get(key: string): string | number | null | boolean | undefined;
/**
* Returns 0 for non-numeric values
*/
getNumber(key: string): number;
getCalculatedFromGroup(params: GetCalculatedFromGroupParams): GetCalculatedFromGroupResult;
private _get;
private _getCalculatedFromGroup;
/**
* @param skipSingleMatch When true, skips groups that match only one key. Used for testing groups.
*/
getCalculated(key: string, skipSingleMatch?: boolean): {
value: string | number | boolean | null;
groupIndex: number;
};
private _getCalculated;
toJSON(): Record<string, string | number | boolean | null>;
}
export {};