array/reverse.js

  1. import { applyArrayMethod } from './applyArrayMethod'
  2. /**
  3. * Replaces an array reversing the elements from the former array.
  4. * @function
  5. * @memberof array
  6. * @param {Object} object The object to modify.
  7. * @param {Array|string} path The path of the property to set.
  8. * @return {Object} Returns the updated object.
  9. * @example reverse({ nested: { prop: [1, 2, 3] } }, 'nested.prop') // => { nested: { prop: [3, 2, 1] } }
  10. * @see {@link https://mdn.io/Array.prototype.reverse|Array.prototype.reverse} for more information..
  11. * @since 0.3.0
  12. */
  13. const reverse = applyArrayMethod('reverse', { fixedArity: true })
  14. export { reverse }