From 6886f616bf699f0024f03dc5a6d001944e132492 Mon Sep 17 00:00:00 2001 From: Mihai Ciuraru Date: Sun, 19 May 2024 13:01:49 +0300 Subject: [PATCH] New version 4.0.3 --- linq.js | 6 +++--- package.json | 4 ++-- test/iterator.js | 5 ++++- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/linq.js b/linq.js index a034fc7..5d10134 100644 --- a/linq.js +++ b/linq.js @@ -336,8 +336,8 @@ Enumerable.from = function (obj) { }); } - // iterator object - if (typeof Symbol !== 'undefined' && typeof obj.next !== 'undefined') { + // object conforming to the iterator protocol + if (typeof obj.next == Types.Function) { return new Enumerable(function () { return new IEnumerator( Functions.Blank, @@ -3081,4 +3081,4 @@ var Grouping = function (groupKey, elements) { }; Grouping.prototype = new ArrayEnumerable(); -export default Enumerable; \ No newline at end of file +export default Enumerable; diff --git a/package.json b/package.json index 00ffe4d..04e10c0 100644 --- a/package.json +++ b/package.json @@ -3,7 +3,7 @@ "author": "Mihai Ciuraru ", "description": "linq.js - LINQ for JavaScript", "type": "module", - "version": "4.0.2", + "version": "4.0.3", "license": "MIT", "homepage": "https://github.com/mihaifm/linq", "repository": { @@ -24,4 +24,4 @@ "main": "./linq.js", "exports": "./linq.js", "types": "./linq.d.ts" -} \ No newline at end of file +} diff --git a/test/iterator.js b/test/iterator.js index 214be9f..3fa4a3e 100644 --- a/test/iterator.js +++ b/test/iterator.js @@ -1,4 +1,4 @@ -import { test, testModule, deepEqual } from './testutils.js' +import { test, testModule, deepEqual, equal } from './testutils.js' import Enumerable from '../linq.js' testModule("Iterator"); @@ -54,6 +54,9 @@ test("from Iterable object", function () { actual.push(a[0]); } deepEqual(actual, [1, 2]); + + const set = new Set([1, 2, 3]) + equal(Enumerable.from(set).first(), 1) }); test("from Iterator object", function () {