mirror of
https://github.com/arcodange-org/mediabunny.git
synced 2026-09-29 11:53:52 +02:00
Add some more argument validation
This commit is contained in:
@@ -239,3 +239,9 @@ export const toAsyncIterator = async function* <T>(source: AnyIterable<T>): Asyn
|
||||
yield* source[Symbol.asyncIterator]();
|
||||
}
|
||||
};
|
||||
|
||||
export const validateAnyIterable = (iterable: AnyIterable<unknown>) => {
|
||||
if (!(Symbol.iterator in iterable) && !(Symbol.asyncIterator in iterable)) {
|
||||
throw new TypeError('Argument must be an iterable or async iterable.');
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user