Skip to content

nuragic/underscore-mixins

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

underscore-mixins

This is an open collection of underscore mixins*. Feel free to criticize/contribute.

_.squeeze(object)

(AKA extract/flatten) - Walks over the given Object and returns an Array with only its values. See the test for more details.

Example usage

You can easily implement a search method for your Backbone.Collection using _.squeeze as showed below:

Backbone.Collection.extend({
    
  // …
  
  search: function (criteria) {
    
    return this.filter(function (model) {
      
      var modelValuesArray = _.squeeze(model.toJSON());
      
      return modelValuesArray.toString().search(new RegExp(criteria, 'gi')) !== -1 ;
    });
  }

});

*just one for now! :D

About

A collection of underscore mixins.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published