string/substr.js

  1. import { convertStringMethod } from './convertStringMethod'
  2. /**
  3. * Replaces by a slice of former string starting at <code>beginIndex</code>.
  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?} length Length of slice.
  10. * @return {Object} Returns the updated object.
  11. * @example substr({ nested: { a: 'Hello World !' } }, 6) // => { nested: { a: 'World !' } }
  12. * @example substr({ nested: { a: 'Hello World !' } }, 6, 5) // => { nested: { a: 'World' } }
  13. * @see {@link https://mdn.io/String.prototype.substr|String.prototype.substr} for more information.
  14. * @since 1.0.0
  15. */
  16. const substr = convertStringMethod('substr')
  17. export { substr }