Repositorio del curso CCOM4030 el semestre B91 del proyecto Artesanías con el Instituto de Cultura

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. declare const dotProp: {
  2. /**
  3. @param object - Object to get the `path` value.
  4. @param path - Path of the property in the object, using `.` to separate each nested key. Use `\\.` if you have a `.` in the key.
  5. @param defaultValue - Default value.
  6. @example
  7. ```
  8. import dotProp = require('dot-prop');
  9. dotProp.get({foo: {bar: 'unicorn'}}, 'foo.bar');
  10. //=> 'unicorn'
  11. dotProp.get({foo: {bar: 'a'}}, 'foo.notDefined.deep');
  12. //=> undefined
  13. dotProp.get({foo: {bar: 'a'}}, 'foo.notDefined.deep', 'default value');
  14. //=> 'default value'
  15. dotProp.get({foo: {'dot.dot': 'unicorn'}}, 'foo.dot\\.dot');
  16. //=> 'unicorn'
  17. ```
  18. */
  19. get<T>(
  20. object: {[key: string]: any} | undefined,
  21. path: string
  22. ): T | undefined;
  23. get<T>(
  24. object: {[key: string]: any} | undefined,
  25. path: string,
  26. defaultValue: T
  27. ): T;
  28. /**
  29. @param object - Object to set the `path` value.
  30. @param path - Path of the property in the object, using `.` to separate each nested key. Use `\\.` if you have a `.` in the key.
  31. @param value - Value to set at `path`.
  32. @returns The object.
  33. @example
  34. ```
  35. import dotProp = require('dot-prop');
  36. const object = {foo: {bar: 'a'}};
  37. dotProp.set(object, 'foo.bar', 'b');
  38. console.log(object);
  39. //=> {foo: {bar: 'b'}}
  40. const foo = dotProp.set({}, 'foo.bar', 'c');
  41. console.log(foo);
  42. //=> {foo: {bar: 'c'}}
  43. dotProp.set(object, 'foo.baz', 'x');
  44. console.log(object);
  45. //=> {foo: {bar: 'b', baz: 'x'}}
  46. ```
  47. */
  48. set<T extends {[key: string]: any}>(
  49. object: T,
  50. path: string,
  51. value: unknown
  52. ): T;
  53. /**
  54. @param object - Object to test the `path` value.
  55. @param path - Path of the property in the object, using `.` to separate each nested key. Use `\\.` if you have a `.` in the key.
  56. @example
  57. ```
  58. import dotProp = require('dot-prop');
  59. dotProp.has({foo: {bar: 'unicorn'}}, 'foo.bar');
  60. //=> true
  61. ```
  62. */
  63. has(object: {[key: string]: any} | undefined, path: string): boolean;
  64. /**
  65. @param object - Object to delete the `path` value.
  66. @param path - Path of the property in the object, using `.` to separate each nested key. Use `\\.` if you have a `.` in the key.
  67. @returns A boolean of whether the property existed before being deleted.
  68. @example
  69. ```
  70. import dotProp = require('dot-prop');
  71. const object = {foo: {bar: 'a'}};
  72. dotProp.delete(object, 'foo.bar');
  73. console.log(object);
  74. //=> {foo: {}}
  75. object.foo.bar = {x: 'y', y: 'x'};
  76. dotProp.delete(object, 'foo.bar.x');
  77. console.log(object);
  78. //=> {foo: {bar: {y: 'x'}}}
  79. ```
  80. */
  81. delete(object: {[key: string]: any}, path: string): boolean;
  82. };
  83. export = dotProp;