aureooms/js-tape

View on GitHub
src/asyncIterableMap.js

Summary

Maintainability
A
0 mins
Test Coverage
A
100%
import asyncIteratorMap from './asyncIteratorMap.js';

/**
 * Utility function to apply a sync callable to each item of an async iterable.
 *
 * @private
 * @param {Function} callable - The callable to apply.
 * @param {AsyncIterable} iterable - The iterable to process.
 * @returns {AsyncIterable} The iterable of mapped values.
 */
export default function asyncIterableMap(callable, iterable) {
    return asyncIteratorMap(callable, iterable[Symbol.asyncIterator]());
}