check-iterable
Advanced tools
Comparing version 1.0.5 to 1.1.0
26
index.js
@@ -13,8 +13,7 @@ "use strict"; | ||
exports.isAsyncGenerator = isAsyncGenerator; | ||
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } | ||
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); } | ||
if (!Symbol.asyncIterator) { | ||
Symbol.asyncIterator = Symbol("Symbol.asyncIterator"); | ||
} | ||
/** | ||
@@ -24,7 +23,6 @@ * Checks if the given object is an Iterable (implemented `@@iterator`). | ||
*/ | ||
function isIterable(obj) { | ||
return obj !== null && obj !== undefined && typeof obj[Symbol.iterator] === "function"; | ||
} | ||
/** | ||
@@ -34,7 +32,6 @@ * Checks if the given object is an AsyncIterable (implemented `@@asyncIterator`). | ||
*/ | ||
function isAsyncIterable(obj) { | ||
return obj !== null && obj !== undefined && typeof obj[Symbol.asyncIterator] === "function"; | ||
} | ||
/** | ||
@@ -44,4 +41,2 @@ * Checks if the given object is an IteratorLike (implemented `next`). | ||
*/ | ||
function isIteratorLike(obj) { | ||
@@ -52,2 +47,3 @@ // An iterable object has a 'next' method, however including a 'next' method | ||
} | ||
/** | ||
@@ -57,7 +53,6 @@ * Checks if the given object is an IterableIterator (implemented both | ||
*/ | ||
function isIterableIterator(obj) { | ||
return isIteratorLike(obj) && typeof obj[Symbol.iterator] === "function"; | ||
} | ||
/** | ||
@@ -68,7 +63,6 @@ * Checks if the given object is an AsyncIterableIterator (implemented | ||
*/ | ||
function isAsyncIterableIterator(obj) { | ||
return isIteratorLike(obj) && typeof obj[Symbol.asyncIterator] === "function"; | ||
} | ||
/** | ||
@@ -78,7 +72,6 @@ * Checks if the given object is a Generator. | ||
*/ | ||
function isGenerator(obj) { | ||
return isIterableIterator(obj) && hasGeneratorSpecials(obj); | ||
} | ||
/** | ||
@@ -88,10 +81,7 @@ * Checks if the given object is an AsyncGenerator. | ||
*/ | ||
function isAsyncGenerator(obj) { | ||
return isAsyncIterableIterator(obj) && hasGeneratorSpecials(obj); | ||
} | ||
function hasGeneratorSpecials(obj) { | ||
return typeof obj["return"] === "function" && typeof obj["throw"] === "function"; | ||
} |
{ | ||
"name": "check-iterable", | ||
"version": "1.0.5", | ||
"version": "1.1.0", | ||
"description": "A toolbox to check if an object is iterable, an iterator or a generator, etc.", | ||
@@ -16,3 +16,3 @@ "main": "index.js", | ||
"type": "git", | ||
"url": "git+https://github.com/hyurl/check-iterable.git" | ||
"url": "git+https://github.com/ayonli/check-iterable.git" | ||
}, | ||
@@ -28,8 +28,8 @@ "keywords": [ | ||
], | ||
"author": "A-yon Lee <i@hyurl.com>", | ||
"author": "A-yon Lee <the@ayon.li>", | ||
"license": "MIT", | ||
"bugs": { | ||
"url": "https://github.com/hyurl/check-iterable/issues" | ||
"url": "https://github.com/ayonli/check-iterable/issues" | ||
}, | ||
"homepage": "https://github.com/hyurl/check-iterable#readme", | ||
"homepage": "https://github.com/ayonli/check-iterable#readme", | ||
"devDependencies": { | ||
@@ -36,0 +36,0 @@ "@babel/preset-env": "^7.12.7", |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
7366
1