string/substring.js

  1. import { convertStringMethod } from './convertStringMethod'
  2. /**
  3. * Replaces by a slice of former string starting at <code>beginIndex</code> and ending at <code>endIndex</code> or end of the string.
  4. * @function
  5. * @memberof string
  6. * @param {Object} object The object to modify.
  7. * @param {Array|string} path The path of the property to set.
  8. * @param {number} beginIndex Beginning index of slice.
  9. * @param {number?} endIndex Ending index of slice.
  10. * @return {Object} Returns the updated object.
  11. * @example substring({ nested: { a: 'Hello World !' } }, 6) // => { nested: { a: 'World !' } }
  12. * @example substring({ nested: { a: 'Hello World !' } }, 6, 11) // => { nested: { a: 'World' } }
  13. * @see {@link https://mdn.io/String.prototype.substring|String.prototype.substring} for more information.
  14. * @since 1.0.0
  15. */
  16. const substring = convertStringMethod('substring')
  17. export { substring }