{"version":3,"file":"in_memory.cjs","names":["BaseFileStore"],"sources":["../../../src/stores/file/in_memory.ts"],"sourcesContent":["import { BaseFileStore } from \"./base.js\";\n\n/**\n * Class that provides an in-memory file storage system. It extends the\n * BaseFileStore class and implements its readFile and writeFile methods.\n * This class is typically used in scenarios where temporary, in-memory\n * file storage is needed, such as during testing or for caching files in\n * memory for quick access.\n */\nexport class InMemoryFileStore extends BaseFileStore {\n  lc_namespace = [\"langchain\", \"stores\", \"file\", \"in_memory\"];\n\n  private files: Map<string, string> = new Map();\n\n  /**\n   * Retrieves the contents of a file given its path. If the file does not\n   * exist, it throws an error.\n   * @param path The path of the file to read.\n   * @returns The contents of the file as a string.\n   */\n  async readFile(path: string): Promise<string> {\n    const contents = this.files.get(path);\n    if (contents === undefined) {\n      throw new Error(`File not found: ${path}`);\n    }\n    return contents;\n  }\n\n  /**\n   * Writes contents to a file at a given path. If the file already exists,\n   * it overwrites the existing contents.\n   * @param path The path of the file to write.\n   * @param contents The contents to write to the file.\n   * @returns Void\n   */\n  async writeFile(path: string, contents: string): Promise<void> {\n    this.files.set(path, contents);\n  }\n}\n"],"mappings":";;;;;;;;;;;;AASA,IAAa,oBAAb,cAAuCA,aAAAA,cAAc;CACnD,eAAe;EAAC;EAAa;EAAU;EAAQ;EAAY;CAE3D,wBAAqC,IAAI,KAAK;;;;;;;CAQ9C,MAAM,SAAS,MAA+B;EAC5C,MAAM,WAAW,KAAK,MAAM,IAAI,KAAK;AACrC,MAAI,aAAa,KAAA,EACf,OAAM,IAAI,MAAM,mBAAmB,OAAO;AAE5C,SAAO;;;;;;;;;CAUT,MAAM,UAAU,MAAc,UAAiC;AAC7D,OAAK,MAAM,IAAI,MAAM,SAAS"}