"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.forEach2ObjArr = forEach2ObjArr;
exports.isArray = isArray;
exports.isDate = isDate;
exports.isObject = isObject;
exports.reqStringify = reqStringify;
var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
var _qs = require("qs");
function isArray(val) {
  return (0, _typeof2.default)(val) === 'object' && Object.prototype.toString.call(val) === '[object Array]';
}
function isDate(val) {
  return (0, _typeof2.default)(val) === 'object' && Object.prototype.toString.call(val) === '[object Date]';
}
function isObject(val) {
  return val !== null && (0, _typeof2.default)(val) === 'object';
}
function forEach2ObjArr(target, callback) {
  if (!target) return;
  if ((0, _typeof2.default)(target) !== 'object') {
    target = [target];
  }
  if (isArray(target)) {
    for (var i = 0; i < target.length; i++) {
      callback.call(null, target[i], i, target);
    }
  } else {
    for (var key in target) {
      if (Object.prototype.hasOwnProperty.call(target, key)) {
        callback.call(null, target[key], key, target);
      }
    }
  }
}
function reqStringify(val) {
  return (0, _qs.stringify)(val, {
    arrayFormat: 'repeat',
    strictNullHandling: true
  });
}