string/padStart.js

  1. import { convertStringMethod } from './convertStringMethod'
  2. /**
  3. * Replaces by former string padded at the start with <code>padString</code> to the given <code>length</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} targetLength The length to pad to.
  9. * @param {string} [padString=' '] String to add.
  10. * @return {Object} Returns the updated object.
  11. * @example padStart({ nested: { a: 'Hellow' } }, 10) // => { nested: { a: ' Hellow' } }
  12. * @example padStart({ nested: { a: 'Hellow' } }, 10, '?!') // => { nested: { a: '?!?!Hellow' } }
  13. * @see {@link https://mdn.io/String.prototype.padStart|String.prototype.padStart} for more information.
  14. * @since 1.0.0
  15. */
  16. const padStart = convertStringMethod('padStart')
  17. export { padStart }