Guest User

Untitled

a guest
Feb 19th, 2018
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.45 KB | None | 0 0
  1. /**
  2. * compactObject
  3. * =============
  4. * Simple port of Underscore Array's compact function. You need to replace _.trim function if underscore.string it's not included.
  5. */
  6.  
  7. _.mixin({
  8. compactObject: function(to_clean) {
  9. _.map(to_clean, function(value, key, to_clean) {
  10. if ( !!!value || (_.isString(value) && _.trim(value).length === 0)) {
  11. delete to_clean[key];
  12. }
  13. });
  14. return to_clean;
  15. }
  16. });
Add Comment
Please, Sign In to add comment