You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

31 line
723 B

4 年之前
  1. import _curry2 from "./internal/_curry2.js";
  2. /**
  3. * Returns a new object that does not contain a `prop` property.
  4. *
  5. * @func
  6. * @memberOf R
  7. * @since v0.10.0
  8. * @category Object
  9. * @sig String -> {k: v} -> {k: v}
  10. * @param {String} prop The name of the property to dissociate
  11. * @param {Object} obj The object to clone
  12. * @return {Object} A new object equivalent to the original but without the specified property
  13. * @see R.assoc, R.omit
  14. * @example
  15. *
  16. * R.dissoc('b', {a: 1, b: 2, c: 3}); //=> {a: 1, c: 3}
  17. */
  18. var dissoc =
  19. /*#__PURE__*/
  20. _curry2(function dissoc(prop, obj) {
  21. var result = {};
  22. for (var p in obj) {
  23. result[p] = obj[p];
  24. }
  25. delete result[prop];
  26. return result;
  27. });
  28. export default dissoc;