All files / virtual-keyboard/src/composer identity.ts

100% Statements 4/4
100% Branches 0/0
100% Functions 3/3
100% Lines 4/4

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                          4x   45x     1x     247x      
import type { Composer } from "../types";
 
/**
 * The default 1:1 composer: every key commits immediately and nothing is ever
 * left composing. This is the seam future IME composers (Hangul 두벌식, etc.)
 * will slot into without a breaking API change.
 *
 * @example
 * ```ts
 * const s = identityComposer.reset();
 * identityComposer.input(s, "a"); // → { committed: "a", composing: "", next: s }
 * ```
 */
export const identityComposer: Composer = {
  input(state, key) {
    return { committed: key, composing: "", next: state };
  },
  flush(state) {
    return { committed: "", composing: "", next: state };
  },
  reset() {
    return { buffer: "" };
  },
};