Unverified Commit 9553e573 authored by Hong Minhee's avatar Hong Minhee
Browse files

Remove dependency on aitertools

parent da0a803d
Loading
Loading
Loading
Loading
+1 −2
Original line number Diff line number Diff line
import { toSet } from "@hongminhee/aitertools";
import { assertEquals } from "@std/assert";
import { join } from "@std/path";
import { test } from "../testing/mod.ts";
@@ -18,7 +17,7 @@ test("readDirRecursive()", async () => {

  // Read the directory recursively:
  assertEquals(
    await toSet(readDirRecursive(dir)),
    new Set(await Array.fromAsync(readDirRecursive(dir))),
    new Set([
      join("a", "aa", "aaa.txt"),
      join("a", "aa.txt"),
+0 −1
Original line number Diff line number Diff line
@@ -20,7 +20,6 @@
    "@cfworker/json-schema": "npm:@cfworker/json-schema@^2.0.1",
    "@david/which-runtime": "jsr:@david/which-runtime@^0.2.1",
    "@deno/dnt": "jsr:@deno/dnt@0.41.3",
    "@hongminhee/aitertools": "jsr:@hongminhee/aitertools@^0.6.0",
    "@hugoalh/http-header-link": "jsr:@hugoalh/http-header-link@^1.0.2",
    "@opentelemetry/api": "npm:@opentelemetry/api@^1.9.0",
    "@opentelemetry/semantic-conventions": "npm:@opentelemetry/semantic-conventions@^1.27.0",
+3 −4
Original line number Diff line number Diff line
import { toArray } from "@hongminhee/aitertools";
import { assertEquals, assertInstanceOf } from "@std/assert";
import * as mf from "mock_fetch";
import { mockDocumentLoader } from "../testing/docloader.ts";
@@ -110,7 +109,7 @@ test("traverseCollection()", async () => {
  );
  assertInstanceOf(collection, Collection);
  assertEquals(
    await toArray(traverseCollection(collection, options)),
    await Array.fromAsync(traverseCollection(collection, options)),
    [
      new Note({ content: "This is a simple note" }),
      new Note({ content: "This is another simple note" }),
@@ -123,7 +122,7 @@ test("traverseCollection()", async () => {
  );
  assertInstanceOf(pagedCollection, Collection);
  assertEquals(
    await toArray(traverseCollection(pagedCollection, options)),
    await Array.fromAsync(traverseCollection(pagedCollection, options)),
    [
      new Note({ content: "This is a simple note" }),
      new Note({ content: "This is another simple note" }),
@@ -131,7 +130,7 @@ test("traverseCollection()", async () => {
    ],
  );
  assertEquals(
    await toArray(
    await Array.fromAsync(
      traverseCollection(pagedCollection, {
        ...options,
        interval: { milliseconds: 250 },
+17 −12
Original line number Diff line number Diff line
import { isDeno } from "@david/which-runtime";
import { toArray } from "@hongminhee/aitertools";
import { parseLanguageTag } from "@phensley/language-tag";
import {
  assertEquals,
@@ -444,7 +443,7 @@ test("Activity.getObjects()", async () => {
      }),
    ],
  });
  const objects = await toArray(
  const objects = await Array.fromAsync(
    activity.getObjects({
      documentLoader: mockDocumentLoader,
      contextLoader: mockDocumentLoader,
@@ -465,7 +464,9 @@ test("Activity.getObjects()", async () => {
      }),
    ],
  });
  const objects2 = await toArray(activity2.getObjects({ suppressError: true }));
  const objects2 = await Array.fromAsync(
    activity2.getObjects({ suppressError: true }),
  );
  assertEquals(objects2.length, 1);
  assertInstanceOf(objects2[0], Object);
  assertEquals(objects2[0].name, "Second object");
@@ -910,7 +911,7 @@ for (const typeUri in types) {
        }
        if (!property.functional) {
          assertEquals(
            await toArray(
            await Array.fromAsync(
              instance[`get${toPascalCase(property.pluralName)}`].call(
                instance,
                { documentLoader: mockDocumentLoader },
@@ -949,7 +950,7 @@ for (const typeUri in types) {
          }
          if (!property.functional) {
            assertEquals(
              await toArray(
              await Array.fromAsync(
                empty[`get${toPascalCase(property.pluralName)}`].call(
                  empty,
                  { documentLoader: mockDocumentLoader },
@@ -1104,7 +1105,9 @@ for (const typeUri in types) {
          instance,
          { documentLoader: docLoader },
        );
        assertEquals(await toArray(value), [sampleValues[property.range[0]]]);
        assertEquals(await Array.fromAsync(value), [
          sampleValues[property.range[0]],
        ]);

        if (property.untyped) return;
        const wrongRef = new cls({
@@ -1112,12 +1115,14 @@ for (const typeUri in types) {
        });
        await assertRejects(
          () =>
            toArray(wrongRef[`get${toPascalCase(property.pluralName)}`].call(
            Array.fromAsync(
              wrongRef[`get${toPascalCase(property.pluralName)}`].call(
                wrongRef,
                {
                  documentLoader: mockDocumentLoader,
                },
            )),
              ),
            ),
          TypeError,
        );
      });