function map_to_json(map, size = 0) {
    let chunk = [],
        json = [];

    if (size) {
        size = 0 | chunk_size_map * (chunk_size_reg / size);
    }
    for (const item of map.entries()) {
        json.push(item);
        if (json.length === size) {
            chunk.push(json);
            json = [];
        }
    }
    json.length && chunk.push(json);
    return chunk;
}
@param {Map<IntermediateSearchResults>|KeystoreMap<IntermediateSearchResults>} map
@param {number=} size
@return {Array<Object>}