Ohm-Management - Projektarbeit B-ME
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

_arrayFilter.js 632B

12345678910111213141516171819202122232425
  1. /**
  2. * A specialized version of `_.filter` for arrays without support for
  3. * iteratee shorthands.
  4. *
  5. * @private
  6. * @param {Array} [array] The array to iterate over.
  7. * @param {Function} predicate The function invoked per iteration.
  8. * @returns {Array} Returns the new filtered array.
  9. */
  10. function arrayFilter(array, predicate) {
  11. var index = -1,
  12. length = array == null ? 0 : array.length,
  13. resIndex = 0,
  14. result = [];
  15. while (++index < length) {
  16. var value = array[index];
  17. if (predicate(value, index, array)) {
  18. result[resIndex++] = value;
  19. }
  20. }
  21. return result;
  22. }
  23. module.exports = arrayFilter;