@jlucaspains/sharp-recipe-parser
Version:
Recipe parsing tools
31 lines • 1.4 kB
TypeScript
/**
* This function parses a given instruction string.
* It identifies and extracts the time, temperature, and units from the instruction.
* It also provides alternative temperature conversions if the option is set.
* @param {string} text - The instruction string to be parsed.
* @param {Types.ValidLanguages} language - The language of the instruction.
* @param {ParseInstructionOptions} options - The options for parsing the instruction.
* @returns {InstructionParseResult | null} An object containing the parsed time, temperature, and units, or null if no tokens are found.
* @throws {Error} Throws an error if the language is not supported.
*/
export function parseInstruction(text: string, language: Types.ValidLanguages, options?: ParseInstructionOptions): InstructionParseResult | null;
export type InstructionTime = {
timeInSeconds: number;
timeUnitText: string;
timeText: string;
};
export type InstructionParseResult = {
totalTimeInSeconds: number;
timeItems: InstructionTime[];
temperature: number;
temperatureUnit: string;
temperatureText: string;
temperatureUnitText: string;
alternativeTemperatures: Types.AlternativeQuantity[];
};
export type ParseInstructionOptions = {
includeAlternativeTemperatureUnit: boolean;
fallbackLanguage: string;
};
import * as Types from "./types.js";
//# sourceMappingURL=instructionParser.d.ts.map