index.js
function collectTargetObservablesAndContext(templateObject) {
  var targets = [];
  var contexts = [];

  /**
   *
   * ```
   *   // context index sample (`x` == Observable)
   *   {
   *     foo: x, // => ['foo']
   *     bar: {
   *       foo: x, // => ['bar', 'foo']
   *       bar: [_, _, x]  // => ['bar', 'bar', 2]
   *     },
   *     baz: [_, x, _], // => ['baz', 1]
   *     qux: {
   *       foo: {
   *         foo: x // => ['qux', 'foo', 'foo']
   *       }
   *     }
   *   }
   * ```
   *
   * @param {Array<*>|Object<*>} list
   * @param {Array<Array<number|string>>} parentContext like [0, 3, 2...]
   */
  function walker(list, parentContext) {

    if (Array.isArray(list)) {
      list.forEach(evaluator);
    } else {
      Object.keys(list).forEach(function(key) {
        evaluator(list[key], key);
      });
    }

    function evaluator(value, key) {
      var context = parentContext.slice();
      context.push(key);

      // maybe isObservable
      if (value != null && value.subscribe != null && value.publish != null) {
        targets.push(value);
        contexts.push(context);

        // isArray || isObject
      } else if (Array.isArray(value) || (!!value && typeof value === 'object')) {
        walker(value, context);
      }
    }
  }

  walker(templateObject, []);

  return {
    targets  : targets,
    contexts : contexts
  };
}
function collectTargetObservablesAndContext(templateObject) {
  var targets = [];
  var contexts = [];

  /**
   *
   * ```
   *   // context index sample (`x` == Observable)
   *   {
   *     foo: x, // => ['foo']
   *     bar: {
   *       foo: x, // => ['bar', 'foo']
   *       bar: [_, _, x]  // => ['bar', 'bar', 2]
   *     },
   *     baz: [_, x, _], // => ['baz', 1]
   *     qux: {
   *       foo: {
   *         foo: x // => ['qux', 'foo', 'foo']
   *       }
   *     }
   *   }
   * ```
   *
   * @param {Array<*>|Object<*>} list
   * @param {Array<Array<number|string>>} parentContext like [0, 3, 2...]
   */
  function walker(list, parentContext) {

    if (Array.isArray(list)) {
      list.forEach(evaluator);
    } else {
      Object.keys(list).forEach(function(key) {
        evaluator(list[key], key);
      });
    }

    function evaluator(value, key) {
      var context = parentContext.slice();
      context.push(key);

      // maybe isObservable
      if (value != null && value.subscribe != null && value.publish != null) {
        targets.push(value);
        contexts.push(context);

        // isArray || isObject
      } else if (Array.isArray(value) || (!!value && typeof value === 'object')) {
        walker(value, context);
      }
    }
  }

  walker(templateObject, []);

  return {
    targets  : targets,
    contexts : contexts
  };
}
function collectTargetObservablesAndContext ( templateObject ) { var targets = [ ] ; var contexts = [ ] ; /**
   *
   * ```
   *   // context index sample (`x` == Observable)
   *   {
   *     foo: x, // => ['foo']
   *     bar: {
   *       foo: x, // => ['bar', 'foo']
   *       bar: [_, _, x]  // => ['bar', 'bar', 2]
   *     },
   *     baz: [_, x, _], // => ['baz', 1]
   *     qux: {
   *       foo: {
   *         foo: x // => ['qux', 'foo', 'foo']
   *       }
   *     }
   *   }
   * ```
   *
   * @param {Array<*>|Object<*>} list
   * @param {Array<Array<number|string>>} parentContext like [0, 3, 2...]
   */ function walker ( list , parentContext ) { if ( Array . isArray ( list ) ) { list . forEach ( evaluator ) ; } else { Object . keys ( list ) . forEach ( function ( key ) { evaluator ( list [ key ] , key ) ; } ) ; } function evaluator ( value , key ) { var context = parentContext . slice ( ) ; context . push ( key ) ; // maybe isObservable if ( value != null && value . subscribe != null && value . publish != null ) { targets . push ( value ) ; contexts . push ( context ) ; // isArray || isObject } else if ( Array . isArray ( value ) || ( ! ! value && typeof value === 'object' ) ) { walker ( value , context ) ; } } } walker ( templateObject , [ ] ) ; return { targets : targets , contexts : contexts } ; }
Log target observable & context that indicates the position in the object.

@param {Object} templateObject
@returns {{targets: Array, contexts: Array}}
Log target observable & context that indicates the position in the object .