set.d.ts 991 B

1234567891011121314151617181920212223242526272829303132
  1. /**
  2. * Sets the value at `path` of `object`. If a portion of `path` doesn't exist,
  3. * it's created. Arrays are created for missing index properties while objects
  4. * are created for all other missing properties. Use `setWith` to customize
  5. * `path` creation.
  6. *
  7. * **Note:** This method mutates `object`.
  8. *
  9. * Inlined to just use set functionality and patch vulnerabilities
  10. * on existing isolated "lodash.set" package.
  11. *
  12. * @since 3.7.0
  13. * @category Object
  14. * @param {Object} object The object to modify.
  15. * @param {Array|string} path The path of the property to set.
  16. * @param {*} value The value to set.
  17. * @returns {Object} Returns `object`.
  18. * @see has, hasIn, get, unset
  19. * @example
  20. *
  21. * const object = { 'a': [{ 'b': { 'c': 3 } }] }
  22. *
  23. * set(object, 'a[0].b.c', 4)
  24. * console.log(object.a[0].b.c)
  25. * // => 4
  26. *
  27. * set(object, ['x', '0', 'y', 'z'], 5)
  28. * console.log(object.x[0].y.z)
  29. * // => 5
  30. */
  31. declare function set(object: any, path: any, value: any): any;
  32. export default set;