You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
18 lines
475 B
18 lines
475 B
"use strict";
|
|
|
|
/**
|
|
* Returns `true` when the argument is an iterable, `false` otherwise
|
|
*
|
|
* @alias module:samsam.isIterable
|
|
* @param {*} val - A value to examine
|
|
* @returns {boolean} Returns `true` when the argument is an iterable, `false` otherwise
|
|
*/
|
|
function isIterable(val) {
|
|
// checks for null and undefined
|
|
if (typeof val !== "object") {
|
|
return false;
|
|
}
|
|
return typeof val[Symbol.iterator] === "function";
|
|
}
|
|
|
|
module.exports = isIterable;
|
|
|