UNPKG

wordmap

Version:
42 lines (41 loc) 1.24 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const FrequencyIndex_1 = require("./FrequencyIndex"); /** * An index of alignment frequencies */ class AlignmentIndex extends FrequencyIndex_1.default { /** * Reads a value from the index * @param alignment - the alignment index to read. This may be a specific key, or the alignment object to read the default key. */ read(alignment) { if (typeof alignment === "string") { return this.readIndex(alignment); } else { return this.readIndex(alignment.key); } } /** * Writes a value to the index * @deprecated - use {@link increment} instead * @param {Alignment} alignment * @param {number} value */ write(alignment, value) { this.writeIndex(alignment.key, value); } /** * Increments a value in the index * @param {Alignment} alignment * @param {number} value */ increment(alignment, value = 1) { this.incrementIndex(alignment.key, value); if (alignment.lemmaKey !== undefined) { this.incrementIndex(alignment.lemmaKey, value); } } } exports.default = AlignmentIndex;