All files / domain SnapshotDeduper.res.mjs

91.66% Statements 11/12
90% Branches 9/10
100% Functions 3/3
91.66% Lines 11/12

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 40 41 42 43 44 45 46 47 48 49 50 51          3x             1x 1x                   9x 9x 9x 9x 9x 9x       9x           1x                        
// Generated by ReScript, PLEASE EDIT WITH CARE
 
import * as Primitive_object from "@rescript/runtime/lib/es6/Primitive_object.js";
 
function request(state) {
  return {
    last: state.last,
    forced: state.forced + 1 | 0
  };
}
 
function cancel(state) {
  if (state.forced > 0) {
    return {
      last: state.last,
      forced: state.forced - 1 | 0
    };
  } else E{
    return state;
  }
}
 
function observe(state, snapshot) {
  let previous = state.last;
  let duplicate = previous !== undefined ? Primitive_object.equal(previous.serial, snapshot.serial) && previous.facelets === snapshot.facelets : false;
  let forced = state.forced > 0;
  let next_last = snapshot;
  let next_forced = forced ? state.forced - 1 | 0 : state.forced;
  let next = {
    last: next_last,
    forced: next_forced
  };
  return [
    next,
    forced || !duplicate
  ];
}
 
let initial = {
  last: undefined,
  forced: 0
};
 
export {
  initial,
  request,
  cancel,
  observe,
}
/* No side effect */