Sha256: ce43e2c00956ed8fcc89a35f7bbfd47f200d9914673736610566b6c3974ba28d
Contents?: true
Size: 935 Bytes
Versions: 14
Compression:
Stored size: 935 Bytes
Contents
function extremaBy(source, keySelector, comparer) { return new AnonymousObservable(function (o) { var hasValue = false, lastKey = null, list = []; return source.subscribe(function (x) { var comparison, key; try { key = keySelector(x); } catch (ex) { o.onError(ex); return; } comparison = 0; if (!hasValue) { hasValue = true; lastKey = key; } else { try { comparison = comparer(key, lastKey); } catch (ex1) { o.onError(ex1); return; } } if (comparison > 0) { lastKey = key; list = []; } if (comparison >= 0) { list.push(x); } }, function (e) { o.onError(e); }, function () { o.onNext(list); o.onCompleted(); }); }, source); }
Version data entries
14 entries across 7 versions & 1 rubygems