dist/functions.js
function cautiouslyApplyEach(
array,
fns,
log = true,
keepOldValueOnFalseyReturn = false)
{
  let items = Array.from(array);

  if (items && Array.isArray(items) && fns && Array.isArray(fns)) {
    items.forEach((item, itemIndex, itemArray) => {
      let newItem = item;

      fns.forEach(fn => {
        try {
          let bindFunctor = Array.isArray(fn) && fn[1];
          let functor = bindFunctor ?
          fn[0].bind(newItem) :
          Array.isArray(fn) ? fn[0] : fn;

          if (keepOldValueOnFalseyReturn)
          newItem = functor(newItem, itemIndex, itemArray) || newItem;else

          newItem = functor(newItem, itemIndex, itemArray);
        }
        catch (error) {
          if (log) {
            console.error(error);
          }
        }
      });

      items[itemIndex] = newItem;
    });
  }

  return items;
}
function cautiouslyApplyEach(
array,
fns,
log = true,
keepOldValueOnFalseyReturn = false)
{
  let items = Array.from(array);

  if (items && Array.isArray(items) && fns && Array.isArray(fns)) {
    items.forEach((item, itemIndex, itemArray) => {
      let newItem = item;

      fns.forEach(fn => {
        try {
          let bindFunctor = Array.isArray(fn) && fn[1];
          let functor = bindFunctor ?
          fn[0].bind(newItem) :
          Array.isArray(fn) ? fn[0] : fn;

          if (keepOldValueOnFalseyReturn)
          newItem = functor(newItem, itemIndex, itemArray) || newItem;else

          newItem = functor(newItem, itemIndex, itemArray);
        }
        catch (error) {
          if (log) {
            console.error(error);
          }
        }
      });

      items[itemIndex] = newItem;
    });
  }

  return items;
}
function cautiouslyApplyEach ( array , fns , log = true , keepOldValueOnFalseyReturn = false ) { let items = Array . from ( array ) ; if ( items && Array . isArray ( items ) && fns && Array . isArray ( fns ) ) { items . forEach ( ( item , itemIndex , itemArray ) => { let newItem = item ; fns . forEach ( fn => { try { let bindFunctor = Array . isArray ( fn ) && fn [ 1 ] ; let functor = bindFunctor ? fn [ 0 ] . bind ( newItem ) : Array . isArray ( fn ) ? fn [ 0 ] : fn ; if ( keepOldValueOnFalseyReturn ) newItem = functor ( newItem , itemIndex , itemArray ) || newItem ; else newItem = functor ( newItem , itemIndex , itemArray ) ; } catch ( error ) { if ( log ) { console . error ( error ) ; } } } ) ; items [ itemIndex ] = newItem ; } ) ; } return items ; }
Nearly identical to `cautiouslyApply`, this function works on an array of
items rather than a single item. The only other difference is that the
supplied functors receive the index of the item and the array the item is
contained within as second and third parameters, respectively.

@param {Array<mixed>} array an array of values to apply each functor to
@param {Array<Function>} fns an array of `Function` objects that are to be
executed with the supplied `item` as its input and the new value as its
output. An error or fals
@param {boolean} log true if any errors caused by function execution should
be logged
@param {boolean} keepOldValueOnFalseyReturn if true and the functor returns
a falsey value, the value passed to it as a parameter is used instead
@return {Array<mixed>} a copy of the array passed as `array` but with
potentially modified internal values
Nearly identical to cautiouslyApply this function works on an array of items rather than a single item . The only other difference is that the supplied functors receive the index of the item and the array the item is contained within as second and third parameters respectively .