/**
 * DevExtreme (cjs/core/utils/iterator.js)
 * Version: 23.2.6 (build 24140-0112)
 * Build date: Sun May 19 2024
 *
 * Copyright (c) 2012 - 2024 Developer Express Inc. ALL RIGHTS RESERVED
 * Read about DevExtreme licensing here: https://js.devexpress.com/Licensing/
 */
"use strict";
exports.reverseEach = exports.map = exports.each = void 0;
const map = (values, callback) => {
    if (Array.isArray(values)) {
        return values.map(callback)
    }
    const result = [];
    for (const key in values) {
        result.push(callback(values[key], key))
    }
    return result
};
exports.map = map;
const each = (values, callback) => {
    if (!values) {
        return
    }
    if ("length" in values) {
        for (let i = 0; i < values.length; i++) {
            if (false === callback.call(values[i], i, values[i])) {
                break
            }
        }
    } else {
        for (const key in values) {
            if (false === callback.call(values[key], key, values[key])) {
                break
            }
        }
    }
    return values
};
exports.each = each;
const reverseEach = (array, callback) => {
    if (!array || !("length" in array) || 0 === array.length) {
        return
    }
    for (let i = array.length - 1; i >= 0; i--) {
        if (false === callback.call(array[i], i, array[i])) {
            break
        }
    }
};
exports.reverseEach = reverseEach;
