axax
Version:
A library of async iterator extensions for JavaScript including ```map```, ```reduce```, ```filter```, ```flatMap```, ```pipe``` and [more](https://github.com/jamiemccrindle/axax/blob/master/docs/API.md#functions).
18 lines (17 loc) • 483 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
/**
* Only emit when the current value is different than the last.
*/
function distinctUntilChanged() {
return async function* inner(source) {
let previousItem;
for await (const item of source) {
if (previousItem !== item) {
yield item;
}
previousItem = item;
}
};
}
exports.distinctUntilChanged = distinctUntilChanged;