mirror of
https://github.com/HSLdevcom/digitransit-ui
synced 2025-07-05 16:30:37 +02:00
14 lines
366 B
JavaScript
14 lines
366 B
JavaScript
function isObject(it) {
|
|
return typeof it === 'object' ? it !== null : typeof it === 'function';
|
|
}
|
|
|
|
export default function iter(it) {
|
|
const iterFn = it[Symbol.iterator];
|
|
if (typeof iterFn !== 'function') {
|
|
throw TypeError(`${it} is not iterable!`);
|
|
}
|
|
if (!isObject(it)) {
|
|
throw TypeError(`${it} is not an object!`);
|
|
}
|
|
return iterFn.call(it);
|
|
}
|