benchmarks/scenarios/ember.js
function subscribe(pattern, object) {
    var paths = pattern.split('.');
    var path;
    var regex = [];

    for (var i = 0, l = paths.length; i < l; i++) {
      path = paths[i];
      if (path === '*') {
        regex.push('[^\\.]*');
      } else {
        regex.push(path);
      }
    }

    regex = regex.join('\\.');
    regex = regex + '(\\..*)?';

    var subscriber = {
      pattern: pattern,
      regex: new RegExp('^' + regex + '$'),
      object: object
    };

    subscribers.push(subscriber);
    cache = {};

    return subscriber;
  }
function subscribe(pattern, object) {
    var paths = pattern.split('.');
    var path;
    var regex = [];

    for (var i = 0, l = paths.length; i < l; i++) {
      path = paths[i];
      if (path === '*') {
        regex.push('[^\\.]*');
      } else {
        regex.push(path);
      }
    }

    regex = regex.join('\\.');
    regex = regex + '(\\..*)?';

    var subscriber = {
      pattern: pattern,
      regex: new RegExp('^' + regex + '$'),
      object: object
    };

    subscribers.push(subscriber);
    cache = {};

    return subscriber;
  }
function subscribe ( pattern , object ) { var paths = pattern . split ( '.' ) ; var path ; var regex = [ ] ; for ( var i = 0 , l = paths . length ; i < l ; i ++ ) { path = paths [ i ] ; if ( path === '*' ) { regex . push ( '[^\\.]*' ) ; } else { regex . push ( path ) ; } } regex = regex . join ( '\\.' ) ; regex = regex + '(\\..*)?' ; var subscriber = { pattern : pattern , regex : new RegExp ( '^' + regex + '$' ) , object : object } ; subscribers . push ( subscriber ) ; cache = { } ; return subscriber ; }
Subscribes to a particular event or instrumented block of code.

@method subscribe
@namespace Ember.Instrumentation

@param {String} [pattern] Namespaced event name.
@param {Object} [object] Before and After hooks.

@return {Subscriber}
@private
Subscribes to a particular event or instrumented block of code .