{"ast":null,"code":"import { Subscriber } from '../Subscriber';\nexport function find(predicate, thisArg) {\n  if (typeof predicate !== 'function') {\n    throw new TypeError('predicate is not a function');\n  }\n\n  return source => source.lift(new FindValueOperator(predicate, source, false, thisArg));\n}\nexport class FindValueOperator {\n  constructor(predicate, source, yieldIndex, thisArg) {\n    this.predicate = predicate;\n    this.source = source;\n    this.yieldIndex = yieldIndex;\n    this.thisArg = thisArg;\n  }\n\n  call(observer, source) {\n    return source.subscribe(new FindValueSubscriber(observer, this.predicate, this.source, this.yieldIndex, this.thisArg));\n  }\n\n}\nexport class FindValueSubscriber extends Subscriber {\n  constructor(destination, predicate, source, yieldIndex, thisArg) {\n    super(destination);\n    this.predicate = predicate;\n    this.source = source;\n    this.yieldIndex = yieldIndex;\n    this.thisArg = thisArg;\n    this.index = 0;\n  }\n\n  notifyComplete(value) {\n    const destination = this.destination;\n    destination.next(value);\n    destination.complete();\n    this.unsubscribe();\n  }\n\n  _next(value) {\n    const {\n      predicate,\n      thisArg\n    } = this;\n    const index = this.index++;\n\n    try {\n      const result = predicate.call(thisArg || this, value, index, this.source);\n\n      if (result) {\n        this.notifyComplete(this.yieldIndex ? index : value);\n      }\n    } catch (err) {\n      this.destination.error(err);\n    }\n  }\n\n  _complete() {\n    this.notifyComplete(this.yieldIndex ? -1 : undefined);\n  }\n\n} //# sourceMappingURL=find.js.map","map":null,"metadata":{},"sourceType":"module"}