UNPKG

js-mdict

Version:

mdict (*.mdx, *.mdd) file reader. Licensed under AGPL-3.0 for better community cooperation and commercial value protection.

40 lines 1.22 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.MDD = void 0; const mdict_js_1 = require("./mdict.js"); const BASE64ENCODER = function (arrayBuffer) { return Buffer.from(arrayBuffer).toString('base64'); }; class MDD extends mdict_js_1.Mdict { /** * locate the resource key * @param resourceKey resource key * @returns the keyText and definition */ locate(resourceKey) { let normalizedKey = resourceKey.replace(/\//g, '\\'); if (normalizedKey.length > 0 && !normalizedKey.startsWith('\\')) { normalizedKey = '\\' + normalizedKey; } const item = this.lookupKeyBlockByWord(normalizedKey); if (!item) { return { keyText: resourceKey, definition: null }; } const meaningBuff = this.lookupRecordByKeyBlock(item); if (!meaningBuff) { return { keyText: resourceKey, definition: null }; } return { keyText: resourceKey, definition: BASE64ENCODER(meaningBuff) }; } } exports.MDD = MDD; //# sourceMappingURL=mdd.js.map