@ipp/cli
Version:
An image build orchestrator for the modern web
30 lines (29 loc) • 902 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.map = void 0;
const object_stream_1 = require("../object_stream");
function map(fn, complete) {
return (source) => (0, object_stream_1.createObjectStream)((async function* () {
for await (const item of source) {
const results = await fn(item);
if (results === null)
continue;
if (Array.isArray(results)) {
for (const result of results)
yield result;
}
else {
yield results;
}
}
if (complete)
await complete();
})());
}
exports.map = map;