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

66.66% Statements 26/39
100% Branches 0/0
0% Functions 0/1
66.66% Lines 26/39

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 37 38 39 401x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x                            
 
/* ------------------------------------------------------------------
 * meta 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 'meta' section
 */
export interface BUILDER_META extends BUILDER_SECTION {
  author: BUILDER_STR_REF; //str
  conform: BUILDER_STR_REF; //str
  layout: BUILDER_STR_REF; //str
  name: BUILDER_STR_REF; //str
  indicator: BUILDER_STR_REF; //str
  version: BUILDER_STR_REF; //str
  settings: number; //bitfield
};
 
export function build_meta(kmxplus: KMXPlusData, sect_strs: BUILDER_STRS): BUILDER_META {
  return {
    ident: constants.hex_section_id(constants.section.meta),
    size: constants.length_meta,
    _offset: 0,
    author: build_strs_index(sect_strs, kmxplus.meta.author),
    conform: build_strs_index(sect_strs, kmxplus.meta.conform),
    layout: build_strs_index(sect_strs, kmxplus.meta.layout),
    name: build_strs_index(sect_strs, kmxplus.meta.name),
    indicator: build_strs_index(sect_strs, kmxplus.meta.indicator),
    version: build_strs_index(sect_strs, kmxplus.meta.version),
    settings: kmxplus.meta.settings ?? 0,
  };
}