omit.js 678 B

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