Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.

35 wiersze
936 B

4 lat temu
  1. import _curry3 from "./internal/_curry3.js";
  2. /**
  3. * Makes a shallow clone of an object, setting or overriding the specified
  4. * property with the given value. Note that this copies and flattens prototype
  5. * properties onto the new object as well. All non-primitive properties are
  6. * copied by reference.
  7. *
  8. * @func
  9. * @memberOf R
  10. * @since v0.8.0
  11. * @category Object
  12. * @sig String -> a -> {k: v} -> {k: v}
  13. * @param {String} prop The property name to set
  14. * @param {*} val The new value
  15. * @param {Object} obj The object to clone
  16. * @return {Object} A new object equivalent to the original except for the changed property.
  17. * @see R.dissoc, R.pick
  18. * @example
  19. *
  20. * R.assoc('c', 3, {a: 1, b: 2}); //=> {a: 1, b: 2, c: 3}
  21. */
  22. var assoc =
  23. /*#__PURE__*/
  24. _curry3(function assoc(prop, val, obj) {
  25. var result = {};
  26. for (var p in obj) {
  27. result[p] = obj[p];
  28. }
  29. result[prop] = val;
  30. return result;
  31. });
  32. export default assoc;