Repository: marpple/FxTS (ts)

Issue:
feat: `fx` is also applied to operate as iterable by default.
# Suggestion

<!--
  Please fill in each section completely. Thank you!
-->


Even if we do not apply a method to `fx`, it operates as an iterable by default.

## ⭐ Suggestion

<!-- What would you like to be added? -->

## 💻 Use Cases

<!-- What do you want to use this for? -->


Pull request description:
feat: expose public iterable properties
Fixes #273



Patch:
diff --git a/src/Lazy/fx.ts b/src/Lazy/fx.ts
index bf3c3295..7ee8e164 100644
--- a/src/Lazy/fx.ts
+++ b/src/Lazy/fx.ts
@@ -36,8 +36,8 @@ class FxAsyncIterable<A> {
     this.asyncIterable = asyncIterable;
   }
 
-  private [Symbol.asyncIterator]() {
-    return this.asyncIterable;
+  [Symbol.asyncIterator]() {
+    return this.asyncIterable[Symbol.asyncIterator]();
   }
 
   /**
@@ -297,8 +297,8 @@ export class FxIterable<A> {
     this.iterable = iterable;
   }
 
-  private [Symbol.iterator]() {
-    return this.iterable;
+  [Symbol.iterator]() {
+    return this.iterable[Symbol.iterator]();
   }
 
   /**


Test patch:
diff --git a/test/Lazy/fx.spec.ts b/test/Lazy/fx.spec.ts
index bc6174f1..45348c31 100644
--- a/test/Lazy/fx.spec.ts
+++ b/test/Lazy/fx.spec.ts
@@ -1,7 +1,15 @@
-import { fx, toAsync } from "../../src";
+import { fx, toArray, toAsync } from "../../src";
 
 describe("fx", function () {
   describe("sync", function () {
+    it("handle fx iterable (default)", function () {
+      const res1 = [...fx([1, 2, 3, 4, 5])];
+      expect(res1).toEqual([1, 2, 3, 4, 5]);
+
+      const res2 = [...fx("abc")];
+      expect(res2).toEqual(["a", "b", "c"]);
+    });
+
     it("handle fx iterable", function () {
       const res = fx([1, 2, 3, 4, 5])
         .map((a) => a + 10)
@@ -11,6 +19,14 @@ describe("fx", function () {
   });
 
   describe("async", () => {
+    it("handle fx asyncIterable (default)", async function () {
+      const res1 = await toArray(fx(toAsync([1, 2, 3, 4, 5])));
+      expect(res1).toEqual([1, 2, 3, 4, 5]);
+
+      const res2 = await toArray(fx(toAsync("abc")));
+      expect(res2).toEqual(["a", "b", "c"]);
+    });
+
     it("handle fx asyncIterable", async function () {
       const res1 = await fx(toAsync([1, 2, 3, 4, 5]))
         .map(async (a) => a + 10)
diff --git a/type-check/Lazy/fx.test.ts b/type-check/Lazy/fx.test.ts
index ecbf9d1b..b572c1dc 100644
--- a/type-check/Lazy/fx.test.ts
+++ b/type-check/Lazy/fx.test.ts
@@ -21,6 +21,9 @@ const res7 = fx(toAsync([1, 2, 3]))
   .map((a) => a)
   .toArray();
 
+const res8 = [...fx([1, 2, 3])];
+const res9 = [...fx("abc")];
+
 checks([
   check<typeof res1, Cast<Iterable<number>, typeof res1>, Test.Pass>(),
   check<typeof res2, number[], Test.Pass>(),
@@ -29,4 +32,6 @@ checks([
   check<typeof res5, Cast<AsyncIterable<number>, typeof res5>, Test.Pass>(),
   check<typeof res6, Cast<AsyncIterable<number>, typeof res5>, Test.Pass>(),
   check<typeof res7, Promise<number[]>, Test.Pass>(),
+  check<typeof res8, number[], Test.Pass>(),
+  check<typeof res9, string[], Test.Pass>(),
 ]);