async function normalize(items, context, extraConfigTypes) {

	const allowFunctions = extraConfigTypes.includes('function');
	const allowArrays = extraConfigTypes.includes('array');

	async function *flatTraverse(array) {
		for (let item of array) {
			if (typeof item === 'function') {
				if (!allowFunctions) {
					throw new TypeError('Unexpected function.');
				}

				item = item(context);
				if (item.then) {
					item = await item;
				}
			}

			if (Array.isArray(item)) {
				if (!allowArrays) {
					throw new TypeError('Unexpected array.');
				}
				yield * flatTraverse(item);
			} else if (typeof item === 'function') {
				throw new TypeError('A config function can only return an object or array.');
			} else {
				yield item;
			}
		}
	}

	/*
	 * Async iterables cannot be used with the spread operator, so we need to manually
	 * create the array to return.
	 */
	const asyncIterable = await flatTraverse(items);
	const configs = [];

	for await (const config of asyncIterable) {
		configs.push(config);
	}

	return configs;
}
/**
 * Normalizes a `ConfigArray` by flattening it and executing any functions
 * that are found inside.
 * @param {Array} items The items in a `ConfigArray`.
 * @param {Object} context The context object to pass into any function
 *      found.
 * @param {Array<string>} extraConfigTypes The config types to check.
 * @returns {Promise<Array>} A flattened array containing only config objects.
 * @throws {TypeError} When a config function returns a function.
 */
Normalizes a `ConfigArray` by flattening it and executing any functions
that are found inside.
@param {Array} items The items in a `ConfigArray`.
@param {Object} context The context object to pass into any function
found.
@param {Array} extraConfigTypes The config types to check.
@returns {Promise} A flattened array containing only config objects.
@throws {TypeError} When a config function returns a function.
Normalizes a ` ConfigArray ` by flattening it and executing any functions that are found inside . @param { Array } items The items in a ` ConfigArray ` . @param { Object } context The context object to pass into any function found . @param { Array } extraConfigTypes The config types to check . @returns { Promise } A flattened array containing only config objects . @throws { TypeError } When a config function returns a function .
async function normalize(items, context, extraConfigTypes) {
	const allowFunctions = extraConfigTypes.includes('function');
	const allowArrays = extraConfigTypes.includes('array');
	async function *flatTraverse(array) {
		for (let item of array) {
			if (typeof item === 'function') {
				if (!allowFunctions) {
					throw new TypeError('Unexpected function.');
				}
				item = item(context);
				if (item.then) {
					item = await item;
				}
			}
			if (Array.isArray(item)) {
				if (!allowArrays) {
					throw new TypeError('Unexpected array.');
				}
				yield * flatTraverse(item);
			} else if (typeof item === 'function') {
				throw new TypeError('A config function can only return an object or array.');
			} else {
				yield item;
			}
		}
	}
	const asyncIterable = await flatTraverse(items);
	const configs = [];
	for await (const config of asyncIterable) {
		configs.push(config);
	}
	return configs;
}
async function normalize ( items , context , extraConfigTypes ) { const allowFunctions = extraConfigTypes . includes ( 'function' ) ; const allowArrays = extraConfigTypes . includes ( 'array' ) ; async function * flatTraverse ( array ) { for ( let item of array ) { if ( typeof item === 'function' ) { if ( ! allowFunctions ) { throw new TypeError ( 'Unexpected function.' ) ; } item = item ( context ) ; if ( item . then ) { item = await item ; } } if ( Array . isArray ( item ) ) { if ( ! allowArrays ) { throw new TypeError ( 'Unexpected array.' ) ; } yield * flatTraverse ( item ) ; } else if ( typeof item === 'function' ) { throw new TypeError ( 'A config function can only return an object or array.' ) ; } else { yield item ; } } } const asyncIterable = await flatTraverse ( items ) ; const configs = [ ] ; for await ( const config of asyncIterable ) { configs . push ( config ) ; } return configs ; }
Normalizes a `ConfigArray` by flattening it and executing any functions
 that are found inside.
Normalizes a ` ConfigArray ` by flattening it and executing any functions that are found inside .
/*
	 * Async iterables cannot be used with the spread operator, so we need to manually
	 * create the array to return.
	 */