"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = useMemo;
var _vueDemi = require("vue-demi");
function useMemo(getValue, condition, shouldUpdate) {
  const cacheRef = (0, _vueDemi.ref)(getValue());
  (0, _vueDemi.watch)(condition, (next, pre) => {
    if (shouldUpdate) {
      if (shouldUpdate(next, pre)) {
        cacheRef.value = getValue();
      }
    } else {
      cacheRef.value = getValue();
    }
  });
  return cacheRef;
}