omit.js 708 B

12345678910111213141516171819202122
  1. import restArguments from './restArguments.js';
  2. import isFunction from './isFunction.js';
  3. import negate from './negate.js';
  4. import map from './map.js';
  5. import flatten from './_flatten.js';
  6. import contains from './contains.js';
  7. import pick from './pick.js';
  8. // Return a copy of the object without the disallowed properties.
  9. export default restArguments(function(obj, keys) {
  10. var iteratee = keys[0], context;
  11. if (isFunction(iteratee)) {
  12. iteratee = negate(iteratee);
  13. if (keys.length > 1) context = keys[1];
  14. } else {
  15. keys = map(flatten(keys, false, false), String);
  16. iteratee = function(value, key) {
  17. return !contains(keys, key);
  18. };
  19. }
  20. return pick(obj, iteratee, context);
  21. });