"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.getSearchFunction = void 0;

var _mock_data = _interopRequireDefault(require("./mock_data"));

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }

var getSearchFunction = function getSearchFunction() {
  var DELAY = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 500;
  return function (_ref) {
    var query = _ref.query,
        per_page = _ref.per_page;
    return new Promise(function (r) {
      return setTimeout(r, DELAY);
    }).then(function () {
      return _mock_data["default"].filter(function (item) {
        return item.name.includes(query) || item.description.includes(query);
      }).slice(0, per_page);
    });
  };
};

exports.getSearchFunction = getSearchFunction;