'use strict';

var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol ? "symbol" : typeof obj; };

Object.defineProperty(exports, "__esModule", {
  value: true
});

var _constants = require('./constants');

exports.default = {
  isStore: isStore, isObserverArray: isObserverArray, isPrimitive: isPrimitive, hasKey: hasKey
};

var storeKeys = ['dispatch', 'getState', 'subscribe'];
function isStore(val) {
  if (!val) {
    return false;
  }
  return storeKeys.every(function (key) {
    return has.call(val, key);
  });
}

function isObserverArray(val) {
  if (!Array.isArray(val)) {
    return false;
  }
  return val.every(isObserver);
}

function isObserver(val) {
  return typeof val === 'function' && val[_constants.OBSERVER];
}

var primitives = ['string', 'number', 'boolean'];
function isPrimitive(val) {
  return primitives.some(function (p) {
    return (typeof val === 'undefined' ? 'undefined' : _typeof(val)) === p;
  });
}

var has = Object.prototype.hasOwnProperty;
function hasKey(obj, key) {
  return has.call(obj, key);
}