function Collection(options) {
  if (!(this instanceof Collection)){
    return new Collection(options);
  }

  options = options || {};

  if (options instanceof Array) {
    this.modelType = undefined;
    this.items = options;
  } else {
    this.modelType = options.modelType;
    this.items = options.items || [];

    if (!(this.items instanceof Array)) {
      throw new CollectionException('Items must be an array');
    }
  }
}

function
Collection
(
options
)
{
if
(
!
(
this
instanceof
Collection
)
)
{
return
new
Collection
(
options
)
;
}
options
=
options
||
{
}
;
if
(
options
instanceof
Array
)
{
this
.
modelType
=
undefined
;
this
.
items
=
options
;
}
else
{
this
.
modelType
=
options
.
modelType
;
this
.
items
=
options
.
items
||
[
]
;
if
(
!
(
this
.
items
instanceof
Array
)
)
{
throw
new
CollectionException
(
'Items must be an array'
)
;
}
}
}

Create a new collection

@param {Object} options       the options


function find(filter) {
  var item;
  var i;
  var ilen;
  var keys;
  var key;
  var k;
  var klen;
  var found;

  if (filter instanceof Function) {
    for (i = 0, ilen = this.items.length; i < ilen; ++i) {
      item = this.items[i];
      if (filter(item, i)) {
        return item;
      }
    }
  } else if (filter !== null && filter !== undefined) {
    if (typeof filter === 'object') {
      keys = Object.keys(filter);
      klen = keys.length;
      for (i = 0, ilen = this.items.length; i < ilen; ++i) {
        item = this.items[i];
        found = true;
        for (k = 0; k < klen && found; ++k) {
          key = keys[k];
          if (filter[key] !== item[key]) {
            found = false;
          }
        }
        if (found) {
          return item;
        }
      }
    } else if (this.modelType) {
      keys = Object.keys(this.modelType.attributes);
      klen = keys.length;
      for (i = 0, ilen = this.items.length; i < ilen; ++i) {
        item = this.items[i];
        found = false;
        for (k = 0; k < klen && !found; ++k) {
          key = keys[k];
          if (filter === item[key]) {
            found = true;
          }
        }
        if (found) {
          return item;
        }
      }
    } else {
      for (i = 0, ilen = this.items.length; i < ilen; ++i) {
        item = this.items[i];
        found = false;
        keys = Object.keys(item);
        for (k = 0, klen = keys.length; k < klen && !found; ++k) {
          key = keys[k];
          if (filter === item[key]) {
            found = true;
          }
        }
        if (found) {
          return item;
        }
      }
    }
  }

  return undefined;
}

function find ( filter ) { var item ; var i ; var ilen ; var keys ; var key ; var k ; var klen ; var found ; if ( filter instanceof Function ) { for ( i = 0 , ilen = this . items . length ; i < ilen ; ++ i ) { item = this . items [ i ] ; if ( filter ( item , i ) ) { return item ; } } } else if ( filter !== null && filter !== undefined ) { if ( typeof filter === 'object' ) { keys = Object . keys ( filter ) ; klen = keys . length ; for ( i = 0 , ilen = this . items . length ; i < ilen ; ++ i ) { item = this . items [ i ] ; found = true ; for ( k = 0 ; k < klen && found ; ++ k ) { key = keys [ k ] ; if ( filter [ key ] !== item [ key ] ) { found = false ; } } if ( found ) { return item ; } } } else if ( this . modelType ) { keys = Object . keys ( this . modelType . attributes ) ; klen = keys . length ; for ( i = 0 , ilen = this . items . length ; i < ilen ; ++ i ) { item = this . items [ i ] ; found = false ; for ( k = 0 ; k < klen && ! found ; ++ k ) { key = keys [ k ] ; if ( filter === item [ key ] ) { found = true ; } } if ( found ) { return item ; } } } else { for ( i = 0 , ilen = this . items . length ; i < ilen ; ++ i ) { item = this . items [ i ] ; found = false ; keys = Object . keys ( item ) ; for ( k = 0 , klen = keys . length ; k < klen && ! found ; ++ k ) { key = keys [ k ] ; if ( filter === item [ key ] ) { found = true ; } } if ( found ) { return item ; } } } } return undefined ; }

Find the first item matching filter

@param {string|Object} filter      the filter
@return {Object}                   the model found


function (context, grunt) {
  this.context = context;
  this.grunt = grunt;

  // Merge task-specific and/or target-specific options with these defaults.
  this.options = context.options(defaultOptions);
}

function ( context , grunt ) { this . context = context ; this . grunt = grunt ; this . options = context . options ( defaultOptions ) ; }

Creates a new task.

@param context Task function context (='this' inside a grunt task function)
@param grunt Grunt object