All files / src/types/kmx/kmx-plus-builder build-loca.ts

60% Statements 21/35
100% Branches 0/0
0% Functions 0/1
60% Lines 21/35

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 371x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x                                
 
/* ------------------------------------------------------------------
 * loca section
   ------------------------------------------------------------------ */
 
import { constants } from "@keymanapp/ldml-keyboard-constants";
import { KMXPlus } from "@keymanapp/common-types";
import { build_strs_index, BUILDER_STR_REF, BUILDER_STRS } from "./build-strs.js";
import { BUILDER_SECTION } from "./builder-section.js";
 
import KMXPlusData = KMXPlus.KMXPlusData;
 
/**
 * Builder for the 'loca' section
 */
export interface BUILDER_LOCA extends BUILDER_SECTION {
  count: number;
  items: BUILDER_STR_REF[]; //str[]
};
 
export function build_loca(kmxplus: KMXPlusData, sect_strs: BUILDER_STRS): BUILDER_LOCA {
  const loca: BUILDER_LOCA = {
    ident: constants.hex_section_id(constants.section.loca),
    size: constants.length_loca + constants.length_loca_item * kmxplus.loca.locales.length,
    _offset: 0,
    count: kmxplus.loca.locales.length,
    items: []
  };

  for(const item of kmxplus.loca.locales) {
    loca.items.push(build_strs_index(sect_strs, item));
  }

  return loca;
}