"use strict";var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.objectToArray=objectToArray;exports.objectToArrayMap=objectToArrayMap;var _isNonNegativeInteger=_interopRequireDefault(require("./isNonNegativeInteger"));









function objectToArray(payload){
const indices=Object.keys(payload).
map(Number).
filter(_isNonNegativeInteger.default);

const minKey=Math.min(...indices);
const maxKey=Math.max(...indices);
const arr=[];

for(let i=minKey;i<=maxKey;++i){
arr[i]=payload[i];
}

return arr;
}

function objectItterance(payload){
let tmp=[];

const keys=Object.keys(payload);
const values=Object.values(payload);
const sourceLength=keys.length;

for(let i=0;i<sourceLength;i++){
let obj={
key:"",
value:null};

obj.key=keys[i];
obj.value=values[i];
tmp[i]=obj;
}

return tmp;
}

function objectToArrayMap(payload,...restPayload){
let tmp=[];

tmp=objectItterance(payload);

if(typeof restPayload!=="undefined"){
restPayload.forEach(item=>{
const arr=objectItterance(item);
tmp=[...tmp,...arr];
});
}

return tmp;
}