lib/index.js
function Match(elm, options, data) {
    this.ev = new EventEmitter();
    this.data = options.data || data;
    this.found = {};
    this.timestamps = [];
    this.flippedPairs = 0;

    // [elm, elm]
    this.active = [];

    this.options = Ul.deepMerge(options, {
        autoremove: true
      , size: {
            x: 4
          , y: 4
        }
      , classes: {
            active: "active"
        }
      , step: {
            x: 43
          , y: 43
        }
    });

    this.blocks_count = this.options.size.x * this.options.size.y;
    this.count = this.blocks_count / 2;

    if (this.blocks_count % 2) {
        throw new Error("The number of blocks should be even.");
    }

    this.ui = {
        container: ElmSelect(elm)[0]
      , items: []
      , template: options.templateElm
                ? ElmSelect(options.templateElm)[0].outerHTML
                : options.template
    };

    if (!Array.isArray(this.data)) {
        throw new Error("Data should be an array.");
    }
}
function Match(elm, options, data) {
    this.ev = new EventEmitter();
    this.data = options.data || data;
    this.found = {};
    this.timestamps = [];
    this.flippedPairs = 0;

    // [elm, elm]
    this.active = [];

    this.options = Ul.deepMerge(options, {
        autoremove: true
      , size: {
            x: 4
          , y: 4
        }
      , classes: {
            active: "active"
        }
      , step: {
            x: 43
          , y: 43
        }
    });

    this.blocks_count = this.options.size.x * this.options.size.y;
    this.count = this.blocks_count / 2;

    if (this.blocks_count % 2) {
        throw new Error("The number of blocks should be even.");
    }

    this.ui = {
        container: ElmSelect(elm)[0]
      , items: []
      , template: options.templateElm
                ? ElmSelect(options.templateElm)[0].outerHTML
                : options.template
    };

    if (!Array.isArray(this.data)) {
        throw new Error("Data should be an array.");
    }
}
function Match ( elm , options , data ) { this . ev = new EventEmitter ( ) ; this . data = options . data || data ; this . found = { } ; this . timestamps = [ ] ; this . flippedPairs = 0 ; // [elm, elm] this . active = [ ] ; this . options = Ul . deepMerge ( options , { autoremove : true , size : { x : 4 , y : 4 } , classes : { active : "active" } , step : { x : 43 , y : 43 } } ) ; this . blocks_count = this . options . size . x * this . options . size . y ; this . count = this . blocks_count / 2 ; if ( this . blocks_count % 2 ) { throw new Error ( "The number of blocks should be even." ) ; } this . ui = { container : ElmSelect ( elm ) [ 0 ] , items : [ ] , template : options . templateElm ? ElmSelect ( options . templateElm ) [ 0 ] . outerHTML : options . template } ; if ( ! Array . isArray ( this . data ) ) { throw new Error ( "Data should be an array." ) ; } }
Match
Creates a new `Match` instance.

Events you can listen to:

- `deactivate` (HTMLElement): Triggered when the block is deactivated.
- `activate` (HTMLElement): Triggered when the block is activated.
- `pair-flip` (HTMLElement, HTMLElement): After a pair flip.
- `success` (HTMLElement, HTMLElement): When a match is found.
- `win` (Number): Emitted when the game is over (the first argument is a
number representing the number of miliseconds from the moment the game
was started to now).
- `render` (currentElement, data, isDuplicate): Emitted on render–the HTML
element can be modified which will end in the editing the HTML. The data
object is the current data object reference. The `isDuplicate` parameter
takes a value of `0` or `1` (when the match is rendered).
- `time` (Number): Like `win`, but emitted every second, during the game.

@name Match
@function
@param {Element|String} elm The HTML element or the query selector.
@param {Object} options An object containing the following fields:

- `autoremove` (Boolean): If `true`, the blocks will be removed when they are matching (default: `true`).
- `size` (Object):
- `x` (Number): How many blocks per row (default: `4`).
- `y` (Number): How many blocks per column (default: `4`).
- `classes` (Object):
- `active` (String): The active class added the active block elements (default: `"active"`).
- `step` (Object):
- `x` (Number): How much should be increased the `x` coordinate for each block.
- `y` (Number): How much should be increased the `y` coordinate for each block.

@param {Array} data Array of objects used in the templating.
@return {Match} The `Match` instance.
Match Creates a new Match instance .