client/assets/scripts/services/search.js
function (items, query, fields, exact) {
        var self = this;
        var isTarget = function (fieldName) {
          return fields.indexOf(fieldName) !== -1;
        };
        if (query === '') {
          return items;
        }
        fields = fields || ['name', 'owner', 'description', 'keyword'];
        return _.filter(items, function (item) {
          if ((isTarget('name') && self.matchedInString(query, item.name, exact)) ||
              (isTarget('owner') && self.matchedInString(query, item.owner, exact)) ||
              (isTarget('description') && self.matchedInString(query, item.description, exact)) ||
              (isTarget('keyword') && self.matchedInArray(query, item.keywords, exact))) {
            return true;
          }
          return false;
        });
      }
function (items, query, fields, exact) {
        var self = this;
        var isTarget = function (fieldName) {
          return fields.indexOf(fieldName) !== -1;
        };
        if (query === '') {
          return items;
        }
        fields = fields || ['name', 'owner', 'description', 'keyword'];
        return _.filter(items, function (item) {
          if ((isTarget('name') && self.matchedInString(query, item.name, exact)) ||
              (isTarget('owner') && self.matchedInString(query, item.owner, exact)) ||
              (isTarget('description') && self.matchedInString(query, item.description, exact)) ||
              (isTarget('keyword') && self.matchedInArray(query, item.keywords, exact))) {
            return true;
          }
          return false;
        });
      }
function ( items , query , fields , exact ) { var self = this ; var isTarget = function ( fieldName ) { return fields . indexOf ( fieldName ) !== - 1 ; } ; if ( query === '' ) { return items ; } fields = fields || [ 'name' , 'owner' , 'description' , 'keyword' ] ; return _ . filter ( items , function ( item ) { if ( ( isTarget ( 'name' ) && self . matchedInString ( query , item . name , exact ) ) || ( isTarget ( 'owner' ) && self . matchedInString ( query , item . owner , exact ) ) || ( isTarget ( 'description' ) && self . matchedInString ( query , item . description , exact ) ) || ( isTarget ( 'keyword' ) && self . matchedInArray ( query , item . keywords , exact ) ) ) { return true ; } return false ; } ) ; }
Find items by query
Find items by query