{"ast":null,"code":"import { EmptyError } from '../util/EmptyError';\nimport { SequenceError } from '../util/SequenceError';\nimport { NotFoundError } from '../util/NotFoundError';\nimport { operate } from '../util/lift';\nimport { createOperatorSubscriber } from './OperatorSubscriber';\nexport function single(predicate) {\n  return operate((source, subscriber) => {\n    let hasValue = false;\n    let singleValue;\n    let seenValue = false;\n    let index = 0;\n    source.subscribe(createOperatorSubscriber(subscriber, value => {\n      seenValue = true;\n      if (!predicate || predicate(value, index++, source)) {\n        hasValue && subscriber.error(new SequenceError('Too many matching values'));\n        hasValue = true;\n        singleValue = value;\n      }\n    }, () => {\n      if (hasValue) {\n        subscriber.next(singleValue);\n        subscriber.complete();\n      } else {\n        subscriber.error(seenValue ? new NotFoundError('No matching values') : new EmptyError());\n      }\n    }));\n  });\n}\n//# sourceMappingURL=single.js.map","map":null,"metadata":{},"sourceType":"module","externalDependencies":[]}