import _checkForMethod from "./internal/_checkForMethod.js"; import _curry2 from "./internal/_curry2.js"; /** * Iterate over an input `list`, calling a provided function `fn` for each * element in the list. * * `fn` receives one argument: *(value)*. * * Note: `R.forEach` does not skip deleted or unassigned indices (sparse * arrays), unlike the native `Array.prototype.forEach` method. For more * details on this behavior, see: * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/forEach#Description * * Also note that, unlike `Array.prototype.forEach`, Ramda's `forEach` returns * the original array. In some libraries this function is named `each`. * * Dispatches to the `forEach` method of the second argument, if present. * * @func * @memberOf R * @since v0.1.1 * @category List * @sig (a -> *) -> [a] -> [a] * @param {Function} fn The function to invoke. Receives one argument, `value`. * @param {Array} list The list to iterate over. * @return {Array} The original list. * @see R.addIndex * @example * * const printXPlusFive = x => console.log(x + 5); * R.forEach(printXPlusFive, [1, 2, 3]); //=> [1, 2, 3] * // logs 6 * // logs 7 * // logs 8 * @symb R.forEach(f, [a, b, c]) = [a, b, c] */ var forEach = /*#__PURE__*/ _curry2( /*#__PURE__*/ _checkForMethod('forEach', function forEach(fn, list) { var len = list.length; var idx = 0; while (idx < len) { fn(list[idx]); idx += 1; } return list; })); export default forEach;