{"size": 2292, "ext": "js", "max_stars_repo_path": "node_modules/react-instantsearch-core/dist/cjs/core/utils.js", "max_stars_repo_name": "ethaneisenhard/gatsby-airtable", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "node_modules/react-instantsearch-core/dist/cjs/core/utils.js", "max_issues_repo_name": "ethaneisenhard/gatsby-airtable", "max_issues_repo_issues_event_min_datetime": "2021-09-01T19:31:00.000Z", "max_issues_repo_issues_event_max_datetime": "2022-02-26T15:28:33.000Z", "max_forks_repo_path": "node_modules/react-instantsearch-core/dist/cjs/core/utils.js", "max_forks_repo_name": "ethaneisenhard/gatsby-airtable", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": 5, "max_forks_count": null, "avg_line_length": 25.1868131868, "max_line_length": 96, "alphanum_fraction": 0.6915357766}
"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.addAbsolutePositions = addAbsolutePositions;
exports.addQueryID = addQueryID;
exports.removeEmptyKey = exports.defer = exports.getDisplayName = exports.shallowEqual = void 0;

var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread"));

var _isPlainObject2 = _interopRequireDefault(require("lodash/isPlainObject"));

var _isEmpty2 = _interopRequireDefault(require("lodash/isEmpty"));

// From https://github.com/reactjs/react-redux/blob/master/src/utils/shallowEqual.js
var shallowEqual = function shallowEqual(objA, objB) {
  if (objA === objB) {
    return true;
  }

  var keysA = Object.keys(objA);
  var keysB = Object.keys(objB);

  if (keysA.length !== keysB.length) {
    return false;
  } // Test for A's keys different from B.


  var hasOwn = Object.prototype.hasOwnProperty;

  for (var i = 0; i < keysA.length; i++) {
    if (!hasOwn.call(objB, keysA[i]) || objA[keysA[i]] !== objB[keysA[i]]) {
      return false;
    }
  }

  return true;
};

exports.shallowEqual = shallowEqual;

var getDisplayName = function getDisplayName(Component) {
  return Component.displayName || Component.name || 'UnknownComponent';
};

exports.getDisplayName = getDisplayName;
var resolved = Promise.resolve();

var defer = function defer(f) {
  resolved.then(f);
};

exports.defer = defer;

var removeEmptyKey = function removeEmptyKey(obj) {
  Object.keys(obj).forEach(function (key) {
    var value = obj[key];

    if ((0, _isEmpty2.default)(value) && (0, _isPlainObject2.default)(value)) {
      delete obj[key];
    } else if ((0, _isPlainObject2.default)(value)) {
      removeEmptyKey(value);
    }
  });
  return obj;
};

exports.removeEmptyKey = removeEmptyKey;

function addAbsolutePositions(hits, hitsPerPage, page) {
  return hits.map(function (hit, index) {
    return (0, _objectSpread2.default)({}, hit, {
      __position: hitsPerPage * page + index + 1
    });
  });
}

function addQueryID(hits, queryID) {
  if (!queryID) {
    return hits;
  }

  return hits.map(function (hit) {
    return (0, _objectSpread2.default)({}, hit, {
      __queryID: queryID
    });
  });
}