@ipp/cli
Version:
An image build orchestrator for the modern web
23 lines (22 loc) • 927 B
JavaScript
;
/**
* Image Processing Pipeline - Copyright (c) Marcus Cemes
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.exceptionCounter = exports.completedCounter = exports.sourceCounter = void 0;
const common_1 = require("@ipp/common");
const map_1 = require("../lib/stream/operators/map");
const types_1 = require("./types");
function createCounter(fn, key) {
return (ctx) => (0, map_1.map)((item) => {
if (fn(item))
ctx.state.update((state) => ++state.images[key]);
return item;
});
}
exports.sourceCounter = createCounter(types_1.isTaskSource, "found");
exports.completedCounter = createCounter(types_1.isCompletedTask, "completed");
exports.exceptionCounter = createCounter((x) => x instanceof common_1.Exception, "failed");