Skip to main content
Glama
archive.js•2.3 kB
"use strict"; var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; Object.defineProperty(exports, "__esModule", { value: true }); const xmldom_1 = require("@xmldom/xmldom"); class Archive { constructor(filename) { this.buffer = []; this.options = { type: 'nodebuffer', }; this.filename = filename; } parseXml(xmlString) { const dom = new xmldom_1.DOMParser(); return dom.parseFromString(xmlString); } serializeXml(XmlDocument) { const s = new xmldom_1.XMLSerializer(); const xmlBuffer = s.serializeToString(XmlDocument); return xmlBuffer; } writeBuffer(archiveType) { return __awaiter(this, void 0, void 0, function* () { for (const buffered of this.buffer) { const serialized = this.serializeXml(buffered.content); yield archiveType.write(buffered.relativePath, serialized); } }); } toBuffer(relativePath, content) { const existing = this.fromBuffer(relativePath); if (!existing) { this.buffer.push({ relativePath, name: relativePath, content: content, }); } } setOptions(params) { if (params.compression > 0) { this.options.compression = 'DEFLATE'; this.options.compressionOptions = { level: params.compression, }; } } fromBuffer(relativePath) { return this.buffer.find((file) => file.relativePath === relativePath); } } exports.default = Archive; //# sourceMappingURL=archive.js.map

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/guangxiangdebizi/PPT-MCP'

If you have feedback or need assistance with the MCP directory API, please join our Discord server