Fork me on GitHub

AFrameJS

- Javascript MVC Library

static class AFrame.EnumerableMixin

A collection of functions common to enumerable objects. When mixing in this class, the class being mixed into must define a forEach function.

Methods

Methods Returns Description
filter( search ) array

Get a set of items in the collection using the search function. The search function will be called once for each item in the collection. Any time the search function returns true, the item will be added to the results list.

// Filter the collection to find a set of items that have company == 'AFrame Foundary'
var matches = collection.filter( function( item, id, collection ) {
    // do search here, returning true if item matches.
    return item.company == 'AFrame Foundary';
} );

Parameters:

  • search <function>
    • the search function
    • Returns:

      • <array>

        array of results. If no results are found, returns an empty array.

getCount( ) number

Get the current count of items

// using hash from top of the page
var count = hash.getCount();

Returns:

  • <number>

    current count

search( search ) item

Search for the first item in the collection that matches the search function.

// search for the first item with company == 'AFrame Foundary'
var item = collection.search( function( item, id, collection ) {
    return item.company == 'AFrame Foundary';
} );

Parameters:

  • search <function>
    • the search function.
    • Returns:

      • <item>

        item if an item matches, undefined otw.