UNPKG

devextreme

Version:

JavaScript/TypeScript Component Suite for Responsive Web Development

57 lines (53 loc) • 1.34 kB
/** * DevExtreme (esm/__internal/core/utils/m_iterator.js) * Version: 26.1.6 * Build date: Fri Oct 16 2026 * * Copyright (c) 2012 - 2026 Developer Express Inc. ALL RIGHTS RESERVED * Read about DevExtreme licensing here: https://js.devexpress.com/Licensing/ */ const hasLength = values => "length" in values; function 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 } function each(values, callback) { if (!values) { return } if (hasLength(values)) { for (let i = 0; i < values.length; i += 1) { 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 } function reverseEach(array, callback) { if (!array || !("length" in array) || 0 === array.length) { return } for (let i = array.length - 1; i >= 0; i -= 1) { if (false === callback.call(array[i], i, array[i])) { break } } } export { each, map, reverseEach };