UNPKG

@azure/search-documents

Version:
24 lines 772 B
// Copyright (c) Microsoft Corporation. // Licensed under the MIT License. import fs from "node:fs"; import { promisify } from "node:util"; const readFileAsync = promisify(fs.readFile); /** * Helper method to create a SynonymMap object. This is a NodeJS only method. * * @param name - Name of the SynonymMap. * @param filePath - Path of the file that contains the Synonyms (seperated by new lines) * @returns SynonymMap object */ export async function createSynonymMapFromFile(name, filePath) { const synonyms = (await readFileAsync(filePath, "utf-8")) .replace(/\r/g, "") .split("\n") .map((line) => line.trim()) .filter(Boolean); return { name, synonyms, }; } //# sourceMappingURL=synonymMapHelper.js.map