@bitblit/ratchet-common
Version:
Common tools for general use
27 lines • 832 B
JavaScript
export class CompositeLastSuccessProvider {
sources;
mostRecent;
constructor(src, mostRecentSrc = true) {
if (!src || src.length == 0) {
throw Error('Cannot create composite provider with null/empty sources');
}
this.sources = src;
this.mostRecent = mostRecentSrc;
}
lastSuccess() {
let rval = null;
this.sources.forEach((s) => {
const val = s.lastSuccess();
if (val != null) {
if (rval == null) {
rval = val;
}
else {
rval = (val > rval && this.mostRecent) || (val < rval && !this.mostRecent) ? val : rval;
}
}
});
return rval;
}
}
//# sourceMappingURL=composite-last-success-provider.js.map