array/takeRightWhile.js

  1. import { takeRightWhile as _takeRightWhile } from 'lodash'
  2. import { convert } from 'immutadot'
  3. /**
  4. * Creates a slice of array with elements taken from the end.
  5. * Elements are taken until predicate returns falsey.
  6. * The predicate is invoked with three arguments: (value, index, array).
  7. * @function
  8. * @memberof array
  9. * @param {Object} object The object to modify.
  10. * @param {Array|string} path The path of the property to set.
  11. * @param {Function} [predicate={@link https://lodash.com/docs#identity|lodash.identity}] The function invoked per iteration.
  12. * @return {Object} Returns the updated object.
  13. * @example takeRightWhile({ nested: { prop: [1, 2, 3, 4] } }, 'nested.prop', v => v > 3) // => { nested: { prop: [4] } }
  14. * @see {@link https://lodash.com/docs#takeRightWhile|lodash.takeRightWhile} for more information.
  15. * @since 1.0.0
  16. */
  17. const takeRightWhile = convert(_takeRightWhile)
  18. export { takeRightWhile }