Skip to content
This repository has been archived by the owner on Oct 2, 2024. It is now read-only.

Commit

Permalink
Use static Symbol check
Browse files Browse the repository at this point in the history
  • Loading branch information
Eli Skeggs committed Oct 18, 2018
1 parent 774ed58 commit f231550
Showing 1 changed file with 6 additions and 23 deletions.
29 changes: 6 additions & 23 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -197,31 +197,14 @@ internals.checkIpV6 = function (items) {
};


internals.isIterable = function (value) {
internals.isIterable = Array.isArray;

/* $lab:coverage:off$ */
if (!value) {
return false;
}
/* $lab:coverage:on$ */

if (typeof value !== 'object') {
return false;
}

// Return early in case we're on a version that doesn't support iterators.
if (Array.isArray(value)) {
return true;
}

/* $lab:coverage:off$ */
if (typeof Symbol === 'undefined') {
return false;
}
/* $lab:coverage:on$ */

return typeof value[Symbol.iterator] === 'function';
};
/* $lab:coverage:off$ */
if (typeof Symbol !== 'undefined') {
internals.isIterable = (value) => Array.isArray(value) || (!!value && typeof value === 'object' && typeof value[Symbol.iterator] === 'function');
}
/* $lab:coverage:on$ */


// Node 10 introduced isSet and isMap, which are useful for cross-context type
Expand Down

0 comments on commit f231550

Please sign in to comment.