From fa4d77e8715d783da749857005a218563f035e37 Mon Sep 17 00:00:00 2001 From: Wesley Guthrie Date: Sun, 9 Mar 2025 23:05:11 -0500 Subject: [PATCH 01/13] base functions added --- .gitignore | 1 + README.md | 3 +- index.ts | 7 + package.json | 28 ++ src/every.test.ts | 118 +++++++++ src/every.ts | 14 + src/filter.test.ts | 78 ++++++ src/filter.ts | 12 + src/find.test.ts | 142 ++++++++++ src/find.ts | 14 + src/map.test.ts | 18 ++ src/map.ts | 14 + src/mapParallel.test.ts | 68 +++++ src/mapParallel.ts | 62 +++++ src/reduce.test.ts | 32 +++ src/reduce.ts | 14 + src/sleep.ts | 4 + src/some.test.ts | 116 +++++++++ src/some.ts | 14 + tsconfig.json | 113 ++++++++ yarn.lock | 558 ++++++++++++++++++++++++++++++++++++++++ 21 files changed, 1429 insertions(+), 1 deletion(-) create mode 100644 .gitignore create mode 100644 index.ts create mode 100644 package.json create mode 100644 src/every.test.ts create mode 100644 src/every.ts create mode 100644 src/filter.test.ts create mode 100644 src/filter.ts create mode 100644 src/find.test.ts create mode 100644 src/find.ts create mode 100644 src/map.test.ts create mode 100644 src/map.ts create mode 100644 src/mapParallel.test.ts create mode 100644 src/mapParallel.ts create mode 100644 src/reduce.test.ts create mode 100644 src/reduce.ts create mode 100644 src/sleep.ts create mode 100644 src/some.test.ts create mode 100644 src/some.ts create mode 100644 tsconfig.json create mode 100644 yarn.lock diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..30bc162 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/node_modules \ No newline at end of file diff --git a/README.md b/README.md index 37fbbd3..2ea5080 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,3 @@ # async-iterators -A JavaScript utility library for asynchrous array iteration. + +A TypeScript utility library for asynchronous array iteration. diff --git a/index.ts b/index.ts new file mode 100644 index 0000000..b15df51 --- /dev/null +++ b/index.ts @@ -0,0 +1,7 @@ +export { default as every } from "./src/every"; +export { default as filter } from "./src/filter"; +export { default as find } from "./src/find"; +export { default as map } from "./src/map"; +export { default as mapParallel } from "./src/mapParallel"; +export { default as reduce } from "./src/reduce"; +export { default as some } from "./src/some"; diff --git a/package.json b/package.json new file mode 100644 index 0000000..d38e714 --- /dev/null +++ b/package.json @@ -0,0 +1,28 @@ +{ + "name": "async-iterators", + "author": "Wesley Guthrie", + "license": "MIT", + "version": "1.0.0", + "description": "A TypeScript utility library for asynchronous array iteration.", + "homepage": "https://github.com/GuthrieW/async-iterators", + "repository": "GuthrieW/async-iterators", + "files": [ + "index.js" + ], + "main": "index.js", + "scripts": { + "test": "vitest" + }, + "keywords": [ + "array", + "async", + "iteraor" + ], + "engines": { + "node": ">=22.0.0" + }, + "dependencies": {}, + "devDependencies": { + "vitest": "^3.0.8" + } +} diff --git a/src/every.test.ts b/src/every.test.ts new file mode 100644 index 0000000..a9c3f7f --- /dev/null +++ b/src/every.test.ts @@ -0,0 +1,118 @@ +import every from "./every"; +import { describe, it, expect } from "vitest"; + +describe("every tests", () => { + describe("isTrue", () => { + it("array of numbers", async () => { + const numbers: number[] = [5, 5, 5, 5, 5]; + const arrResult: boolean = numbers.every((number) => number === 5); + const asyncResult: boolean = await every( + numbers, + async (number) => number === 5 + ); + expect(asyncResult).toBe(true); + expect(arrResult).toEqual(asyncResult); + }); + + it("array of strings", async () => { + const strings: string[] = ["e", "e", "e", "e", "e"]; + const arrResult: boolean = strings.every((s) => s === "e"); + const asyncResult: boolean = await every(strings, async (s) => s === "e"); + expect(asyncResult).toBe(true); + expect(arrResult).toEqual(asyncResult); + }); + + it("array of booleans", async () => { + const objects: boolean[] = [true, true, true, true, true]; + const arrResult: boolean = objects.every((bool) => bool); + const asyncResult: boolean = await every(objects, async (bool) => bool); + expect(asyncResult).toBe(true); + expect(arrResult).toEqual(asyncResult); + }); + + it("array of objects", async () => { + const objects: { val: string }[] = [ + { val: "e" }, + { val: "e" }, + { val: "e" }, + { val: "e" }, + { val: "e" }, + ]; + const arrResult: boolean = objects.every((obj) => obj.val === "e"); + const asyncResult: boolean = await every( + objects, + async (obj) => obj.val === "e" + ); + expect(asyncResult).toBe(true); + expect(arrResult).toEqual(asyncResult); + }); + }); + describe("isFalse", () => { + it("array of numbers", async () => { + const numbers: number[] = [1, 2, 3, 4, 5]; + const arrResult: boolean = numbers.every((number) => number === 5); + const asyncResult: boolean = await every( + numbers, + async (number) => number === 5 + ); + expect(asyncResult).toBe(false); + expect(arrResult).toEqual(asyncResult); + }); + + it("array of strings", async () => { + const strings: string[] = ["a", "b", "c", "d", "e"]; + const arrResult: boolean = strings.every((s) => s === "e"); + const asyncResult: boolean = await every(strings, async (s) => s === "e"); + + expect(asyncResult).toBe(false); + expect(arrResult).toEqual(asyncResult); + }); + + it("array of booleans", async () => { + const objects: boolean[] = [false, false, false, false, true]; + const arrResult: boolean = objects.every((bool) => bool); + const asyncResult: boolean = await every(objects, async (bool) => bool); + expect(asyncResult).toBe(false); + expect(arrResult).toEqual(asyncResult); + }); + + it("array of objects", async () => { + const objects: { val: string }[] = [ + { val: "a" }, + { val: "b" }, + { val: "c" }, + { val: "d" }, + { val: "e" }, + ]; + const arrResult: boolean = objects.every((obj) => obj.val === "e"); + const asyncResult: boolean = await every( + objects, + async (obj) => obj.val === "e" + ); + expect(asyncResult).toBe(false); + expect(arrResult).toEqual(asyncResult); + }); + + it("array of undefineds", async () => { + const objects: any[] = [ + undefined, + undefined, + undefined, + undefined, + undefined, + ]; + const arrResult: boolean = objects.every((u) => u === "e"); + const asyncResult: boolean = await every(objects, async (u) => u === "e"); + expect(asyncResult).toBe(false); + expect(arrResult).toEqual(asyncResult); + }); + + it("array of nulls", async () => { + const objects: any[] = [null, null, null, null, null]; + const arrResult: boolean = objects.every((n) => n === "e"); + const asyncResult: boolean = await every(objects, async (n) => n === "e"); + expect(asyncResult).toBe(false); + expect(arrResult).toEqual(asyncResult); + }); + }); +}); diff --git a/src/every.ts b/src/every.ts new file mode 100644 index 0000000..ba454c7 --- /dev/null +++ b/src/every.ts @@ -0,0 +1,14 @@ +export default async function every( + array: T[], + iterator: (val: T, index?: number) => Promise +): Promise { + if (!Array.isArray(array) || !array?.length) return false; + for (let i = 0; i < array.length; i++) { + const element = array.at(i) as T; + const result = await iterator(element, i); + if (!result) { + return false; + } + } + return true; +} diff --git a/src/filter.test.ts b/src/filter.test.ts new file mode 100644 index 0000000..55ecdcb --- /dev/null +++ b/src/filter.test.ts @@ -0,0 +1,78 @@ +import filter from "./filter"; +import { describe, it, expect } from "vitest"; + +describe("filter tests", () => { + it("array of numbers", async () => { + const numbers: number[] = [1, 2, 3, 4, 5]; + const arrResult: number[] = numbers.filter((number) => number === 5); + const asyncResult: number[] = await filter( + numbers, + async (number) => number === 5 + ); + expect(arrResult).toEqual(asyncResult); + }); + + it("array of strings", async () => { + const strings: string[] = ["a", "b", "c", "d", "e"]; + const arrResult: string[] = strings.filter((s) => s === "e"); + const asyncResult: string[] = await filter(strings, async (s) => s === "e"); + expect(arrResult).toEqual(asyncResult); + }); + + it("array of booleans", async () => { + const objects: boolean[] = [false, false, false, false, true]; + const arrResult: boolean[] = objects.filter((bool) => bool); + const asyncResult: boolean[] = await filter(objects, async (bool) => bool); + expect(arrResult).toEqual(asyncResult); + }); + + it("array of objects", async () => { + const objects: { val: string }[] = [ + { val: "a" }, + { val: "b" }, + { val: "c" }, + { val: "d" }, + { val: "e" }, + ]; + const arrResult: { val: string }[] = objects.filter( + (obj) => obj.val === "e" + ); + const asyncResult: { val: string }[] = await filter( + objects, + async (obj) => obj.val === "e" + ); + expect(arrResult).toEqual(asyncResult); + }); + + it("array of undefineds", async () => { + const objects: any[] = [ + undefined, + undefined, + undefined, + undefined, + undefined, + ]; + const arrResult: boolean[] = objects.filter((u) => u === "e"); + const asyncResult: boolean[] = await filter( + objects, + async (u) => u === "e" + ); + expect(arrResult).toEqual(asyncResult); + }); + + it("array of nulls", async () => { + const objects: any[] = [null, null, null, null, null]; + const arrResult: any[] = objects.filter((n) => n === "e"); + const asyncResult: any[] = await filter(objects, async (n) => n === "e"); + expect(arrResult).toEqual(asyncResult); + }); + + it("non-boolean return value", async () => { + const numbers: number[] = [1, 2, 3, 4, 5]; + const arrResult: number[] = numbers.filter((n) => n * 2); + const asyncResult: number[] = await filter(numbers, async (n) => + Boolean(n * 2) + ); + expect(arrResult).toEqual(asyncResult); + }); +}); diff --git a/src/filter.ts b/src/filter.ts new file mode 100644 index 0000000..af72546 --- /dev/null +++ b/src/filter.ts @@ -0,0 +1,12 @@ +export default async function filter( + array: T[], + iterator: (val: T, index?: number) => Promise +): Promise { + if (!Array.isArray(array) || !array?.length) return []; + const results: T[] = []; + for (let i = 0; i < array.length; i++) { + const result = await iterator(array[i], i); + if (result) results.push(array[i]); + } + return results; +} diff --git a/src/find.test.ts b/src/find.test.ts new file mode 100644 index 0000000..5d2f26d --- /dev/null +++ b/src/find.test.ts @@ -0,0 +1,142 @@ +import find from "./find"; +import { describe, it, expect } from "vitest"; + +describe("find tests", () => { + describe("truthy", () => { + it("array of numbers", async () => { + const numbers: number[] = [1, 2, 3, 4, 5]; + const arrResult: number | undefined = numbers.find( + (number) => number === 5 + ); + const asyncResult: number | undefined = await find( + numbers, + async (number) => number === 5 + ); + expect(asyncResult).toBe(5); + expect(arrResult).toEqual(asyncResult); + }); + + it("array of strings", async () => { + const strings: string[] = ["a", "b", "c", "d", "e"]; + const arrResult: string | undefined = strings.find((s) => s === "e"); + const asyncResult: string | undefined = await find( + strings, + async (s) => s === "e" + ); + expect(asyncResult).toBe("e"); + expect(arrResult).toEqual(asyncResult); + }); + + it("array of booleans", async () => { + const objects: boolean[] = [false, false, false, false, true]; + const arrResult: boolean | undefined = objects.find((bool) => bool); + const asyncResult: boolean | undefined = await find( + objects, + async (bool) => bool + ); + expect(asyncResult).toBe(true); + expect(arrResult).toEqual(asyncResult); + }); + + it("array of objects", async () => { + const objects: { val: string }[] = [ + { val: "a" }, + { val: "b" }, + { val: "c" }, + { val: "d" }, + { val: "e" }, + ]; + const arrResult: { val: string } | undefined = objects.find( + (obj) => obj.val === "e" + ); + const asyncResult: { val: string } | undefined = await find( + objects, + async (obj) => obj.val === "e" + ); + expect(asyncResult).toEqual(expect.objectContaining({ val: "e" })); + expect(arrResult).toEqual(asyncResult); + }); + }); + describe("falsy", () => { + it("array of numbers", async () => { + const numbers: number[] = [1, 2, 3, 4]; + const arrResult: number | undefined = numbers.find( + (number) => number === 5 + ); + const asyncResult: number | undefined = await find( + numbers, + async (number) => number === 5 + ); + expect(asyncResult).toBe(undefined); + expect(arrResult).toEqual(asyncResult); + }); + + it("array of strings", async () => { + const strings: string[] = ["a", "b", "c", "d"]; + const arrResult: string | undefined = strings.find((s) => s === "e"); + const asyncResult: string | undefined = await find( + strings, + async (s) => s === "e" + ); + expect(asyncResult).toBe(undefined); + expect(arrResult).toEqual(asyncResult); + }); + + it("array of booleans", async () => { + const objects: boolean[] = [false, false, false, false]; + const arrResult: boolean | undefined = objects.find((bool) => bool); + const asyncResult: boolean | undefined = await find( + objects, + async (bool) => bool + ); + expect(asyncResult).toBe(undefined); + expect(arrResult).toEqual(asyncResult); + }); + + it("array of objects", async () => { + const objects: { val: string }[] = [ + { val: "a" }, + { val: "b" }, + { val: "c" }, + { val: "d" }, + ]; + const arrResult: { val: string } | undefined = objects.find( + (obj) => obj.val === "e" + ); + const asyncResult: { val: string } | undefined = await find( + objects, + async (obj) => obj.val === "e" + ); + expect(asyncResult).toBe(undefined); + expect(arrResult).toEqual(asyncResult); + }); + + it("array of undefineds", async () => { + const objects: any[] = [ + undefined, + undefined, + undefined, + undefined, + undefined, + ]; + const arrResult: any | undefined = objects.find((u) => u === "e"); + const asyncResult: any | undefined = await find( + objects, + async (u) => u === "e" + ); + expect(asyncResult).toBe(undefined); + expect(arrResult).toEqual(asyncResult); + }); + + it("array of nulls", async () => { + const objects: any[] = [null, null, null, null, null]; + const arrResult: any | undefined = objects.find((n) => n === "e"); + const asyncResult: any | undefined = await find( + objects, + async (n) => n === "e" + ); + expect(asyncResult).toBe(undefined); + expect(arrResult).toEqual(asyncResult); + }); + }); +}); diff --git a/src/find.ts b/src/find.ts new file mode 100644 index 0000000..d2c4a07 --- /dev/null +++ b/src/find.ts @@ -0,0 +1,14 @@ +export default async function find( + array: T[], + iterator: (val: T, index?: number) => Promise +): Promise { + if (!Array.isArray(array) || !array?.length) return undefined; + for (let i = 0; i < array.length; i++) { + const element = array.at(i) as T; + const result = await iterator(element, i); + if (result) { + return element; + } + } + return undefined; +} diff --git a/src/map.test.ts b/src/map.test.ts new file mode 100644 index 0000000..7e25f67 --- /dev/null +++ b/src/map.test.ts @@ -0,0 +1,18 @@ +// @ts-strict-ignore +import { sleep } from "./sleep"; +import map from "./map"; +import { describe, it, expect } from "vitest"; + +describe("map tests", () => { + const numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]; + + it("correctly iterates", async () => { + const indices: number[] = []; + + await map(numbers, async (number, index) => { + await sleep(12 - index); + indices.push(index); + }); + expect(indices).to.eql(numbers.map((number) => number - 1)); + }); +}); diff --git a/src/map.ts b/src/map.ts new file mode 100644 index 0000000..e6b9606 --- /dev/null +++ b/src/map.ts @@ -0,0 +1,14 @@ +export default async function map( + array: T[], + iterator: (val: T, i: number) => Promise +): Promise { + if (!Array.isArray(array) || !array?.length) return; + + const results: V[] = []; + for (let i = 0; i < array.length; i++) { + const element = array[i]; + + results.push(await iterator(element, i)); + } + return results; +} diff --git a/src/mapParallel.test.ts b/src/mapParallel.test.ts new file mode 100644 index 0000000..53300a0 --- /dev/null +++ b/src/mapParallel.test.ts @@ -0,0 +1,68 @@ +import mapParallel from "./mapParallel"; +import { sleep } from "./sleep"; +import { describe, it, expect } from "vitest"; + +describe("mapParallel tests", () => { + const numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]; + const expectedDoubledNumbers = numbers.map((number) => number * 2); + + it("returns all values when passed a maxParallelBatchSize", async () => { + const doubledNumbers = await mapParallel( + numbers, + async (number) => { + await sleep(number); + return number * 2; + }, + 5 + ); + expect(doubledNumbers).to.eql(expectedDoubledNumbers); + }); + + it("returns all values when not passed a maxParallelBatchSize", async () => { + const doubledNumbers = await mapParallel(numbers, async (number) => { + await sleep(number); + return number * 2; + }); + expect(doubledNumbers).to.eql(expectedDoubledNumbers); + }); + + it("returns all values when passed a maxParallelBatchSize larger than the length of the array", async () => { + const doubledNumbers = await mapParallel( + numbers, + async (number) => { + await sleep(number); + return number * 2; + }, + 20 + ); + expect(doubledNumbers).to.eql(expectedDoubledNumbers); + }); + + it("correctly iterates", async () => { + const indices: number[] = []; + await mapParallel( + numbers, + async (number, i) => { + indices.push(i); + }, + 5 + ); + expect(indices).to.eql(numbers.map((number) => number - 1)); + }); + + it("does not wait for all tasks in a batch to finish before starting any new ones", async () => { + const start = Date.now(); + await mapParallel( + numbers, + async (number) => { + await sleep(number * 100); // wait `number` deciseconds + return number; + }, + 10 + ); + const end = Date.now(); + // waiting for the first ten to finish and then starting on the 11th would result in a delay of 10 + 11 = 21ds + // starting the 11th after the first resolves would result in a delay of only 1 + 11 = 12ds + expect(end - start).to.be.lessThan(20 * 100); + }); +}); diff --git a/src/mapParallel.ts b/src/mapParallel.ts new file mode 100644 index 0000000..2a20353 --- /dev/null +++ b/src/mapParallel.ts @@ -0,0 +1,62 @@ +/** + * take and complete tasks from a queue until that queue is empty. + * @param {{ task: T; index: number }[]} array + * @param {(val: T, index?: number) => Promise} iterator + */ +async function takeAndCompleteFromQueueUntilDone( + array: { task: T; index: number }[], + iterator: (val: T, index: number) => Promise +): Promise<{ result: V; index: number }[]> { + const item = array.shift(); + if (!item) { + return []; + } + const completedTask = await iterator(item.task, item.index); + const followingCompletedTasks = await takeAndCompleteFromQueueUntilDone( + array, + iterator + ); + return followingCompletedTasks.concat({ + result: completedTask, + index: item.index, + }); +} + +/** + * iterate over the passed in array in parallel, running the iterator on each element. + * @param {T[]} array + * @param {(val: T, index?: number) => Promise} iterator + * @param {number} [maxParallelBatchSize] + */ +export default async function mapParallel( + array: T[], + iterator: (val: T, index: number) => Promise, + maxParallelBatchSize?: number +): Promise { + if (!Array.isArray(array) || !array?.length) return []; + const arrayWithIndexKeys = array.map((item, i) => { + return { + task: item, + index: i, + }; + }); + let effectiveMaxBatchSize = maxParallelBatchSize; + if (!effectiveMaxBatchSize || effectiveMaxBatchSize > array.length) { + effectiveMaxBatchSize = array.length; + } + const coolEmptyArray = Array(effectiveMaxBatchSize).fill(undefined); + + let results: V[] = []; + await Promise.all( + coolEmptyArray.map(async () => { + const resultsWithIndex = await takeAndCompleteFromQueueUntilDone( + arrayWithIndexKeys, + iterator + ); + resultsWithIndex.forEach((result) => { + results[result.index] = result.result; + }); + }) + ); + return results; +} diff --git a/src/reduce.test.ts b/src/reduce.test.ts new file mode 100644 index 0000000..8ed7fc7 --- /dev/null +++ b/src/reduce.test.ts @@ -0,0 +1,32 @@ +import reduce from "./reduce"; +import { describe, it, expect } from "vitest"; + +describe("asyncReduce tests", () => { + it("array of numbers", async () => { + const numbers: number[] = [1, 2, 3, 4, 5]; + const arrResult: number = numbers.reduce( + (prev, current) => prev + current, + 0 + ); + const asyncResult: number = await reduce( + numbers, + async (prev, current) => prev + current, + 0 + ); + expect(arrResult).toEqual(asyncResult); + }); + + it("array of strings", async () => { + const strings: string[] = ["a", "b", "c", "d", "e"]; + const arrResult: string = strings.reduce( + (prev, current) => prev + current, + "" + ); + const asyncResult: string = await reduce( + strings, + async (prev, current) => prev + current, + "" + ); + expect(arrResult).toEqual(asyncResult); + }); +}); diff --git a/src/reduce.ts b/src/reduce.ts new file mode 100644 index 0000000..15bdc4a --- /dev/null +++ b/src/reduce.ts @@ -0,0 +1,14 @@ +export default async function reduce( + array: T[], + iterator: (accumulator: V, currentValue: T) => Promise, + initialValue: V +): Promise { + if (!Array.isArray(array) || !array?.length) return initialValue; + + let result = initialValue; + for (let i = 0; i < array.length; i++) { + result = await iterator(result, array.at(i) as T); + } + + return result; +} diff --git a/src/sleep.ts b/src/sleep.ts new file mode 100644 index 0000000..b92820b --- /dev/null +++ b/src/sleep.ts @@ -0,0 +1,4 @@ +// wait for the specified amount of time and then resolve. +export async function sleep(delay = 0): Promise { + return new Promise((resolve) => setTimeout(resolve, delay)); +} diff --git a/src/some.test.ts b/src/some.test.ts new file mode 100644 index 0000000..c0269be --- /dev/null +++ b/src/some.test.ts @@ -0,0 +1,116 @@ +import some from "./some"; +import { describe, it, expect } from "vitest"; + +describe("asyncSome tests", () => { + describe("truthy", () => { + it("array of numbers", async () => { + const numbers: number[] = [1, 2, 3, 4, 5]; + const arrResult: boolean = numbers.some((number) => number === 5); + const asyncResult: boolean = await some( + numbers, + async (number) => number === 5 + ); + expect(asyncResult).toBe(true); + expect(arrResult).toEqual(asyncResult); + }); + + it("array of strings", async () => { + const strings: string[] = ["a", "b", "c", "d", "e"]; + const arrResult: boolean = strings.some((s) => s === "e"); + const asyncResult: boolean = await some(strings, async (s) => s === "e"); + expect(asyncResult).toBe(true); + expect(arrResult).toEqual(asyncResult); + }); + + it("array of booleans", async () => { + const objects: boolean[] = [false, false, false, false, true]; + const arrResult: boolean = objects.some((bool) => bool); + const asyncResult: boolean = await some(objects, async (bool) => bool); + expect(asyncResult).toBe(true); + expect(arrResult).toEqual(asyncResult); + }); + + it("array of objects", async () => { + const objects: { val: string }[] = [ + { val: "a" }, + { val: "b" }, + { val: "c" }, + { val: "d" }, + { val: "e" }, + ]; + const arrResult: boolean = objects.some((obj) => obj.val === "e"); + const asyncResult: boolean = await some( + objects, + async (obj) => obj.val === "e" + ); + expect(asyncResult).toBe(true); + expect(arrResult).toEqual(asyncResult); + }); + }); + describe("falsy", () => { + it("array of numbers", async () => { + const numbers: number[] = [1, 2, 3, 4]; + const arrResult: boolean = numbers.some((number) => number === 5); + const asyncResult: boolean = await some( + numbers, + async (number) => number === 5 + ); + expect(asyncResult).toBe(false); + expect(arrResult).toEqual(asyncResult); + }); + + it("array of strings", async () => { + const strings: string[] = ["a", "b", "c", "d"]; + const arrResult: boolean = strings.some((s) => s === "e"); + const asyncResult: boolean = await some(strings, async (s) => s === "e"); + expect(asyncResult).toBe(false); + expect(arrResult).toEqual(asyncResult); + }); + + it("array of booleans", async () => { + const objects: boolean[] = [false, false, false, false]; + const arrResult: boolean = objects.some((bool) => bool); + const asyncResult: boolean = await some(objects, async (bool) => bool); + expect(asyncResult).toBe(false); + expect(arrResult).toEqual(asyncResult); + }); + + it("array of objects", async () => { + const objects: { val: string }[] = [ + { val: "a" }, + { val: "b" }, + { val: "c" }, + { val: "d" }, + ]; + const arrResult: boolean = objects.some((obj) => obj.val === "e"); + const asyncResult: boolean = await some( + objects, + async (obj) => obj.val === "e" + ); + expect(asyncResult).toBe(false); + expect(arrResult).toEqual(asyncResult); + }); + + it("array of undefineds", async () => { + const objects: any[] = [ + undefined, + undefined, + undefined, + undefined, + undefined, + ]; + const arrResult: boolean = objects.some((u) => u === "e"); + const asyncResult: boolean = await some(objects, async (u) => u === "e"); + expect(asyncResult).toBe(false); + expect(arrResult).toEqual(asyncResult); + }); + + it("array of nulls", async () => { + const objects: any[] = [null, null, null, null, null]; + const arrResult: boolean = objects.some((n) => n === "e"); + const asyncResult: boolean = await some(objects, async (n) => n === "e"); + expect(asyncResult).toBe(false); + expect(arrResult).toEqual(asyncResult); + }); + }); +}); diff --git a/src/some.ts b/src/some.ts new file mode 100644 index 0000000..8192f09 --- /dev/null +++ b/src/some.ts @@ -0,0 +1,14 @@ +export default async function some( + array: T[], + iterator: (val: T, index?: number) => Promise +): Promise { + if (!Array.isArray(array) || !array?.length) return false; + for (let i = 0; i < array.length; i++) { + const element = array.at(i) as T; + const result = await iterator(element, i); + if (result) { + return true; + } + } + return false; +} diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 0000000..17d4262 --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,113 @@ +{ + "compilerOptions": { + /* Visit https://aka.ms/tsconfig to read more about this file */ + + /* Projects */ + // "incremental": true, /* Save .tsbuildinfo files to allow for incremental compilation of projects. */ + // "composite": true, /* Enable constraints that allow a TypeScript project to be used with project references. */ + // "tsBuildInfoFile": "./.tsbuildinfo", /* Specify the path to .tsbuildinfo incremental compilation file. */ + // "disableSourceOfProjectReferenceRedirect": true, /* Disable preferring source files instead of declaration files when referencing composite projects. */ + // "disableSolutionSearching": true, /* Opt a project out of multi-project reference checking when editing. */ + // "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */ + + /* Language and Environment */ + "target": "es2022" /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */, + // "lib": [], /* Specify a set of bundled library declaration files that describe the target runtime environment. */ + // "jsx": "preserve", /* Specify what JSX code is generated. */ + // "libReplacement": true, /* Enable lib replacement. */ + // "experimentalDecorators": true, /* Enable experimental support for legacy experimental decorators. */ + // "emitDecoratorMetadata": true, /* Emit design-type metadata for decorated declarations in source files. */ + // "jsxFactory": "", /* Specify the JSX factory function used when targeting React JSX emit, e.g. 'React.createElement' or 'h'. */ + // "jsxFragmentFactory": "", /* Specify the JSX Fragment reference used for fragments when targeting React JSX emit e.g. 'React.Fragment' or 'Fragment'. */ + // "jsxImportSource": "", /* Specify module specifier used to import the JSX factory functions when using 'jsx: react-jsx*'. */ + // "reactNamespace": "", /* Specify the object invoked for 'createElement'. This only applies when targeting 'react' JSX emit. */ + // "noLib": true, /* Disable including any library files, including the default lib.d.ts. */ + // "useDefineForClassFields": true, /* Emit ECMAScript-standard-compliant class fields. */ + // "moduleDetection": "auto", /* Control what method is used to detect module-format JS files. */ + + /* Modules */ + "module": "commonjs" /* Specify what module code is generated. */, + // "rootDir": "./", /* Specify the root folder within your source files. */ + // "moduleResolution": "node10", /* Specify how TypeScript looks up a file from a given module specifier. */ + // "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */ + // "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */ + // "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */ + // "typeRoots": [], /* Specify multiple folders that act like './node_modules/@types'. */ + // "types": [], /* Specify type package names to be included without being referenced in a source file. */ + // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */ + // "moduleSuffixes": [], /* List of file name suffixes to search when resolving a module. */ + // "allowImportingTsExtensions": true, /* Allow imports to include TypeScript file extensions. Requires '--moduleResolution bundler' and either '--noEmit' or '--emitDeclarationOnly' to be set. */ + // "rewriteRelativeImportExtensions": true, /* Rewrite '.ts', '.tsx', '.mts', and '.cts' file extensions in relative import paths to their JavaScript equivalent in output files. */ + // "resolvePackageJsonExports": true, /* Use the package.json 'exports' field when resolving package imports. */ + // "resolvePackageJsonImports": true, /* Use the package.json 'imports' field when resolving imports. */ + // "customConditions": [], /* Conditions to set in addition to the resolver-specific defaults when resolving imports. */ + // "noUncheckedSideEffectImports": true, /* Check side effect imports. */ + // "resolveJsonModule": true, /* Enable importing .json files. */ + // "allowArbitraryExtensions": true, /* Enable importing files with any extension, provided a declaration file is present. */ + // "noResolve": true, /* Disallow 'import's, 'require's or ''s from expanding the number of files TypeScript should add to a project. */ + + /* JavaScript Support */ + // "allowJs": true, /* Allow JavaScript files to be a part of your program. Use the 'checkJS' option to get errors from these files. */ + // "checkJs": true, /* Enable error reporting in type-checked JavaScript files. */ + // "maxNodeModuleJsDepth": 1, /* Specify the maximum folder depth used for checking JavaScript files from 'node_modules'. Only applicable with 'allowJs'. */ + + /* Emit */ + // "declaration": true, /* Generate .d.ts files from TypeScript and JavaScript files in your project. */ + // "declarationMap": true, /* Create sourcemaps for d.ts files. */ + // "emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */ + // "sourceMap": true, /* Create source map files for emitted JavaScript files. */ + // "inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */ + // "noEmit": true, /* Disable emitting files from a compilation. */ + // "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If 'declaration' is true, also designates a file that bundles all .d.ts output. */ + // "outDir": "./", /* Specify an output folder for all emitted files. */ + // "removeComments": true, /* Disable emitting comments. */ + // "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */ + // "downlevelIteration": true, /* Emit more compliant, but verbose and less performant JavaScript for iteration. */ + // "sourceRoot": "", /* Specify the root path for debuggers to find the reference source code. */ + // "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */ + // "inlineSources": true, /* Include source code in the sourcemaps inside the emitted JavaScript. */ + // "emitBOM": true, /* Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files. */ + // "newLine": "crlf", /* Set the newline character for emitting files. */ + // "stripInternal": true, /* Disable emitting declarations that have '@internal' in their JSDoc comments. */ + // "noEmitHelpers": true, /* Disable generating custom helper functions like '__extends' in compiled output. */ + // "noEmitOnError": true, /* Disable emitting files if any type checking errors are reported. */ + // "preserveConstEnums": true, /* Disable erasing 'const enum' declarations in generated code. */ + // "declarationDir": "./", /* Specify the output directory for generated declaration files. */ + + /* Interop Constraints */ + // "isolatedModules": true, /* Ensure that each file can be safely transpiled without relying on other imports. */ + // "verbatimModuleSyntax": true, /* Do not transform or elide any imports or exports not marked as type-only, ensuring they are written in the output file's format based on the 'module' setting. */ + // "isolatedDeclarations": true, /* Require sufficient annotation on exports so other tools can trivially generate declaration files. */ + // "erasableSyntaxOnly": true, /* Do not allow runtime constructs that are not part of ECMAScript. */ + // "allowSyntheticDefaultImports": true, /* Allow 'import x from y' when a module doesn't have a default export. */ + "esModuleInterop": true /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */, + // "preserveSymlinks": true, /* Disable resolving symlinks to their realpath. This correlates to the same flag in node. */ + "forceConsistentCasingInFileNames": true /* Ensure that casing is correct in imports. */, + + /* Type Checking */ + "strict": true /* Enable all strict type-checking options. */, + // "noImplicitAny": true, /* Enable error reporting for expressions and declarations with an implied 'any' type. */ + // "strictNullChecks": true, /* When type checking, take into account 'null' and 'undefined'. */ + // "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */ + // "strictBindCallApply": true, /* Check that the arguments for 'bind', 'call', and 'apply' methods match the original function. */ + // "strictPropertyInitialization": true, /* Check for class properties that are declared but not set in the constructor. */ + // "strictBuiltinIteratorReturn": true, /* Built-in iterators are instantiated with a 'TReturn' type of 'undefined' instead of 'any'. */ + // "noImplicitThis": true, /* Enable error reporting when 'this' is given the type 'any'. */ + // "useUnknownInCatchVariables": true, /* Default catch clause variables as 'unknown' instead of 'any'. */ + // "alwaysStrict": true, /* Ensure 'use strict' is always emitted. */ + // "noUnusedLocals": true, /* Enable error reporting when local variables aren't read. */ + // "noUnusedParameters": true, /* Raise an error when a function parameter isn't read. */ + // "exactOptionalPropertyTypes": true, /* Interpret optional property types as written, rather than adding 'undefined'. */ + // "noImplicitReturns": true, /* Enable error reporting for codepaths that do not explicitly return in a function. */ + // "noFallthroughCasesInSwitch": true, /* Enable error reporting for fallthrough cases in switch statements. */ + // "noUncheckedIndexedAccess": true, /* Add 'undefined' to a type when accessed using an index. */ + // "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an override modifier. */ + // "noPropertyAccessFromIndexSignature": true, /* Enforces using indexed accessors for keys declared using an indexed type. */ + // "allowUnusedLabels": true, /* Disable error reporting for unused labels. */ + // "allowUnreachableCode": true, /* Disable error reporting for unreachable code. */ + + /* Completeness */ + // "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */ + "skipLibCheck": true /* Skip type checking all .d.ts files. */ + } +} diff --git a/yarn.lock b/yarn.lock new file mode 100644 index 0000000..17f8622 --- /dev/null +++ b/yarn.lock @@ -0,0 +1,558 @@ +# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. +# yarn lockfile v1 + + +"@esbuild/aix-ppc64@0.25.0": + version "0.25.0" + resolved "https://registry.yarnpkg.com/@esbuild/aix-ppc64/-/aix-ppc64-0.25.0.tgz#499600c5e1757a524990d5d92601f0ac3ce87f64" + integrity sha512-O7vun9Sf8DFjH2UtqK8Ku3LkquL9SZL8OLY1T5NZkA34+wG3OQF7cl4Ql8vdNzM6fzBbYfLaiRLIOZ+2FOCgBQ== + +"@esbuild/android-arm64@0.25.0": + version "0.25.0" + resolved "https://registry.yarnpkg.com/@esbuild/android-arm64/-/android-arm64-0.25.0.tgz#b9b8231561a1dfb94eb31f4ee056b92a985c324f" + integrity sha512-grvv8WncGjDSyUBjN9yHXNt+cq0snxXbDxy5pJtzMKGmmpPxeAmAhWxXI+01lU5rwZomDgD3kJwulEnhTRUd6g== + +"@esbuild/android-arm@0.25.0": + version "0.25.0" + resolved "https://registry.yarnpkg.com/@esbuild/android-arm/-/android-arm-0.25.0.tgz#ca6e7888942505f13e88ac9f5f7d2a72f9facd2b" + integrity sha512-PTyWCYYiU0+1eJKmw21lWtC+d08JDZPQ5g+kFyxP0V+es6VPPSUhM6zk8iImp2jbV6GwjX4pap0JFbUQN65X1g== + +"@esbuild/android-x64@0.25.0": + version "0.25.0" + resolved "https://registry.yarnpkg.com/@esbuild/android-x64/-/android-x64-0.25.0.tgz#e765ea753bac442dfc9cb53652ce8bd39d33e163" + integrity sha512-m/ix7SfKG5buCnxasr52+LI78SQ+wgdENi9CqyCXwjVR2X4Jkz+BpC3le3AoBPYTC9NHklwngVXvbJ9/Akhrfg== + +"@esbuild/darwin-arm64@0.25.0": + version "0.25.0" + resolved "https://registry.yarnpkg.com/@esbuild/darwin-arm64/-/darwin-arm64-0.25.0.tgz#fa394164b0d89d4fdc3a8a21989af70ef579fa2c" + integrity sha512-mVwdUb5SRkPayVadIOI78K7aAnPamoeFR2bT5nszFUZ9P8UpK4ratOdYbZZXYSqPKMHfS1wdHCJk1P1EZpRdvw== + +"@esbuild/darwin-x64@0.25.0": + version "0.25.0" + resolved "https://registry.yarnpkg.com/@esbuild/darwin-x64/-/darwin-x64-0.25.0.tgz#91979d98d30ba6e7d69b22c617cc82bdad60e47a" + integrity sha512-DgDaYsPWFTS4S3nWpFcMn/33ZZwAAeAFKNHNa1QN0rI4pUjgqf0f7ONmXf6d22tqTY+H9FNdgeaAa+YIFUn2Rg== + +"@esbuild/freebsd-arm64@0.25.0": + version "0.25.0" + resolved "https://registry.yarnpkg.com/@esbuild/freebsd-arm64/-/freebsd-arm64-0.25.0.tgz#b97e97073310736b430a07b099d837084b85e9ce" + integrity sha512-VN4ocxy6dxefN1MepBx/iD1dH5K8qNtNe227I0mnTRjry8tj5MRk4zprLEdG8WPyAPb93/e4pSgi1SoHdgOa4w== + +"@esbuild/freebsd-x64@0.25.0": + version "0.25.0" + resolved "https://registry.yarnpkg.com/@esbuild/freebsd-x64/-/freebsd-x64-0.25.0.tgz#f3b694d0da61d9910ec7deff794d444cfbf3b6e7" + integrity sha512-mrSgt7lCh07FY+hDD1TxiTyIHyttn6vnjesnPoVDNmDfOmggTLXRv8Id5fNZey1gl/V2dyVK1VXXqVsQIiAk+A== + +"@esbuild/linux-arm64@0.25.0": + version "0.25.0" + resolved "https://registry.yarnpkg.com/@esbuild/linux-arm64/-/linux-arm64-0.25.0.tgz#f921f699f162f332036d5657cad9036f7a993f73" + integrity sha512-9QAQjTWNDM/Vk2bgBl17yWuZxZNQIF0OUUuPZRKoDtqF2k4EtYbpyiG5/Dk7nqeK6kIJWPYldkOcBqjXjrUlmg== + +"@esbuild/linux-arm@0.25.0": + version "0.25.0" + resolved "https://registry.yarnpkg.com/@esbuild/linux-arm/-/linux-arm-0.25.0.tgz#cc49305b3c6da317c900688995a4050e6cc91ca3" + integrity sha512-vkB3IYj2IDo3g9xX7HqhPYxVkNQe8qTK55fraQyTzTX/fxaDtXiEnavv9geOsonh2Fd2RMB+i5cbhu2zMNWJwg== + +"@esbuild/linux-ia32@0.25.0": + version "0.25.0" + resolved "https://registry.yarnpkg.com/@esbuild/linux-ia32/-/linux-ia32-0.25.0.tgz#3e0736fcfab16cff042dec806247e2c76e109e19" + integrity sha512-43ET5bHbphBegyeqLb7I1eYn2P/JYGNmzzdidq/w0T8E2SsYL1U6un2NFROFRg1JZLTzdCoRomg8Rvf9M6W6Gg== + +"@esbuild/linux-loong64@0.25.0": + version "0.25.0" + resolved "https://registry.yarnpkg.com/@esbuild/linux-loong64/-/linux-loong64-0.25.0.tgz#ea2bf730883cddb9dfb85124232b5a875b8020c7" + integrity sha512-fC95c/xyNFueMhClxJmeRIj2yrSMdDfmqJnyOY4ZqsALkDrrKJfIg5NTMSzVBr5YW1jf+l7/cndBfP3MSDpoHw== + +"@esbuild/linux-mips64el@0.25.0": + version "0.25.0" + resolved "https://registry.yarnpkg.com/@esbuild/linux-mips64el/-/linux-mips64el-0.25.0.tgz#4cababb14eede09248980a2d2d8b966464294ff1" + integrity sha512-nkAMFju7KDW73T1DdH7glcyIptm95a7Le8irTQNO/qtkoyypZAnjchQgooFUDQhNAy4iu08N79W4T4pMBwhPwQ== + +"@esbuild/linux-ppc64@0.25.0": + version "0.25.0" + resolved "https://registry.yarnpkg.com/@esbuild/linux-ppc64/-/linux-ppc64-0.25.0.tgz#8860a4609914c065373a77242e985179658e1951" + integrity sha512-NhyOejdhRGS8Iwv+KKR2zTq2PpysF9XqY+Zk77vQHqNbo/PwZCzB5/h7VGuREZm1fixhs4Q/qWRSi5zmAiO4Fw== + +"@esbuild/linux-riscv64@0.25.0": + version "0.25.0" + resolved "https://registry.yarnpkg.com/@esbuild/linux-riscv64/-/linux-riscv64-0.25.0.tgz#baf26e20bb2d38cfb86ee282dff840c04f4ed987" + integrity sha512-5S/rbP5OY+GHLC5qXp1y/Mx//e92L1YDqkiBbO9TQOvuFXM+iDqUNG5XopAnXoRH3FjIUDkeGcY1cgNvnXp/kA== + +"@esbuild/linux-s390x@0.25.0": + version "0.25.0" + resolved "https://registry.yarnpkg.com/@esbuild/linux-s390x/-/linux-s390x-0.25.0.tgz#8323afc0d6cb1b6dc6e9fd21efd9e1542c3640a4" + integrity sha512-XM2BFsEBz0Fw37V0zU4CXfcfuACMrppsMFKdYY2WuTS3yi8O1nFOhil/xhKTmE1nPmVyvQJjJivgDT+xh8pXJA== + +"@esbuild/linux-x64@0.25.0": + version "0.25.0" + resolved "https://registry.yarnpkg.com/@esbuild/linux-x64/-/linux-x64-0.25.0.tgz#08fcf60cb400ed2382e9f8e0f5590bac8810469a" + integrity sha512-9yl91rHw/cpwMCNytUDxwj2XjFpxML0y9HAOH9pNVQDpQrBxHy01Dx+vaMu0N1CKa/RzBD2hB4u//nfc+Sd3Cw== + +"@esbuild/netbsd-arm64@0.25.0": + version "0.25.0" + resolved "https://registry.yarnpkg.com/@esbuild/netbsd-arm64/-/netbsd-arm64-0.25.0.tgz#935c6c74e20f7224918fbe2e6c6fe865b6c6ea5b" + integrity sha512-RuG4PSMPFfrkH6UwCAqBzauBWTygTvb1nxWasEJooGSJ/NwRw7b2HOwyRTQIU97Hq37l3npXoZGYMy3b3xYvPw== + +"@esbuild/netbsd-x64@0.25.0": + version "0.25.0" + resolved "https://registry.yarnpkg.com/@esbuild/netbsd-x64/-/netbsd-x64-0.25.0.tgz#414677cef66d16c5a4d210751eb2881bb9c1b62b" + integrity sha512-jl+qisSB5jk01N5f7sPCsBENCOlPiS/xptD5yxOx2oqQfyourJwIKLRA2yqWdifj3owQZCL2sn6o08dBzZGQzA== + +"@esbuild/openbsd-arm64@0.25.0": + version "0.25.0" + resolved "https://registry.yarnpkg.com/@esbuild/openbsd-arm64/-/openbsd-arm64-0.25.0.tgz#8fd55a4d08d25cdc572844f13c88d678c84d13f7" + integrity sha512-21sUNbq2r84YE+SJDfaQRvdgznTD8Xc0oc3p3iW/a1EVWeNj/SdUCbm5U0itZPQYRuRTW20fPMWMpcrciH2EJw== + +"@esbuild/openbsd-x64@0.25.0": + version "0.25.0" + resolved "https://registry.yarnpkg.com/@esbuild/openbsd-x64/-/openbsd-x64-0.25.0.tgz#0c48ddb1494bbc2d6bcbaa1429a7f465fa1dedde" + integrity sha512-2gwwriSMPcCFRlPlKx3zLQhfN/2WjJ2NSlg5TKLQOJdV0mSxIcYNTMhk3H3ulL/cak+Xj0lY1Ym9ysDV1igceg== + +"@esbuild/sunos-x64@0.25.0": + version "0.25.0" + resolved "https://registry.yarnpkg.com/@esbuild/sunos-x64/-/sunos-x64-0.25.0.tgz#86ff9075d77962b60dd26203d7352f92684c8c92" + integrity sha512-bxI7ThgLzPrPz484/S9jLlvUAHYMzy6I0XiU1ZMeAEOBcS0VePBFxh1JjTQt3Xiat5b6Oh4x7UC7IwKQKIJRIg== + +"@esbuild/win32-arm64@0.25.0": + version "0.25.0" + resolved "https://registry.yarnpkg.com/@esbuild/win32-arm64/-/win32-arm64-0.25.0.tgz#849c62327c3229467f5b5cd681bf50588442e96c" + integrity sha512-ZUAc2YK6JW89xTbXvftxdnYy3m4iHIkDtK3CLce8wg8M2L+YZhIvO1DKpxrd0Yr59AeNNkTiic9YLf6FTtXWMw== + +"@esbuild/win32-ia32@0.25.0": + version "0.25.0" + resolved "https://registry.yarnpkg.com/@esbuild/win32-ia32/-/win32-ia32-0.25.0.tgz#f62eb480cd7cca088cb65bb46a6db25b725dc079" + integrity sha512-eSNxISBu8XweVEWG31/JzjkIGbGIJN/TrRoiSVZwZ6pkC6VX4Im/WV2cz559/TXLcYbcrDN8JtKgd9DJVIo8GA== + +"@esbuild/win32-x64@0.25.0": + version "0.25.0" + resolved "https://registry.yarnpkg.com/@esbuild/win32-x64/-/win32-x64-0.25.0.tgz#c8e119a30a7c8d60b9d2e22d2073722dde3b710b" + integrity sha512-ZENoHJBxA20C2zFzh6AI4fT6RraMzjYw4xKWemRTRmRVtN9c5DcH9r/f2ihEkMjOW5eGgrwCslG/+Y/3bL+DHQ== + +"@jridgewell/sourcemap-codec@^1.5.0": + version "1.5.0" + resolved "https://registry.yarnpkg.com/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.5.0.tgz#3188bcb273a414b0d215fd22a58540b989b9409a" + integrity sha512-gv3ZRaISU3fjPAgNsriBRqGWQL6quFx04YMPW/zD8XMLsU32mhCCbfbO6KZFLjvYpCZ8zyDEgqsgf+PwPaM7GQ== + +"@rollup/rollup-android-arm-eabi@4.35.0": + version "4.35.0" + resolved "https://registry.yarnpkg.com/@rollup/rollup-android-arm-eabi/-/rollup-android-arm-eabi-4.35.0.tgz#e1d7700735f7e8de561ef7d1fa0362082a180c43" + integrity sha512-uYQ2WfPaqz5QtVgMxfN6NpLD+no0MYHDBywl7itPYd3K5TjjSghNKmX8ic9S8NU8w81NVhJv/XojcHptRly7qQ== + +"@rollup/rollup-android-arm64@4.35.0": + version "4.35.0" + resolved "https://registry.yarnpkg.com/@rollup/rollup-android-arm64/-/rollup-android-arm64-4.35.0.tgz#fa6cdfb1fc9e2c8e227a7f35d524d8f7f90cf4db" + integrity sha512-FtKddj9XZudurLhdJnBl9fl6BwCJ3ky8riCXjEw3/UIbjmIY58ppWwPEvU3fNu+W7FUsAsB1CdH+7EQE6CXAPA== + +"@rollup/rollup-darwin-arm64@4.35.0": + version "4.35.0" + resolved "https://registry.yarnpkg.com/@rollup/rollup-darwin-arm64/-/rollup-darwin-arm64-4.35.0.tgz#6da5a1ddc4f11d4a7ae85ab443824cb6bf614e30" + integrity sha512-Uk+GjOJR6CY844/q6r5DR/6lkPFOw0hjfOIzVx22THJXMxktXG6CbejseJFznU8vHcEBLpiXKY3/6xc+cBm65Q== + +"@rollup/rollup-darwin-x64@4.35.0": + version "4.35.0" + resolved "https://registry.yarnpkg.com/@rollup/rollup-darwin-x64/-/rollup-darwin-x64-4.35.0.tgz#25b74ce2d8d3f9ea8e119b01384d44a1c0a0d3ae" + integrity sha512-3IrHjfAS6Vkp+5bISNQnPogRAW5GAV1n+bNCrDwXmfMHbPl5EhTmWtfmwlJxFRUCBZ+tZ/OxDyU08aF6NI/N5Q== + +"@rollup/rollup-freebsd-arm64@4.35.0": + version "4.35.0" + resolved "https://registry.yarnpkg.com/@rollup/rollup-freebsd-arm64/-/rollup-freebsd-arm64-4.35.0.tgz#be3d39e3441df5d6e187c83d158c60656c82e203" + integrity sha512-sxjoD/6F9cDLSELuLNnY0fOrM9WA0KrM0vWm57XhrIMf5FGiN8D0l7fn+bpUeBSU7dCgPV2oX4zHAsAXyHFGcQ== + +"@rollup/rollup-freebsd-x64@4.35.0": + version "4.35.0" + resolved "https://registry.yarnpkg.com/@rollup/rollup-freebsd-x64/-/rollup-freebsd-x64-4.35.0.tgz#cd932d3ec679711efd65ca25821fb318e25b7ce4" + integrity sha512-2mpHCeRuD1u/2kruUiHSsnjWtHjqVbzhBkNVQ1aVD63CcexKVcQGwJ2g5VphOd84GvxfSvnnlEyBtQCE5hxVVw== + +"@rollup/rollup-linux-arm-gnueabihf@4.35.0": + version "4.35.0" + resolved "https://registry.yarnpkg.com/@rollup/rollup-linux-arm-gnueabihf/-/rollup-linux-arm-gnueabihf-4.35.0.tgz#d300b74c6f805474225632f185daaeae760ac2bb" + integrity sha512-mrA0v3QMy6ZSvEuLs0dMxcO2LnaCONs1Z73GUDBHWbY8tFFocM6yl7YyMu7rz4zS81NDSqhrUuolyZXGi8TEqg== + +"@rollup/rollup-linux-arm-musleabihf@4.35.0": + version "4.35.0" + resolved "https://registry.yarnpkg.com/@rollup/rollup-linux-arm-musleabihf/-/rollup-linux-arm-musleabihf-4.35.0.tgz#2caac622380f314c41934ed1e68ceaf6cc380cc3" + integrity sha512-DnYhhzcvTAKNexIql8pFajr0PiDGrIsBYPRvCKlA5ixSS3uwo/CWNZxB09jhIapEIg945KOzcYEAGGSmTSpk7A== + +"@rollup/rollup-linux-arm64-gnu@4.35.0": + version "4.35.0" + resolved "https://registry.yarnpkg.com/@rollup/rollup-linux-arm64-gnu/-/rollup-linux-arm64-gnu-4.35.0.tgz#1ec841650b038cc15c194c26326483fd7ebff3e3" + integrity sha512-uagpnH2M2g2b5iLsCTZ35CL1FgyuzzJQ8L9VtlJ+FckBXroTwNOaD0z0/UF+k5K3aNQjbm8LIVpxykUOQt1m/A== + +"@rollup/rollup-linux-arm64-musl@4.35.0": + version "4.35.0" + resolved "https://registry.yarnpkg.com/@rollup/rollup-linux-arm64-musl/-/rollup-linux-arm64-musl-4.35.0.tgz#2fc70a446d986e27f6101ea74e81746987f69150" + integrity sha512-XQxVOCd6VJeHQA/7YcqyV0/88N6ysSVzRjJ9I9UA/xXpEsjvAgDTgH3wQYz5bmr7SPtVK2TsP2fQ2N9L4ukoUg== + +"@rollup/rollup-linux-loongarch64-gnu@4.35.0": + version "4.35.0" + resolved "https://registry.yarnpkg.com/@rollup/rollup-linux-loongarch64-gnu/-/rollup-linux-loongarch64-gnu-4.35.0.tgz#561bd045cd9ce9e08c95f42e7a8688af8c93d764" + integrity sha512-5pMT5PzfgwcXEwOaSrqVsz/LvjDZt+vQ8RT/70yhPU06PTuq8WaHhfT1LW+cdD7mW6i/J5/XIkX/1tCAkh1W6g== + +"@rollup/rollup-linux-powerpc64le-gnu@4.35.0": + version "4.35.0" + resolved "https://registry.yarnpkg.com/@rollup/rollup-linux-powerpc64le-gnu/-/rollup-linux-powerpc64le-gnu-4.35.0.tgz#45d849a0b33813f33fe5eba9f99e0ff15ab5caad" + integrity sha512-c+zkcvbhbXF98f4CtEIP1EBA/lCic5xB0lToneZYvMeKu5Kamq3O8gqrxiYYLzlZH6E3Aq+TSW86E4ay8iD8EA== + +"@rollup/rollup-linux-riscv64-gnu@4.35.0": + version "4.35.0" + resolved "https://registry.yarnpkg.com/@rollup/rollup-linux-riscv64-gnu/-/rollup-linux-riscv64-gnu-4.35.0.tgz#78dde3e6fcf5b5733a97d0a67482d768aa1e83a5" + integrity sha512-s91fuAHdOwH/Tad2tzTtPX7UZyytHIRR6V4+2IGlV0Cej5rkG0R61SX4l4y9sh0JBibMiploZx3oHKPnQBKe4g== + +"@rollup/rollup-linux-s390x-gnu@4.35.0": + version "4.35.0" + resolved "https://registry.yarnpkg.com/@rollup/rollup-linux-s390x-gnu/-/rollup-linux-s390x-gnu-4.35.0.tgz#2e34835020f9e03dfb411473a5c2a0e8a9c5037b" + integrity sha512-hQRkPQPLYJZYGP+Hj4fR9dDBMIM7zrzJDWFEMPdTnTy95Ljnv0/4w/ixFw3pTBMEuuEuoqtBINYND4M7ujcuQw== + +"@rollup/rollup-linux-x64-gnu@4.35.0": + version "4.35.0" + resolved "https://registry.yarnpkg.com/@rollup/rollup-linux-x64-gnu/-/rollup-linux-x64-gnu-4.35.0.tgz#4f9774beddc6f4274df57ac99862eb23040de461" + integrity sha512-Pim1T8rXOri+0HmV4CdKSGrqcBWX0d1HoPnQ0uw0bdp1aP5SdQVNBy8LjYncvnLgu3fnnCt17xjWGd4cqh8/hA== + +"@rollup/rollup-linux-x64-musl@4.35.0": + version "4.35.0" + resolved "https://registry.yarnpkg.com/@rollup/rollup-linux-x64-musl/-/rollup-linux-x64-musl-4.35.0.tgz#dfcff2c1aed518b3d23ccffb49afb349d74fb608" + integrity sha512-QysqXzYiDvQWfUiTm8XmJNO2zm9yC9P/2Gkrwg2dH9cxotQzunBHYr6jk4SujCTqnfGxduOmQcI7c2ryuW8XVg== + +"@rollup/rollup-win32-arm64-msvc@4.35.0": + version "4.35.0" + resolved "https://registry.yarnpkg.com/@rollup/rollup-win32-arm64-msvc/-/rollup-win32-arm64-msvc-4.35.0.tgz#b0b37e2d77041e3aa772f519291309abf4c03a84" + integrity sha512-OUOlGqPkVJCdJETKOCEf1mw848ZyJ5w50/rZ/3IBQVdLfR5jk/6Sr5m3iO2tdPgwo0x7VcncYuOvMhBWZq8ayg== + +"@rollup/rollup-win32-ia32-msvc@4.35.0": + version "4.35.0" + resolved "https://registry.yarnpkg.com/@rollup/rollup-win32-ia32-msvc/-/rollup-win32-ia32-msvc-4.35.0.tgz#5b5a40e44a743ddc0e06b8e1b3982f856dc9ce0a" + integrity sha512-2/lsgejMrtwQe44glq7AFFHLfJBPafpsTa6JvP2NGef/ifOa4KBoglVf7AKN7EV9o32evBPRqfg96fEHzWo5kw== + +"@rollup/rollup-win32-x64-msvc@4.35.0": + version "4.35.0" + resolved "https://registry.yarnpkg.com/@rollup/rollup-win32-x64-msvc/-/rollup-win32-x64-msvc-4.35.0.tgz#05f25dbc9981bee1ae6e713daab10397044a46ca" + integrity sha512-PIQeY5XDkrOysbQblSW7v3l1MDZzkTEzAfTPkj5VAu3FW8fS4ynyLg2sINp0fp3SjZ8xkRYpLqoKcYqAkhU1dw== + +"@types/estree@1.0.6", "@types/estree@^1.0.0": + version "1.0.6" + resolved "https://registry.yarnpkg.com/@types/estree/-/estree-1.0.6.tgz#628effeeae2064a1b4e79f78e81d87b7e5fc7b50" + integrity sha512-AYnb1nQyY49te+VRAVgmzfcgjYS91mY5P0TKUDCLEM+gNnA+3T6rWITXRLYCpahpqSQbN5cE+gHpnPyXjHWxcw== + +"@vitest/expect@3.0.8": + version "3.0.8" + resolved "https://registry.yarnpkg.com/@vitest/expect/-/expect-3.0.8.tgz#53c408180d6476c7363eb976dcaae8e7b1f1a078" + integrity sha512-Xu6TTIavTvSSS6LZaA3EebWFr6tsoXPetOWNMOlc7LO88QVVBwq2oQWBoDiLCN6YTvNYsGSjqOO8CAdjom5DCQ== + dependencies: + "@vitest/spy" "3.0.8" + "@vitest/utils" "3.0.8" + chai "^5.2.0" + tinyrainbow "^2.0.0" + +"@vitest/mocker@3.0.8": + version "3.0.8" + resolved "https://registry.yarnpkg.com/@vitest/mocker/-/mocker-3.0.8.tgz#01638859e7dd422a8aaf04ef63dca9e1bbb9838d" + integrity sha512-n3LjS7fcW1BCoF+zWZxG7/5XvuYH+lsFg+BDwwAz0arIwHQJFUEsKBQ0BLU49fCxuM/2HSeBPHQD8WjgrxMfow== + dependencies: + "@vitest/spy" "3.0.8" + estree-walker "^3.0.3" + magic-string "^0.30.17" + +"@vitest/pretty-format@3.0.8", "@vitest/pretty-format@^3.0.8": + version "3.0.8" + resolved "https://registry.yarnpkg.com/@vitest/pretty-format/-/pretty-format-3.0.8.tgz#89f6111d141142689871f5a4e62ad679bb6b6357" + integrity sha512-BNqwbEyitFhzYMYHUVbIvepOyeQOSFA/NeJMIP9enMntkkxLgOcgABH6fjyXG85ipTgvero6noreavGIqfJcIg== + dependencies: + tinyrainbow "^2.0.0" + +"@vitest/runner@3.0.8": + version "3.0.8" + resolved "https://registry.yarnpkg.com/@vitest/runner/-/runner-3.0.8.tgz#dda7223c25a89a829a29c3f0c037a99e028a9c64" + integrity sha512-c7UUw6gEcOzI8fih+uaAXS5DwjlBaCJUo7KJ4VvJcjL95+DSR1kova2hFuRt3w41KZEFcOEiq098KkyrjXeM5w== + dependencies: + "@vitest/utils" "3.0.8" + pathe "^2.0.3" + +"@vitest/snapshot@3.0.8": + version "3.0.8" + resolved "https://registry.yarnpkg.com/@vitest/snapshot/-/snapshot-3.0.8.tgz#b65d738c00ff052a323125ad7dfb001927049c78" + integrity sha512-x8IlMGSEMugakInj44nUrLSILh/zy1f2/BgH0UeHpNyOocG18M9CWVIFBaXPt8TrqVZWmcPjwfG/ht5tnpba8A== + dependencies: + "@vitest/pretty-format" "3.0.8" + magic-string "^0.30.17" + pathe "^2.0.3" + +"@vitest/spy@3.0.8": + version "3.0.8" + resolved "https://registry.yarnpkg.com/@vitest/spy/-/spy-3.0.8.tgz#2a31ce28858aae50286644d64f886c72d55ae2ce" + integrity sha512-MR+PzJa+22vFKYb934CejhR4BeRpMSoxkvNoDit68GQxRLSf11aT6CTj3XaqUU9rxgWJFnqicN/wxw6yBRkI1Q== + dependencies: + tinyspy "^3.0.2" + +"@vitest/utils@3.0.8": + version "3.0.8" + resolved "https://registry.yarnpkg.com/@vitest/utils/-/utils-3.0.8.tgz#289277fbd8e733dff69cfa993c34665415c9b66b" + integrity sha512-nkBC3aEhfX2PdtQI/QwAWp8qZWwzASsU4Npbcd5RdMPBSSLCpkZp52P3xku3s3uA0HIEhGvEcF8rNkBsz9dQ4Q== + dependencies: + "@vitest/pretty-format" "3.0.8" + loupe "^3.1.3" + tinyrainbow "^2.0.0" + +assertion-error@^2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/assertion-error/-/assertion-error-2.0.1.tgz#f641a196b335690b1070bf00b6e7593fec190bf7" + integrity sha512-Izi8RQcffqCeNVgFigKli1ssklIbpHnCYc6AknXGYoB6grJqyeby7jv12JUQgmTAnIDnbck1uxksT4dzN3PWBA== + +cac@^6.7.14: + version "6.7.14" + resolved "https://registry.yarnpkg.com/cac/-/cac-6.7.14.tgz#804e1e6f506ee363cb0e3ccbb09cad5dd9870959" + integrity sha512-b6Ilus+c3RrdDk+JhLKUAQfzzgLEPy6wcXqS7f/xe1EETvsDP6GORG7SFuOs6cID5YkqchW/LXZbX5bc8j7ZcQ== + +chai@^5.2.0: + version "5.2.0" + resolved "https://registry.yarnpkg.com/chai/-/chai-5.2.0.tgz#1358ee106763624114addf84ab02697e411c9c05" + integrity sha512-mCuXncKXk5iCLhfhwTc0izo0gtEmpz5CtG2y8GiOINBlMVS6v8TMRc5TaLWKS6692m9+dVVfzgeVxR5UxWHTYw== + dependencies: + assertion-error "^2.0.1" + check-error "^2.1.1" + deep-eql "^5.0.1" + loupe "^3.1.0" + pathval "^2.0.0" + +check-error@^2.1.1: + version "2.1.1" + resolved "https://registry.yarnpkg.com/check-error/-/check-error-2.1.1.tgz#87eb876ae71ee388fa0471fe423f494be1d96ccc" + integrity sha512-OAlb+T7V4Op9OwdkjmguYRqncdlx5JiofwOAUkmTF+jNdHwzTaTs4sRAGpzLF3oOz5xAyDGrPgeIDFQmDOTiJw== + +debug@^4.4.0: + version "4.4.0" + resolved "https://registry.yarnpkg.com/debug/-/debug-4.4.0.tgz#2b3f2aea2ffeb776477460267377dc8710faba8a" + integrity sha512-6WTZ/IxCY/T6BALoZHaE4ctp9xm+Z5kY/pzYaCHRFeyVhojxlrm+46y68HA6hr0TcwEssoxNiDEUJQjfPZ/RYA== + dependencies: + ms "^2.1.3" + +deep-eql@^5.0.1: + version "5.0.2" + resolved "https://registry.yarnpkg.com/deep-eql/-/deep-eql-5.0.2.tgz#4b756d8d770a9257300825d52a2c2cff99c3a341" + integrity sha512-h5k/5U50IJJFpzfL6nO9jaaumfjO/f2NjK/oYB2Djzm4p9L+3T9qWpZqZ2hAbLPuuYq9wrU08WQyBTL5GbPk5Q== + +es-module-lexer@^1.6.0: + version "1.6.0" + resolved "https://registry.yarnpkg.com/es-module-lexer/-/es-module-lexer-1.6.0.tgz#da49f587fd9e68ee2404fe4e256c0c7d3a81be21" + integrity sha512-qqnD1yMU6tk/jnaMosogGySTZP8YtUgAffA9nMN+E/rjxcfRQ6IEk7IiozUjgxKoFHBGjTLnrHB/YC45r/59EQ== + +esbuild@^0.25.0: + version "0.25.0" + resolved "https://registry.yarnpkg.com/esbuild/-/esbuild-0.25.0.tgz#0de1787a77206c5a79eeb634a623d39b5006ce92" + integrity sha512-BXq5mqc8ltbaN34cDqWuYKyNhX8D/Z0J1xdtdQ8UcIIIyJyz+ZMKUt58tF3SrZ85jcfN/PZYhjR5uDQAYNVbuw== + optionalDependencies: + "@esbuild/aix-ppc64" "0.25.0" + "@esbuild/android-arm" "0.25.0" + "@esbuild/android-arm64" "0.25.0" + "@esbuild/android-x64" "0.25.0" + "@esbuild/darwin-arm64" "0.25.0" + "@esbuild/darwin-x64" "0.25.0" + "@esbuild/freebsd-arm64" "0.25.0" + "@esbuild/freebsd-x64" "0.25.0" + "@esbuild/linux-arm" "0.25.0" + "@esbuild/linux-arm64" "0.25.0" + "@esbuild/linux-ia32" "0.25.0" + "@esbuild/linux-loong64" "0.25.0" + "@esbuild/linux-mips64el" "0.25.0" + "@esbuild/linux-ppc64" "0.25.0" + "@esbuild/linux-riscv64" "0.25.0" + "@esbuild/linux-s390x" "0.25.0" + "@esbuild/linux-x64" "0.25.0" + "@esbuild/netbsd-arm64" "0.25.0" + "@esbuild/netbsd-x64" "0.25.0" + "@esbuild/openbsd-arm64" "0.25.0" + "@esbuild/openbsd-x64" "0.25.0" + "@esbuild/sunos-x64" "0.25.0" + "@esbuild/win32-arm64" "0.25.0" + "@esbuild/win32-ia32" "0.25.0" + "@esbuild/win32-x64" "0.25.0" + +estree-walker@^3.0.3: + version "3.0.3" + resolved "https://registry.yarnpkg.com/estree-walker/-/estree-walker-3.0.3.tgz#67c3e549ec402a487b4fc193d1953a524752340d" + integrity sha512-7RUKfXgSMMkzt6ZuXmqapOurLGPPfgj6l9uRZ7lRGolvk0y2yocc35LdcxKC5PQZdn2DMqioAQ2NoWcrTKmm6g== + dependencies: + "@types/estree" "^1.0.0" + +expect-type@^1.1.0: + version "1.2.0" + resolved "https://registry.yarnpkg.com/expect-type/-/expect-type-1.2.0.tgz#b52a0a1117260f5a8dcf33aef66365be18c13415" + integrity sha512-80F22aiJ3GLyVnS/B3HzgR6RelZVumzj9jkL0Rhz4h0xYbNW9PjlQz5h3J/SShErbXBc295vseR4/MIbVmUbeA== + +fsevents@~2.3.2, fsevents@~2.3.3: + version "2.3.3" + resolved "https://registry.yarnpkg.com/fsevents/-/fsevents-2.3.3.tgz#cac6407785d03675a2a5e1a5305c697b347d90d6" + integrity sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw== + +loupe@^3.1.0, loupe@^3.1.3: + version "3.1.3" + resolved "https://registry.yarnpkg.com/loupe/-/loupe-3.1.3.tgz#042a8f7986d77f3d0f98ef7990a2b2fef18b0fd2" + integrity sha512-kkIp7XSkP78ZxJEsSxW3712C6teJVoeHHwgo9zJ380de7IYyJ2ISlxojcH2pC5OFLewESmnRi/+XCDIEEVyoug== + +magic-string@^0.30.17: + version "0.30.17" + resolved "https://registry.yarnpkg.com/magic-string/-/magic-string-0.30.17.tgz#450a449673d2460e5bbcfba9a61916a1714c7453" + integrity sha512-sNPKHvyjVf7gyjwS4xGTaW/mCnF8wnjtifKBEhxfZ7E/S8tQ0rssrwGNn6q8JH/ohItJfSQp9mBtQYuTlH5QnA== + dependencies: + "@jridgewell/sourcemap-codec" "^1.5.0" + +ms@^2.1.3: + version "2.1.3" + resolved "https://registry.yarnpkg.com/ms/-/ms-2.1.3.tgz#574c8138ce1d2b5861f0b44579dbadd60c6615b2" + integrity sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA== + +nanoid@^3.3.8: + version "3.3.9" + resolved "https://registry.yarnpkg.com/nanoid/-/nanoid-3.3.9.tgz#e0097d8e026b3343ff053e9ccd407360a03f503a" + integrity sha512-SppoicMGpZvbF1l3z4x7No3OlIjP7QJvC9XR7AhZr1kL133KHnKPztkKDc+Ir4aJ/1VhTySrtKhrsycmrMQfvg== + +pathe@^2.0.3: + version "2.0.3" + resolved "https://registry.yarnpkg.com/pathe/-/pathe-2.0.3.tgz#3ecbec55421685b70a9da872b2cff3e1cbed1716" + integrity sha512-WUjGcAqP1gQacoQe+OBJsFA7Ld4DyXuUIjZ5cc75cLHvJ7dtNsTugphxIADwspS+AraAUePCKrSVtPLFj/F88w== + +pathval@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/pathval/-/pathval-2.0.0.tgz#7e2550b422601d4f6b8e26f1301bc8f15a741a25" + integrity sha512-vE7JKRyES09KiunauX7nd2Q9/L7lhok4smP9RZTDeD4MVs72Dp2qNFVz39Nz5a0FVEW0BJR6C0DYrq6unoziZA== + +picocolors@^1.1.1: + version "1.1.1" + resolved "https://registry.yarnpkg.com/picocolors/-/picocolors-1.1.1.tgz#3d321af3eab939b083c8f929a1d12cda81c26b6b" + integrity sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA== + +postcss@^8.5.3: + version "8.5.3" + resolved "https://registry.yarnpkg.com/postcss/-/postcss-8.5.3.tgz#1463b6f1c7fb16fe258736cba29a2de35237eafb" + integrity sha512-dle9A3yYxlBSrt8Fu+IpjGT8SY8hN0mlaA6GY8t0P5PjIOZemULz/E2Bnm/2dcUOena75OTNkHI76uZBNUUq3A== + dependencies: + nanoid "^3.3.8" + picocolors "^1.1.1" + source-map-js "^1.2.1" + +rollup@^4.30.1: + version "4.35.0" + resolved "https://registry.yarnpkg.com/rollup/-/rollup-4.35.0.tgz#76c95dba17a579df4c00c3955aed32aa5d4dc66d" + integrity sha512-kg6oI4g+vc41vePJyO6dHt/yl0Rz3Thv0kJeVQ3D1kS3E5XSuKbPc29G4IpT/Kv1KQwgHVcN+HtyS+HYLNSvQg== + dependencies: + "@types/estree" "1.0.6" + optionalDependencies: + "@rollup/rollup-android-arm-eabi" "4.35.0" + "@rollup/rollup-android-arm64" "4.35.0" + "@rollup/rollup-darwin-arm64" "4.35.0" + "@rollup/rollup-darwin-x64" "4.35.0" + "@rollup/rollup-freebsd-arm64" "4.35.0" + "@rollup/rollup-freebsd-x64" "4.35.0" + "@rollup/rollup-linux-arm-gnueabihf" "4.35.0" + "@rollup/rollup-linux-arm-musleabihf" "4.35.0" + "@rollup/rollup-linux-arm64-gnu" "4.35.0" + "@rollup/rollup-linux-arm64-musl" "4.35.0" + "@rollup/rollup-linux-loongarch64-gnu" "4.35.0" + "@rollup/rollup-linux-powerpc64le-gnu" "4.35.0" + "@rollup/rollup-linux-riscv64-gnu" "4.35.0" + "@rollup/rollup-linux-s390x-gnu" "4.35.0" + "@rollup/rollup-linux-x64-gnu" "4.35.0" + "@rollup/rollup-linux-x64-musl" "4.35.0" + "@rollup/rollup-win32-arm64-msvc" "4.35.0" + "@rollup/rollup-win32-ia32-msvc" "4.35.0" + "@rollup/rollup-win32-x64-msvc" "4.35.0" + fsevents "~2.3.2" + +siginfo@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/siginfo/-/siginfo-2.0.0.tgz#32e76c70b79724e3bb567cb9d543eb858ccfaf30" + integrity sha512-ybx0WO1/8bSBLEWXZvEd7gMW3Sn3JFlW3TvX1nREbDLRNQNaeNN8WK0meBwPdAaOI7TtRRRJn/Es1zhrrCHu7g== + +source-map-js@^1.2.1: + version "1.2.1" + resolved "https://registry.yarnpkg.com/source-map-js/-/source-map-js-1.2.1.tgz#1ce5650fddd87abc099eda37dcff024c2667ae46" + integrity sha512-UXWMKhLOwVKb728IUtQPXxfYU+usdybtUrK/8uGE8CQMvrhOpwvzDBwj0QhSL7MQc7vIsISBG8VQ8+IDQxpfQA== + +stackback@0.0.2: + version "0.0.2" + resolved "https://registry.yarnpkg.com/stackback/-/stackback-0.0.2.tgz#1ac8a0d9483848d1695e418b6d031a3c3ce68e3b" + integrity sha512-1XMJE5fQo1jGH6Y/7ebnwPOBEkIEnT4QF32d5R1+VXdXveM0IBMJt8zfaxX1P3QhVwrYe+576+jkANtSS2mBbw== + +std-env@^3.8.0: + version "3.8.1" + resolved "https://registry.yarnpkg.com/std-env/-/std-env-3.8.1.tgz#2b81c631c62e3d0b964b87f099b8dcab6c9a5346" + integrity sha512-vj5lIj3Mwf9D79hBkltk5qmkFI+biIKWS2IBxEyEU3AX1tUf7AoL8nSazCOiiqQsGKIq01SClsKEzweu34uwvA== + +tinybench@^2.9.0: + version "2.9.0" + resolved "https://registry.yarnpkg.com/tinybench/-/tinybench-2.9.0.tgz#103c9f8ba6d7237a47ab6dd1dcff77251863426b" + integrity sha512-0+DUvqWMValLmha6lr4kD8iAMK1HzV0/aKnCtWb9v9641TnP/MFb7Pc2bxoxQjTXAErryXVgUOfv2YqNllqGeg== + +tinyexec@^0.3.2: + version "0.3.2" + resolved "https://registry.yarnpkg.com/tinyexec/-/tinyexec-0.3.2.tgz#941794e657a85e496577995c6eef66f53f42b3d2" + integrity sha512-KQQR9yN7R5+OSwaK0XQoj22pwHoTlgYqmUscPYoknOoWCWfj/5/ABTMRi69FrKU5ffPVh5QcFikpWJI/P1ocHA== + +tinypool@^1.0.2: + version "1.0.2" + resolved "https://registry.yarnpkg.com/tinypool/-/tinypool-1.0.2.tgz#706193cc532f4c100f66aa00b01c42173d9051b2" + integrity sha512-al6n+QEANGFOMf/dmUMsuS5/r9B06uwlyNjZZql/zv8J7ybHCgoihBNORZCY2mzUuAnomQa2JdhyHKzZxPCrFA== + +tinyrainbow@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/tinyrainbow/-/tinyrainbow-2.0.0.tgz#9509b2162436315e80e3eee0fcce4474d2444294" + integrity sha512-op4nsTR47R6p0vMUUoYl/a+ljLFVtlfaXkLQmqfLR1qHma1h/ysYk4hEXZ880bf2CYgTskvTa/e196Vd5dDQXw== + +tinyspy@^3.0.2: + version "3.0.2" + resolved "https://registry.yarnpkg.com/tinyspy/-/tinyspy-3.0.2.tgz#86dd3cf3d737b15adcf17d7887c84a75201df20a" + integrity sha512-n1cw8k1k0x4pgA2+9XrOkFydTerNcJ1zWCO5Nn9scWHTD+5tp8dghT2x1uduQePZTZgd3Tupf+x9BxJjeJi77Q== + +vite-node@3.0.8: + version "3.0.8" + resolved "https://registry.yarnpkg.com/vite-node/-/vite-node-3.0.8.tgz#69cd1e0b9c7c37a8e7ab3b87ce259cbbf9a7bd72" + integrity sha512-6PhR4H9VGlcwXZ+KWCdMqbtG649xCPZqfI9j2PsK1FcXgEzro5bGHcVKFCTqPLaNKZES8Evqv4LwvZARsq5qlg== + dependencies: + cac "^6.7.14" + debug "^4.4.0" + es-module-lexer "^1.6.0" + pathe "^2.0.3" + vite "^5.0.0 || ^6.0.0" + +"vite@^5.0.0 || ^6.0.0": + version "6.2.1" + resolved "https://registry.yarnpkg.com/vite/-/vite-6.2.1.tgz#ae865d4bb93a11844be1bc647c8b2dd1856ea180" + integrity sha512-n2GnqDb6XPhlt9B8olZPrgMD/es/Nd1RdChF6CBD/fHW6pUyUTt2sQW2fPRX5GiD9XEa6+8A6A4f2vT6pSsE7Q== + dependencies: + esbuild "^0.25.0" + postcss "^8.5.3" + rollup "^4.30.1" + optionalDependencies: + fsevents "~2.3.3" + +vitest@^3.0.8: + version "3.0.8" + resolved "https://registry.yarnpkg.com/vitest/-/vitest-3.0.8.tgz#2b85e689d3067cf3b8e174626ecfcb8b24be0785" + integrity sha512-dfqAsNqRGUc8hB9OVR2P0w8PZPEckti2+5rdZip0WIz9WW0MnImJ8XiR61QhqLa92EQzKP2uPkzenKOAHyEIbA== + dependencies: + "@vitest/expect" "3.0.8" + "@vitest/mocker" "3.0.8" + "@vitest/pretty-format" "^3.0.8" + "@vitest/runner" "3.0.8" + "@vitest/snapshot" "3.0.8" + "@vitest/spy" "3.0.8" + "@vitest/utils" "3.0.8" + chai "^5.2.0" + debug "^4.4.0" + expect-type "^1.1.0" + magic-string "^0.30.17" + pathe "^2.0.3" + std-env "^3.8.0" + tinybench "^2.9.0" + tinyexec "^0.3.2" + tinypool "^1.0.2" + tinyrainbow "^2.0.0" + vite "^5.0.0 || ^6.0.0" + vite-node "3.0.8" + why-is-node-running "^2.3.0" + +why-is-node-running@^2.3.0: + version "2.3.0" + resolved "https://registry.yarnpkg.com/why-is-node-running/-/why-is-node-running-2.3.0.tgz#a3f69a97107f494b3cdc3bdddd883a7d65cebf04" + integrity sha512-hUrmaWBdVDcxvYqnyh09zunKzROWjbZTiNy8dBEjkS7ehEDQibXJ7XvlmtbwuTclUiIyN+CyXQD4Vmko8fNm8w== + dependencies: + siginfo "^2.0.0" + stackback "0.0.2" From 2d8ea17db17e9de19ce0599503871f88bce8de03 Mon Sep 17 00:00:00 2001 From: Wesley Guthrie Date: Sun, 9 Mar 2025 23:05:45 -0500 Subject: [PATCH 02/13] add utils folder --- src/map.test.ts | 2 +- src/mapParallel.test.ts | 2 +- src/{ => utils}/sleep.ts | 0 3 files changed, 2 insertions(+), 2 deletions(-) rename src/{ => utils}/sleep.ts (100%) diff --git a/src/map.test.ts b/src/map.test.ts index 7e25f67..db7b223 100644 --- a/src/map.test.ts +++ b/src/map.test.ts @@ -1,5 +1,5 @@ // @ts-strict-ignore -import { sleep } from "./sleep"; +import { sleep } from "./utils/sleep"; import map from "./map"; import { describe, it, expect } from "vitest"; diff --git a/src/mapParallel.test.ts b/src/mapParallel.test.ts index 53300a0..14246c1 100644 --- a/src/mapParallel.test.ts +++ b/src/mapParallel.test.ts @@ -1,5 +1,5 @@ import mapParallel from "./mapParallel"; -import { sleep } from "./sleep"; +import { sleep } from "./utils/sleep"; import { describe, it, expect } from "vitest"; describe("mapParallel tests", () => { diff --git a/src/sleep.ts b/src/utils/sleep.ts similarity index 100% rename from src/sleep.ts rename to src/utils/sleep.ts From 4532ad595f9b7668badd35d343a4c488255c9ed4 Mon Sep 17 00:00:00 2001 From: Wesley Guthrie Date: Mon, 10 Mar 2025 00:15:19 -0500 Subject: [PATCH 03/13] add files for other iterators --- src/every.ts | 5 ++++- src/filter.ts | 4 +++- src/find.ts | 4 +++- src/findIndex.test.ts | 0 src/findIndex.ts | 0 src/findLast.test.ts | 0 src/findLast.ts | 0 src/findLastIndex.test.ts | 0 src/findLastIndex.ts | 0 src/index.d.ts | 3 +++ src/indexOf.test.ts | 0 src/indexOf.ts | 0 src/lastIndexOf.test.ts | 0 src/lastIndexOf.ts | 0 src/map.ts | 4 +++- src/mapParallel.ts | 5 ++++- src/reduceRight.test.ts | 0 src/reduceRight.ts | 0 src/some.ts | 4 +++- 19 files changed, 23 insertions(+), 6 deletions(-) create mode 100644 src/findIndex.test.ts create mode 100644 src/findIndex.ts create mode 100644 src/findLast.test.ts create mode 100644 src/findLast.ts create mode 100644 src/findLastIndex.test.ts create mode 100644 src/findLastIndex.ts create mode 100644 src/index.d.ts create mode 100644 src/indexOf.test.ts create mode 100644 src/indexOf.ts create mode 100644 src/lastIndexOf.test.ts create mode 100644 src/lastIndexOf.ts create mode 100644 src/reduceRight.test.ts create mode 100644 src/reduceRight.ts diff --git a/src/every.ts b/src/every.ts index ba454c7..9812da6 100644 --- a/src/every.ts +++ b/src/every.ts @@ -1,8 +1,11 @@ +import { BooleanIterator } from "."; + export default async function every( array: T[], - iterator: (val: T, index?: number) => Promise + iterator: BooleanIterator ): Promise { if (!Array.isArray(array) || !array?.length) return false; + for (let i = 0; i < array.length; i++) { const element = array.at(i) as T; const result = await iterator(element, i); diff --git a/src/filter.ts b/src/filter.ts index af72546..af22986 100644 --- a/src/filter.ts +++ b/src/filter.ts @@ -1,6 +1,8 @@ +import { BooleanIterator } from "."; + export default async function filter( array: T[], - iterator: (val: T, index?: number) => Promise + iterator: BooleanIterator ): Promise { if (!Array.isArray(array) || !array?.length) return []; const results: T[] = []; diff --git a/src/find.ts b/src/find.ts index d2c4a07..f46e9ea 100644 --- a/src/find.ts +++ b/src/find.ts @@ -1,6 +1,8 @@ +import { BooleanIterator } from "."; + export default async function find( array: T[], - iterator: (val: T, index?: number) => Promise + iterator: BooleanIterator ): Promise { if (!Array.isArray(array) || !array?.length) return undefined; for (let i = 0; i < array.length; i++) { diff --git a/src/findIndex.test.ts b/src/findIndex.test.ts new file mode 100644 index 0000000..e69de29 diff --git a/src/findIndex.ts b/src/findIndex.ts new file mode 100644 index 0000000..e69de29 diff --git a/src/findLast.test.ts b/src/findLast.test.ts new file mode 100644 index 0000000..e69de29 diff --git a/src/findLast.ts b/src/findLast.ts new file mode 100644 index 0000000..e69de29 diff --git a/src/findLastIndex.test.ts b/src/findLastIndex.test.ts new file mode 100644 index 0000000..e69de29 diff --git a/src/findLastIndex.ts b/src/findLastIndex.ts new file mode 100644 index 0000000..e69de29 diff --git a/src/index.d.ts b/src/index.d.ts new file mode 100644 index 0000000..0509c36 --- /dev/null +++ b/src/index.d.ts @@ -0,0 +1,3 @@ +export type BooleanIterator = (value: T, index: number) => Promise; + +export type ArrayIterator = (value: T, index: number) => Promise; diff --git a/src/indexOf.test.ts b/src/indexOf.test.ts new file mode 100644 index 0000000..e69de29 diff --git a/src/indexOf.ts b/src/indexOf.ts new file mode 100644 index 0000000..e69de29 diff --git a/src/lastIndexOf.test.ts b/src/lastIndexOf.test.ts new file mode 100644 index 0000000..e69de29 diff --git a/src/lastIndexOf.ts b/src/lastIndexOf.ts new file mode 100644 index 0000000..e69de29 diff --git a/src/map.ts b/src/map.ts index e6b9606..f197136 100644 --- a/src/map.ts +++ b/src/map.ts @@ -1,6 +1,8 @@ +import { ArrayIterator } from "."; + export default async function map( array: T[], - iterator: (val: T, i: number) => Promise + iterator: ArrayIterator ): Promise { if (!Array.isArray(array) || !array?.length) return; diff --git a/src/mapParallel.ts b/src/mapParallel.ts index 2a20353..365a5c3 100644 --- a/src/mapParallel.ts +++ b/src/mapParallel.ts @@ -1,3 +1,5 @@ +import { ArrayIterator } from "."; + /** * take and complete tasks from a queue until that queue is empty. * @param {{ task: T; index: number }[]} array @@ -30,10 +32,11 @@ async function takeAndCompleteFromQueueUntilDone( */ export default async function mapParallel( array: T[], - iterator: (val: T, index: number) => Promise, + iterator: ArrayIterator, maxParallelBatchSize?: number ): Promise { if (!Array.isArray(array) || !array?.length) return []; + const arrayWithIndexKeys = array.map((item, i) => { return { task: item, diff --git a/src/reduceRight.test.ts b/src/reduceRight.test.ts new file mode 100644 index 0000000..e69de29 diff --git a/src/reduceRight.ts b/src/reduceRight.ts new file mode 100644 index 0000000..e69de29 diff --git a/src/some.ts b/src/some.ts index 8192f09..d4f2548 100644 --- a/src/some.ts +++ b/src/some.ts @@ -1,6 +1,8 @@ +import { BooleanIterator } from "."; + export default async function some( array: T[], - iterator: (val: T, index?: number) => Promise + iterator: BooleanIterator ): Promise { if (!Array.isArray(array) || !array?.length) return false; for (let i = 0; i < array.length; i++) { From a9a38099c4da8235523a06c3b4995203dfcdd3c1 Mon Sep 17 00:00:00 2001 From: Wesley Guthrie Date: Mon, 10 Mar 2025 10:29:11 -0500 Subject: [PATCH 04/13] add pr template --- .github/pull_request_template.md | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 .github/pull_request_template.md diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md new file mode 100644 index 0000000..9282965 --- /dev/null +++ b/.github/pull_request_template.md @@ -0,0 +1,19 @@ +# Description + +## Summary of Changes + +## Related Issue + +## Type of Change + +- [ ] Bug fix (non-breaking change which fixes an issue) +- [ ] New feature (non-breaking change which adds functionality) +- [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected) +- [ ] This change requires a documentation update + +# Checklist: + +- [ ] I have performed a self-review of my code +- [ ] I have made corresponding changes to the documentation +- [ ] My changes generate no new warnings +- [ ] I have added or refactored the necessary tests that prove my fix is effective or that my feature works From 9b5ff030e23db33221aded93f21adaa309581183 Mon Sep 17 00:00:00 2001 From: Wesley Guthrie Date: Mon, 10 Mar 2025 12:44:04 -0500 Subject: [PATCH 05/13] add github action for PRs, move tests to their own folder, add dist folder as outDir --- .../lint-test-build-pull-request.yaml | 67 +++++++++ .gitignore | 3 +- index.ts | 1 + package.json | 13 +- src/every.ts | 4 +- src/filter.ts | 4 +- src/find.ts | 4 +- src/index.d.ts | 3 - src/map.ts | 4 +- src/mapParallel.ts | 4 +- src/reduceRight.test.ts | 0 src/reduceRight.ts | 14 ++ src/some.ts | 4 +- src/utils/sleep.ts | 4 - {src => test}/every.test.ts | 2 +- {src => test}/filter.test.ts | 2 +- {src => test}/find.test.ts | 2 +- {src => test}/findIndex.test.ts | 0 {src => test}/findLast.test.ts | 0 {src => test}/findLastIndex.test.ts | 0 {src => test}/indexOf.test.ts | 0 {src => test}/lastIndexOf.test.ts | 0 {src => test}/map.test.ts | 6 +- {src => test}/mapParallel.test.ts | 11 +- {src => test}/reduce.test.ts | 4 +- test/reduceRight.test.ts | 32 +++++ {src => test}/some.test.ts | 4 +- tsconfig.json | 127 +++--------------- yarn.lock | 5 + 29 files changed, 167 insertions(+), 157 deletions(-) create mode 100644 .github/workflows/lint-test-build-pull-request.yaml delete mode 100644 src/index.d.ts delete mode 100644 src/reduceRight.test.ts delete mode 100644 src/utils/sleep.ts rename {src => test}/every.test.ts (99%) rename {src => test}/filter.test.ts (98%) rename {src => test}/find.test.ts (99%) rename {src => test}/findIndex.test.ts (100%) rename {src => test}/findLast.test.ts (100%) rename {src => test}/findLastIndex.test.ts (100%) rename {src => test}/indexOf.test.ts (100%) rename {src => test}/lastIndexOf.test.ts (100%) rename {src => test}/map.test.ts (76%) rename {src => test}/mapParallel.test.ts (89%) rename {src => test}/reduce.test.ts (91%) create mode 100644 test/reduceRight.test.ts rename {src => test}/some.test.ts (98%) diff --git a/.github/workflows/lint-test-build-pull-request.yaml b/.github/workflows/lint-test-build-pull-request.yaml new file mode 100644 index 0000000..423a7b5 --- /dev/null +++ b/.github/workflows/lint-test-build-pull-request.yaml @@ -0,0 +1,67 @@ +name: Lint, Test, and Build Pull Request +on: + pull_request: + branches: main +jobs: + lint: + runs-on: ubuntu-latest + name: ES Lint + strategy: + matrix: + node-version: ["18.*"] + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + - name: Use node version ${{ matrix.node-version }} + uses: actions/setup-node@v3 + with: + node-version: ${{ matrix.node-version }} + + - name: install modules + run: yarn install + + - name: run eslint + run: yarn lint + + test: + runs-on: ubuntu-latest + name: Test + strategy: + matrix: + node-version: ["18.*"] + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + - name: Use node version ${{ matrix.node-version }} + uses: actions/setup-node@v3 + with: + node-version: ${{ matrix.node-version }} + + - name: Install modules + run: yarn install + + - name: Run tests + run: yarn test + + build: + runs-on: ubuntu-latest + name: Build + strategy: + matrix: + node-version: ["18.*"] + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + - name: Use node version ${{ matrix.node-version }} + uses: actions/setup-node@v3 + with: + node-version: ${{ matrix.node-version }} + + - name: Install modules + run: yarn install + + - name: Build package + run: yarn build diff --git a/.gitignore b/.gitignore index 30bc162..31022da 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ -/node_modules \ No newline at end of file +/node_modules +yarn-error.log \ No newline at end of file diff --git a/index.ts b/index.ts index b15df51..d7b0b4c 100644 --- a/index.ts +++ b/index.ts @@ -4,4 +4,5 @@ export { default as find } from "./src/find"; export { default as map } from "./src/map"; export { default as mapParallel } from "./src/mapParallel"; export { default as reduce } from "./src/reduce"; +export { default as reduceRight } from "./src/reduceRight"; export { default as some } from "./src/some"; diff --git a/package.json b/package.json index d38e714..6fc9dea 100644 --- a/package.json +++ b/package.json @@ -7,10 +7,13 @@ "homepage": "https://github.com/GuthrieW/async-iterators", "repository": "GuthrieW/async-iterators", "files": [ - "index.js" + "/dist" ], - "main": "index.js", + "main": "dist/index.js", + "types": "dist/index.d.ts", "scripts": { + "build": "yarn clean && yarn tsc && rm -rf ./dist/test", + "clean": "rm -rf ./dist", "test": "vitest" }, "keywords": [ @@ -19,9 +22,11 @@ "iteraor" ], "engines": { - "node": ">=22.0.0" + "node": ">=18.0.0" + }, + "dependencies": { + "typescript": "^5.8.2" }, - "dependencies": {}, "devDependencies": { "vitest": "^3.0.8" } diff --git a/src/every.ts b/src/every.ts index 9812da6..7d4915e 100644 --- a/src/every.ts +++ b/src/every.ts @@ -1,8 +1,6 @@ -import { BooleanIterator } from "."; - export default async function every( array: T[], - iterator: BooleanIterator + iterator: (value: T, index: number) => Promise ): Promise { if (!Array.isArray(array) || !array?.length) return false; diff --git a/src/filter.ts b/src/filter.ts index af22986..b9efff2 100644 --- a/src/filter.ts +++ b/src/filter.ts @@ -1,8 +1,6 @@ -import { BooleanIterator } from "."; - export default async function filter( array: T[], - iterator: BooleanIterator + iterator: (value: T, index: number) => Promise ): Promise { if (!Array.isArray(array) || !array?.length) return []; const results: T[] = []; diff --git a/src/find.ts b/src/find.ts index f46e9ea..36b0c13 100644 --- a/src/find.ts +++ b/src/find.ts @@ -1,8 +1,6 @@ -import { BooleanIterator } from "."; - export default async function find( array: T[], - iterator: BooleanIterator + iterator: (value: T, index: number) => Promise ): Promise { if (!Array.isArray(array) || !array?.length) return undefined; for (let i = 0; i < array.length; i++) { diff --git a/src/index.d.ts b/src/index.d.ts deleted file mode 100644 index 0509c36..0000000 --- a/src/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -export type BooleanIterator = (value: T, index: number) => Promise; - -export type ArrayIterator = (value: T, index: number) => Promise; diff --git a/src/map.ts b/src/map.ts index f197136..96119be 100644 --- a/src/map.ts +++ b/src/map.ts @@ -1,8 +1,6 @@ -import { ArrayIterator } from "."; - export default async function map( array: T[], - iterator: ArrayIterator + iterator: (value: T, index: number) => Promise ): Promise { if (!Array.isArray(array) || !array?.length) return; diff --git a/src/mapParallel.ts b/src/mapParallel.ts index 365a5c3..4815bec 100644 --- a/src/mapParallel.ts +++ b/src/mapParallel.ts @@ -1,5 +1,3 @@ -import { ArrayIterator } from "."; - /** * take and complete tasks from a queue until that queue is empty. * @param {{ task: T; index: number }[]} array @@ -32,7 +30,7 @@ async function takeAndCompleteFromQueueUntilDone( */ export default async function mapParallel( array: T[], - iterator: ArrayIterator, + iterator: (value: T, index: number) => Promise, maxParallelBatchSize?: number ): Promise { if (!Array.isArray(array) || !array?.length) return []; diff --git a/src/reduceRight.test.ts b/src/reduceRight.test.ts deleted file mode 100644 index e69de29..0000000 diff --git a/src/reduceRight.ts b/src/reduceRight.ts index e69de29..b9f3fd2 100644 --- a/src/reduceRight.ts +++ b/src/reduceRight.ts @@ -0,0 +1,14 @@ +export default async function reduceRight( + array: T[], + iterator: (accumulator: V, currentValue: T) => Promise, + initialValue: V +): Promise { + if (!Array.isArray(array) || !array?.length) return initialValue; + + let result = initialValue; + for (let i = array.length; i >= 0; i--) { + result = await iterator(result, array.at(i) as T); + } + + return result; +} diff --git a/src/some.ts b/src/some.ts index d4f2548..9a15c99 100644 --- a/src/some.ts +++ b/src/some.ts @@ -1,8 +1,6 @@ -import { BooleanIterator } from "."; - export default async function some( array: T[], - iterator: BooleanIterator + iterator: (value: T, index: number) => Promise ): Promise { if (!Array.isArray(array) || !array?.length) return false; for (let i = 0; i < array.length; i++) { diff --git a/src/utils/sleep.ts b/src/utils/sleep.ts deleted file mode 100644 index b92820b..0000000 --- a/src/utils/sleep.ts +++ /dev/null @@ -1,4 +0,0 @@ -// wait for the specified amount of time and then resolve. -export async function sleep(delay = 0): Promise { - return new Promise((resolve) => setTimeout(resolve, delay)); -} diff --git a/src/every.test.ts b/test/every.test.ts similarity index 99% rename from src/every.test.ts rename to test/every.test.ts index a9c3f7f..073b2dd 100644 --- a/src/every.test.ts +++ b/test/every.test.ts @@ -1,4 +1,4 @@ -import every from "./every"; +import { every } from "index"; import { describe, it, expect } from "vitest"; describe("every tests", () => { diff --git a/src/filter.test.ts b/test/filter.test.ts similarity index 98% rename from src/filter.test.ts rename to test/filter.test.ts index 55ecdcb..55abf54 100644 --- a/src/filter.test.ts +++ b/test/filter.test.ts @@ -1,4 +1,4 @@ -import filter from "./filter"; +import { filter } from "index"; import { describe, it, expect } from "vitest"; describe("filter tests", () => { diff --git a/src/find.test.ts b/test/find.test.ts similarity index 99% rename from src/find.test.ts rename to test/find.test.ts index 5d2f26d..09a2436 100644 --- a/src/find.test.ts +++ b/test/find.test.ts @@ -1,4 +1,4 @@ -import find from "./find"; +import { find } from "index"; import { describe, it, expect } from "vitest"; describe("find tests", () => { diff --git a/src/findIndex.test.ts b/test/findIndex.test.ts similarity index 100% rename from src/findIndex.test.ts rename to test/findIndex.test.ts diff --git a/src/findLast.test.ts b/test/findLast.test.ts similarity index 100% rename from src/findLast.test.ts rename to test/findLast.test.ts diff --git a/src/findLastIndex.test.ts b/test/findLastIndex.test.ts similarity index 100% rename from src/findLastIndex.test.ts rename to test/findLastIndex.test.ts diff --git a/src/indexOf.test.ts b/test/indexOf.test.ts similarity index 100% rename from src/indexOf.test.ts rename to test/indexOf.test.ts diff --git a/src/lastIndexOf.test.ts b/test/lastIndexOf.test.ts similarity index 100% rename from src/lastIndexOf.test.ts rename to test/lastIndexOf.test.ts diff --git a/src/map.test.ts b/test/map.test.ts similarity index 76% rename from src/map.test.ts rename to test/map.test.ts index db7b223..512d72e 100644 --- a/src/map.test.ts +++ b/test/map.test.ts @@ -1,6 +1,4 @@ -// @ts-strict-ignore -import { sleep } from "./utils/sleep"; -import map from "./map"; +import { map } from "index"; import { describe, it, expect } from "vitest"; describe("map tests", () => { @@ -10,7 +8,7 @@ describe("map tests", () => { const indices: number[] = []; await map(numbers, async (number, index) => { - await sleep(12 - index); + // await sleep(12 - index); indices.push(index); }); expect(indices).to.eql(numbers.map((number) => number - 1)); diff --git a/src/mapParallel.test.ts b/test/mapParallel.test.ts similarity index 89% rename from src/mapParallel.test.ts rename to test/mapParallel.test.ts index 14246c1..013a7cd 100644 --- a/src/mapParallel.test.ts +++ b/test/mapParallel.test.ts @@ -1,5 +1,4 @@ -import mapParallel from "./mapParallel"; -import { sleep } from "./utils/sleep"; +import { mapParallel } from "index"; import { describe, it, expect } from "vitest"; describe("mapParallel tests", () => { @@ -10,7 +9,7 @@ describe("mapParallel tests", () => { const doubledNumbers = await mapParallel( numbers, async (number) => { - await sleep(number); + // await sleep(number); return number * 2; }, 5 @@ -20,7 +19,7 @@ describe("mapParallel tests", () => { it("returns all values when not passed a maxParallelBatchSize", async () => { const doubledNumbers = await mapParallel(numbers, async (number) => { - await sleep(number); + // await sleep(number); return number * 2; }); expect(doubledNumbers).to.eql(expectedDoubledNumbers); @@ -30,7 +29,7 @@ describe("mapParallel tests", () => { const doubledNumbers = await mapParallel( numbers, async (number) => { - await sleep(number); + // await sleep(number); return number * 2; }, 20 @@ -55,7 +54,7 @@ describe("mapParallel tests", () => { await mapParallel( numbers, async (number) => { - await sleep(number * 100); // wait `number` deciseconds + // await sleep(number * 100); // wait `number` deciseconds return number; }, 10 diff --git a/src/reduce.test.ts b/test/reduce.test.ts similarity index 91% rename from src/reduce.test.ts rename to test/reduce.test.ts index 8ed7fc7..13098fc 100644 --- a/src/reduce.test.ts +++ b/test/reduce.test.ts @@ -1,7 +1,7 @@ -import reduce from "./reduce"; +import { reduce } from "index"; import { describe, it, expect } from "vitest"; -describe("asyncReduce tests", () => { +describe("reduce tests", () => { it("array of numbers", async () => { const numbers: number[] = [1, 2, 3, 4, 5]; const arrResult: number = numbers.reduce( diff --git a/test/reduceRight.test.ts b/test/reduceRight.test.ts new file mode 100644 index 0000000..6116668 --- /dev/null +++ b/test/reduceRight.test.ts @@ -0,0 +1,32 @@ +import { reduceRight } from "index"; +import { describe, it, expect } from "vitest"; + +describe("reduceRight tests", () => { + it("array of numbers", async () => { + const numbers: number[] = [1, 2, 3, 4, 5]; + const arrResult: number = numbers.reduceRight( + (prev, current) => prev + current, + 0 + ); + const asyncResult: number = await reduceRight( + numbers, + async (prev, current) => prev + current, + 0 + ); + expect(arrResult).toEqual(asyncResult); + }); + + it("array of strings", async () => { + const strings: string[] = ["a", "b", "c", "d", "e"]; + const arrResult: string = strings.reduceRight( + (prev, current) => prev + current, + "" + ); + const asyncResult: string = await reduceRight( + strings, + async (prev, current) => prev + current, + "" + ); + expect(arrResult).toEqual(asyncResult); + }); +}); diff --git a/src/some.test.ts b/test/some.test.ts similarity index 98% rename from src/some.test.ts rename to test/some.test.ts index c0269be..22f3e10 100644 --- a/src/some.test.ts +++ b/test/some.test.ts @@ -1,7 +1,7 @@ -import some from "./some"; +import { some } from "index"; import { describe, it, expect } from "vitest"; -describe("asyncSome tests", () => { +describe("some tests", () => { describe("truthy", () => { it("array of numbers", async () => { const numbers: number[] = [1, 2, 3, 4, 5]; diff --git a/tsconfig.json b/tsconfig.json index 17d4262..0f1692a 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,113 +1,20 @@ { "compilerOptions": { - /* Visit https://aka.ms/tsconfig to read more about this file */ - - /* Projects */ - // "incremental": true, /* Save .tsbuildinfo files to allow for incremental compilation of projects. */ - // "composite": true, /* Enable constraints that allow a TypeScript project to be used with project references. */ - // "tsBuildInfoFile": "./.tsbuildinfo", /* Specify the path to .tsbuildinfo incremental compilation file. */ - // "disableSourceOfProjectReferenceRedirect": true, /* Disable preferring source files instead of declaration files when referencing composite projects. */ - // "disableSolutionSearching": true, /* Opt a project out of multi-project reference checking when editing. */ - // "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */ - - /* Language and Environment */ - "target": "es2022" /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */, - // "lib": [], /* Specify a set of bundled library declaration files that describe the target runtime environment. */ - // "jsx": "preserve", /* Specify what JSX code is generated. */ - // "libReplacement": true, /* Enable lib replacement. */ - // "experimentalDecorators": true, /* Enable experimental support for legacy experimental decorators. */ - // "emitDecoratorMetadata": true, /* Emit design-type metadata for decorated declarations in source files. */ - // "jsxFactory": "", /* Specify the JSX factory function used when targeting React JSX emit, e.g. 'React.createElement' or 'h'. */ - // "jsxFragmentFactory": "", /* Specify the JSX Fragment reference used for fragments when targeting React JSX emit e.g. 'React.Fragment' or 'Fragment'. */ - // "jsxImportSource": "", /* Specify module specifier used to import the JSX factory functions when using 'jsx: react-jsx*'. */ - // "reactNamespace": "", /* Specify the object invoked for 'createElement'. This only applies when targeting 'react' JSX emit. */ - // "noLib": true, /* Disable including any library files, including the default lib.d.ts. */ - // "useDefineForClassFields": true, /* Emit ECMAScript-standard-compliant class fields. */ - // "moduleDetection": "auto", /* Control what method is used to detect module-format JS files. */ - - /* Modules */ - "module": "commonjs" /* Specify what module code is generated. */, - // "rootDir": "./", /* Specify the root folder within your source files. */ - // "moduleResolution": "node10", /* Specify how TypeScript looks up a file from a given module specifier. */ - // "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */ - // "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */ - // "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */ - // "typeRoots": [], /* Specify multiple folders that act like './node_modules/@types'. */ - // "types": [], /* Specify type package names to be included without being referenced in a source file. */ - // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */ - // "moduleSuffixes": [], /* List of file name suffixes to search when resolving a module. */ - // "allowImportingTsExtensions": true, /* Allow imports to include TypeScript file extensions. Requires '--moduleResolution bundler' and either '--noEmit' or '--emitDeclarationOnly' to be set. */ - // "rewriteRelativeImportExtensions": true, /* Rewrite '.ts', '.tsx', '.mts', and '.cts' file extensions in relative import paths to their JavaScript equivalent in output files. */ - // "resolvePackageJsonExports": true, /* Use the package.json 'exports' field when resolving package imports. */ - // "resolvePackageJsonImports": true, /* Use the package.json 'imports' field when resolving imports. */ - // "customConditions": [], /* Conditions to set in addition to the resolver-specific defaults when resolving imports. */ - // "noUncheckedSideEffectImports": true, /* Check side effect imports. */ - // "resolveJsonModule": true, /* Enable importing .json files. */ - // "allowArbitraryExtensions": true, /* Enable importing files with any extension, provided a declaration file is present. */ - // "noResolve": true, /* Disallow 'import's, 'require's or ''s from expanding the number of files TypeScript should add to a project. */ - - /* JavaScript Support */ - // "allowJs": true, /* Allow JavaScript files to be a part of your program. Use the 'checkJS' option to get errors from these files. */ - // "checkJs": true, /* Enable error reporting in type-checked JavaScript files. */ - // "maxNodeModuleJsDepth": 1, /* Specify the maximum folder depth used for checking JavaScript files from 'node_modules'. Only applicable with 'allowJs'. */ - - /* Emit */ - // "declaration": true, /* Generate .d.ts files from TypeScript and JavaScript files in your project. */ - // "declarationMap": true, /* Create sourcemaps for d.ts files. */ - // "emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */ - // "sourceMap": true, /* Create source map files for emitted JavaScript files. */ - // "inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */ - // "noEmit": true, /* Disable emitting files from a compilation. */ - // "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If 'declaration' is true, also designates a file that bundles all .d.ts output. */ - // "outDir": "./", /* Specify an output folder for all emitted files. */ - // "removeComments": true, /* Disable emitting comments. */ - // "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */ - // "downlevelIteration": true, /* Emit more compliant, but verbose and less performant JavaScript for iteration. */ - // "sourceRoot": "", /* Specify the root path for debuggers to find the reference source code. */ - // "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */ - // "inlineSources": true, /* Include source code in the sourcemaps inside the emitted JavaScript. */ - // "emitBOM": true, /* Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files. */ - // "newLine": "crlf", /* Set the newline character for emitting files. */ - // "stripInternal": true, /* Disable emitting declarations that have '@internal' in their JSDoc comments. */ - // "noEmitHelpers": true, /* Disable generating custom helper functions like '__extends' in compiled output. */ - // "noEmitOnError": true, /* Disable emitting files if any type checking errors are reported. */ - // "preserveConstEnums": true, /* Disable erasing 'const enum' declarations in generated code. */ - // "declarationDir": "./", /* Specify the output directory for generated declaration files. */ - - /* Interop Constraints */ - // "isolatedModules": true, /* Ensure that each file can be safely transpiled without relying on other imports. */ - // "verbatimModuleSyntax": true, /* Do not transform or elide any imports or exports not marked as type-only, ensuring they are written in the output file's format based on the 'module' setting. */ - // "isolatedDeclarations": true, /* Require sufficient annotation on exports so other tools can trivially generate declaration files. */ - // "erasableSyntaxOnly": true, /* Do not allow runtime constructs that are not part of ECMAScript. */ - // "allowSyntheticDefaultImports": true, /* Allow 'import x from y' when a module doesn't have a default export. */ - "esModuleInterop": true /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */, - // "preserveSymlinks": true, /* Disable resolving symlinks to their realpath. This correlates to the same flag in node. */ - "forceConsistentCasingInFileNames": true /* Ensure that casing is correct in imports. */, - - /* Type Checking */ - "strict": true /* Enable all strict type-checking options. */, - // "noImplicitAny": true, /* Enable error reporting for expressions and declarations with an implied 'any' type. */ - // "strictNullChecks": true, /* When type checking, take into account 'null' and 'undefined'. */ - // "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */ - // "strictBindCallApply": true, /* Check that the arguments for 'bind', 'call', and 'apply' methods match the original function. */ - // "strictPropertyInitialization": true, /* Check for class properties that are declared but not set in the constructor. */ - // "strictBuiltinIteratorReturn": true, /* Built-in iterators are instantiated with a 'TReturn' type of 'undefined' instead of 'any'. */ - // "noImplicitThis": true, /* Enable error reporting when 'this' is given the type 'any'. */ - // "useUnknownInCatchVariables": true, /* Default catch clause variables as 'unknown' instead of 'any'. */ - // "alwaysStrict": true, /* Ensure 'use strict' is always emitted. */ - // "noUnusedLocals": true, /* Enable error reporting when local variables aren't read. */ - // "noUnusedParameters": true, /* Raise an error when a function parameter isn't read. */ - // "exactOptionalPropertyTypes": true, /* Interpret optional property types as written, rather than adding 'undefined'. */ - // "noImplicitReturns": true, /* Enable error reporting for codepaths that do not explicitly return in a function. */ - // "noFallthroughCasesInSwitch": true, /* Enable error reporting for fallthrough cases in switch statements. */ - // "noUncheckedIndexedAccess": true, /* Add 'undefined' to a type when accessed using an index. */ - // "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an override modifier. */ - // "noPropertyAccessFromIndexSignature": true, /* Enforces using indexed accessors for keys declared using an indexed type. */ - // "allowUnusedLabels": true, /* Disable error reporting for unused labels. */ - // "allowUnreachableCode": true, /* Disable error reporting for unreachable code. */ - - /* Completeness */ - // "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */ - "skipLibCheck": true /* Skip type checking all .d.ts files. */ - } + "baseUrl": ".", + "paths": { + // "*": ["*"] + }, + "outDir": "dist", + "target": "ES2022", + "module": "NodeNext", + "moduleResolution": "nodenext", + "esModuleInterop": true, + "forceConsistentCasingInFileNames": true, + "allowJs": false, + "strict": true, + "skipLibCheck": true, + "declaration": true + }, + "include": ["**/*.ts"], + "exclude": ["./node_modules", "./dist"] } diff --git a/yarn.lock b/yarn.lock index 17f8622..212ee0c 100644 --- a/yarn.lock +++ b/yarn.lock @@ -501,6 +501,11 @@ tinyspy@^3.0.2: resolved "https://registry.yarnpkg.com/tinyspy/-/tinyspy-3.0.2.tgz#86dd3cf3d737b15adcf17d7887c84a75201df20a" integrity sha512-n1cw8k1k0x4pgA2+9XrOkFydTerNcJ1zWCO5Nn9scWHTD+5tp8dghT2x1uduQePZTZgd3Tupf+x9BxJjeJi77Q== +typescript@^5.8.2: + version "5.8.2" + resolved "https://registry.yarnpkg.com/typescript/-/typescript-5.8.2.tgz#8170b3702f74b79db2e5a96207c15e65807999e4" + integrity sha512-aJn6wq13/afZp/jT9QZmwEjDqqvSGp1VT5GVg+f/t6/oVyrgXM6BY1h9BRh/O5p3PlUPAe+WuiEZOmb/49RqoQ== + vite-node@3.0.8: version "3.0.8" resolved "https://registry.yarnpkg.com/vite-node/-/vite-node-3.0.8.tgz#69cd1e0b9c7c37a8e7ab3b87ce259cbbf9a7bd72" From 16fbc0a9e8d8bd6823becb0b69d8d48540f71dea Mon Sep 17 00:00:00 2001 From: Wesley Guthrie Date: Mon, 10 Mar 2025 13:17:31 -0500 Subject: [PATCH 06/13] added files for more iteration functions --- index.ts | 5 +++++ src/findIndex.ts | 3 +++ src/findLast.ts | 3 +++ src/findLastIndex.ts | 3 +++ src/indexOf.ts | 3 +++ src/lastIndexOf.ts | 3 +++ 6 files changed, 20 insertions(+) diff --git a/index.ts b/index.ts index d7b0b4c..7f40bfb 100644 --- a/index.ts +++ b/index.ts @@ -1,6 +1,11 @@ export { default as every } from "./src/every"; export { default as filter } from "./src/filter"; export { default as find } from "./src/find"; +export { default as findIndex } from "./src/findIndex"; +export { default as findLast } from "./src/findLast"; +export { default as findLastIndex } from "./src/findLastIndex"; +export { default as indexOf } from "./src/indexOf"; +export { default as lastIndexOf } from "./src/lastIndexOf"; export { default as map } from "./src/map"; export { default as mapParallel } from "./src/mapParallel"; export { default as reduce } from "./src/reduce"; diff --git a/src/findIndex.ts b/src/findIndex.ts index e69de29..d2dfa0b 100644 --- a/src/findIndex.ts +++ b/src/findIndex.ts @@ -0,0 +1,3 @@ +export default async function findIndex(): Promise { + throw new Error("Not implemented"); +} diff --git a/src/findLast.ts b/src/findLast.ts index e69de29..06c68fa 100644 --- a/src/findLast.ts +++ b/src/findLast.ts @@ -0,0 +1,3 @@ +export default async function findLast(): Promise { + throw new Error("Not implemented"); +} diff --git a/src/findLastIndex.ts b/src/findLastIndex.ts index e69de29..2010bc5 100644 --- a/src/findLastIndex.ts +++ b/src/findLastIndex.ts @@ -0,0 +1,3 @@ +export default async function findLastIndex(): Promise { + throw new Error("Not implemented"); +} diff --git a/src/indexOf.ts b/src/indexOf.ts index e69de29..b971e33 100644 --- a/src/indexOf.ts +++ b/src/indexOf.ts @@ -0,0 +1,3 @@ +export default async function indexOf(): Promise { + throw new Error("Not implemented"); +} diff --git a/src/lastIndexOf.ts b/src/lastIndexOf.ts index e69de29..3ac0d0e 100644 --- a/src/lastIndexOf.ts +++ b/src/lastIndexOf.ts @@ -0,0 +1,3 @@ +export default async function lastIndexOf(): Promise { + throw new Error("Not implemented"); +} From 8d4d4fe5a9fccf336744fad8330bd6e1db356857 Mon Sep 17 00:00:00 2001 From: Wesley Guthrie Date: Mon, 10 Mar 2025 15:39:58 -0500 Subject: [PATCH 07/13] start adding linter --- dist/index.d.ts | 11 + dist/index.js | 28 ++ dist/src/every.d.ts | 1 + dist/src/every.js | 15 + dist/src/filter.d.ts | 1 + dist/src/filter.js | 17 + dist/src/find.d.ts | 1 + dist/src/find.js | 15 + dist/src/findIndex.d.ts | 1 + dist/src/findIndex.js | 15 + dist/src/findLast.d.ts | 1 + dist/src/findLast.js | 15 + dist/src/findLastIndex.d.ts | 1 + dist/src/findLastIndex.js | 15 + dist/src/map.d.ts | 1 + dist/src/map.js | 13 + dist/src/mapParallel.d.ts | 7 + dist/src/mapParallel.js | 49 +++ dist/src/reduce.d.ts | 1 + dist/src/reduce.js | 13 + dist/src/reduceRight.d.ts | 1 + dist/src/reduceRight.js | 12 + dist/src/some.d.ts | 1 + dist/src/some.js | 15 + index.ts | 2 - package.json | 5 +- src/every.ts | 7 +- src/filter.ts | 10 +- src/find.ts | 7 +- src/findIndex.ts | 17 +- src/findLast.ts | 17 +- src/findLastIndex.ts | 17 +- src/indexOf.ts | 3 - src/lastIndexOf.ts | 3 - src/map.ts | 10 +- src/reduce.ts | 5 +- src/reduceRight.ts | 4 +- src/some.ts | 7 +- test/findIndex.test.ts | 12 + test/findLast.test.ts | 12 + test/findLastIndex.test.ts | 12 + test/indexOf.test.ts | 0 test/lastIndexOf.test.ts | 0 tsconfig.json | 3 - yarn.lock | 676 +++++++++++++++++++++++++++++++++--- 45 files changed, 994 insertions(+), 85 deletions(-) create mode 100644 dist/index.d.ts create mode 100644 dist/index.js create mode 100644 dist/src/every.d.ts create mode 100644 dist/src/every.js create mode 100644 dist/src/filter.d.ts create mode 100644 dist/src/filter.js create mode 100644 dist/src/find.d.ts create mode 100644 dist/src/find.js create mode 100644 dist/src/findIndex.d.ts create mode 100644 dist/src/findIndex.js create mode 100644 dist/src/findLast.d.ts create mode 100644 dist/src/findLast.js create mode 100644 dist/src/findLastIndex.d.ts create mode 100644 dist/src/findLastIndex.js create mode 100644 dist/src/map.d.ts create mode 100644 dist/src/map.js create mode 100644 dist/src/mapParallel.d.ts create mode 100644 dist/src/mapParallel.js create mode 100644 dist/src/reduce.d.ts create mode 100644 dist/src/reduce.js create mode 100644 dist/src/reduceRight.d.ts create mode 100644 dist/src/reduceRight.js create mode 100644 dist/src/some.d.ts create mode 100644 dist/src/some.js delete mode 100644 src/indexOf.ts delete mode 100644 src/lastIndexOf.ts delete mode 100644 test/indexOf.test.ts delete mode 100644 test/lastIndexOf.test.ts diff --git a/dist/index.d.ts b/dist/index.d.ts new file mode 100644 index 0000000..6bc0fe0 --- /dev/null +++ b/dist/index.d.ts @@ -0,0 +1,11 @@ +export { default as every } from "./src/every"; +export { default as filter } from "./src/filter"; +export { default as find } from "./src/find"; +export { default as findIndex } from "./src/findIndex"; +export { default as findLast } from "./src/findLast"; +export { default as findLastIndex } from "./src/findLastIndex"; +export { default as map } from "./src/map"; +export { default as mapParallel } from "./src/mapParallel"; +export { default as reduce } from "./src/reduce"; +export { default as reduceRight } from "./src/reduceRight"; +export { default as some } from "./src/some"; diff --git a/dist/index.js b/dist/index.js new file mode 100644 index 0000000..dabd156 --- /dev/null +++ b/dist/index.js @@ -0,0 +1,28 @@ +"use strict"; +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.some = exports.reduceRight = exports.reduce = exports.mapParallel = exports.map = exports.findLastIndex = exports.findLast = exports.findIndex = exports.find = exports.filter = exports.every = void 0; +var every_1 = require("./src/every"); +Object.defineProperty(exports, "every", { enumerable: true, get: function () { return __importDefault(every_1).default; } }); +var filter_1 = require("./src/filter"); +Object.defineProperty(exports, "filter", { enumerable: true, get: function () { return __importDefault(filter_1).default; } }); +var find_1 = require("./src/find"); +Object.defineProperty(exports, "find", { enumerable: true, get: function () { return __importDefault(find_1).default; } }); +var findIndex_1 = require("./src/findIndex"); +Object.defineProperty(exports, "findIndex", { enumerable: true, get: function () { return __importDefault(findIndex_1).default; } }); +var findLast_1 = require("./src/findLast"); +Object.defineProperty(exports, "findLast", { enumerable: true, get: function () { return __importDefault(findLast_1).default; } }); +var findLastIndex_1 = require("./src/findLastIndex"); +Object.defineProperty(exports, "findLastIndex", { enumerable: true, get: function () { return __importDefault(findLastIndex_1).default; } }); +var map_1 = require("./src/map"); +Object.defineProperty(exports, "map", { enumerable: true, get: function () { return __importDefault(map_1).default; } }); +var mapParallel_1 = require("./src/mapParallel"); +Object.defineProperty(exports, "mapParallel", { enumerable: true, get: function () { return __importDefault(mapParallel_1).default; } }); +var reduce_1 = require("./src/reduce"); +Object.defineProperty(exports, "reduce", { enumerable: true, get: function () { return __importDefault(reduce_1).default; } }); +var reduceRight_1 = require("./src/reduceRight"); +Object.defineProperty(exports, "reduceRight", { enumerable: true, get: function () { return __importDefault(reduceRight_1).default; } }); +var some_1 = require("./src/some"); +Object.defineProperty(exports, "some", { enumerable: true, get: function () { return __importDefault(some_1).default; } }); diff --git a/dist/src/every.d.ts b/dist/src/every.d.ts new file mode 100644 index 0000000..ecfa851 --- /dev/null +++ b/dist/src/every.d.ts @@ -0,0 +1 @@ +export default function every(array: T[], iterator: (value: T, index: number) => Promise): Promise; diff --git a/dist/src/every.js b/dist/src/every.js new file mode 100644 index 0000000..c7485cb --- /dev/null +++ b/dist/src/every.js @@ -0,0 +1,15 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.default = every; +async function every(array, iterator) { + if (!Array.isArray(array) || !array?.length) + return false; + for (let index = 0; index < array.length; index++) { + const element = array.at(index); + const result = await iterator(element, index); + if (!result) { + return false; + } + } + return true; +} diff --git a/dist/src/filter.d.ts b/dist/src/filter.d.ts new file mode 100644 index 0000000..98b2eaf --- /dev/null +++ b/dist/src/filter.d.ts @@ -0,0 +1 @@ +export default function filter(array: T[], iterator: (value: T, index: number) => Promise): Promise; diff --git a/dist/src/filter.js b/dist/src/filter.js new file mode 100644 index 0000000..4fabf23 --- /dev/null +++ b/dist/src/filter.js @@ -0,0 +1,17 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.default = filter; +async function filter(array, iterator) { + if (!Array.isArray(array) || !array?.length) + return []; + const thing = 1; + const results = []; + for (let index = 0; index < array.length; index++) { + const element = array.at(index); + const result = await iterator(element, index); + if (result) { + results.push(element); + } + } + return results; +} diff --git a/dist/src/find.d.ts b/dist/src/find.d.ts new file mode 100644 index 0000000..e3a6985 --- /dev/null +++ b/dist/src/find.d.ts @@ -0,0 +1 @@ +export default function find(array: T[], iterator: (value: T, index: number) => Promise): Promise; diff --git a/dist/src/find.js b/dist/src/find.js new file mode 100644 index 0000000..dbd9614 --- /dev/null +++ b/dist/src/find.js @@ -0,0 +1,15 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.default = find; +async function find(array, iterator) { + if (!Array.isArray(array) || !array?.length) + return undefined; + for (let index = 0; index < array.length; index++) { + const element = array[index]; + const result = await iterator(element, index); + if (result) { + return element; + } + } + return undefined; +} diff --git a/dist/src/findIndex.d.ts b/dist/src/findIndex.d.ts new file mode 100644 index 0000000..d431c37 --- /dev/null +++ b/dist/src/findIndex.d.ts @@ -0,0 +1 @@ +export default function findIndex(array: T[], iterator: (value: T, index: number) => Promise): Promise; diff --git a/dist/src/findIndex.js b/dist/src/findIndex.js new file mode 100644 index 0000000..6a3ce9c --- /dev/null +++ b/dist/src/findIndex.js @@ -0,0 +1,15 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.default = findIndex; +async function findIndex(array, iterator) { + if (!Array.isArray(array) || !array?.length) + return -1; + for (let index = 0; index < array.length; index++) { + const element = array.at(index); + const result = await iterator(element, index); + if (result) { + return index; + } + } + return -1; +} diff --git a/dist/src/findLast.d.ts b/dist/src/findLast.d.ts new file mode 100644 index 0000000..056de06 --- /dev/null +++ b/dist/src/findLast.d.ts @@ -0,0 +1 @@ +export default function findLast(array: T[], iterator: (value: T, index: number) => Promise): Promise; diff --git a/dist/src/findLast.js b/dist/src/findLast.js new file mode 100644 index 0000000..d8f9fcc --- /dev/null +++ b/dist/src/findLast.js @@ -0,0 +1,15 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.default = findLast; +async function findLast(array, iterator) { + if (!Array.isArray(array) || !array?.length) + return undefined; + for (let index = array.length; index >= 0; index--) { + const element = array.at(index); + const result = await iterator(element, index); + if (result) { + return element; + } + } + return undefined; +} diff --git a/dist/src/findLastIndex.d.ts b/dist/src/findLastIndex.d.ts new file mode 100644 index 0000000..cc8b9f3 --- /dev/null +++ b/dist/src/findLastIndex.d.ts @@ -0,0 +1 @@ +export default function findLastIndex(array: T[], iterator: (value: T, index: number) => Promise): Promise; diff --git a/dist/src/findLastIndex.js b/dist/src/findLastIndex.js new file mode 100644 index 0000000..bd7e400 --- /dev/null +++ b/dist/src/findLastIndex.js @@ -0,0 +1,15 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.default = findLastIndex; +async function findLastIndex(array, iterator) { + if (!Array.isArray(array) || !array?.length) + return -1; + for (let index = array.length; index >= 0; index--) { + const element = array[index]; + const result = await iterator(element, index); + if (result) { + return index; + } + } + return -1; +} diff --git a/dist/src/map.d.ts b/dist/src/map.d.ts new file mode 100644 index 0000000..212ceb7 --- /dev/null +++ b/dist/src/map.d.ts @@ -0,0 +1 @@ +export default function map(array: T[], iterator: (value: T, index: number) => Promise): Promise; diff --git a/dist/src/map.js b/dist/src/map.js new file mode 100644 index 0000000..5e5430c --- /dev/null +++ b/dist/src/map.js @@ -0,0 +1,13 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.default = map; +async function map(array, iterator) { + if (!Array.isArray(array) || !array?.length) + return []; + const results = []; + for (let index = 0; index < array.length; index++) { + const element = array[index]; + results.push(await iterator(element, index)); + } + return results; +} diff --git a/dist/src/mapParallel.d.ts b/dist/src/mapParallel.d.ts new file mode 100644 index 0000000..45608eb --- /dev/null +++ b/dist/src/mapParallel.d.ts @@ -0,0 +1,7 @@ +/** + * iterate over the passed in array in parallel, running the iterator on each element. + * @param {T[]} array + * @param {(val: T, index?: number) => Promise} iterator + * @param {number} [maxParallelBatchSize] + */ +export default function mapParallel(array: T[], iterator: (value: T, index: number) => Promise, maxParallelBatchSize?: number): Promise; diff --git a/dist/src/mapParallel.js b/dist/src/mapParallel.js new file mode 100644 index 0000000..452b58e --- /dev/null +++ b/dist/src/mapParallel.js @@ -0,0 +1,49 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.default = mapParallel; +/** + * take and complete tasks from a queue until that queue is empty. + * @param {{ task: T; index: number }[]} array + * @param {(val: T, index?: number) => Promise} iterator + */ +async function takeAndCompleteFromQueueUntilDone(array, iterator) { + const item = array.shift(); + if (!item) { + return []; + } + const completedTask = await iterator(item.task, item.index); + const followingCompletedTasks = await takeAndCompleteFromQueueUntilDone(array, iterator); + return followingCompletedTasks.concat({ + result: completedTask, + index: item.index, + }); +} +/** + * iterate over the passed in array in parallel, running the iterator on each element. + * @param {T[]} array + * @param {(val: T, index?: number) => Promise} iterator + * @param {number} [maxParallelBatchSize] + */ +async function mapParallel(array, iterator, maxParallelBatchSize) { + if (!Array.isArray(array) || !array?.length) + return []; + const arrayWithIndexKeys = array.map((item, i) => { + return { + task: item, + index: i, + }; + }); + let effectiveMaxBatchSize = maxParallelBatchSize; + if (!effectiveMaxBatchSize || effectiveMaxBatchSize > array.length) { + effectiveMaxBatchSize = array.length; + } + const coolEmptyArray = Array(effectiveMaxBatchSize).fill(undefined); + let results = []; + await Promise.all(coolEmptyArray.map(async () => { + const resultsWithIndex = await takeAndCompleteFromQueueUntilDone(arrayWithIndexKeys, iterator); + resultsWithIndex.forEach((result) => { + results[result.index] = result.result; + }); + })); + return results; +} diff --git a/dist/src/reduce.d.ts b/dist/src/reduce.d.ts new file mode 100644 index 0000000..fbfac32 --- /dev/null +++ b/dist/src/reduce.d.ts @@ -0,0 +1 @@ +export default function reduce(array: T[], iterator: (accumulator: V, currentValue: T) => Promise, initialValue: V): Promise; diff --git a/dist/src/reduce.js b/dist/src/reduce.js new file mode 100644 index 0000000..497f576 --- /dev/null +++ b/dist/src/reduce.js @@ -0,0 +1,13 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.default = reduce; +async function reduce(array, iterator, initialValue) { + if (!Array.isArray(array) || !array?.length) + return initialValue; + let result = initialValue; + for (let index = 0; index < array.length; index++) { + const element = array[index]; + result = await iterator(result, element); + } + return result; +} diff --git a/dist/src/reduceRight.d.ts b/dist/src/reduceRight.d.ts new file mode 100644 index 0000000..3c94cae --- /dev/null +++ b/dist/src/reduceRight.d.ts @@ -0,0 +1 @@ +export default function reduceRight(array: T[], iterator: (accumulator: V, currentValue: T) => Promise, initialValue: V): Promise; diff --git a/dist/src/reduceRight.js b/dist/src/reduceRight.js new file mode 100644 index 0000000..7211e99 --- /dev/null +++ b/dist/src/reduceRight.js @@ -0,0 +1,12 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.default = reduceRight; +async function reduceRight(array, iterator, initialValue) { + if (!Array.isArray(array) || !array?.length) + return initialValue; + let result = initialValue; + for (let index = array.length - 1; index >= 0; index--) { + result = await iterator(result, array[index]); + } + return result; +} diff --git a/dist/src/some.d.ts b/dist/src/some.d.ts new file mode 100644 index 0000000..f65f67c --- /dev/null +++ b/dist/src/some.d.ts @@ -0,0 +1 @@ +export default function some(array: T[], iterator: (value: T, index: number) => Promise): Promise; diff --git a/dist/src/some.js b/dist/src/some.js new file mode 100644 index 0000000..acf7852 --- /dev/null +++ b/dist/src/some.js @@ -0,0 +1,15 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.default = some; +async function some(array, iterator) { + if (!Array.isArray(array) || !array?.length) + return false; + for (let index = 0; index < array.length; index++) { + const element = array[index]; + const result = await iterator(element, index); + if (result) { + return true; + } + } + return false; +} diff --git a/index.ts b/index.ts index 7f40bfb..6bc0fe0 100644 --- a/index.ts +++ b/index.ts @@ -4,8 +4,6 @@ export { default as find } from "./src/find"; export { default as findIndex } from "./src/findIndex"; export { default as findLast } from "./src/findLast"; export { default as findLastIndex } from "./src/findLastIndex"; -export { default as indexOf } from "./src/indexOf"; -export { default as lastIndexOf } from "./src/lastIndexOf"; export { default as map } from "./src/map"; export { default as mapParallel } from "./src/mapParallel"; export { default as reduce } from "./src/reduce"; diff --git a/package.json b/package.json index 6fc9dea..e230023 100644 --- a/package.json +++ b/package.json @@ -6,6 +6,7 @@ "description": "A TypeScript utility library for asynchronous array iteration.", "homepage": "https://github.com/GuthrieW/async-iterators", "repository": "GuthrieW/async-iterators", + "type": "commonjs", "files": [ "/dist" ], @@ -14,6 +15,7 @@ "scripts": { "build": "yarn clean && yarn tsc && rm -rf ./dist/test", "clean": "rm -rf ./dist", + "lint": "eslint", "test": "vitest" }, "keywords": [ @@ -25,9 +27,10 @@ "node": ">=18.0.0" }, "dependencies": { - "typescript": "^5.8.2" + "eslint": "8.0.0" }, "devDependencies": { + "typescript": "^5.8.2", "vitest": "^3.0.8" } } diff --git a/src/every.ts b/src/every.ts index 7d4915e..55e842f 100644 --- a/src/every.ts +++ b/src/every.ts @@ -4,12 +4,13 @@ export default async function every( ): Promise { if (!Array.isArray(array) || !array?.length) return false; - for (let i = 0; i < array.length; i++) { - const element = array.at(i) as T; - const result = await iterator(element, i); + for (let index = 0; index < array.length; index++) { + const element = array.at(index) as T; + const result = await iterator(element, index); if (!result) { return false; } } + return true; } diff --git a/src/filter.ts b/src/filter.ts index b9efff2..ab7d2c0 100644 --- a/src/filter.ts +++ b/src/filter.ts @@ -3,10 +3,14 @@ export default async function filter( iterator: (value: T, index: number) => Promise ): Promise { if (!Array.isArray(array) || !array?.length) return []; + const results: T[] = []; - for (let i = 0; i < array.length; i++) { - const result = await iterator(array[i], i); - if (result) results.push(array[i]); + for (let index = 0; index < array.length; index++) { + const element = array.at(index) as T; + const result = await iterator(element, index); + if (result) { + results.push(element); + } } return results; } diff --git a/src/find.ts b/src/find.ts index 36b0c13..fc84500 100644 --- a/src/find.ts +++ b/src/find.ts @@ -3,9 +3,10 @@ export default async function find( iterator: (value: T, index: number) => Promise ): Promise { if (!Array.isArray(array) || !array?.length) return undefined; - for (let i = 0; i < array.length; i++) { - const element = array.at(i) as T; - const result = await iterator(element, i); + + for (let index = 0; index < array.length; index++) { + const element = array[index]; + const result = await iterator(element, index); if (result) { return element; } diff --git a/src/findIndex.ts b/src/findIndex.ts index d2dfa0b..7fbd0e2 100644 --- a/src/findIndex.ts +++ b/src/findIndex.ts @@ -1,3 +1,16 @@ -export default async function findIndex(): Promise { - throw new Error("Not implemented"); +export default async function findIndex( + array: T[], + iterator: (value: T, index: number) => Promise +): Promise { + if (!Array.isArray(array) || !array?.length) return -1; + + for (let index = 0; index < array.length; index++) { + const element = array.at(index) as T; + const result = await iterator(element, index); + if (result) { + return index; + } + } + + return -1; } diff --git a/src/findLast.ts b/src/findLast.ts index 06c68fa..a65fb94 100644 --- a/src/findLast.ts +++ b/src/findLast.ts @@ -1,3 +1,16 @@ -export default async function findLast(): Promise { - throw new Error("Not implemented"); +export default async function findLast( + array: T[], + iterator: (value: T, index: number) => Promise +): Promise { + if (!Array.isArray(array) || !array?.length) return undefined; + + for (let index = array.length; index >= 0; index--) { + const element = array.at(index) as T; + const result = await iterator(element, index); + if (result) { + return element; + } + } + + return undefined; } diff --git a/src/findLastIndex.ts b/src/findLastIndex.ts index 2010bc5..af7d190 100644 --- a/src/findLastIndex.ts +++ b/src/findLastIndex.ts @@ -1,3 +1,16 @@ -export default async function findLastIndex(): Promise { - throw new Error("Not implemented"); +export default async function findLastIndex( + array: T[], + iterator: (value: T, index: number) => Promise +): Promise { + if (!Array.isArray(array) || !array?.length) return -1; + + for (let index = array.length; index >= 0; index--) { + const element = array[index]; + const result = await iterator(element, index); + if (result) { + return index; + } + } + + return -1; } diff --git a/src/indexOf.ts b/src/indexOf.ts deleted file mode 100644 index b971e33..0000000 --- a/src/indexOf.ts +++ /dev/null @@ -1,3 +0,0 @@ -export default async function indexOf(): Promise { - throw new Error("Not implemented"); -} diff --git a/src/lastIndexOf.ts b/src/lastIndexOf.ts deleted file mode 100644 index 3ac0d0e..0000000 --- a/src/lastIndexOf.ts +++ /dev/null @@ -1,3 +0,0 @@ -export default async function lastIndexOf(): Promise { - throw new Error("Not implemented"); -} diff --git a/src/map.ts b/src/map.ts index 96119be..c52e570 100644 --- a/src/map.ts +++ b/src/map.ts @@ -1,14 +1,14 @@ export default async function map( array: T[], iterator: (value: T, index: number) => Promise -): Promise { - if (!Array.isArray(array) || !array?.length) return; +): Promise { + if (!Array.isArray(array) || !array?.length) return []; const results: V[] = []; - for (let i = 0; i < array.length; i++) { - const element = array[i]; + for (let index = 0; index < array.length; index++) { + const element = array[index]; - results.push(await iterator(element, i)); + results.push(await iterator(element, index)); } return results; } diff --git a/src/reduce.ts b/src/reduce.ts index 15bdc4a..98c47bc 100644 --- a/src/reduce.ts +++ b/src/reduce.ts @@ -6,8 +6,9 @@ export default async function reduce( if (!Array.isArray(array) || !array?.length) return initialValue; let result = initialValue; - for (let i = 0; i < array.length; i++) { - result = await iterator(result, array.at(i) as T); + for (let index = 0; index < array.length; index++) { + const element = array[index]; + result = await iterator(result, element); } return result; diff --git a/src/reduceRight.ts b/src/reduceRight.ts index b9f3fd2..9c59292 100644 --- a/src/reduceRight.ts +++ b/src/reduceRight.ts @@ -6,8 +6,8 @@ export default async function reduceRight( if (!Array.isArray(array) || !array?.length) return initialValue; let result = initialValue; - for (let i = array.length; i >= 0; i--) { - result = await iterator(result, array.at(i) as T); + for (let index = array.length - 1; index >= 0; index--) { + result = await iterator(result, array[index]); } return result; diff --git a/src/some.ts b/src/some.ts index 9a15c99..a94839c 100644 --- a/src/some.ts +++ b/src/some.ts @@ -3,9 +3,10 @@ export default async function some( iterator: (value: T, index: number) => Promise ): Promise { if (!Array.isArray(array) || !array?.length) return false; - for (let i = 0; i < array.length; i++) { - const element = array.at(i) as T; - const result = await iterator(element, i); + + for (let index = 0; index < array.length; index++) { + const element = array[index]; + const result = await iterator(element, index); if (result) { return true; } diff --git a/test/findIndex.test.ts b/test/findIndex.test.ts index e69de29..f6f7c4e 100644 --- a/test/findIndex.test.ts +++ b/test/findIndex.test.ts @@ -0,0 +1,12 @@ +import { findIndex } from "index"; +import { describe, it, expect } from "vitest"; + +describe("findIndex tests", () => { + describe("truthy", () => { + it("", async () => {}); + }); + + describe("falsy", () => { + it("", async () => {}); + }); +}); diff --git a/test/findLast.test.ts b/test/findLast.test.ts index e69de29..01b4958 100644 --- a/test/findLast.test.ts +++ b/test/findLast.test.ts @@ -0,0 +1,12 @@ +import { findLast } from "index"; +import { describe, it, expect } from "vitest"; + +describe("findLast tests", () => { + describe("truthy", () => { + it("", async () => {}); + }); + + describe("falsy", () => { + it("", async () => {}); + }); +}); diff --git a/test/findLastIndex.test.ts b/test/findLastIndex.test.ts index e69de29..50b2e14 100644 --- a/test/findLastIndex.test.ts +++ b/test/findLastIndex.test.ts @@ -0,0 +1,12 @@ +import { findLastIndex } from "index"; +import { describe, it, expect } from "vitest"; + +describe("findLastIndex tests", () => { + describe("truthy", () => { + it("", async () => {}); + }); + + describe("falsy", () => { + it("", async () => {}); + }); +}); diff --git a/test/indexOf.test.ts b/test/indexOf.test.ts deleted file mode 100644 index e69de29..0000000 diff --git a/test/lastIndexOf.test.ts b/test/lastIndexOf.test.ts deleted file mode 100644 index e69de29..0000000 diff --git a/tsconfig.json b/tsconfig.json index 0f1692a..e1173bf 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,9 +1,6 @@ { "compilerOptions": { "baseUrl": ".", - "paths": { - // "*": ["*"] - }, "outDir": "dist", "target": "ES2022", "module": "NodeNext", diff --git a/yarn.lock b/yarn.lock index 212ee0c..1c15a7e 100644 --- a/yarn.lock +++ b/yarn.lock @@ -29,7 +29,7 @@ "@esbuild/darwin-x64@0.25.0": version "0.25.0" - resolved "https://registry.yarnpkg.com/@esbuild/darwin-x64/-/darwin-x64-0.25.0.tgz#91979d98d30ba6e7d69b22c617cc82bdad60e47a" + resolved "https://registry.npmjs.org/@esbuild/darwin-x64/-/darwin-x64-0.25.0.tgz" integrity sha512-DgDaYsPWFTS4S3nWpFcMn/33ZZwAAeAFKNHNa1QN0rI4pUjgqf0f7ONmXf6d22tqTY+H9FNdgeaAa+YIFUn2Rg== "@esbuild/freebsd-arm64@0.25.0": @@ -127,9 +127,38 @@ resolved "https://registry.yarnpkg.com/@esbuild/win32-x64/-/win32-x64-0.25.0.tgz#c8e119a30a7c8d60b9d2e22d2073722dde3b710b" integrity sha512-ZENoHJBxA20C2zFzh6AI4fT6RraMzjYw4xKWemRTRmRVtN9c5DcH9r/f2ihEkMjOW5eGgrwCslG/+Y/3bL+DHQ== +"@eslint/eslintrc@^1.0.2": + version "1.4.1" + resolved "https://registry.yarnpkg.com/@eslint/eslintrc/-/eslintrc-1.4.1.tgz#af58772019a2d271b7e2d4c23ff4ddcba3ccfb3e" + integrity sha512-XXrH9Uarn0stsyldqDYq8r++mROmWRI1xKMXa640Bb//SY1+ECYX6VzT6Lcx5frD0V30XieqJ0oX9I2Xj5aoMA== + dependencies: + ajv "^6.12.4" + debug "^4.3.2" + espree "^9.4.0" + globals "^13.19.0" + ignore "^5.2.0" + import-fresh "^3.2.1" + js-yaml "^4.1.0" + minimatch "^3.1.2" + strip-json-comments "^3.1.1" + +"@humanwhocodes/config-array@^0.6.0": + version "0.6.0" + resolved "https://registry.yarnpkg.com/@humanwhocodes/config-array/-/config-array-0.6.0.tgz#b5621fdb3b32309d2d16575456cbc277fa8f021a" + integrity sha512-JQlEKbcgEUjBFhLIF4iqM7u/9lwgHRBcpHrmUNCALK0Q3amXN6lxdoXLnF0sm11E9VqTmBALR87IlUg1bZ8A9A== + dependencies: + "@humanwhocodes/object-schema" "^1.2.0" + debug "^4.1.1" + minimatch "^3.0.4" + +"@humanwhocodes/object-schema@^1.2.0": + version "1.2.1" + resolved "https://registry.yarnpkg.com/@humanwhocodes/object-schema/-/object-schema-1.2.1.tgz#b520529ec21d8e5945a1851dfd1c32e94e39ff45" + integrity sha512-ZnQMnLV4e7hDlUvw8H+U8ASL02SS2Gn6+9Ac3wGGLIe7+je2AeAOxPY+izIPJDfFDb7eDjev0Us8MO1iFRN8hA== + "@jridgewell/sourcemap-codec@^1.5.0": version "1.5.0" - resolved "https://registry.yarnpkg.com/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.5.0.tgz#3188bcb273a414b0d215fd22a58540b989b9409a" + resolved "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.5.0.tgz" integrity sha512-gv3ZRaISU3fjPAgNsriBRqGWQL6quFx04YMPW/zD8XMLsU32mhCCbfbO6KZFLjvYpCZ8zyDEgqsgf+PwPaM7GQ== "@rollup/rollup-android-arm-eabi@4.35.0": @@ -149,7 +178,7 @@ "@rollup/rollup-darwin-x64@4.35.0": version "4.35.0" - resolved "https://registry.yarnpkg.com/@rollup/rollup-darwin-x64/-/rollup-darwin-x64-4.35.0.tgz#25b74ce2d8d3f9ea8e119b01384d44a1c0a0d3ae" + resolved "https://registry.npmjs.org/@rollup/rollup-darwin-x64/-/rollup-darwin-x64-4.35.0.tgz" integrity sha512-3IrHjfAS6Vkp+5bISNQnPogRAW5GAV1n+bNCrDwXmfMHbPl5EhTmWtfmwlJxFRUCBZ+tZ/OxDyU08aF6NI/N5Q== "@rollup/rollup-freebsd-arm64@4.35.0": @@ -229,12 +258,12 @@ "@types/estree@1.0.6", "@types/estree@^1.0.0": version "1.0.6" - resolved "https://registry.yarnpkg.com/@types/estree/-/estree-1.0.6.tgz#628effeeae2064a1b4e79f78e81d87b7e5fc7b50" + resolved "https://registry.npmjs.org/@types/estree/-/estree-1.0.6.tgz" integrity sha512-AYnb1nQyY49te+VRAVgmzfcgjYS91mY5P0TKUDCLEM+gNnA+3T6rWITXRLYCpahpqSQbN5cE+gHpnPyXjHWxcw== "@vitest/expect@3.0.8": version "3.0.8" - resolved "https://registry.yarnpkg.com/@vitest/expect/-/expect-3.0.8.tgz#53c408180d6476c7363eb976dcaae8e7b1f1a078" + resolved "https://registry.npmjs.org/@vitest/expect/-/expect-3.0.8.tgz" integrity sha512-Xu6TTIavTvSSS6LZaA3EebWFr6tsoXPetOWNMOlc7LO88QVVBwq2oQWBoDiLCN6YTvNYsGSjqOO8CAdjom5DCQ== dependencies: "@vitest/spy" "3.0.8" @@ -244,7 +273,7 @@ "@vitest/mocker@3.0.8": version "3.0.8" - resolved "https://registry.yarnpkg.com/@vitest/mocker/-/mocker-3.0.8.tgz#01638859e7dd422a8aaf04ef63dca9e1bbb9838d" + resolved "https://registry.npmjs.org/@vitest/mocker/-/mocker-3.0.8.tgz" integrity sha512-n3LjS7fcW1BCoF+zWZxG7/5XvuYH+lsFg+BDwwAz0arIwHQJFUEsKBQ0BLU49fCxuM/2HSeBPHQD8WjgrxMfow== dependencies: "@vitest/spy" "3.0.8" @@ -253,14 +282,14 @@ "@vitest/pretty-format@3.0.8", "@vitest/pretty-format@^3.0.8": version "3.0.8" - resolved "https://registry.yarnpkg.com/@vitest/pretty-format/-/pretty-format-3.0.8.tgz#89f6111d141142689871f5a4e62ad679bb6b6357" + resolved "https://registry.npmjs.org/@vitest/pretty-format/-/pretty-format-3.0.8.tgz" integrity sha512-BNqwbEyitFhzYMYHUVbIvepOyeQOSFA/NeJMIP9enMntkkxLgOcgABH6fjyXG85ipTgvero6noreavGIqfJcIg== dependencies: tinyrainbow "^2.0.0" "@vitest/runner@3.0.8": version "3.0.8" - resolved "https://registry.yarnpkg.com/@vitest/runner/-/runner-3.0.8.tgz#dda7223c25a89a829a29c3f0c037a99e028a9c64" + resolved "https://registry.npmjs.org/@vitest/runner/-/runner-3.0.8.tgz" integrity sha512-c7UUw6gEcOzI8fih+uaAXS5DwjlBaCJUo7KJ4VvJcjL95+DSR1kova2hFuRt3w41KZEFcOEiq098KkyrjXeM5w== dependencies: "@vitest/utils" "3.0.8" @@ -268,7 +297,7 @@ "@vitest/snapshot@3.0.8": version "3.0.8" - resolved "https://registry.yarnpkg.com/@vitest/snapshot/-/snapshot-3.0.8.tgz#b65d738c00ff052a323125ad7dfb001927049c78" + resolved "https://registry.npmjs.org/@vitest/snapshot/-/snapshot-3.0.8.tgz" integrity sha512-x8IlMGSEMugakInj44nUrLSILh/zy1f2/BgH0UeHpNyOocG18M9CWVIFBaXPt8TrqVZWmcPjwfG/ht5tnpba8A== dependencies: "@vitest/pretty-format" "3.0.8" @@ -277,33 +306,93 @@ "@vitest/spy@3.0.8": version "3.0.8" - resolved "https://registry.yarnpkg.com/@vitest/spy/-/spy-3.0.8.tgz#2a31ce28858aae50286644d64f886c72d55ae2ce" + resolved "https://registry.npmjs.org/@vitest/spy/-/spy-3.0.8.tgz" integrity sha512-MR+PzJa+22vFKYb934CejhR4BeRpMSoxkvNoDit68GQxRLSf11aT6CTj3XaqUU9rxgWJFnqicN/wxw6yBRkI1Q== dependencies: tinyspy "^3.0.2" "@vitest/utils@3.0.8": version "3.0.8" - resolved "https://registry.yarnpkg.com/@vitest/utils/-/utils-3.0.8.tgz#289277fbd8e733dff69cfa993c34665415c9b66b" + resolved "https://registry.npmjs.org/@vitest/utils/-/utils-3.0.8.tgz" integrity sha512-nkBC3aEhfX2PdtQI/QwAWp8qZWwzASsU4Npbcd5RdMPBSSLCpkZp52P3xku3s3uA0HIEhGvEcF8rNkBsz9dQ4Q== dependencies: "@vitest/pretty-format" "3.0.8" loupe "^3.1.3" tinyrainbow "^2.0.0" +acorn-jsx@^5.3.2: + version "5.3.2" + resolved "https://registry.npmjs.org/acorn-jsx/-/acorn-jsx-5.3.2.tgz" + integrity sha512-rq9s+JNhf0IChjtDXxllJ7g41oZk5SlXtp0LHwyA5cejwn7vKmKp4pPri6YEePv2PU65sAsegbXtIinmDFDXgQ== + +acorn@^8.9.0: + version "8.14.1" + resolved "https://registry.yarnpkg.com/acorn/-/acorn-8.14.1.tgz#721d5dc10f7d5b5609a891773d47731796935dfb" + integrity sha512-OvQ/2pUDKmgfCg++xsTX1wGxfTaszcHVcTctW4UJB4hibJx2HXxxO5UmVgyjMa+ZDsiaf5wWLXYpRWMmBI0QHg== + +ajv@^6.10.0, ajv@^6.12.4: + version "6.12.6" + resolved "https://registry.yarnpkg.com/ajv/-/ajv-6.12.6.tgz#baf5a62e802b07d977034586f8c3baf5adf26df4" + integrity sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g== + dependencies: + fast-deep-equal "^3.1.1" + fast-json-stable-stringify "^2.0.0" + json-schema-traverse "^0.4.1" + uri-js "^4.2.2" + +ansi-colors@^4.1.1: + version "4.1.3" + resolved "https://registry.yarnpkg.com/ansi-colors/-/ansi-colors-4.1.3.tgz#37611340eb2243e70cc604cad35d63270d48781b" + integrity sha512-/6w/C21Pm1A7aZitlI5Ni/2J6FFQN8i1Cvz3kHABAAbw93v/NlvKdVOqz7CCWz/3iv/JplRSEEZ83XION15ovw== + +ansi-regex@^5.0.1: + version "5.0.1" + resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-5.0.1.tgz#082cb2c89c9fe8659a311a53bd6a4dc5301db304" + integrity sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ== + +ansi-styles@^4.1.0: + version "4.3.0" + resolved "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz" + integrity sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg== + dependencies: + color-convert "^2.0.1" + +argparse@^2.0.1: + version "2.0.1" + resolved "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz" + integrity sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q== + assertion-error@^2.0.1: version "2.0.1" - resolved "https://registry.yarnpkg.com/assertion-error/-/assertion-error-2.0.1.tgz#f641a196b335690b1070bf00b6e7593fec190bf7" + resolved "https://registry.npmjs.org/assertion-error/-/assertion-error-2.0.1.tgz" integrity sha512-Izi8RQcffqCeNVgFigKli1ssklIbpHnCYc6AknXGYoB6grJqyeby7jv12JUQgmTAnIDnbck1uxksT4dzN3PWBA== +balanced-match@^1.0.0: + version "1.0.2" + resolved "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz" + integrity sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw== + +brace-expansion@^1.1.7: + version "1.1.11" + resolved "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz" + integrity sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA== + dependencies: + balanced-match "^1.0.0" + concat-map "0.0.1" + cac@^6.7.14: version "6.7.14" - resolved "https://registry.yarnpkg.com/cac/-/cac-6.7.14.tgz#804e1e6f506ee363cb0e3ccbb09cad5dd9870959" + resolved "https://registry.npmjs.org/cac/-/cac-6.7.14.tgz" integrity sha512-b6Ilus+c3RrdDk+JhLKUAQfzzgLEPy6wcXqS7f/xe1EETvsDP6GORG7SFuOs6cID5YkqchW/LXZbX5bc8j7ZcQ== +callsites@^3.0.0: + version "3.1.0" + resolved "https://registry.npmjs.org/callsites/-/callsites-3.1.0.tgz" + integrity sha512-P8BjAsXvZS+VIDUI11hHCQEv74YT67YUi5JJFNWIqL235sBmjX4+qx9Muvls5ivyNENctx46xQLQ3aTuE7ssaQ== + chai@^5.2.0: version "5.2.0" - resolved "https://registry.yarnpkg.com/chai/-/chai-5.2.0.tgz#1358ee106763624114addf84ab02697e411c9c05" + resolved "https://registry.npmjs.org/chai/-/chai-5.2.0.tgz" integrity sha512-mCuXncKXk5iCLhfhwTc0izo0gtEmpz5CtG2y8GiOINBlMVS6v8TMRc5TaLWKS6692m9+dVVfzgeVxR5UxWHTYw== dependencies: assertion-error "^2.0.1" @@ -312,31 +401,85 @@ chai@^5.2.0: loupe "^3.1.0" pathval "^2.0.0" +chalk@^4.0.0: + version "4.1.2" + resolved "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz" + integrity sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA== + dependencies: + ansi-styles "^4.1.0" + supports-color "^7.1.0" + check-error@^2.1.1: version "2.1.1" - resolved "https://registry.yarnpkg.com/check-error/-/check-error-2.1.1.tgz#87eb876ae71ee388fa0471fe423f494be1d96ccc" + resolved "https://registry.npmjs.org/check-error/-/check-error-2.1.1.tgz" integrity sha512-OAlb+T7V4Op9OwdkjmguYRqncdlx5JiofwOAUkmTF+jNdHwzTaTs4sRAGpzLF3oOz5xAyDGrPgeIDFQmDOTiJw== -debug@^4.4.0: +color-convert@^2.0.1: + version "2.0.1" + resolved "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz" + integrity sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ== + dependencies: + color-name "~1.1.4" + +color-name@~1.1.4: + version "1.1.4" + resolved "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz" + integrity sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA== + +concat-map@0.0.1: + version "0.0.1" + resolved "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz" + integrity sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg== + +cross-spawn@^7.0.2: + version "7.0.6" + resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-7.0.6.tgz#8a58fe78f00dcd70c370451759dfbfaf03e8ee9f" + integrity sha512-uV2QOWP2nWzsy2aMp8aRibhi9dlzF5Hgh5SHaB9OiTGEyDTiJJyx0uy51QXdyWbtAHNua4XJzUKca3OzKUd3vA== + dependencies: + path-key "^3.1.0" + shebang-command "^2.0.0" + which "^2.0.1" + +debug@^4.1.1, debug@^4.3.2, debug@^4.4.0: version "4.4.0" - resolved "https://registry.yarnpkg.com/debug/-/debug-4.4.0.tgz#2b3f2aea2ffeb776477460267377dc8710faba8a" + resolved "https://registry.npmjs.org/debug/-/debug-4.4.0.tgz" integrity sha512-6WTZ/IxCY/T6BALoZHaE4ctp9xm+Z5kY/pzYaCHRFeyVhojxlrm+46y68HA6hr0TcwEssoxNiDEUJQjfPZ/RYA== dependencies: ms "^2.1.3" deep-eql@^5.0.1: version "5.0.2" - resolved "https://registry.yarnpkg.com/deep-eql/-/deep-eql-5.0.2.tgz#4b756d8d770a9257300825d52a2c2cff99c3a341" + resolved "https://registry.npmjs.org/deep-eql/-/deep-eql-5.0.2.tgz" integrity sha512-h5k/5U50IJJFpzfL6nO9jaaumfjO/f2NjK/oYB2Djzm4p9L+3T9qWpZqZ2hAbLPuuYq9wrU08WQyBTL5GbPk5Q== +deep-is@^0.1.3: + version "0.1.4" + resolved "https://registry.npmjs.org/deep-is/-/deep-is-0.1.4.tgz" + integrity sha512-oIPzksmTg4/MriiaYGO+okXDT7ztn/w3Eptv/+gSIdMdKsJo0u4CfYNFJPy+4SKMuCqGw2wxnA+URMg3t8a/bQ== + +doctrine@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/doctrine/-/doctrine-3.0.0.tgz#addebead72a6574db783639dc87a121773973961" + integrity sha512-yS+Q5i3hBf7GBkd4KG8a7eBNNWNGLTaEwwYWUijIYM7zrlYDM0BFXHjjPWlWZ1Rg7UaddZeIDmi9jF3HmqiQ2w== + dependencies: + esutils "^2.0.2" + +enquirer@^2.3.5: + version "2.4.1" + resolved "https://registry.yarnpkg.com/enquirer/-/enquirer-2.4.1.tgz#93334b3fbd74fc7097b224ab4a8fb7e40bf4ae56" + integrity sha512-rRqJg/6gd538VHvR3PSrdRBb/1Vy2YfzHqzvbhGIQpDRKIa4FgV/54b5Q1xYSxOOwKvjXweS26E0Q+nAMwp2pQ== + dependencies: + ansi-colors "^4.1.1" + strip-ansi "^6.0.1" + es-module-lexer@^1.6.0: version "1.6.0" - resolved "https://registry.yarnpkg.com/es-module-lexer/-/es-module-lexer-1.6.0.tgz#da49f587fd9e68ee2404fe4e256c0c7d3a81be21" + resolved "https://registry.npmjs.org/es-module-lexer/-/es-module-lexer-1.6.0.tgz" integrity sha512-qqnD1yMU6tk/jnaMosogGySTZP8YtUgAffA9nMN+E/rjxcfRQ6IEk7IiozUjgxKoFHBGjTLnrHB/YC45r/59EQ== esbuild@^0.25.0: version "0.25.0" - resolved "https://registry.yarnpkg.com/esbuild/-/esbuild-0.25.0.tgz#0de1787a77206c5a79eeb634a623d39b5006ce92" + resolved "https://registry.npmjs.org/esbuild/-/esbuild-0.25.0.tgz" integrity sha512-BXq5mqc8ltbaN34cDqWuYKyNhX8D/Z0J1xdtdQ8UcIIIyJyz+ZMKUt58tF3SrZ85jcfN/PZYhjR5uDQAYNVbuw== optionalDependencies: "@esbuild/aix-ppc64" "0.25.0" @@ -365,72 +508,431 @@ esbuild@^0.25.0: "@esbuild/win32-ia32" "0.25.0" "@esbuild/win32-x64" "0.25.0" +escape-string-regexp@^4.0.0: + version "4.0.0" + resolved "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz" + integrity sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA== + +eslint-scope@^6.0.0: + version "6.0.0" + resolved "https://registry.yarnpkg.com/eslint-scope/-/eslint-scope-6.0.0.tgz#9cf45b13c5ac8f3d4c50f46a5121f61b3e318978" + integrity sha512-uRDL9MWmQCkaFus8RF5K9/L/2fn+80yoW3jkD53l4shjCh26fCtvJGasxjUqP5OT87SYTxCVA3BwTUzuELx9kA== + dependencies: + esrecurse "^4.3.0" + estraverse "^5.2.0" + +eslint-utils@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/eslint-utils/-/eslint-utils-3.0.0.tgz#8aebaface7345bb33559db0a1f13a1d2d48c3672" + integrity sha512-uuQC43IGctw68pJA1RgbQS8/NP7rch6Cwd4j3ZBtgo4/8Flj4eGE7ZYSZRN3iq5pVUv6GPdW5Z1RFleo84uLDA== + dependencies: + eslint-visitor-keys "^2.0.0" + +eslint-visitor-keys@^2.0.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/eslint-visitor-keys/-/eslint-visitor-keys-2.1.0.tgz#f65328259305927392c938ed44eb0a5c9b2bd303" + integrity sha512-0rSmRBzXgDzIsD6mGdJgevzgezI534Cer5L/vyMX0kHzT/jiB43jRhd9YUlMGYLQy2zprNmoT8qasCGtY+QaKw== + +eslint-visitor-keys@^3.0.0, eslint-visitor-keys@^3.4.1: + version "3.4.3" + resolved "https://registry.yarnpkg.com/eslint-visitor-keys/-/eslint-visitor-keys-3.4.3.tgz#0cd72fe8550e3c2eae156a96a4dddcd1c8ac5800" + integrity sha512-wpc+LXeiyiisxPlEkUzU6svyS1frIO3Mgxj1fdy7Pm8Ygzguax2N3Fa/D/ag1WqbOprdI+uY6wMUl8/a2G+iag== + +eslint@8.0.0: + version "8.0.0" + resolved "https://registry.yarnpkg.com/eslint/-/eslint-8.0.0.tgz#2c2d0ac6353755667ac90c9ff4a9c1315e43fcff" + integrity sha512-03spzPzMAO4pElm44m60Nj08nYonPGQXmw6Ceai/S4QK82IgwWO1EXx1s9namKzVlbVu3Jf81hb+N+8+v21/HQ== + dependencies: + "@eslint/eslintrc" "^1.0.2" + "@humanwhocodes/config-array" "^0.6.0" + ajv "^6.10.0" + chalk "^4.0.0" + cross-spawn "^7.0.2" + debug "^4.3.2" + doctrine "^3.0.0" + enquirer "^2.3.5" + escape-string-regexp "^4.0.0" + eslint-scope "^6.0.0" + eslint-utils "^3.0.0" + eslint-visitor-keys "^3.0.0" + espree "^9.0.0" + esquery "^1.4.0" + esutils "^2.0.2" + fast-deep-equal "^3.1.3" + file-entry-cache "^6.0.1" + functional-red-black-tree "^1.0.1" + glob-parent "^6.0.1" + globals "^13.6.0" + ignore "^4.0.6" + import-fresh "^3.0.0" + imurmurhash "^0.1.4" + is-glob "^4.0.0" + js-yaml "^4.1.0" + json-stable-stringify-without-jsonify "^1.0.1" + levn "^0.4.1" + lodash.merge "^4.6.2" + minimatch "^3.0.4" + natural-compare "^1.4.0" + optionator "^0.9.1" + progress "^2.0.0" + regexpp "^3.2.0" + semver "^7.2.1" + strip-ansi "^6.0.0" + strip-json-comments "^3.1.0" + text-table "^0.2.0" + v8-compile-cache "^2.0.3" + +espree@^9.0.0, espree@^9.4.0: + version "9.6.1" + resolved "https://registry.yarnpkg.com/espree/-/espree-9.6.1.tgz#a2a17b8e434690a5432f2f8018ce71d331a48c6f" + integrity sha512-oruZaFkjorTpF32kDSI5/75ViwGeZginGGy2NoOSg3Q9bnwlnmDm4HLnkl0RE3n+njDXR037aY1+x58Z/zFdwQ== + dependencies: + acorn "^8.9.0" + acorn-jsx "^5.3.2" + eslint-visitor-keys "^3.4.1" + +esquery@^1.4.0: + version "1.6.0" + resolved "https://registry.yarnpkg.com/esquery/-/esquery-1.6.0.tgz#91419234f804d852a82dceec3e16cdc22cf9dae7" + integrity sha512-ca9pw9fomFcKPvFLXhBKUK90ZvGibiGOvRJNbjljY7s7uq/5YO4BOzcYtJqExdx99rF6aAcnRxHmcUHcz6sQsg== + dependencies: + estraverse "^5.1.0" + +esrecurse@^4.3.0: + version "4.3.0" + resolved "https://registry.npmjs.org/esrecurse/-/esrecurse-4.3.0.tgz" + integrity sha512-KmfKL3b6G+RXvP8N1vr3Tq1kL/oCFgn2NYXEtqP8/L3pKapUA4G8cFVaoF3SU323CD4XypR/ffioHmkti6/Tag== + dependencies: + estraverse "^5.2.0" + +estraverse@^5.1.0, estraverse@^5.2.0: + version "5.3.0" + resolved "https://registry.npmjs.org/estraverse/-/estraverse-5.3.0.tgz" + integrity sha512-MMdARuVEQziNTeJD8DgMqmhwR11BRQ/cBP+pLtYdSTnf3MIO8fFeiINEbX36ZdNlfU/7A9f3gUw49B3oQsvwBA== + estree-walker@^3.0.3: version "3.0.3" - resolved "https://registry.yarnpkg.com/estree-walker/-/estree-walker-3.0.3.tgz#67c3e549ec402a487b4fc193d1953a524752340d" + resolved "https://registry.npmjs.org/estree-walker/-/estree-walker-3.0.3.tgz" integrity sha512-7RUKfXgSMMkzt6ZuXmqapOurLGPPfgj6l9uRZ7lRGolvk0y2yocc35LdcxKC5PQZdn2DMqioAQ2NoWcrTKmm6g== dependencies: "@types/estree" "^1.0.0" +esutils@^2.0.2: + version "2.0.3" + resolved "https://registry.npmjs.org/esutils/-/esutils-2.0.3.tgz" + integrity sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g== + expect-type@^1.1.0: version "1.2.0" - resolved "https://registry.yarnpkg.com/expect-type/-/expect-type-1.2.0.tgz#b52a0a1117260f5a8dcf33aef66365be18c13415" + resolved "https://registry.npmjs.org/expect-type/-/expect-type-1.2.0.tgz" integrity sha512-80F22aiJ3GLyVnS/B3HzgR6RelZVumzj9jkL0Rhz4h0xYbNW9PjlQz5h3J/SShErbXBc295vseR4/MIbVmUbeA== +fast-deep-equal@^3.1.1, fast-deep-equal@^3.1.3: + version "3.1.3" + resolved "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz" + integrity sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q== + +fast-json-stable-stringify@^2.0.0: + version "2.1.0" + resolved "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz" + integrity sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw== + +fast-levenshtein@^2.0.6: + version "2.0.6" + resolved "https://registry.npmjs.org/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz" + integrity sha512-DCXu6Ifhqcks7TZKY3Hxp3y6qphY5SJZmrWMDrKcERSOXWQdMhU9Ig/PYrzyw/ul9jOIyh0N4M0tbC5hodg8dw== + +file-entry-cache@^6.0.1: + version "6.0.1" + resolved "https://registry.yarnpkg.com/file-entry-cache/-/file-entry-cache-6.0.1.tgz#211b2dd9659cb0394b073e7323ac3c933d522027" + integrity sha512-7Gps/XWymbLk2QLYK4NzpMOrYjMhdIxXuIvy2QBsLE6ljuodKvdkWs/cpyJJ3CVIVpH0Oi1Hvg1ovbMzLdFBBg== + dependencies: + flat-cache "^3.0.4" + +flat-cache@^3.0.4: + version "3.2.0" + resolved "https://registry.yarnpkg.com/flat-cache/-/flat-cache-3.2.0.tgz#2c0c2d5040c99b1632771a9d105725c0115363ee" + integrity sha512-CYcENa+FtcUKLmhhqyctpclsq7QF38pKjZHsGNiSQF5r4FtoKDWabFDl3hzaEQMvT1LHEysw5twgLvpYYb4vbw== + dependencies: + flatted "^3.2.9" + keyv "^4.5.3" + rimraf "^3.0.2" + +flatted@^3.2.9: + version "3.3.3" + resolved "https://registry.npmjs.org/flatted/-/flatted-3.3.3.tgz" + integrity sha512-GX+ysw4PBCz0PzosHDepZGANEuFCMLrnRTiEy9McGjmkCQYwRq4A/X786G/fjM/+OjsWSU1ZrY5qyARZmO/uwg== + +fs.realpath@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/fs.realpath/-/fs.realpath-1.0.0.tgz#1504ad2523158caa40db4a2787cb01411994ea4f" + integrity sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw== + fsevents@~2.3.2, fsevents@~2.3.3: version "2.3.3" - resolved "https://registry.yarnpkg.com/fsevents/-/fsevents-2.3.3.tgz#cac6407785d03675a2a5e1a5305c697b347d90d6" + resolved "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz" integrity sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw== +functional-red-black-tree@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/functional-red-black-tree/-/functional-red-black-tree-1.0.1.tgz#1b0ab3bd553b2a0d6399d29c0e3ea0b252078327" + integrity sha512-dsKNQNdj6xA3T+QlADDA7mOSlX0qiMINjn0cgr+eGHGsbSHzTabcIogz2+p/iqP1Xs6EP/sS2SbqH+brGTbq0g== + +glob-parent@^6.0.1: + version "6.0.2" + resolved "https://registry.yarnpkg.com/glob-parent/-/glob-parent-6.0.2.tgz#6d237d99083950c79290f24c7642a3de9a28f9e3" + integrity sha512-XxwI8EOhVQgWp6iDL+3b0r86f4d6AX6zSU55HfB4ydCEuXLXc5FcYeOu+nnGftS4TEju/11rt4KJPTMgbfmv4A== + dependencies: + is-glob "^4.0.3" + +glob@^7.1.3: + version "7.2.3" + resolved "https://registry.yarnpkg.com/glob/-/glob-7.2.3.tgz#b8df0fb802bbfa8e89bd1d938b4e16578ed44f2b" + integrity sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q== + dependencies: + fs.realpath "^1.0.0" + inflight "^1.0.4" + inherits "2" + minimatch "^3.1.1" + once "^1.3.0" + path-is-absolute "^1.0.0" + +globals@^13.19.0, globals@^13.6.0: + version "13.24.0" + resolved "https://registry.yarnpkg.com/globals/-/globals-13.24.0.tgz#8432a19d78ce0c1e833949c36adb345400bb1171" + integrity sha512-AhO5QUcj8llrbG09iWhPU2B204J1xnPeL8kQmVorSsy+Sjj1sk8gIyh6cUocGmH4L0UuhAJy+hJMRA4mgA4mFQ== + dependencies: + type-fest "^0.20.2" + +has-flag@^4.0.0: + version "4.0.0" + resolved "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz" + integrity sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ== + +ignore@^4.0.6: + version "4.0.6" + resolved "https://registry.yarnpkg.com/ignore/-/ignore-4.0.6.tgz#750e3db5862087b4737ebac8207ffd1ef27b25fc" + integrity sha512-cyFDKrqc/YdcWFniJhzI42+AzS+gNwmUzOSFcRCQYwySuBBBy/KjuxWLZ/FHEH6Moq1NizMOBWyTcv8O4OZIMg== + +ignore@^5.2.0: + version "5.3.2" + resolved "https://registry.npmjs.org/ignore/-/ignore-5.3.2.tgz" + integrity sha512-hsBTNUqQTDwkWtcdYI2i06Y/nUBEsNEDJKjWdigLvegy8kDuJAS8uRlpkkcQpyEXL0Z/pjDy5HBmMjRCJ2gq+g== + +import-fresh@^3.0.0, import-fresh@^3.2.1: + version "3.3.1" + resolved "https://registry.yarnpkg.com/import-fresh/-/import-fresh-3.3.1.tgz#9cecb56503c0ada1f2741dbbd6546e4b13b57ccf" + integrity sha512-TR3KfrTZTYLPB6jUjfx6MF9WcWrHL9su5TObK4ZkYgBdWKPOFoSoQIdEuTuR82pmtxH2spWG9h6etwfr1pLBqQ== + dependencies: + parent-module "^1.0.0" + resolve-from "^4.0.0" + +imurmurhash@^0.1.4: + version "0.1.4" + resolved "https://registry.npmjs.org/imurmurhash/-/imurmurhash-0.1.4.tgz" + integrity sha512-JmXMZ6wuvDmLiHEml9ykzqO6lwFbof0GG4IkcGaENdCRDDmMVnny7s5HsIgHCbaq0w2MyPhDqkhTUgS2LU2PHA== + +inflight@^1.0.4: + version "1.0.6" + resolved "https://registry.yarnpkg.com/inflight/-/inflight-1.0.6.tgz#49bd6331d7d02d0c09bc910a1075ba8165b56df9" + integrity sha512-k92I/b08q4wvFscXCLvqfsHCrjrF7yiXsQuIVvVE7N82W3+aqpzuUdBbfhWcy/FZR3/4IgflMgKLOsvPDrGCJA== + dependencies: + once "^1.3.0" + wrappy "1" + +inherits@2: + version "2.0.4" + resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.4.tgz#0fa2c64f932917c3433a0ded55363aae37416b7c" + integrity sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ== + +is-extglob@^2.1.1: + version "2.1.1" + resolved "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz" + integrity sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ== + +is-glob@^4.0.0, is-glob@^4.0.3: + version "4.0.3" + resolved "https://registry.npmjs.org/is-glob/-/is-glob-4.0.3.tgz" + integrity sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg== + dependencies: + is-extglob "^2.1.1" + +isexe@^2.0.0: + version "2.0.0" + resolved "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz" + integrity sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw== + +js-yaml@^4.1.0: + version "4.1.0" + resolved "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.0.tgz" + integrity sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA== + dependencies: + argparse "^2.0.1" + +json-buffer@3.0.1: + version "3.0.1" + resolved "https://registry.npmjs.org/json-buffer/-/json-buffer-3.0.1.tgz" + integrity sha512-4bV5BfR2mqfQTJm+V5tPPdf+ZpuhiIvTuAB5g8kcrXOZpTT/QwwVRWBywX1ozr6lEuPdbHxwaJlm9G6mI2sfSQ== + +json-schema-traverse@^0.4.1: + version "0.4.1" + resolved "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz" + integrity sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg== + +json-stable-stringify-without-jsonify@^1.0.1: + version "1.0.1" + resolved "https://registry.npmjs.org/json-stable-stringify-without-jsonify/-/json-stable-stringify-without-jsonify-1.0.1.tgz" + integrity sha512-Bdboy+l7tA3OGW6FjyFHWkP5LuByj1Tk33Ljyq0axyzdk9//JSi2u3fP1QSmd1KNwq6VOKYGlAu87CisVir6Pw== + +keyv@^4.5.3: + version "4.5.4" + resolved "https://registry.yarnpkg.com/keyv/-/keyv-4.5.4.tgz#a879a99e29452f942439f2a405e3af8b31d4de93" + integrity sha512-oxVHkHR/EJf2CNXnWxRLW6mg7JyCCUcG0DtEGmL2ctUo1PNTin1PUil+r/+4r5MpVgC/fn1kjsx7mjSujKqIpw== + dependencies: + json-buffer "3.0.1" + +levn@^0.4.1: + version "0.4.1" + resolved "https://registry.npmjs.org/levn/-/levn-0.4.1.tgz" + integrity sha512-+bT2uH4E5LGE7h/n3evcS/sQlJXCpIp6ym8OWJ5eV6+67Dsql/LaaT7qJBAt2rzfoa/5QBGBhxDix1dMt2kQKQ== + dependencies: + prelude-ls "^1.2.1" + type-check "~0.4.0" + +lodash.merge@^4.6.2: + version "4.6.2" + resolved "https://registry.npmjs.org/lodash.merge/-/lodash.merge-4.6.2.tgz" + integrity sha512-0KpjqXRVvrYyCsX1swR/XTK0va6VQkQM6MNo7PqW77ByjAhoARA8EfrP1N4+KlKj8YS0ZUCtRT/YUuhyYDujIQ== + loupe@^3.1.0, loupe@^3.1.3: version "3.1.3" - resolved "https://registry.yarnpkg.com/loupe/-/loupe-3.1.3.tgz#042a8f7986d77f3d0f98ef7990a2b2fef18b0fd2" + resolved "https://registry.npmjs.org/loupe/-/loupe-3.1.3.tgz" integrity sha512-kkIp7XSkP78ZxJEsSxW3712C6teJVoeHHwgo9zJ380de7IYyJ2ISlxojcH2pC5OFLewESmnRi/+XCDIEEVyoug== magic-string@^0.30.17: version "0.30.17" - resolved "https://registry.yarnpkg.com/magic-string/-/magic-string-0.30.17.tgz#450a449673d2460e5bbcfba9a61916a1714c7453" + resolved "https://registry.npmjs.org/magic-string/-/magic-string-0.30.17.tgz" integrity sha512-sNPKHvyjVf7gyjwS4xGTaW/mCnF8wnjtifKBEhxfZ7E/S8tQ0rssrwGNn6q8JH/ohItJfSQp9mBtQYuTlH5QnA== dependencies: "@jridgewell/sourcemap-codec" "^1.5.0" +minimatch@^3.0.4, minimatch@^3.1.1, minimatch@^3.1.2: + version "3.1.2" + resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.1.2.tgz#19cd194bfd3e428f049a70817c038d89ab4be35b" + integrity sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw== + dependencies: + brace-expansion "^1.1.7" + ms@^2.1.3: version "2.1.3" - resolved "https://registry.yarnpkg.com/ms/-/ms-2.1.3.tgz#574c8138ce1d2b5861f0b44579dbadd60c6615b2" + resolved "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz" integrity sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA== nanoid@^3.3.8: version "3.3.9" - resolved "https://registry.yarnpkg.com/nanoid/-/nanoid-3.3.9.tgz#e0097d8e026b3343ff053e9ccd407360a03f503a" + resolved "https://registry.npmjs.org/nanoid/-/nanoid-3.3.9.tgz" integrity sha512-SppoicMGpZvbF1l3z4x7No3OlIjP7QJvC9XR7AhZr1kL133KHnKPztkKDc+Ir4aJ/1VhTySrtKhrsycmrMQfvg== +natural-compare@^1.4.0: + version "1.4.0" + resolved "https://registry.npmjs.org/natural-compare/-/natural-compare-1.4.0.tgz" + integrity sha512-OWND8ei3VtNC9h7V60qff3SVobHr996CTwgxubgyQYEpg290h9J0buyECNNJexkFm5sOajh5G116RYA1c8ZMSw== + +once@^1.3.0: + version "1.4.0" + resolved "https://registry.yarnpkg.com/once/-/once-1.4.0.tgz#583b1aa775961d4b113ac17d9c50baef9dd76bd1" + integrity sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w== + dependencies: + wrappy "1" + +optionator@^0.9.1: + version "0.9.4" + resolved "https://registry.yarnpkg.com/optionator/-/optionator-0.9.4.tgz#7ea1c1a5d91d764fb282139c88fe11e182a3a734" + integrity sha512-6IpQ7mKUxRcZNLIObR0hz7lxsapSSIYNZJwXPGeF0mTVqGKFIXj1DQcMoT22S3ROcLyY/rz0PWaWZ9ayWmad9g== + dependencies: + deep-is "^0.1.3" + fast-levenshtein "^2.0.6" + levn "^0.4.1" + prelude-ls "^1.2.1" + type-check "^0.4.0" + word-wrap "^1.2.5" + +parent-module@^1.0.0: + version "1.0.1" + resolved "https://registry.npmjs.org/parent-module/-/parent-module-1.0.1.tgz" + integrity sha512-GQ2EWRpQV8/o+Aw8YqtfZZPfNRWZYkbidE9k5rpl/hC3vtHHBfGm2Ifi6qWV+coDGkrUKZAxE3Lot5kcsRlh+g== + dependencies: + callsites "^3.0.0" + +path-is-absolute@^1.0.0: + version "1.0.1" + resolved "https://registry.yarnpkg.com/path-is-absolute/-/path-is-absolute-1.0.1.tgz#174b9268735534ffbc7ace6bf53a5a9e1b5c5f5f" + integrity sha512-AVbw3UJ2e9bq64vSaS9Am0fje1Pa8pbGqTTsmXfaIiMpnr5DlDhfJOuLj9Sf95ZPVDAUerDfEk88MPmPe7UCQg== + +path-key@^3.1.0: + version "3.1.1" + resolved "https://registry.npmjs.org/path-key/-/path-key-3.1.1.tgz" + integrity sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q== + pathe@^2.0.3: version "2.0.3" - resolved "https://registry.yarnpkg.com/pathe/-/pathe-2.0.3.tgz#3ecbec55421685b70a9da872b2cff3e1cbed1716" + resolved "https://registry.npmjs.org/pathe/-/pathe-2.0.3.tgz" integrity sha512-WUjGcAqP1gQacoQe+OBJsFA7Ld4DyXuUIjZ5cc75cLHvJ7dtNsTugphxIADwspS+AraAUePCKrSVtPLFj/F88w== pathval@^2.0.0: version "2.0.0" - resolved "https://registry.yarnpkg.com/pathval/-/pathval-2.0.0.tgz#7e2550b422601d4f6b8e26f1301bc8f15a741a25" + resolved "https://registry.npmjs.org/pathval/-/pathval-2.0.0.tgz" integrity sha512-vE7JKRyES09KiunauX7nd2Q9/L7lhok4smP9RZTDeD4MVs72Dp2qNFVz39Nz5a0FVEW0BJR6C0DYrq6unoziZA== picocolors@^1.1.1: version "1.1.1" - resolved "https://registry.yarnpkg.com/picocolors/-/picocolors-1.1.1.tgz#3d321af3eab939b083c8f929a1d12cda81c26b6b" + resolved "https://registry.npmjs.org/picocolors/-/picocolors-1.1.1.tgz" integrity sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA== postcss@^8.5.3: version "8.5.3" - resolved "https://registry.yarnpkg.com/postcss/-/postcss-8.5.3.tgz#1463b6f1c7fb16fe258736cba29a2de35237eafb" + resolved "https://registry.npmjs.org/postcss/-/postcss-8.5.3.tgz" integrity sha512-dle9A3yYxlBSrt8Fu+IpjGT8SY8hN0mlaA6GY8t0P5PjIOZemULz/E2Bnm/2dcUOena75OTNkHI76uZBNUUq3A== dependencies: nanoid "^3.3.8" picocolors "^1.1.1" source-map-js "^1.2.1" +prelude-ls@^1.2.1: + version "1.2.1" + resolved "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.2.1.tgz" + integrity sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g== + +progress@^2.0.0: + version "2.0.3" + resolved "https://registry.yarnpkg.com/progress/-/progress-2.0.3.tgz#7e8cf8d8f5b8f239c1bc68beb4eb78567d572ef8" + integrity sha512-7PiHtLll5LdnKIMw100I+8xJXR5gW2QwWYkT6iJva0bXitZKa/XMrSbdmg3r2Xnaidz9Qumd0VPaMrZlF9V9sA== + +punycode@^2.1.0: + version "2.3.1" + resolved "https://registry.npmjs.org/punycode/-/punycode-2.3.1.tgz" + integrity sha512-vYt7UD1U9Wg6138shLtLOvdAu+8DsC/ilFtEVHcH+wydcSpNE20AfSOduf6MkRFahL5FY7X1oU7nKVZFtfq8Fg== + +regexpp@^3.2.0: + version "3.2.0" + resolved "https://registry.yarnpkg.com/regexpp/-/regexpp-3.2.0.tgz#0425a2768d8f23bad70ca4b90461fa2f1213e1b2" + integrity sha512-pq2bWo9mVD43nbts2wGv17XLiNLya+GklZ8kaDLV2Z08gDCsGpnKn9BFMepvWuHCbyVvY7J5o5+BVvoQbmlJLg== + +resolve-from@^4.0.0: + version "4.0.0" + resolved "https://registry.npmjs.org/resolve-from/-/resolve-from-4.0.0.tgz" + integrity sha512-pb/MYmXstAkysRFx8piNI1tGFNQIFA3vkE3Gq4EuA1dF6gHp/+vgZqsCGJapvy8N3Q+4o7FwvquPJcnZ7RYy4g== + +rimraf@^3.0.2: + version "3.0.2" + resolved "https://registry.yarnpkg.com/rimraf/-/rimraf-3.0.2.tgz#f1a5402ba6220ad52cc1282bac1ae3aa49fd061a" + integrity sha512-JZkJMZkAGFFPP2YqXZXPbMlMBgsxzE8ILs4lMIX/2o0L9UBw9O/Y3o6wFw/i9YLapcUJWwqbi3kdxIPdC62TIA== + dependencies: + glob "^7.1.3" + rollup@^4.30.1: version "4.35.0" - resolved "https://registry.yarnpkg.com/rollup/-/rollup-4.35.0.tgz#76c95dba17a579df4c00c3955aed32aa5d4dc66d" + resolved "https://registry.npmjs.org/rollup/-/rollup-4.35.0.tgz" integrity sha512-kg6oI4g+vc41vePJyO6dHt/yl0Rz3Thv0kJeVQ3D1kS3E5XSuKbPc29G4IpT/Kv1KQwgHVcN+HtyS+HYLNSvQg== dependencies: "@types/estree" "1.0.6" @@ -456,59 +958,124 @@ rollup@^4.30.1: "@rollup/rollup-win32-x64-msvc" "4.35.0" fsevents "~2.3.2" +semver@^7.2.1: + version "7.7.1" + resolved "https://registry.yarnpkg.com/semver/-/semver-7.7.1.tgz#abd5098d82b18c6c81f6074ff2647fd3e7220c9f" + integrity sha512-hlq8tAfn0m/61p4BVRcPzIGr6LKiMwo4VM6dGi6pt4qcRkmNzTcWq6eCEjEh+qXjkMDvPlOFFSGwQjoEa6gyMA== + +shebang-command@^2.0.0: + version "2.0.0" + resolved "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz" + integrity sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA== + dependencies: + shebang-regex "^3.0.0" + +shebang-regex@^3.0.0: + version "3.0.0" + resolved "https://registry.npmjs.org/shebang-regex/-/shebang-regex-3.0.0.tgz" + integrity sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A== + siginfo@^2.0.0: version "2.0.0" - resolved "https://registry.yarnpkg.com/siginfo/-/siginfo-2.0.0.tgz#32e76c70b79724e3bb567cb9d543eb858ccfaf30" + resolved "https://registry.npmjs.org/siginfo/-/siginfo-2.0.0.tgz" integrity sha512-ybx0WO1/8bSBLEWXZvEd7gMW3Sn3JFlW3TvX1nREbDLRNQNaeNN8WK0meBwPdAaOI7TtRRRJn/Es1zhrrCHu7g== source-map-js@^1.2.1: version "1.2.1" - resolved "https://registry.yarnpkg.com/source-map-js/-/source-map-js-1.2.1.tgz#1ce5650fddd87abc099eda37dcff024c2667ae46" + resolved "https://registry.npmjs.org/source-map-js/-/source-map-js-1.2.1.tgz" integrity sha512-UXWMKhLOwVKb728IUtQPXxfYU+usdybtUrK/8uGE8CQMvrhOpwvzDBwj0QhSL7MQc7vIsISBG8VQ8+IDQxpfQA== stackback@0.0.2: version "0.0.2" - resolved "https://registry.yarnpkg.com/stackback/-/stackback-0.0.2.tgz#1ac8a0d9483848d1695e418b6d031a3c3ce68e3b" + resolved "https://registry.npmjs.org/stackback/-/stackback-0.0.2.tgz" integrity sha512-1XMJE5fQo1jGH6Y/7ebnwPOBEkIEnT4QF32d5R1+VXdXveM0IBMJt8zfaxX1P3QhVwrYe+576+jkANtSS2mBbw== std-env@^3.8.0: version "3.8.1" - resolved "https://registry.yarnpkg.com/std-env/-/std-env-3.8.1.tgz#2b81c631c62e3d0b964b87f099b8dcab6c9a5346" + resolved "https://registry.npmjs.org/std-env/-/std-env-3.8.1.tgz" integrity sha512-vj5lIj3Mwf9D79hBkltk5qmkFI+biIKWS2IBxEyEU3AX1tUf7AoL8nSazCOiiqQsGKIq01SClsKEzweu34uwvA== +strip-ansi@^6.0.0, strip-ansi@^6.0.1: + version "6.0.1" + resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9" + integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A== + dependencies: + ansi-regex "^5.0.1" + +strip-json-comments@^3.1.0, strip-json-comments@^3.1.1: + version "3.1.1" + resolved "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-3.1.1.tgz" + integrity sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig== + +supports-color@^7.1.0: + version "7.2.0" + resolved "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz" + integrity sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw== + dependencies: + has-flag "^4.0.0" + +text-table@^0.2.0: + version "0.2.0" + resolved "https://registry.yarnpkg.com/text-table/-/text-table-0.2.0.tgz#7f5ee823ae805207c00af2df4a84ec3fcfa570b4" + integrity sha512-N+8UisAXDGk8PFXP4HAzVR9nbfmVJ3zYLAWiTIoqC5v5isinhr+r5uaO8+7r3BMfuNIufIsA7RdpVgacC2cSpw== + tinybench@^2.9.0: version "2.9.0" - resolved "https://registry.yarnpkg.com/tinybench/-/tinybench-2.9.0.tgz#103c9f8ba6d7237a47ab6dd1dcff77251863426b" + resolved "https://registry.npmjs.org/tinybench/-/tinybench-2.9.0.tgz" integrity sha512-0+DUvqWMValLmha6lr4kD8iAMK1HzV0/aKnCtWb9v9641TnP/MFb7Pc2bxoxQjTXAErryXVgUOfv2YqNllqGeg== tinyexec@^0.3.2: version "0.3.2" - resolved "https://registry.yarnpkg.com/tinyexec/-/tinyexec-0.3.2.tgz#941794e657a85e496577995c6eef66f53f42b3d2" + resolved "https://registry.npmjs.org/tinyexec/-/tinyexec-0.3.2.tgz" integrity sha512-KQQR9yN7R5+OSwaK0XQoj22pwHoTlgYqmUscPYoknOoWCWfj/5/ABTMRi69FrKU5ffPVh5QcFikpWJI/P1ocHA== tinypool@^1.0.2: version "1.0.2" - resolved "https://registry.yarnpkg.com/tinypool/-/tinypool-1.0.2.tgz#706193cc532f4c100f66aa00b01c42173d9051b2" + resolved "https://registry.npmjs.org/tinypool/-/tinypool-1.0.2.tgz" integrity sha512-al6n+QEANGFOMf/dmUMsuS5/r9B06uwlyNjZZql/zv8J7ybHCgoihBNORZCY2mzUuAnomQa2JdhyHKzZxPCrFA== tinyrainbow@^2.0.0: version "2.0.0" - resolved "https://registry.yarnpkg.com/tinyrainbow/-/tinyrainbow-2.0.0.tgz#9509b2162436315e80e3eee0fcce4474d2444294" + resolved "https://registry.npmjs.org/tinyrainbow/-/tinyrainbow-2.0.0.tgz" integrity sha512-op4nsTR47R6p0vMUUoYl/a+ljLFVtlfaXkLQmqfLR1qHma1h/ysYk4hEXZ880bf2CYgTskvTa/e196Vd5dDQXw== tinyspy@^3.0.2: version "3.0.2" - resolved "https://registry.yarnpkg.com/tinyspy/-/tinyspy-3.0.2.tgz#86dd3cf3d737b15adcf17d7887c84a75201df20a" + resolved "https://registry.npmjs.org/tinyspy/-/tinyspy-3.0.2.tgz" integrity sha512-n1cw8k1k0x4pgA2+9XrOkFydTerNcJ1zWCO5Nn9scWHTD+5tp8dghT2x1uduQePZTZgd3Tupf+x9BxJjeJi77Q== +type-check@^0.4.0, type-check@~0.4.0: + version "0.4.0" + resolved "https://registry.npmjs.org/type-check/-/type-check-0.4.0.tgz" + integrity sha512-XleUoc9uwGXqjWwXaUTZAmzMcFZ5858QA2vvx1Ur5xIcixXIP+8LnFDgRplU30us6teqdlskFfu+ae4K79Ooew== + dependencies: + prelude-ls "^1.2.1" + +type-fest@^0.20.2: + version "0.20.2" + resolved "https://registry.yarnpkg.com/type-fest/-/type-fest-0.20.2.tgz#1bf207f4b28f91583666cb5fbd327887301cd5f4" + integrity sha512-Ne+eE4r0/iWnpAxD852z3A+N0Bt5RN//NjJwRd2VFHEmrywxf5vsZlh4R6lixl6B+wz/8d+maTSAkN1FIkI3LQ== + typescript@^5.8.2: version "5.8.2" - resolved "https://registry.yarnpkg.com/typescript/-/typescript-5.8.2.tgz#8170b3702f74b79db2e5a96207c15e65807999e4" + resolved "https://registry.npmjs.org/typescript/-/typescript-5.8.2.tgz" integrity sha512-aJn6wq13/afZp/jT9QZmwEjDqqvSGp1VT5GVg+f/t6/oVyrgXM6BY1h9BRh/O5p3PlUPAe+WuiEZOmb/49RqoQ== +uri-js@^4.2.2: + version "4.4.1" + resolved "https://registry.npmjs.org/uri-js/-/uri-js-4.4.1.tgz" + integrity sha512-7rKUyy33Q1yc98pQ1DAmLtwX109F7TIfWlW1Ydo8Wl1ii1SeHieeh0HHfPeL2fMXK6z0s8ecKs9frCuLJvndBg== + dependencies: + punycode "^2.1.0" + +v8-compile-cache@^2.0.3: + version "2.4.0" + resolved "https://registry.yarnpkg.com/v8-compile-cache/-/v8-compile-cache-2.4.0.tgz#cdada8bec61e15865f05d097c5f4fd30e94dc128" + integrity sha512-ocyWc3bAHBB/guyqJQVI5o4BZkPhznPYUG2ea80Gond/BgNWpap8TOmLSeeQG7bnh2KMISxskdADG59j7zruhw== + vite-node@3.0.8: version "3.0.8" - resolved "https://registry.yarnpkg.com/vite-node/-/vite-node-3.0.8.tgz#69cd1e0b9c7c37a8e7ab3b87ce259cbbf9a7bd72" + resolved "https://registry.npmjs.org/vite-node/-/vite-node-3.0.8.tgz" integrity sha512-6PhR4H9VGlcwXZ+KWCdMqbtG649xCPZqfI9j2PsK1FcXgEzro5bGHcVKFCTqPLaNKZES8Evqv4LwvZARsq5qlg== dependencies: cac "^6.7.14" @@ -519,7 +1086,7 @@ vite-node@3.0.8: "vite@^5.0.0 || ^6.0.0": version "6.2.1" - resolved "https://registry.yarnpkg.com/vite/-/vite-6.2.1.tgz#ae865d4bb93a11844be1bc647c8b2dd1856ea180" + resolved "https://registry.npmjs.org/vite/-/vite-6.2.1.tgz" integrity sha512-n2GnqDb6XPhlt9B8olZPrgMD/es/Nd1RdChF6CBD/fHW6pUyUTt2sQW2fPRX5GiD9XEa6+8A6A4f2vT6pSsE7Q== dependencies: esbuild "^0.25.0" @@ -530,7 +1097,7 @@ vite-node@3.0.8: vitest@^3.0.8: version "3.0.8" - resolved "https://registry.yarnpkg.com/vitest/-/vitest-3.0.8.tgz#2b85e689d3067cf3b8e174626ecfcb8b24be0785" + resolved "https://registry.npmjs.org/vitest/-/vitest-3.0.8.tgz" integrity sha512-dfqAsNqRGUc8hB9OVR2P0w8PZPEckti2+5rdZip0WIz9WW0MnImJ8XiR61QhqLa92EQzKP2uPkzenKOAHyEIbA== dependencies: "@vitest/expect" "3.0.8" @@ -554,10 +1121,27 @@ vitest@^3.0.8: vite-node "3.0.8" why-is-node-running "^2.3.0" +which@^2.0.1: + version "2.0.2" + resolved "https://registry.npmjs.org/which/-/which-2.0.2.tgz" + integrity sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA== + dependencies: + isexe "^2.0.0" + why-is-node-running@^2.3.0: version "2.3.0" - resolved "https://registry.yarnpkg.com/why-is-node-running/-/why-is-node-running-2.3.0.tgz#a3f69a97107f494b3cdc3bdddd883a7d65cebf04" + resolved "https://registry.npmjs.org/why-is-node-running/-/why-is-node-running-2.3.0.tgz" integrity sha512-hUrmaWBdVDcxvYqnyh09zunKzROWjbZTiNy8dBEjkS7ehEDQibXJ7XvlmtbwuTclUiIyN+CyXQD4Vmko8fNm8w== dependencies: siginfo "^2.0.0" stackback "0.0.2" + +word-wrap@^1.2.5: + version "1.2.5" + resolved "https://registry.npmjs.org/word-wrap/-/word-wrap-1.2.5.tgz" + integrity sha512-BN22B5eaMMI9UMtjrGd5g5eCYPpCPDUy0FJXbYsaT5zYxjFOckS53SQDE3pWkVoWpHXVb3BrYcEN4Twa55B5cA== + +wrappy@1: + version "1.0.2" + resolved "https://registry.yarnpkg.com/wrappy/-/wrappy-1.0.2.tgz#b5243d8f3ec1aa35f1364605bc0d1036e30ab69f" + integrity sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ== From a6232121f8ad2e5f85e1c96709fbf7fb95999e60 Mon Sep 17 00:00:00 2001 From: Wesley Guthrie Date: Mon, 10 Mar 2025 15:41:51 -0500 Subject: [PATCH 08/13] fix all instances of .at --- .github/workflows/lint-test-build-pull-request.yaml | 4 ++-- src/every.ts | 2 +- src/filter.ts | 2 +- src/findIndex.ts | 2 +- src/findLast.ts | 2 +- src/map.ts | 1 - 6 files changed, 6 insertions(+), 7 deletions(-) diff --git a/.github/workflows/lint-test-build-pull-request.yaml b/.github/workflows/lint-test-build-pull-request.yaml index 423a7b5..d1bd813 100644 --- a/.github/workflows/lint-test-build-pull-request.yaml +++ b/.github/workflows/lint-test-build-pull-request.yaml @@ -18,10 +18,10 @@ jobs: with: node-version: ${{ matrix.node-version }} - - name: install modules + - name: Install modules run: yarn install - - name: run eslint + - name: Run eslint run: yarn lint test: diff --git a/src/every.ts b/src/every.ts index 55e842f..d9b22d8 100644 --- a/src/every.ts +++ b/src/every.ts @@ -5,7 +5,7 @@ export default async function every( if (!Array.isArray(array) || !array?.length) return false; for (let index = 0; index < array.length; index++) { - const element = array.at(index) as T; + const element = array[index]; const result = await iterator(element, index); if (!result) { return false; diff --git a/src/filter.ts b/src/filter.ts index ab7d2c0..71f964b 100644 --- a/src/filter.ts +++ b/src/filter.ts @@ -6,7 +6,7 @@ export default async function filter( const results: T[] = []; for (let index = 0; index < array.length; index++) { - const element = array.at(index) as T; + const element = array[index]; const result = await iterator(element, index); if (result) { results.push(element); diff --git a/src/findIndex.ts b/src/findIndex.ts index 7fbd0e2..30d51c0 100644 --- a/src/findIndex.ts +++ b/src/findIndex.ts @@ -5,7 +5,7 @@ export default async function findIndex( if (!Array.isArray(array) || !array?.length) return -1; for (let index = 0; index < array.length; index++) { - const element = array.at(index) as T; + const element = array[index]; const result = await iterator(element, index); if (result) { return index; diff --git a/src/findLast.ts b/src/findLast.ts index a65fb94..59daf27 100644 --- a/src/findLast.ts +++ b/src/findLast.ts @@ -5,7 +5,7 @@ export default async function findLast( if (!Array.isArray(array) || !array?.length) return undefined; for (let index = array.length; index >= 0; index--) { - const element = array.at(index) as T; + const element = array[index]; const result = await iterator(element, index); if (result) { return element; diff --git a/src/map.ts b/src/map.ts index c52e570..0a0af0e 100644 --- a/src/map.ts +++ b/src/map.ts @@ -7,7 +7,6 @@ export default async function map( const results: V[] = []; for (let index = 0; index < array.length; index++) { const element = array[index]; - results.push(await iterator(element, index)); } return results; From 9678ea440165c921b1688a2c19b3d58538f09ebd Mon Sep 17 00:00:00 2001 From: Wesley Guthrie Date: Mon, 10 Mar 2025 22:24:47 -0500 Subject: [PATCH 09/13] add tests and jsdoc --- .github/pull_request_template.md | 1 + dist/src/every.js | 2 +- dist/src/filter.js | 3 +- dist/src/findIndex.js | 2 +- dist/src/findLast.js | 2 +- eslint.config.mjs | 11 + package.json | 10 +- src/every.ts | 16 +- src/filter.ts | 16 +- src/find.ts | 16 +- src/findIndex.ts | 16 +- src/findLast.ts | 18 +- src/findLastIndex.ts | 18 +- src/map.ts | 16 +- src/mapParallel.ts | 18 +- src/reduce.ts | 17 +- src/reduceRight.ts | 17 +- src/some.ts | 16 +- test/every.test.ts | 199 +++++----- test/filter.test.ts | 115 +++--- test/find.test.ts | 211 ++++------ test/findIndex.test.ts | 111 +++++- test/findLast.test.ts | 113 +++++- test/findLastIndex.test.ts | 125 +++++- test/mapParallel.test.ts | 2 +- test/reduce.test.ts | 46 +-- test/reduceRight.test.ts | 52 +-- test/some.test.ts | 184 ++++----- tsconfig.json | 1 + yarn.lock | 638 ++++++++++++++++++++----------- 30 files changed, 1290 insertions(+), 722 deletions(-) create mode 100644 eslint.config.mjs diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md index 9282965..dcba740 100644 --- a/.github/pull_request_template.md +++ b/.github/pull_request_template.md @@ -17,3 +17,4 @@ - [ ] I have made corresponding changes to the documentation - [ ] My changes generate no new warnings - [ ] I have added or refactored the necessary tests that prove my fix is effective or that my feature works +- [ ] I have run the `yarn build` script in order to update the `/dist` folder diff --git a/dist/src/every.js b/dist/src/every.js index c7485cb..47dc6df 100644 --- a/dist/src/every.js +++ b/dist/src/every.js @@ -5,7 +5,7 @@ async function every(array, iterator) { if (!Array.isArray(array) || !array?.length) return false; for (let index = 0; index < array.length; index++) { - const element = array.at(index); + const element = array[index]; const result = await iterator(element, index); if (!result) { return false; diff --git a/dist/src/filter.js b/dist/src/filter.js index 4fabf23..26cad7a 100644 --- a/dist/src/filter.js +++ b/dist/src/filter.js @@ -4,10 +4,9 @@ exports.default = filter; async function filter(array, iterator) { if (!Array.isArray(array) || !array?.length) return []; - const thing = 1; const results = []; for (let index = 0; index < array.length; index++) { - const element = array.at(index); + const element = array[index]; const result = await iterator(element, index); if (result) { results.push(element); diff --git a/dist/src/findIndex.js b/dist/src/findIndex.js index 6a3ce9c..394459b 100644 --- a/dist/src/findIndex.js +++ b/dist/src/findIndex.js @@ -5,7 +5,7 @@ async function findIndex(array, iterator) { if (!Array.isArray(array) || !array?.length) return -1; for (let index = 0; index < array.length; index++) { - const element = array.at(index); + const element = array[index]; const result = await iterator(element, index); if (result) { return index; diff --git a/dist/src/findLast.js b/dist/src/findLast.js index d8f9fcc..a5b9140 100644 --- a/dist/src/findLast.js +++ b/dist/src/findLast.js @@ -5,7 +5,7 @@ async function findLast(array, iterator) { if (!Array.isArray(array) || !array?.length) return undefined; for (let index = array.length; index >= 0; index--) { - const element = array.at(index); + const element = array[index]; const result = await iterator(element, index); if (result) { return element; diff --git a/eslint.config.mjs b/eslint.config.mjs new file mode 100644 index 0000000..b7758c5 --- /dev/null +++ b/eslint.config.mjs @@ -0,0 +1,11 @@ +// @ts-check + +import eslint from "@eslint/js"; +import tseslint from "typescript-eslint"; +import { globalIgnores } from "eslint/config"; + +export default tseslint.config( + eslint.configs.recommended, + tseslint.configs.recommended, + globalIgnores(["dist/*"]) +); diff --git a/package.json b/package.json index e230023..70a86de 100644 --- a/package.json +++ b/package.json @@ -8,7 +8,8 @@ "repository": "GuthrieW/async-iterators", "type": "commonjs", "files": [ - "/dist" + "/dist", + "/src" ], "main": "dist/index.js", "types": "dist/index.d.ts", @@ -26,11 +27,12 @@ "engines": { "node": ">=18.0.0" }, - "dependencies": { - "eslint": "8.0.0" - }, + "dependencies": {}, "devDependencies": { + "@eslint/js": "^9.22.0", + "eslint": "^9.22.0", "typescript": "^5.8.2", + "typescript-eslint": "^8.26.1", "vitest": "^3.0.8" } } diff --git a/src/every.ts b/src/every.ts index d9b22d8..1701015 100644 --- a/src/every.ts +++ b/src/every.ts @@ -1,12 +1,24 @@ +/** + * {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/every|MDN Documentation Array.prototype.every} + * + * @static + * @since 1.0.0 + * @param {T[]} array + * @param {(value: T, index: number) => Promise} iteratee + * @returns {Promise} + * @example + * const array = [3, 3, 3]; + * const allThree = await every(array, async (value) => value === 3); + */ export default async function every( array: T[], - iterator: (value: T, index: number) => Promise + iteratee: (value: T, index: number) => Promise ): Promise { if (!Array.isArray(array) || !array?.length) return false; for (let index = 0; index < array.length; index++) { const element = array[index]; - const result = await iterator(element, index); + const result = await iteratee(element, index); if (!result) { return false; } diff --git a/src/filter.ts b/src/filter.ts index 71f964b..63a726b 100644 --- a/src/filter.ts +++ b/src/filter.ts @@ -1,13 +1,25 @@ +/** + * {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/filter|MDN Documentation Array.prototype.filter} + * + * @static + * @since 1.0.0 + * @param {T[]} array + * @param {(value: T, index: number) => Promise} iteratee + * @returns {Promise} + * @example + * const array = [1, 2, 3]; + * const onlyThree = await filter(array, async (value) => value === 3); + */ export default async function filter( array: T[], - iterator: (value: T, index: number) => Promise + iteratee: (value: T, index: number) => Promise ): Promise { if (!Array.isArray(array) || !array?.length) return []; const results: T[] = []; for (let index = 0; index < array.length; index++) { const element = array[index]; - const result = await iterator(element, index); + const result = await iteratee(element, index); if (result) { results.push(element); } diff --git a/src/find.ts b/src/find.ts index fc84500..00012b5 100644 --- a/src/find.ts +++ b/src/find.ts @@ -1,12 +1,24 @@ +/** + * {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/find|MDN Documentation Array.prototype.find} + * + * @static + * @since 1.0.0 + * @param {T[]} array + * @param {(value: T, index: number) => Promise} iteratee + * @returns {Promise} + * @example + * const array = [1, 2, 3]; + * const foundValue = await find(array, async (value) => value === 3); + */ export default async function find( array: T[], - iterator: (value: T, index: number) => Promise + iteratee: (value: T, index: number) => Promise ): Promise { if (!Array.isArray(array) || !array?.length) return undefined; for (let index = 0; index < array.length; index++) { const element = array[index]; - const result = await iterator(element, index); + const result = await iteratee(element, index); if (result) { return element; } diff --git a/src/findIndex.ts b/src/findIndex.ts index 30d51c0..69d4c57 100644 --- a/src/findIndex.ts +++ b/src/findIndex.ts @@ -1,12 +1,24 @@ +/** + * {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/findIndex|MDN Documentation Array.prototype.findIndex} + * + * @static + * @since 1.0.0 + * @param {T[]} array + * @param {(value: T, index: number) => Promise} iteratee + * @returns {Promise} + * @example + * const array = [1, 2, 3]; + * const foundValueIndex = await findIndex(array, async (value) => value === 3); + */ export default async function findIndex( array: T[], - iterator: (value: T, index: number) => Promise + iteratee: (value: T, index: number) => Promise ): Promise { if (!Array.isArray(array) || !array?.length) return -1; for (let index = 0; index < array.length; index++) { const element = array[index]; - const result = await iterator(element, index); + const result = await iteratee(element, index); if (result) { return index; } diff --git a/src/findLast.ts b/src/findLast.ts index 59daf27..d6b7129 100644 --- a/src/findLast.ts +++ b/src/findLast.ts @@ -1,12 +1,24 @@ +/** + * {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/findLast|MDN Documentation Array.prototype.findLast} + * + * @static + * @since 1.0.0 + * @param {T[]} array + * @param {(value: T, index: number) => Promise} iteratee + * @returns {Promise} + * @example + * const array = [1, 2, 3]; + * const foundValue = await findLast(array, async (value) => value === 3); + */ export default async function findLast( array: T[], - iterator: (value: T, index: number) => Promise + iteratee: (value: T, index: number) => Promise ): Promise { if (!Array.isArray(array) || !array?.length) return undefined; - for (let index = array.length; index >= 0; index--) { + for (let index = array.length - 1; index >= 0; index--) { const element = array[index]; - const result = await iterator(element, index); + const result = await iteratee(element, index); if (result) { return element; } diff --git a/src/findLastIndex.ts b/src/findLastIndex.ts index af7d190..97d97c1 100644 --- a/src/findLastIndex.ts +++ b/src/findLastIndex.ts @@ -1,12 +1,24 @@ +/** + * {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/findLastIndex|MDN Documentation Array.prototype.findLastIndex} + * + * @static + * @since 1.0.0 + * @param {T[]} array + * @param {(value: T, index: number) => Promise} iteratee + * @returns {Promise} + * @example + * const array = [1, 2, 3]; + * const foundValueIndex = await findLastIndex(array, async (value) => value === 3); + */ export default async function findLastIndex( array: T[], - iterator: (value: T, index: number) => Promise + iteratee: (value: T, index: number) => Promise ): Promise { if (!Array.isArray(array) || !array?.length) return -1; - for (let index = array.length; index >= 0; index--) { + for (let index = array.length - 1; index >= 0; index--) { const element = array[index]; - const result = await iterator(element, index); + const result = await iteratee(element, index); if (result) { return index; } diff --git a/src/map.ts b/src/map.ts index 0a0af0e..8f8ccff 100644 --- a/src/map.ts +++ b/src/map.ts @@ -1,13 +1,25 @@ +/** + * {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map|MDN Documentation Array.prototype.map} + * + * @static + * @since 1.0.0 + * @param {T[]} array + * @param {(value: T, index: number) => Promise} iteratee + * @returns {Promise} + * @example + * const array = [1, 2, 3]; + * const doubledArray = await map(array, async (value) => value * 2); + */ export default async function map( array: T[], - iterator: (value: T, index: number) => Promise + iteratee: (value: T, index: number) => Promise ): Promise { if (!Array.isArray(array) || !array?.length) return []; const results: V[] = []; for (let index = 0; index < array.length; index++) { const element = array[index]; - results.push(await iterator(element, index)); + results.push(await iteratee(element, index)); } return results; } diff --git a/src/mapParallel.ts b/src/mapParallel.ts index 4815bec..a4fda6a 100644 --- a/src/mapParallel.ts +++ b/src/mapParallel.ts @@ -1,20 +1,20 @@ /** * take and complete tasks from a queue until that queue is empty. * @param {{ task: T; index: number }[]} array - * @param {(val: T, index?: number) => Promise} iterator + * @param {(val: T, index?: number) => Promise} iteratee */ async function takeAndCompleteFromQueueUntilDone( array: { task: T; index: number }[], - iterator: (val: T, index: number) => Promise + iteratee: (val: T, index: number) => Promise ): Promise<{ result: V; index: number }[]> { const item = array.shift(); if (!item) { return []; } - const completedTask = await iterator(item.task, item.index); + const completedTask = await iteratee(item.task, item.index); const followingCompletedTasks = await takeAndCompleteFromQueueUntilDone( array, - iterator + iteratee ); return followingCompletedTasks.concat({ result: completedTask, @@ -23,14 +23,14 @@ async function takeAndCompleteFromQueueUntilDone( } /** - * iterate over the passed in array in parallel, running the iterator on each element. + * iterate over the passed in array in parallel, running the iteratee on each element. * @param {T[]} array - * @param {(val: T, index?: number) => Promise} iterator + * @param {(val: T, index?: number) => Promise} iteratee * @param {number} [maxParallelBatchSize] */ export default async function mapParallel( array: T[], - iterator: (value: T, index: number) => Promise, + iteratee: (value: T, index: number) => Promise, maxParallelBatchSize?: number ): Promise { if (!Array.isArray(array) || !array?.length) return []; @@ -47,12 +47,12 @@ export default async function mapParallel( } const coolEmptyArray = Array(effectiveMaxBatchSize).fill(undefined); - let results: V[] = []; + const results: V[] = []; await Promise.all( coolEmptyArray.map(async () => { const resultsWithIndex = await takeAndCompleteFromQueueUntilDone( arrayWithIndexKeys, - iterator + iteratee ); resultsWithIndex.forEach((result) => { results[result.index] = result.result; diff --git a/src/reduce.ts b/src/reduce.ts index 98c47bc..5a3ff18 100644 --- a/src/reduce.ts +++ b/src/reduce.ts @@ -1,6 +1,19 @@ +/** + * {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/reduce|MDN Documentation Array.prototype.reduce} + * + * @static + * @since 1.0.0 + * @param {T[]} array + * @param {(accumulator: V, currentValue: T) => Promise} iteratee + * @param {V} initialValue + * @returns {Promise} + * @example + * const array = [1, 2, 3]; + * const sum = await reduce(array, async (accumulator, current) => accumulator + currect, 0); + */ export default async function reduce( array: T[], - iterator: (accumulator: V, currentValue: T) => Promise, + iteratee: (accumulator: V, currentValue: T) => Promise, initialValue: V ): Promise { if (!Array.isArray(array) || !array?.length) return initialValue; @@ -8,7 +21,7 @@ export default async function reduce( let result = initialValue; for (let index = 0; index < array.length; index++) { const element = array[index]; - result = await iterator(result, element); + result = await iteratee(result, element); } return result; diff --git a/src/reduceRight.ts b/src/reduceRight.ts index 9c59292..bec14ee 100644 --- a/src/reduceRight.ts +++ b/src/reduceRight.ts @@ -1,13 +1,26 @@ +/** + * {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/reduceRight|MDN Documentation Array.prototype.reduceRight} + * + * @static + * @since 1.0.0 + * @param {T[]} array + * @param {(accumulator: V, currentValue: T) => Promise} iteratee + * @param {V} initialValue + * @returns {Promise} + * @example + * const array = [1, 2, 3]; + * const sum = await reduceRight(array, async (accumulator, current) => accumulator + currect, 0); + */ export default async function reduceRight( array: T[], - iterator: (accumulator: V, currentValue: T) => Promise, + iteratee: (accumulator: V, currentValue: T) => Promise, initialValue: V ): Promise { if (!Array.isArray(array) || !array?.length) return initialValue; let result = initialValue; for (let index = array.length - 1; index >= 0; index--) { - result = await iterator(result, array[index]); + result = await iteratee(result, array[index]); } return result; diff --git a/src/some.ts b/src/some.ts index a94839c..c81dc96 100644 --- a/src/some.ts +++ b/src/some.ts @@ -1,12 +1,24 @@ +/** + * {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/some|MDN Documentation Array.prototype.some} + * + * @static + * @since 1.0.0 + * @param {T[]} array + * @param {(value: T, index: number) => Promise} iteratee + * @returns {Promise} + * @example + * const array = [1, 2, 3]; + * const hasThree = await some(array, async (value) => value === 3); + */ export default async function some( array: T[], - iterator: (value: T, index: number) => Promise + iteratee: (value: T, index: number) => Promise ): Promise { if (!Array.isArray(array) || !array?.length) return false; for (let index = 0; index < array.length; index++) { const element = array[index]; - const result = await iterator(element, index); + const result = await iteratee(element, index); if (result) { return true; } diff --git a/test/every.test.ts b/test/every.test.ts index 073b2dd..39dba74 100644 --- a/test/every.test.ts +++ b/test/every.test.ts @@ -2,117 +2,114 @@ import { every } from "index"; import { describe, it, expect } from "vitest"; describe("every tests", () => { - describe("isTrue", () => { - it("array of numbers", async () => { - const numbers: number[] = [5, 5, 5, 5, 5]; - const arrResult: boolean = numbers.every((number) => number === 5); - const asyncResult: boolean = await every( - numbers, - async (number) => number === 5 - ); - expect(asyncResult).toBe(true); - expect(arrResult).toEqual(asyncResult); - }); + describe("handles different data types", () => { + describe("truthy", () => { + it("array of numbers", async () => { + const numbers = [5, 5, 5, 5, 5]; + const arrResult = numbers.every((number) => number === 5); + const asyncResult = await every( + numbers, + async (number) => number === 5 + ); + expect(asyncResult).toBe(true); + expect(arrResult).toEqual(asyncResult); + }); - it("array of strings", async () => { - const strings: string[] = ["e", "e", "e", "e", "e"]; - const arrResult: boolean = strings.every((s) => s === "e"); - const asyncResult: boolean = await every(strings, async (s) => s === "e"); - expect(asyncResult).toBe(true); - expect(arrResult).toEqual(asyncResult); - }); + it("array of strings", async () => { + const strings = ["e", "e", "e", "e", "e"]; + const arrResult = strings.every((s) => s === "e"); + const asyncResult = await every(strings, async (s) => s === "e"); + expect(asyncResult).toBe(true); + expect(arrResult).toEqual(asyncResult); + }); - it("array of booleans", async () => { - const objects: boolean[] = [true, true, true, true, true]; - const arrResult: boolean = objects.every((bool) => bool); - const asyncResult: boolean = await every(objects, async (bool) => bool); - expect(asyncResult).toBe(true); - expect(arrResult).toEqual(asyncResult); - }); + it("array of booleans", async () => { + const objects = [true, true, true, true, true]; + const arrResult = objects.every((bool) => bool); + const asyncResult = await every(objects, async (bool) => bool); + expect(asyncResult).toBe(true); + expect(arrResult).toEqual(asyncResult); + }); - it("array of objects", async () => { - const objects: { val: string }[] = [ - { val: "e" }, - { val: "e" }, - { val: "e" }, - { val: "e" }, - { val: "e" }, - ]; - const arrResult: boolean = objects.every((obj) => obj.val === "e"); - const asyncResult: boolean = await every( - objects, - async (obj) => obj.val === "e" - ); - expect(asyncResult).toBe(true); - expect(arrResult).toEqual(asyncResult); - }); - }); - describe("isFalse", () => { - it("array of numbers", async () => { - const numbers: number[] = [1, 2, 3, 4, 5]; - const arrResult: boolean = numbers.every((number) => number === 5); - const asyncResult: boolean = await every( - numbers, - async (number) => number === 5 - ); - expect(asyncResult).toBe(false); - expect(arrResult).toEqual(asyncResult); + it("array of objects", async () => { + const objects = [ + { val: "e" }, + { val: "e" }, + { val: "e" }, + { val: "e" }, + { val: "e" }, + ]; + const arrResult = objects.every((obj) => obj.val === "e"); + const asyncResult = await every( + objects, + async (obj) => obj.val === "e" + ); + expect(asyncResult).toBe(true); + expect(arrResult).toEqual(asyncResult); + }); }); - it("array of strings", async () => { - const strings: string[] = ["a", "b", "c", "d", "e"]; - const arrResult: boolean = strings.every((s) => s === "e"); - const asyncResult: boolean = await every(strings, async (s) => s === "e"); + describe("falsy", () => { + it("array of numbers", async () => { + const numbers = [1, 2, 3, 4, 5]; + const arrResult = numbers.every((number) => number === 5); + const asyncResult = await every( + numbers, + async (number) => number === 5 + ); + expect(asyncResult).toBe(false); + expect(arrResult).toEqual(asyncResult); + }); - expect(asyncResult).toBe(false); - expect(arrResult).toEqual(asyncResult); - }); + it("array of strings", async () => { + const strings = ["a", "b", "c", "d", "e"]; + const arrResult = strings.every((s) => s === "e"); + const asyncResult = await every(strings, async (s) => s === "e"); - it("array of booleans", async () => { - const objects: boolean[] = [false, false, false, false, true]; - const arrResult: boolean = objects.every((bool) => bool); - const asyncResult: boolean = await every(objects, async (bool) => bool); - expect(asyncResult).toBe(false); - expect(arrResult).toEqual(asyncResult); - }); + expect(asyncResult).toBe(false); + expect(arrResult).toEqual(asyncResult); + }); - it("array of objects", async () => { - const objects: { val: string }[] = [ - { val: "a" }, - { val: "b" }, - { val: "c" }, - { val: "d" }, - { val: "e" }, - ]; - const arrResult: boolean = objects.every((obj) => obj.val === "e"); - const asyncResult: boolean = await every( - objects, - async (obj) => obj.val === "e" - ); - expect(asyncResult).toBe(false); - expect(arrResult).toEqual(asyncResult); - }); + it("array of booleans", async () => { + const objects = [false, false, false, false, true]; + const arrResult = objects.every((bool) => bool); + const asyncResult = await every(objects, async (bool) => bool); + expect(asyncResult).toBe(false); + expect(arrResult).toEqual(asyncResult); + }); - it("array of undefineds", async () => { - const objects: any[] = [ - undefined, - undefined, - undefined, - undefined, - undefined, - ]; - const arrResult: boolean = objects.every((u) => u === "e"); - const asyncResult: boolean = await every(objects, async (u) => u === "e"); - expect(asyncResult).toBe(false); - expect(arrResult).toEqual(asyncResult); - }); + it("array of objects", async () => { + const objects = [ + { val: "a" }, + { val: "b" }, + { val: "c" }, + { val: "d" }, + { val: "e" }, + ]; + const arrResult = objects.every((obj) => obj.val === "e"); + const asyncResult = await every( + objects, + async (obj) => obj.val === "e" + ); + expect(asyncResult).toBe(false); + expect(arrResult).toEqual(asyncResult); + }); + + it("array of undefineds", async () => { + const objects = [undefined, undefined, undefined, undefined, undefined]; + const arrResult = objects.every((u) => u === "e"); + const asyncResult = await every(objects, async (u) => u === "e"); + expect(asyncResult).toBe(false); + expect(arrResult).toEqual(asyncResult); + }); - it("array of nulls", async () => { - const objects: any[] = [null, null, null, null, null]; - const arrResult: boolean = objects.every((n) => n === "e"); - const asyncResult: boolean = await every(objects, async (n) => n === "e"); - expect(asyncResult).toBe(false); - expect(arrResult).toEqual(asyncResult); + it("array of nulls", async () => { + const objects = [null, null, null, null, null]; + const arrResult = objects.every((n) => n === "e"); + const asyncResult = await every(objects, async (n) => n === "e"); + expect(asyncResult).toBe(false); + expect(arrResult).toEqual(asyncResult); + }); }); }); }); diff --git a/test/filter.test.ts b/test/filter.test.ts index 55abf54..09a2caa 100644 --- a/test/filter.test.ts +++ b/test/filter.test.ts @@ -2,77 +2,60 @@ import { filter } from "index"; import { describe, it, expect } from "vitest"; describe("filter tests", () => { - it("array of numbers", async () => { - const numbers: number[] = [1, 2, 3, 4, 5]; - const arrResult: number[] = numbers.filter((number) => number === 5); - const asyncResult: number[] = await filter( - numbers, - async (number) => number === 5 - ); - expect(arrResult).toEqual(asyncResult); - }); + describe("handles different data types", () => { + it("array of numbers", async () => { + const numbers = [1, 2, 3, 4, 5]; + const arrResult = numbers.filter((number) => number === 5); + const asyncResult = await filter(numbers, async (number) => number === 5); + expect(arrResult).toEqual(asyncResult); + }); - it("array of strings", async () => { - const strings: string[] = ["a", "b", "c", "d", "e"]; - const arrResult: string[] = strings.filter((s) => s === "e"); - const asyncResult: string[] = await filter(strings, async (s) => s === "e"); - expect(arrResult).toEqual(asyncResult); - }); + it("array of strings", async () => { + const strings = ["a", "b", "c", "d", "e"]; + const arrResult = strings.filter((s) => s === "e"); + const asyncResult = await filter(strings, async (s) => s === "e"); + expect(arrResult).toEqual(asyncResult); + }); - it("array of booleans", async () => { - const objects: boolean[] = [false, false, false, false, true]; - const arrResult: boolean[] = objects.filter((bool) => bool); - const asyncResult: boolean[] = await filter(objects, async (bool) => bool); - expect(arrResult).toEqual(asyncResult); - }); + it("array of booleans", async () => { + const objects = [false, false, false, false, true]; + const arrResult = objects.filter((bool) => bool); + const asyncResult = await filter(objects, async (bool) => bool); + expect(arrResult).toEqual(asyncResult); + }); - it("array of objects", async () => { - const objects: { val: string }[] = [ - { val: "a" }, - { val: "b" }, - { val: "c" }, - { val: "d" }, - { val: "e" }, - ]; - const arrResult: { val: string }[] = objects.filter( - (obj) => obj.val === "e" - ); - const asyncResult: { val: string }[] = await filter( - objects, - async (obj) => obj.val === "e" - ); - expect(arrResult).toEqual(asyncResult); - }); + it("array of objects", async () => { + const objects = [ + { val: "a" }, + { val: "b" }, + { val: "c" }, + { val: "d" }, + { val: "e" }, + ]; + const arrResult = objects.filter((obj) => obj.val === "e"); + const asyncResult = await filter(objects, async (obj) => obj.val === "e"); + expect(arrResult).toEqual(asyncResult); + }); - it("array of undefineds", async () => { - const objects: any[] = [ - undefined, - undefined, - undefined, - undefined, - undefined, - ]; - const arrResult: boolean[] = objects.filter((u) => u === "e"); - const asyncResult: boolean[] = await filter( - objects, - async (u) => u === "e" - ); - expect(arrResult).toEqual(asyncResult); - }); + it("array of undefineds", async () => { + const objects = [undefined, undefined, undefined, undefined, undefined]; + const arrResult = objects.filter((u) => u === "e"); + const asyncResult = await filter(objects, async (u) => u === "e"); + expect(arrResult).toEqual(asyncResult); + }); - it("array of nulls", async () => { - const objects: any[] = [null, null, null, null, null]; - const arrResult: any[] = objects.filter((n) => n === "e"); - const asyncResult: any[] = await filter(objects, async (n) => n === "e"); - expect(arrResult).toEqual(asyncResult); - }); + it("array of nulls", async () => { + const objects = [null, null, null, null, null]; + const arrResult = objects.filter((n) => n === "e"); + const asyncResult = await filter(objects, async (n) => n === "e"); + expect(arrResult).toEqual(asyncResult); + }); - it("non-boolean return value", async () => { - const numbers: number[] = [1, 2, 3, 4, 5]; - const arrResult: number[] = numbers.filter((n) => n * 2); - const asyncResult: number[] = await filter(numbers, async (n) => - Boolean(n * 2) - ); - expect(arrResult).toEqual(asyncResult); + it("non-boolean return value", async () => { + const numbers = [1, 2, 3, 4, 5]; + const arrResult = numbers.filter((n) => n * 2); + const asyncResult = await filter(numbers, async (n) => Boolean(n * 2)); + expect(arrResult).toEqual(asyncResult); + }); }); }); diff --git a/test/find.test.ts b/test/find.test.ts index 09a2436..ad624a3 100644 --- a/test/find.test.ts +++ b/test/find.test.ts @@ -2,141 +2,100 @@ import { find } from "index"; import { describe, it, expect } from "vitest"; describe("find tests", () => { - describe("truthy", () => { - it("array of numbers", async () => { - const numbers: number[] = [1, 2, 3, 4, 5]; - const arrResult: number | undefined = numbers.find( - (number) => number === 5 - ); - const asyncResult: number | undefined = await find( - numbers, - async (number) => number === 5 - ); - expect(asyncResult).toBe(5); - expect(arrResult).toEqual(asyncResult); - }); + describe("handles different data types", () => { + describe("finds value", () => { + it("array of numbers", async () => { + const numbers = [1, 2, 3, 4, 5]; + const arrResult = numbers.find((number) => number === 5); + const asyncResult = await find(numbers, async (number) => number === 5); + expect(asyncResult).toBe(5); + expect(arrResult).toEqual(asyncResult); + }); - it("array of strings", async () => { - const strings: string[] = ["a", "b", "c", "d", "e"]; - const arrResult: string | undefined = strings.find((s) => s === "e"); - const asyncResult: string | undefined = await find( - strings, - async (s) => s === "e" - ); - expect(asyncResult).toBe("e"); - expect(arrResult).toEqual(asyncResult); - }); + it("array of strings", async () => { + const strings = ["a", "b", "c", "d", "e"]; + const arrResult = strings.find((s) => s === "e"); + const asyncResult = await find(strings, async (s) => s === "e"); + expect(asyncResult).toBe("e"); + expect(arrResult).toEqual(asyncResult); + }); - it("array of booleans", async () => { - const objects: boolean[] = [false, false, false, false, true]; - const arrResult: boolean | undefined = objects.find((bool) => bool); - const asyncResult: boolean | undefined = await find( - objects, - async (bool) => bool - ); - expect(asyncResult).toBe(true); - expect(arrResult).toEqual(asyncResult); - }); + it("array of booleans", async () => { + const objects = [false, false, false, false, true]; + const arrResult = objects.find((bool) => bool); + const asyncResult = await find(objects, async (bool) => bool); + expect(asyncResult).toBe(true); + expect(arrResult).toEqual(asyncResult); + }); - it("array of objects", async () => { - const objects: { val: string }[] = [ - { val: "a" }, - { val: "b" }, - { val: "c" }, - { val: "d" }, - { val: "e" }, - ]; - const arrResult: { val: string } | undefined = objects.find( - (obj) => obj.val === "e" - ); - const asyncResult: { val: string } | undefined = await find( - objects, - async (obj) => obj.val === "e" - ); - expect(asyncResult).toEqual(expect.objectContaining({ val: "e" })); - expect(arrResult).toEqual(asyncResult); - }); - }); - describe("falsy", () => { - it("array of numbers", async () => { - const numbers: number[] = [1, 2, 3, 4]; - const arrResult: number | undefined = numbers.find( - (number) => number === 5 - ); - const asyncResult: number | undefined = await find( - numbers, - async (number) => number === 5 - ); - expect(asyncResult).toBe(undefined); - expect(arrResult).toEqual(asyncResult); + it("array of objects", async () => { + const objects = [ + { val: "a" }, + { val: "b" }, + { val: "c" }, + { val: "d" }, + { val: "e" }, + ]; + const arrResult = objects.find((obj) => obj.val === "e"); + const asyncResult = await find(objects, async (obj) => obj.val === "e"); + expect(asyncResult).toEqual(expect.objectContaining({ val: "e" })); + expect(arrResult).toEqual(asyncResult); + }); }); - it("array of strings", async () => { - const strings: string[] = ["a", "b", "c", "d"]; - const arrResult: string | undefined = strings.find((s) => s === "e"); - const asyncResult: string | undefined = await find( - strings, - async (s) => s === "e" - ); - expect(asyncResult).toBe(undefined); - expect(arrResult).toEqual(asyncResult); - }); + describe("does not find value", () => { + it("array of numbers", async () => { + const numbers = [1, 2, 3, 4]; + const arrResult = numbers.find((number) => number === 5); + const asyncResult = await find(numbers, async (number) => number === 5); + expect(asyncResult).toBe(undefined); + expect(arrResult).toEqual(asyncResult); + }); - it("array of booleans", async () => { - const objects: boolean[] = [false, false, false, false]; - const arrResult: boolean | undefined = objects.find((bool) => bool); - const asyncResult: boolean | undefined = await find( - objects, - async (bool) => bool - ); - expect(asyncResult).toBe(undefined); - expect(arrResult).toEqual(asyncResult); - }); + it("array of strings", async () => { + const strings = ["a", "b", "c", "d"]; + const arrResult = strings.find((s) => s === "e"); + const asyncResult = await find(strings, async (s) => s === "e"); + expect(asyncResult).toBe(undefined); + expect(arrResult).toEqual(asyncResult); + }); - it("array of objects", async () => { - const objects: { val: string }[] = [ - { val: "a" }, - { val: "b" }, - { val: "c" }, - { val: "d" }, - ]; - const arrResult: { val: string } | undefined = objects.find( - (obj) => obj.val === "e" - ); - const asyncResult: { val: string } | undefined = await find( - objects, - async (obj) => obj.val === "e" - ); - expect(asyncResult).toBe(undefined); - expect(arrResult).toEqual(asyncResult); - }); + it("array of booleans", async () => { + const objects = [false, false, false, false]; + const arrResult = objects.find((bool) => bool); + const asyncResult = await find(objects, async (bool) => bool); + expect(asyncResult).toBe(undefined); + expect(arrResult).toEqual(asyncResult); + }); - it("array of undefineds", async () => { - const objects: any[] = [ - undefined, - undefined, - undefined, - undefined, - undefined, - ]; - const arrResult: any | undefined = objects.find((u) => u === "e"); - const asyncResult: any | undefined = await find( - objects, - async (u) => u === "e" - ); - expect(asyncResult).toBe(undefined); - expect(arrResult).toEqual(asyncResult); - }); + it("array of objects", async () => { + const objects = [ + { val: "a" }, + { val: "b" }, + { val: "c" }, + { val: "d" }, + ]; + const arrResult = objects.find((obj) => obj.val === "e"); + const asyncResult = await find(objects, async (obj) => obj.val === "e"); + expect(asyncResult).toBe(undefined); + expect(arrResult).toEqual(asyncResult); + }); + + it("array of undefineds", async () => { + const objects = [undefined, undefined, undefined, undefined, undefined]; + const arrResult = objects.find((u) => u === "e"); + const asyncResult = await find(objects, async (u) => u === "e"); + expect(asyncResult).toBe(undefined); + expect(arrResult).toEqual(asyncResult); + }); - it("array of nulls", async () => { - const objects: any[] = [null, null, null, null, null]; - const arrResult: any | undefined = objects.find((n) => n === "e"); - const asyncResult: any | undefined = await find( - objects, - async (n) => n === "e" - ); - expect(asyncResult).toBe(undefined); - expect(arrResult).toEqual(asyncResult); + it("array of nulls", async () => { + const objects = [null, null, null, null, null]; + const arrResult = objects.find((n) => n === "e"); + const asyncResult = await find(objects, async (n) => n === "e"); + expect(asyncResult).toBe(undefined); + expect(arrResult).toEqual(asyncResult); + }); }); }); }); diff --git a/test/findIndex.test.ts b/test/findIndex.test.ts index f6f7c4e..da056ff 100644 --- a/test/findIndex.test.ts +++ b/test/findIndex.test.ts @@ -2,11 +2,112 @@ import { findIndex } from "index"; import { describe, it, expect } from "vitest"; describe("findIndex tests", () => { - describe("truthy", () => { - it("", async () => {}); - }); + describe("handles different data types", () => { + describe("finds index of value", () => { + it("array of numbers", async () => { + const numbers = [1, 2, 3, 4, 5]; + const arrResult = numbers.findIndex((number) => number === 5); + const asyncResult = await findIndex( + numbers, + async (number) => number === 5 + ); + expect(asyncResult).toBe(4); + expect(arrResult).toEqual(asyncResult); + }); + + it("array of strings", async () => { + const strings = ["a", "b", "c", "d", "e"]; + const arrResult = strings.findIndex((s) => s === "e"); + const asyncResult = await findIndex(strings, async (s) => s === "e"); + expect(asyncResult).toBe(4); + expect(arrResult).toEqual(asyncResult); + }); + + it("array of booleans", async () => { + const objects = [false, false, false, false, true]; + const arrResult = objects.findIndex((bool) => bool); + const asyncResult = await findIndex(objects, async (bool) => bool); + expect(asyncResult).toBe(4); + expect(arrResult).toEqual(asyncResult); + }); + + it("array of objects", async () => { + const objects = [ + { val: "a" }, + { val: "b" }, + { val: "c" }, + { val: "d" }, + { val: "e" }, + ]; + const arrResult = objects.findIndex((obj) => obj.val === "e"); + const asyncResult = await findIndex( + objects, + async (obj) => obj.val === "e" + ); + expect(asyncResult).toEqual(4); + expect(arrResult).toEqual(asyncResult); + }); + }); + + describe("does not find index of value", () => { + it("array of numbers", async () => { + const numbers = [1, 2, 3, 4]; + const arrResult = numbers.findIndex((number) => number === 5); + const asyncResult = await findIndex( + numbers, + async (number) => number === 5 + ); + expect(asyncResult).toBe(-1); + expect(arrResult).toEqual(asyncResult); + }); + + it("array of strings", async () => { + const strings = ["a", "b", "c", "d"]; + const arrResult = strings.findIndex((s) => s === "e"); + const asyncResult = await findIndex(strings, async (s) => s === "e"); + expect(asyncResult).toBe(-1); + expect(arrResult).toEqual(asyncResult); + }); + + it("array of booleans", async () => { + const objects = [false, false, false, false]; + const arrResult = objects.findIndex((bool) => bool); + const asyncResult = await findIndex(objects, async (bool) => bool); + expect(asyncResult).toBe(-1); + expect(arrResult).toEqual(asyncResult); + }); + + it("array of objects", async () => { + const objects = [ + { val: "a" }, + { val: "b" }, + { val: "c" }, + { val: "d" }, + ]; + const arrResult = objects.findIndex((obj) => obj.val === "e"); + const asyncResult = await findIndex( + objects, + async (obj) => obj.val === "e" + ); + expect(asyncResult).toBe(-1); + expect(arrResult).toEqual(asyncResult); + }); + + it("array of undefineds", async () => { + const objects = [undefined, undefined, undefined, undefined, undefined]; + const arrResult = objects.findIndex((u) => u === "e"); + const asyncResult = await findIndex(objects, async (u) => u === "e"); + expect(asyncResult).toBe(-1); + expect(arrResult).toEqual(asyncResult); + }); - describe("falsy", () => { - it("", async () => {}); + it("array of nulls", async () => { + const objects = [null, null, null, null, null]; + const arrResult = objects.findIndex((n) => n === "e"); + const asyncResult = await findIndex(objects, async (n) => n === "e"); + expect(asyncResult).toBe(-1); + expect(arrResult).toEqual(asyncResult); + }); + }); }); }); diff --git a/test/findLast.test.ts b/test/findLast.test.ts index 01b4958..0978c25 100644 --- a/test/findLast.test.ts +++ b/test/findLast.test.ts @@ -1,12 +1,113 @@ import { findLast } from "index"; import { describe, it, expect } from "vitest"; -describe("findLast tests", () => { - describe("truthy", () => { - it("", async () => {}); - }); +describe("find tests", () => { + describe("handles different data types", () => { + describe("finds value", () => { + it("array of numbers", async () => { + const numbers = [1, 2, 3, 4, 5]; + const arrResult = numbers.findLast((number) => number === 5); + const asyncResult = await findLast( + numbers, + async (number) => number === 5 + ); + expect(asyncResult).toBe(5); + expect(arrResult).toEqual(asyncResult); + }); + + it("array of strings", async () => { + const strings = ["a", "b", "c", "d", "e"]; + const arrResult = strings.findLast((s) => s === "e"); + const asyncResult = await findLast(strings, async (s) => s === "e"); + expect(asyncResult).toBe("e"); + expect(arrResult).toEqual(asyncResult); + }); + + it("array of booleans", async () => { + const objects = [false, false, false, false, true]; + const arrResult = objects.findLast((bool) => bool); + const asyncResult = await findLast(objects, async (bool) => bool); + expect(asyncResult).toBe(true); + expect(arrResult).toEqual(asyncResult); + }); + + it("array of objects", async () => { + const objects = [ + { val: "a" }, + { val: "b" }, + { val: "c" }, + { val: "d" }, + { val: "e" }, + ]; + const arrResult = objects.findLast((obj) => obj.val === "e"); + const asyncResult = await findLast( + objects, + async (obj) => obj.val === "e" + ); + expect(asyncResult).toEqual(expect.objectContaining({ val: "e" })); + expect(arrResult).toEqual(asyncResult); + }); + }); + + describe("does not find value", () => { + it("array of numbers", async () => { + const numbers = [1, 2, 3, 4]; + const arrResult = numbers.findLast((number) => number === 5); + const asyncResult = await findLast( + numbers, + async (number) => number === 5 + ); + expect(asyncResult).toBe(undefined); + expect(arrResult).toEqual(asyncResult); + }); + + it("array of strings", async () => { + const strings = ["a", "b", "c", "d"]; + const arrResult = strings.findLast((s) => s === "e"); + const asyncResult = await findLast(strings, async (s) => s === "e"); + expect(asyncResult).toBe(undefined); + expect(arrResult).toEqual(asyncResult); + }); + + it("array of booleans", async () => { + const objects = [false, false, false, false]; + const arrResult = objects.findLast((bool) => bool); + const asyncResult = await findLast(objects, async (bool) => bool); + expect(asyncResult).toBe(undefined); + expect(arrResult).toEqual(asyncResult); + }); + + it("array of objects", async () => { + const objects = [ + { val: "a" }, + { val: "b" }, + { val: "c" }, + { val: "d" }, + ]; + const arrResult = objects.findLast((obj) => obj.val === "e"); + const asyncResult = await findLast( + objects, + async (obj) => obj.val === "e" + ); + expect(asyncResult).toBe(undefined); + expect(arrResult).toEqual(asyncResult); + }); + + it("array of undefineds", async () => { + const objects = [undefined, undefined, undefined, undefined, undefined]; + const arrResult = objects.findLast((u) => u === "e"); + const asyncResult = await findLast(objects, async (u) => u === "e"); + expect(asyncResult).toBe(undefined); + expect(arrResult).toEqual(asyncResult); + }); - describe("falsy", () => { - it("", async () => {}); + it("array of nulls", async () => { + const objects = [null, null, null, null, null]; + const arrResult = objects.findLast((n) => n === "e"); + const asyncResult = await findLast(objects, async (n) => n === "e"); + expect(asyncResult).toBe(undefined); + expect(arrResult).toEqual(asyncResult); + }); + }); }); }); diff --git a/test/findLastIndex.test.ts b/test/findLastIndex.test.ts index 50b2e14..77f90c9 100644 --- a/test/findLastIndex.test.ts +++ b/test/findLastIndex.test.ts @@ -1,12 +1,125 @@ import { findLastIndex } from "index"; import { describe, it, expect } from "vitest"; -describe("findLastIndex tests", () => { - describe("truthy", () => { - it("", async () => {}); - }); +describe("findIndex tests", () => { + describe("handles different data types", () => { + describe("finds index of value", () => { + it("array of numbers", async () => { + const numbers = [1, 2, 3, 4, 5]; + const arrResult = numbers.findLastIndex((number) => number === 5); + const asyncResult = await findLastIndex( + numbers, + async (number) => number === 5 + ); + expect(asyncResult).toBe(4); + expect(arrResult).toEqual(asyncResult); + }); + + it("array of strings", async () => { + const strings = ["a", "b", "c", "d", "e"]; + const arrResult = strings.findLastIndex((s) => s === "e"); + const asyncResult = await findLastIndex( + strings, + async (s) => s === "e" + ); + expect(asyncResult).toBe(4); + expect(arrResult).toEqual(asyncResult); + }); + + it("array of booleans", async () => { + const objects = [false, false, false, false, true]; + const arrResult = objects.findLastIndex((bool) => bool); + const asyncResult = await findLastIndex(objects, async (bool) => bool); + expect(asyncResult).toBe(4); + expect(arrResult).toEqual(asyncResult); + }); + + it("array of objects", async () => { + const objects = [ + { val: "a" }, + { val: "b" }, + { val: "c" }, + { val: "d" }, + { val: "e" }, + ]; + const arrResult = objects.findLastIndex((obj) => obj.val === "e"); + const asyncResult = await findLastIndex( + objects, + async (obj) => obj.val === "e" + ); + expect(asyncResult).toEqual(4); + expect(arrResult).toEqual(asyncResult); + }); + }); + + describe("does not find index of value", () => { + it("array of numbers", async () => { + const numbers = [1, 2, 3, 4]; + const arrResult = numbers.findLastIndex((number) => number === 5); + const asyncResult = await findLastIndex( + numbers, + async (number) => number === 5 + ); + expect(asyncResult).toBe(-1); + expect(arrResult).toEqual(asyncResult); + }); + + it("array of strings", async () => { + const strings = ["a", "b", "c", "d"]; + const arrResult = strings.findLastIndex((s) => s === "e"); + const asyncResult = await findLastIndex( + strings, + async (s) => s === "e" + ); + expect(asyncResult).toBe(-1); + expect(arrResult).toEqual(asyncResult); + }); + + it("array of booleans", async () => { + const objects = [false, false, false, false]; + const arrResult = objects.findLastIndex((bool) => bool); + const asyncResult = await findLastIndex(objects, async (bool) => bool); + expect(asyncResult).toBe(-1); + expect(arrResult).toEqual(asyncResult); + }); + + it("array of objects", async () => { + const objects = [ + { val: "a" }, + { val: "b" }, + { val: "c" }, + { val: "d" }, + ]; + const arrResult = objects.findLastIndex((obj) => obj.val === "e"); + const asyncResult = await findLastIndex( + objects, + async (obj) => obj.val === "e" + ); + expect(asyncResult).toBe(-1); + expect(arrResult).toEqual(asyncResult); + }); + + it("array of undefineds", async () => { + const objects = [undefined, undefined, undefined, undefined, undefined]; + const arrResult = objects.findLastIndex((u) => u === "e"); + const asyncResult = await findLastIndex( + objects, + async (u) => u === "e" + ); + expect(asyncResult).toBe(-1); + expect(arrResult).toEqual(asyncResult); + }); - describe("falsy", () => { - it("", async () => {}); + it("array of nulls", async () => { + const objects = [null, null, null, null, null]; + const arrResult = objects.findLastIndex((n) => n === "e"); + const asyncResult = await findLastIndex( + objects, + async (n) => n === "e" + ); + expect(asyncResult).toBe(-1); + expect(arrResult).toEqual(asyncResult); + }); + }); }); }); diff --git a/test/mapParallel.test.ts b/test/mapParallel.test.ts index 013a7cd..9931288 100644 --- a/test/mapParallel.test.ts +++ b/test/mapParallel.test.ts @@ -2,7 +2,7 @@ import { mapParallel } from "index"; import { describe, it, expect } from "vitest"; describe("mapParallel tests", () => { - const numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]; + const numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]; const expectedDoubledNumbers = numbers.map((number) => number * 2); it("returns all values when passed a maxParallelBatchSize", async () => { diff --git a/test/reduce.test.ts b/test/reduce.test.ts index 13098fc..6b2e944 100644 --- a/test/reduce.test.ts +++ b/test/reduce.test.ts @@ -2,31 +2,27 @@ import { reduce } from "index"; import { describe, it, expect } from "vitest"; describe("reduce tests", () => { - it("array of numbers", async () => { - const numbers: number[] = [1, 2, 3, 4, 5]; - const arrResult: number = numbers.reduce( - (prev, current) => prev + current, - 0 - ); - const asyncResult: number = await reduce( - numbers, - async (prev, current) => prev + current, - 0 - ); - expect(arrResult).toEqual(asyncResult); - }); + describe("handles different data types", () => { + it("array of numbers", async () => { + const numbers = [1, 2, 3, 4, 5]; + const arrResult = numbers.reduce((prev, current) => prev + current, 0); + const asyncResult = await reduce( + numbers, + async (prev, current) => prev + current, + 0 + ); + expect(arrResult).toEqual(asyncResult); + }); - it("array of strings", async () => { - const strings: string[] = ["a", "b", "c", "d", "e"]; - const arrResult: string = strings.reduce( - (prev, current) => prev + current, - "" - ); - const asyncResult: string = await reduce( - strings, - async (prev, current) => prev + current, - "" - ); - expect(arrResult).toEqual(asyncResult); + it("array of strings", async () => { + const strings = ["a", "b", "c", "d", "e"]; + const arrResult = strings.reduce((prev, current) => prev + current, ""); + const asyncResult = await reduce( + strings, + async (prev, current) => prev + current, + "" + ); + expect(arrResult).toEqual(asyncResult); + }); }); }); diff --git a/test/reduceRight.test.ts b/test/reduceRight.test.ts index 6116668..41d2efc 100644 --- a/test/reduceRight.test.ts +++ b/test/reduceRight.test.ts @@ -2,31 +2,33 @@ import { reduceRight } from "index"; import { describe, it, expect } from "vitest"; describe("reduceRight tests", () => { - it("array of numbers", async () => { - const numbers: number[] = [1, 2, 3, 4, 5]; - const arrResult: number = numbers.reduceRight( - (prev, current) => prev + current, - 0 - ); - const asyncResult: number = await reduceRight( - numbers, - async (prev, current) => prev + current, - 0 - ); - expect(arrResult).toEqual(asyncResult); - }); + describe("handles different data types", () => { + it("array of numbers", async () => { + const numbers = [1, 2, 3, 4, 5]; + const arrResult = numbers.reduceRight( + (prev, current) => prev + current, + 0 + ); + const asyncResult = await reduceRight( + numbers, + async (prev, current) => prev + current, + 0 + ); + expect(arrResult).toEqual(asyncResult); + }); - it("array of strings", async () => { - const strings: string[] = ["a", "b", "c", "d", "e"]; - const arrResult: string = strings.reduceRight( - (prev, current) => prev + current, - "" - ); - const asyncResult: string = await reduceRight( - strings, - async (prev, current) => prev + current, - "" - ); - expect(arrResult).toEqual(asyncResult); + it("array of strings", async () => { + const strings = ["a", "b", "c", "d", "e"]; + const arrResult = strings.reduceRight( + (prev, current) => prev + current, + "" + ); + const asyncResult = await reduceRight( + strings, + async (prev, current) => prev + current, + "" + ); + expect(arrResult).toEqual(asyncResult); + }); }); }); diff --git a/test/some.test.ts b/test/some.test.ts index 22f3e10..a24d63c 100644 --- a/test/some.test.ts +++ b/test/some.test.ts @@ -2,115 +2,99 @@ import { some } from "index"; import { describe, it, expect } from "vitest"; describe("some tests", () => { - describe("truthy", () => { - it("array of numbers", async () => { - const numbers: number[] = [1, 2, 3, 4, 5]; - const arrResult: boolean = numbers.some((number) => number === 5); - const asyncResult: boolean = await some( - numbers, - async (number) => number === 5 - ); - expect(asyncResult).toBe(true); - expect(arrResult).toEqual(asyncResult); - }); + describe("handles different data types", () => { + describe("truthy", () => { + it("array of numbers", async () => { + const numbers = [1, 2, 3, 4, 5]; + const arrResult = numbers.some((number) => number === 5); + const asyncResult = await some(numbers, async (number) => number === 5); + expect(asyncResult).toBe(true); + expect(arrResult).toEqual(asyncResult); + }); - it("array of strings", async () => { - const strings: string[] = ["a", "b", "c", "d", "e"]; - const arrResult: boolean = strings.some((s) => s === "e"); - const asyncResult: boolean = await some(strings, async (s) => s === "e"); - expect(asyncResult).toBe(true); - expect(arrResult).toEqual(asyncResult); - }); + it("array of strings", async () => { + const strings = ["a", "b", "c", "d", "e"]; + const arrResult = strings.some((s) => s === "e"); + const asyncResult = await some(strings, async (s) => s === "e"); + expect(asyncResult).toBe(true); + expect(arrResult).toEqual(asyncResult); + }); - it("array of booleans", async () => { - const objects: boolean[] = [false, false, false, false, true]; - const arrResult: boolean = objects.some((bool) => bool); - const asyncResult: boolean = await some(objects, async (bool) => bool); - expect(asyncResult).toBe(true); - expect(arrResult).toEqual(asyncResult); - }); + it("array of booleans", async () => { + const objects = [false, false, false, false, true]; + const arrResult = objects.some((bool) => bool); + const asyncResult = await some(objects, async (bool) => bool); + expect(asyncResult).toBe(true); + expect(arrResult).toEqual(asyncResult); + }); - it("array of objects", async () => { - const objects: { val: string }[] = [ - { val: "a" }, - { val: "b" }, - { val: "c" }, - { val: "d" }, - { val: "e" }, - ]; - const arrResult: boolean = objects.some((obj) => obj.val === "e"); - const asyncResult: boolean = await some( - objects, - async (obj) => obj.val === "e" - ); - expect(asyncResult).toBe(true); - expect(arrResult).toEqual(asyncResult); - }); - }); - describe("falsy", () => { - it("array of numbers", async () => { - const numbers: number[] = [1, 2, 3, 4]; - const arrResult: boolean = numbers.some((number) => number === 5); - const asyncResult: boolean = await some( - numbers, - async (number) => number === 5 - ); - expect(asyncResult).toBe(false); - expect(arrResult).toEqual(asyncResult); + it("array of objects", async () => { + const objects = [ + { val: "a" }, + { val: "b" }, + { val: "c" }, + { val: "d" }, + { val: "e" }, + ]; + const arrResult = objects.some((obj) => obj.val === "e"); + const asyncResult = await some(objects, async (obj) => obj.val === "e"); + expect(asyncResult).toBe(true); + expect(arrResult).toEqual(asyncResult); + }); }); + describe("falsy", () => { + it("array of numbers", async () => { + const numbers = [1, 2, 3, 4]; + const arrResult = numbers.some((number) => number === 5); + const asyncResult = await some(numbers, async (number) => number === 5); + expect(asyncResult).toBe(false); + expect(arrResult).toEqual(asyncResult); + }); - it("array of strings", async () => { - const strings: string[] = ["a", "b", "c", "d"]; - const arrResult: boolean = strings.some((s) => s === "e"); - const asyncResult: boolean = await some(strings, async (s) => s === "e"); - expect(asyncResult).toBe(false); - expect(arrResult).toEqual(asyncResult); - }); + it("array of strings", async () => { + const strings = ["a", "b", "c", "d"]; + const arrResult = strings.some((s) => s === "e"); + const asyncResult = await some(strings, async (s) => s === "e"); + expect(asyncResult).toBe(false); + expect(arrResult).toEqual(asyncResult); + }); - it("array of booleans", async () => { - const objects: boolean[] = [false, false, false, false]; - const arrResult: boolean = objects.some((bool) => bool); - const asyncResult: boolean = await some(objects, async (bool) => bool); - expect(asyncResult).toBe(false); - expect(arrResult).toEqual(asyncResult); - }); + it("array of booleans", async () => { + const objects = [false, false, false, false]; + const arrResult = objects.some((bool) => bool); + const asyncResult = await some(objects, async (bool) => bool); + expect(asyncResult).toBe(false); + expect(arrResult).toEqual(asyncResult); + }); - it("array of objects", async () => { - const objects: { val: string }[] = [ - { val: "a" }, - { val: "b" }, - { val: "c" }, - { val: "d" }, - ]; - const arrResult: boolean = objects.some((obj) => obj.val === "e"); - const asyncResult: boolean = await some( - objects, - async (obj) => obj.val === "e" - ); - expect(asyncResult).toBe(false); - expect(arrResult).toEqual(asyncResult); - }); + it("array of objects", async () => { + const objects = [ + { val: "a" }, + { val: "b" }, + { val: "c" }, + { val: "d" }, + ]; + const arrResult = objects.some((obj) => obj.val === "e"); + const asyncResult = await some(objects, async (obj) => obj.val === "e"); + expect(asyncResult).toBe(false); + expect(arrResult).toEqual(asyncResult); + }); - it("array of undefineds", async () => { - const objects: any[] = [ - undefined, - undefined, - undefined, - undefined, - undefined, - ]; - const arrResult: boolean = objects.some((u) => u === "e"); - const asyncResult: boolean = await some(objects, async (u) => u === "e"); - expect(asyncResult).toBe(false); - expect(arrResult).toEqual(asyncResult); - }); + it("array of undefineds", async () => { + const objects = [undefined, undefined, undefined, undefined, undefined]; + const arrResult = objects.some((u) => u === "e"); + const asyncResult = await some(objects, async (u) => u === "e"); + expect(asyncResult).toBe(false); + expect(arrResult).toEqual(asyncResult); + }); - it("array of nulls", async () => { - const objects: any[] = [null, null, null, null, null]; - const arrResult: boolean = objects.some((n) => n === "e"); - const asyncResult: boolean = await some(objects, async (n) => n === "e"); - expect(asyncResult).toBe(false); - expect(arrResult).toEqual(asyncResult); + it("array of nulls", async () => { + const objects = [null, null, null, null, null]; + const arrResult = objects.some((n) => n === "e"); + const asyncResult = await some(objects, async (n) => n === "e"); + expect(asyncResult).toBe(false); + expect(arrResult).toEqual(asyncResult); + }); }); }); }); diff --git a/tsconfig.json b/tsconfig.json index e1173bf..e81e08c 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -3,6 +3,7 @@ "baseUrl": ".", "outDir": "dist", "target": "ES2022", + "lib": ["ES2023", "DOM"], "module": "NodeNext", "moduleResolution": "nodenext", "esModuleInterop": true, diff --git a/yarn.lock b/yarn.lock index 1c15a7e..d8465a7 100644 --- a/yarn.lock +++ b/yarn.lock @@ -127,40 +127,126 @@ resolved "https://registry.yarnpkg.com/@esbuild/win32-x64/-/win32-x64-0.25.0.tgz#c8e119a30a7c8d60b9d2e22d2073722dde3b710b" integrity sha512-ZENoHJBxA20C2zFzh6AI4fT6RraMzjYw4xKWemRTRmRVtN9c5DcH9r/f2ihEkMjOW5eGgrwCslG/+Y/3bL+DHQ== -"@eslint/eslintrc@^1.0.2": - version "1.4.1" - resolved "https://registry.yarnpkg.com/@eslint/eslintrc/-/eslintrc-1.4.1.tgz#af58772019a2d271b7e2d4c23ff4ddcba3ccfb3e" - integrity sha512-XXrH9Uarn0stsyldqDYq8r++mROmWRI1xKMXa640Bb//SY1+ECYX6VzT6Lcx5frD0V30XieqJ0oX9I2Xj5aoMA== +"@eslint-community/eslint-utils@^4.2.0", "@eslint-community/eslint-utils@^4.4.0": + version "4.4.1" + resolved "https://registry.yarnpkg.com/@eslint-community/eslint-utils/-/eslint-utils-4.4.1.tgz#d1145bf2c20132d6400495d6df4bf59362fd9d56" + integrity sha512-s3O3waFUrMV8P/XaF/+ZTp1X9XBZW1a4B97ZnjQF2KYWaFD2A8KyFBsrsfSjEmjn3RGWAIuvlneuZm3CUK3jbA== + dependencies: + eslint-visitor-keys "^3.4.3" + +"@eslint-community/regexpp@^4.10.0", "@eslint-community/regexpp@^4.12.1": + version "4.12.1" + resolved "https://registry.yarnpkg.com/@eslint-community/regexpp/-/regexpp-4.12.1.tgz#cfc6cffe39df390a3841cde2abccf92eaa7ae0e0" + integrity sha512-CCZCDJuduB9OUkFkY2IgppNZMi2lBQgD2qzwXkEia16cge2pijY/aXi96CJMquDMn3nJdlPV1A5KrJEXwfLNzQ== + +"@eslint/config-array@^0.19.2": + version "0.19.2" + resolved "https://registry.yarnpkg.com/@eslint/config-array/-/config-array-0.19.2.tgz#3060b809e111abfc97adb0bb1172778b90cb46aa" + integrity sha512-GNKqxfHG2ySmJOBSHg7LxeUx4xpuCoFjacmlCoYWEbaPXLwvfIjixRI12xCQZeULksQb23uiA8F40w5TojpV7w== + dependencies: + "@eslint/object-schema" "^2.1.6" + debug "^4.3.1" + minimatch "^3.1.2" + +"@eslint/config-helpers@^0.1.0": + version "0.1.0" + resolved "https://registry.yarnpkg.com/@eslint/config-helpers/-/config-helpers-0.1.0.tgz#62f1b7821e9d9ced1b3f512c7ea731825765d1cc" + integrity sha512-kLrdPDJE1ckPo94kmPPf9Hfd0DU0Jw6oKYrhe+pwSC0iTUInmTa+w6fw8sGgcfkFJGNdWOUeOaDM4quW4a7OkA== + +"@eslint/core@^0.12.0": + version "0.12.0" + resolved "https://registry.yarnpkg.com/@eslint/core/-/core-0.12.0.tgz#5f960c3d57728be9f6c65bd84aa6aa613078798e" + integrity sha512-cmrR6pytBuSMTaBweKoGMwu3EiHiEC+DoyupPmlZ0HxBJBtIxwe+j/E4XPIKNx+Q74c8lXKPwYawBf5glsTkHg== + dependencies: + "@types/json-schema" "^7.0.15" + +"@eslint/eslintrc@^3.3.0": + version "3.3.0" + resolved "https://registry.yarnpkg.com/@eslint/eslintrc/-/eslintrc-3.3.0.tgz#96a558f45842989cca7ea1ecd785ad5491193846" + integrity sha512-yaVPAiNAalnCZedKLdR21GOGILMLKPyqSLWaAjQFvYA2i/ciDi8ArYVr69Anohb6cH2Ukhqti4aFnYyPm8wdwQ== dependencies: ajv "^6.12.4" debug "^4.3.2" - espree "^9.4.0" - globals "^13.19.0" + espree "^10.0.1" + globals "^14.0.0" ignore "^5.2.0" import-fresh "^3.2.1" js-yaml "^4.1.0" minimatch "^3.1.2" strip-json-comments "^3.1.1" -"@humanwhocodes/config-array@^0.6.0": - version "0.6.0" - resolved "https://registry.yarnpkg.com/@humanwhocodes/config-array/-/config-array-0.6.0.tgz#b5621fdb3b32309d2d16575456cbc277fa8f021a" - integrity sha512-JQlEKbcgEUjBFhLIF4iqM7u/9lwgHRBcpHrmUNCALK0Q3amXN6lxdoXLnF0sm11E9VqTmBALR87IlUg1bZ8A9A== +"@eslint/js@9.22.0", "@eslint/js@^9.22.0": + version "9.22.0" + resolved "https://registry.yarnpkg.com/@eslint/js/-/js-9.22.0.tgz#4ff53649ded7cbce90b444b494c234137fa1aa3d" + integrity sha512-vLFajx9o8d1/oL2ZkpMYbkLv8nDB6yaIwFNt7nI4+I80U/z03SxmfOMsLbvWr3p7C+Wnoh//aOu2pQW8cS0HCQ== + +"@eslint/object-schema@^2.1.6": + version "2.1.6" + resolved "https://registry.yarnpkg.com/@eslint/object-schema/-/object-schema-2.1.6.tgz#58369ab5b5b3ca117880c0f6c0b0f32f6950f24f" + integrity sha512-RBMg5FRL0I0gs51M/guSAj5/e14VQ4tpZnQNWwuDT66P14I43ItmPfIZRhO9fUVIPOAQXU47atlywZ/czoqFPA== + +"@eslint/plugin-kit@^0.2.7": + version "0.2.7" + resolved "https://registry.yarnpkg.com/@eslint/plugin-kit/-/plugin-kit-0.2.7.tgz#9901d52c136fb8f375906a73dcc382646c3b6a27" + integrity sha512-JubJ5B2pJ4k4yGxaNLdbjrnk9d/iDz6/q8wOilpIowd6PJPgaxCuHBnBszq7Ce2TyMrywm5r4PnKm6V3iiZF+g== dependencies: - "@humanwhocodes/object-schema" "^1.2.0" - debug "^4.1.1" - minimatch "^3.0.4" + "@eslint/core" "^0.12.0" + levn "^0.4.1" -"@humanwhocodes/object-schema@^1.2.0": - version "1.2.1" - resolved "https://registry.yarnpkg.com/@humanwhocodes/object-schema/-/object-schema-1.2.1.tgz#b520529ec21d8e5945a1851dfd1c32e94e39ff45" - integrity sha512-ZnQMnLV4e7hDlUvw8H+U8ASL02SS2Gn6+9Ac3wGGLIe7+je2AeAOxPY+izIPJDfFDb7eDjev0Us8MO1iFRN8hA== +"@humanfs/core@^0.19.1": + version "0.19.1" + resolved "https://registry.yarnpkg.com/@humanfs/core/-/core-0.19.1.tgz#17c55ca7d426733fe3c561906b8173c336b40a77" + integrity sha512-5DyQ4+1JEUzejeK1JGICcideyfUbGixgS9jNgex5nqkW+cY7WZhxBigmieN5Qnw9ZosSNVC9KQKyb+GUaGyKUA== + +"@humanfs/node@^0.16.6": + version "0.16.6" + resolved "https://registry.yarnpkg.com/@humanfs/node/-/node-0.16.6.tgz#ee2a10eaabd1131987bf0488fd9b820174cd765e" + integrity sha512-YuI2ZHQL78Q5HbhDiBA1X4LmYdXCKCMQIfw0pw7piHJwyREFebJUvrQN4cMssyES6x+vfUbx1CIpaQUKYdQZOw== + dependencies: + "@humanfs/core" "^0.19.1" + "@humanwhocodes/retry" "^0.3.0" + +"@humanwhocodes/module-importer@^1.0.1": + version "1.0.1" + resolved "https://registry.yarnpkg.com/@humanwhocodes/module-importer/-/module-importer-1.0.1.tgz#af5b2691a22b44be847b0ca81641c5fb6ad0172c" + integrity sha512-bxveV4V8v5Yb4ncFTT3rPSgZBOpCkjfK0y4oVVVJwIuDVBRMDXrPyXRL988i5ap9m9bnyEEjWfm5WkBmtffLfA== + +"@humanwhocodes/retry@^0.3.0": + version "0.3.1" + resolved "https://registry.yarnpkg.com/@humanwhocodes/retry/-/retry-0.3.1.tgz#c72a5c76a9fbaf3488e231b13dc52c0da7bab42a" + integrity sha512-JBxkERygn7Bv/GbN5Rv8Ul6LVknS+5Bp6RgDC/O8gEBU/yeH5Ui5C/OlWrTb6qct7LjjfT6Re2NxB0ln0yYybA== + +"@humanwhocodes/retry@^0.4.2": + version "0.4.2" + resolved "https://registry.yarnpkg.com/@humanwhocodes/retry/-/retry-0.4.2.tgz#1860473de7dfa1546767448f333db80cb0ff2161" + integrity sha512-xeO57FpIu4p1Ri3Jq/EXq4ClRm86dVF2z/+kvFnyqVYRavTZmaFaUBbWCOuuTh0o/g7DSsk6kc2vrS4Vl5oPOQ== "@jridgewell/sourcemap-codec@^1.5.0": version "1.5.0" resolved "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.5.0.tgz" integrity sha512-gv3ZRaISU3fjPAgNsriBRqGWQL6quFx04YMPW/zD8XMLsU32mhCCbfbO6KZFLjvYpCZ8zyDEgqsgf+PwPaM7GQ== +"@nodelib/fs.scandir@2.1.5": + version "2.1.5" + resolved "https://registry.yarnpkg.com/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz#7619c2eb21b25483f6d167548b4cfd5a7488c3d5" + integrity sha512-vq24Bq3ym5HEQm2NKCr3yXDwjc7vTsEThRDnkp2DK9p1uqLR+DHurm/NOTo0KG7HYHU7eppKZj3MyqYuMBf62g== + dependencies: + "@nodelib/fs.stat" "2.0.5" + run-parallel "^1.1.9" + +"@nodelib/fs.stat@2.0.5", "@nodelib/fs.stat@^2.0.2": + version "2.0.5" + resolved "https://registry.yarnpkg.com/@nodelib/fs.stat/-/fs.stat-2.0.5.tgz#5bd262af94e9d25bd1e71b05deed44876a222e8b" + integrity sha512-RkhPPp2zrqDAQA/2jNhnztcPAlv64XdhIp7a7454A5ovI7Bukxgt7MX7udwAu3zg1DcpPU0rz3VV1SeaqvY4+A== + +"@nodelib/fs.walk@^1.2.3": + version "1.2.8" + resolved "https://registry.yarnpkg.com/@nodelib/fs.walk/-/fs.walk-1.2.8.tgz#e95737e8bb6746ddedf69c556953494f196fe69a" + integrity sha512-oGB+UxlgWcgQkgwo8GcEGwemoTFt3FIO9ababBmaGwXIoBKZ+GTy0pP185beGg7Llih/NSHSV2XAs1lnznocSg== + dependencies: + "@nodelib/fs.scandir" "2.1.5" + fastq "^1.6.0" + "@rollup/rollup-android-arm-eabi@4.35.0": version "4.35.0" resolved "https://registry.yarnpkg.com/@rollup/rollup-android-arm-eabi/-/rollup-android-arm-eabi-4.35.0.tgz#e1d7700735f7e8de561ef7d1fa0362082a180c43" @@ -256,11 +342,97 @@ resolved "https://registry.yarnpkg.com/@rollup/rollup-win32-x64-msvc/-/rollup-win32-x64-msvc-4.35.0.tgz#05f25dbc9981bee1ae6e713daab10397044a46ca" integrity sha512-PIQeY5XDkrOysbQblSW7v3l1MDZzkTEzAfTPkj5VAu3FW8fS4ynyLg2sINp0fp3SjZ8xkRYpLqoKcYqAkhU1dw== -"@types/estree@1.0.6", "@types/estree@^1.0.0": +"@types/estree@1.0.6", "@types/estree@^1.0.0", "@types/estree@^1.0.6": version "1.0.6" resolved "https://registry.npmjs.org/@types/estree/-/estree-1.0.6.tgz" integrity sha512-AYnb1nQyY49te+VRAVgmzfcgjYS91mY5P0TKUDCLEM+gNnA+3T6rWITXRLYCpahpqSQbN5cE+gHpnPyXjHWxcw== +"@types/json-schema@^7.0.15": + version "7.0.15" + resolved "https://registry.yarnpkg.com/@types/json-schema/-/json-schema-7.0.15.tgz#596a1747233694d50f6ad8a7869fcb6f56cf5841" + integrity sha512-5+fP8P8MFNC+AyZCDxrB2pkZFPGzqQWUzpSeuuVLvm8VMcorNYavBqoFcxK8bQz4Qsbn4oUEEem4wDLfcysGHA== + +"@typescript-eslint/eslint-plugin@8.26.1": + version "8.26.1" + resolved "https://registry.yarnpkg.com/@typescript-eslint/eslint-plugin/-/eslint-plugin-8.26.1.tgz#3e48eb847924161843b092c87a9b65176b53782f" + integrity sha512-2X3mwqsj9Bd3Ciz508ZUtoQQYpOhU/kWoUqIf49H8Z0+Vbh6UF/y0OEYp0Q0axOGzaBGs7QxRwq0knSQ8khQNA== + dependencies: + "@eslint-community/regexpp" "^4.10.0" + "@typescript-eslint/scope-manager" "8.26.1" + "@typescript-eslint/type-utils" "8.26.1" + "@typescript-eslint/utils" "8.26.1" + "@typescript-eslint/visitor-keys" "8.26.1" + graphemer "^1.4.0" + ignore "^5.3.1" + natural-compare "^1.4.0" + ts-api-utils "^2.0.1" + +"@typescript-eslint/parser@8.26.1": + version "8.26.1" + resolved "https://registry.yarnpkg.com/@typescript-eslint/parser/-/parser-8.26.1.tgz#0e2f915a497519fc43f52cf2ecbfa607ff56f72e" + integrity sha512-w6HZUV4NWxqd8BdeFf81t07d7/YV9s7TCWrQQbG5uhuvGUAW+fq1usZ1Hmz9UPNLniFnD8GLSsDpjP0hm1S4lQ== + dependencies: + "@typescript-eslint/scope-manager" "8.26.1" + "@typescript-eslint/types" "8.26.1" + "@typescript-eslint/typescript-estree" "8.26.1" + "@typescript-eslint/visitor-keys" "8.26.1" + debug "^4.3.4" + +"@typescript-eslint/scope-manager@8.26.1": + version "8.26.1" + resolved "https://registry.yarnpkg.com/@typescript-eslint/scope-manager/-/scope-manager-8.26.1.tgz#5e6ad0ac258ccf79462e91c3f43a3f1f7f31a6cc" + integrity sha512-6EIvbE5cNER8sqBu6V7+KeMZIC1664d2Yjt+B9EWUXrsyWpxx4lEZrmvxgSKRC6gX+efDL/UY9OpPZ267io3mg== + dependencies: + "@typescript-eslint/types" "8.26.1" + "@typescript-eslint/visitor-keys" "8.26.1" + +"@typescript-eslint/type-utils@8.26.1": + version "8.26.1" + resolved "https://registry.yarnpkg.com/@typescript-eslint/type-utils/-/type-utils-8.26.1.tgz#462f0bae09de72ac6e8e1af2ebe588c23224d7f8" + integrity sha512-Kcj/TagJLwoY/5w9JGEFV0dclQdyqw9+VMndxOJKtoFSjfZhLXhYjzsQEeyza03rwHx2vFEGvrJWJBXKleRvZg== + dependencies: + "@typescript-eslint/typescript-estree" "8.26.1" + "@typescript-eslint/utils" "8.26.1" + debug "^4.3.4" + ts-api-utils "^2.0.1" + +"@typescript-eslint/types@8.26.1": + version "8.26.1" + resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-8.26.1.tgz#d5978721670cff263348d5062773389231a64132" + integrity sha512-n4THUQW27VmQMx+3P+B0Yptl7ydfceUj4ON/AQILAASwgYdZ/2dhfymRMh5egRUrvK5lSmaOm77Ry+lmXPOgBQ== + +"@typescript-eslint/typescript-estree@8.26.1": + version "8.26.1" + resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-8.26.1.tgz#eb0e4ce31753683d83be53441a409fd5f0b34afd" + integrity sha512-yUwPpUHDgdrv1QJ7YQal3cMVBGWfnuCdKbXw1yyjArax3353rEJP1ZA+4F8nOlQ3RfS2hUN/wze3nlY+ZOhvoA== + dependencies: + "@typescript-eslint/types" "8.26.1" + "@typescript-eslint/visitor-keys" "8.26.1" + debug "^4.3.4" + fast-glob "^3.3.2" + is-glob "^4.0.3" + minimatch "^9.0.4" + semver "^7.6.0" + ts-api-utils "^2.0.1" + +"@typescript-eslint/utils@8.26.1": + version "8.26.1" + resolved "https://registry.yarnpkg.com/@typescript-eslint/utils/-/utils-8.26.1.tgz#54cc58469955f25577f659753b71a0e117a0539f" + integrity sha512-V4Urxa/XtSUroUrnI7q6yUTD3hDtfJ2jzVfeT3VK0ciizfK2q/zGC0iDh1lFMUZR8cImRrep6/q0xd/1ZGPQpg== + dependencies: + "@eslint-community/eslint-utils" "^4.4.0" + "@typescript-eslint/scope-manager" "8.26.1" + "@typescript-eslint/types" "8.26.1" + "@typescript-eslint/typescript-estree" "8.26.1" + +"@typescript-eslint/visitor-keys@8.26.1": + version "8.26.1" + resolved "https://registry.yarnpkg.com/@typescript-eslint/visitor-keys/-/visitor-keys-8.26.1.tgz#c5267fcc82795cf10280363023837deacad2647c" + integrity sha512-AjOC3zfnxd6S4Eiy3jwktJPclqhFHNyd8L6Gycf9WUPoKZpgM5PjkxY1X7uSy61xVpiJDhhk7XT2NVsN3ALTWg== + dependencies: + "@typescript-eslint/types" "8.26.1" + eslint-visitor-keys "^4.2.0" + "@vitest/expect@3.0.8": version "3.0.8" resolved "https://registry.npmjs.org/@vitest/expect/-/expect-3.0.8.tgz" @@ -325,12 +497,12 @@ acorn-jsx@^5.3.2: resolved "https://registry.npmjs.org/acorn-jsx/-/acorn-jsx-5.3.2.tgz" integrity sha512-rq9s+JNhf0IChjtDXxllJ7g41oZk5SlXtp0LHwyA5cejwn7vKmKp4pPri6YEePv2PU65sAsegbXtIinmDFDXgQ== -acorn@^8.9.0: +acorn@^8.14.0: version "8.14.1" resolved "https://registry.yarnpkg.com/acorn/-/acorn-8.14.1.tgz#721d5dc10f7d5b5609a891773d47731796935dfb" integrity sha512-OvQ/2pUDKmgfCg++xsTX1wGxfTaszcHVcTctW4UJB4hibJx2HXxxO5UmVgyjMa+ZDsiaf5wWLXYpRWMmBI0QHg== -ajv@^6.10.0, ajv@^6.12.4: +ajv@^6.12.4: version "6.12.6" resolved "https://registry.yarnpkg.com/ajv/-/ajv-6.12.6.tgz#baf5a62e802b07d977034586f8c3baf5adf26df4" integrity sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g== @@ -340,16 +512,6 @@ ajv@^6.10.0, ajv@^6.12.4: json-schema-traverse "^0.4.1" uri-js "^4.2.2" -ansi-colors@^4.1.1: - version "4.1.3" - resolved "https://registry.yarnpkg.com/ansi-colors/-/ansi-colors-4.1.3.tgz#37611340eb2243e70cc604cad35d63270d48781b" - integrity sha512-/6w/C21Pm1A7aZitlI5Ni/2J6FFQN8i1Cvz3kHABAAbw93v/NlvKdVOqz7CCWz/3iv/JplRSEEZ83XION15ovw== - -ansi-regex@^5.0.1: - version "5.0.1" - resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-5.0.1.tgz#082cb2c89c9fe8659a311a53bd6a4dc5301db304" - integrity sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ== - ansi-styles@^4.1.0: version "4.3.0" resolved "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz" @@ -380,6 +542,20 @@ brace-expansion@^1.1.7: balanced-match "^1.0.0" concat-map "0.0.1" +brace-expansion@^2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/brace-expansion/-/brace-expansion-2.0.1.tgz#1edc459e0f0c548486ecf9fc99f2221364b9a0ae" + integrity sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA== + dependencies: + balanced-match "^1.0.0" + +braces@^3.0.3: + version "3.0.3" + resolved "https://registry.yarnpkg.com/braces/-/braces-3.0.3.tgz#490332f40919452272d55a8480adc0c441358789" + integrity sha512-yQbXgO/OSZVD2IsiLlro+7Hf6Q18EJrKSEsdoMzKePKXct3gvD8oLcOQdIzGupr5Fj+EDe8gO/lxc1BzfMpxvA== + dependencies: + fill-range "^7.1.1" + cac@^6.7.14: version "6.7.14" resolved "https://registry.npmjs.org/cac/-/cac-6.7.14.tgz" @@ -431,7 +607,7 @@ concat-map@0.0.1: resolved "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz" integrity sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg== -cross-spawn@^7.0.2: +cross-spawn@^7.0.6: version "7.0.6" resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-7.0.6.tgz#8a58fe78f00dcd70c370451759dfbfaf03e8ee9f" integrity sha512-uV2QOWP2nWzsy2aMp8aRibhi9dlzF5Hgh5SHaB9OiTGEyDTiJJyx0uy51QXdyWbtAHNua4XJzUKca3OzKUd3vA== @@ -440,7 +616,7 @@ cross-spawn@^7.0.2: shebang-command "^2.0.0" which "^2.0.1" -debug@^4.1.1, debug@^4.3.2, debug@^4.4.0: +debug@^4.3.1, debug@^4.3.2, debug@^4.3.4, debug@^4.4.0: version "4.4.0" resolved "https://registry.npmjs.org/debug/-/debug-4.4.0.tgz" integrity sha512-6WTZ/IxCY/T6BALoZHaE4ctp9xm+Z5kY/pzYaCHRFeyVhojxlrm+46y68HA6hr0TcwEssoxNiDEUJQjfPZ/RYA== @@ -457,21 +633,6 @@ deep-is@^0.1.3: resolved "https://registry.npmjs.org/deep-is/-/deep-is-0.1.4.tgz" integrity sha512-oIPzksmTg4/MriiaYGO+okXDT7ztn/w3Eptv/+gSIdMdKsJo0u4CfYNFJPy+4SKMuCqGw2wxnA+URMg3t8a/bQ== -doctrine@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/doctrine/-/doctrine-3.0.0.tgz#addebead72a6574db783639dc87a121773973961" - integrity sha512-yS+Q5i3hBf7GBkd4KG8a7eBNNWNGLTaEwwYWUijIYM7zrlYDM0BFXHjjPWlWZ1Rg7UaddZeIDmi9jF3HmqiQ2w== - dependencies: - esutils "^2.0.2" - -enquirer@^2.3.5: - version "2.4.1" - resolved "https://registry.yarnpkg.com/enquirer/-/enquirer-2.4.1.tgz#93334b3fbd74fc7097b224ab4a8fb7e40bf4ae56" - integrity sha512-rRqJg/6gd538VHvR3PSrdRBb/1Vy2YfzHqzvbhGIQpDRKIa4FgV/54b5Q1xYSxOOwKvjXweS26E0Q+nAMwp2pQ== - dependencies: - ansi-colors "^4.1.1" - strip-ansi "^6.0.1" - es-module-lexer@^1.6.0: version "1.6.0" resolved "https://registry.npmjs.org/es-module-lexer/-/es-module-lexer-1.6.0.tgz" @@ -513,85 +674,75 @@ escape-string-regexp@^4.0.0: resolved "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz" integrity sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA== -eslint-scope@^6.0.0: - version "6.0.0" - resolved "https://registry.yarnpkg.com/eslint-scope/-/eslint-scope-6.0.0.tgz#9cf45b13c5ac8f3d4c50f46a5121f61b3e318978" - integrity sha512-uRDL9MWmQCkaFus8RF5K9/L/2fn+80yoW3jkD53l4shjCh26fCtvJGasxjUqP5OT87SYTxCVA3BwTUzuELx9kA== +eslint-scope@^8.3.0: + version "8.3.0" + resolved "https://registry.yarnpkg.com/eslint-scope/-/eslint-scope-8.3.0.tgz#10cd3a918ffdd722f5f3f7b5b83db9b23c87340d" + integrity sha512-pUNxi75F8MJ/GdeKtVLSbYg4ZI34J6C0C7sbL4YOp2exGwen7ZsuBqKzUhXd0qMQ362yET3z+uPwKeg/0C2XCQ== dependencies: esrecurse "^4.3.0" estraverse "^5.2.0" -eslint-utils@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/eslint-utils/-/eslint-utils-3.0.0.tgz#8aebaface7345bb33559db0a1f13a1d2d48c3672" - integrity sha512-uuQC43IGctw68pJA1RgbQS8/NP7rch6Cwd4j3ZBtgo4/8Flj4eGE7ZYSZRN3iq5pVUv6GPdW5Z1RFleo84uLDA== - dependencies: - eslint-visitor-keys "^2.0.0" - -eslint-visitor-keys@^2.0.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/eslint-visitor-keys/-/eslint-visitor-keys-2.1.0.tgz#f65328259305927392c938ed44eb0a5c9b2bd303" - integrity sha512-0rSmRBzXgDzIsD6mGdJgevzgezI534Cer5L/vyMX0kHzT/jiB43jRhd9YUlMGYLQy2zprNmoT8qasCGtY+QaKw== - -eslint-visitor-keys@^3.0.0, eslint-visitor-keys@^3.4.1: +eslint-visitor-keys@^3.4.3: version "3.4.3" resolved "https://registry.yarnpkg.com/eslint-visitor-keys/-/eslint-visitor-keys-3.4.3.tgz#0cd72fe8550e3c2eae156a96a4dddcd1c8ac5800" integrity sha512-wpc+LXeiyiisxPlEkUzU6svyS1frIO3Mgxj1fdy7Pm8Ygzguax2N3Fa/D/ag1WqbOprdI+uY6wMUl8/a2G+iag== -eslint@8.0.0: - version "8.0.0" - resolved "https://registry.yarnpkg.com/eslint/-/eslint-8.0.0.tgz#2c2d0ac6353755667ac90c9ff4a9c1315e43fcff" - integrity sha512-03spzPzMAO4pElm44m60Nj08nYonPGQXmw6Ceai/S4QK82IgwWO1EXx1s9namKzVlbVu3Jf81hb+N+8+v21/HQ== +eslint-visitor-keys@^4.2.0: + version "4.2.0" + resolved "https://registry.yarnpkg.com/eslint-visitor-keys/-/eslint-visitor-keys-4.2.0.tgz#687bacb2af884fcdda8a6e7d65c606f46a14cd45" + integrity sha512-UyLnSehNt62FFhSwjZlHmeokpRK59rcz29j+F1/aDgbkbRTk7wIc9XzdoasMUbRNKDM0qQt/+BJ4BrpFeABemw== + +eslint@^9.22.0: + version "9.22.0" + resolved "https://registry.yarnpkg.com/eslint/-/eslint-9.22.0.tgz#0760043809fbf836f582140345233984d613c552" + integrity sha512-9V/QURhsRN40xuHXWjV64yvrzMjcz7ZyNoF2jJFmy9j/SLk0u1OLSZgXi28MrXjymnjEGSR80WCdab3RGMDveQ== dependencies: - "@eslint/eslintrc" "^1.0.2" - "@humanwhocodes/config-array" "^0.6.0" - ajv "^6.10.0" + "@eslint-community/eslint-utils" "^4.2.0" + "@eslint-community/regexpp" "^4.12.1" + "@eslint/config-array" "^0.19.2" + "@eslint/config-helpers" "^0.1.0" + "@eslint/core" "^0.12.0" + "@eslint/eslintrc" "^3.3.0" + "@eslint/js" "9.22.0" + "@eslint/plugin-kit" "^0.2.7" + "@humanfs/node" "^0.16.6" + "@humanwhocodes/module-importer" "^1.0.1" + "@humanwhocodes/retry" "^0.4.2" + "@types/estree" "^1.0.6" + "@types/json-schema" "^7.0.15" + ajv "^6.12.4" chalk "^4.0.0" - cross-spawn "^7.0.2" + cross-spawn "^7.0.6" debug "^4.3.2" - doctrine "^3.0.0" - enquirer "^2.3.5" escape-string-regexp "^4.0.0" - eslint-scope "^6.0.0" - eslint-utils "^3.0.0" - eslint-visitor-keys "^3.0.0" - espree "^9.0.0" - esquery "^1.4.0" + eslint-scope "^8.3.0" + eslint-visitor-keys "^4.2.0" + espree "^10.3.0" + esquery "^1.5.0" esutils "^2.0.2" fast-deep-equal "^3.1.3" - file-entry-cache "^6.0.1" - functional-red-black-tree "^1.0.1" - glob-parent "^6.0.1" - globals "^13.6.0" - ignore "^4.0.6" - import-fresh "^3.0.0" + file-entry-cache "^8.0.0" + find-up "^5.0.0" + glob-parent "^6.0.2" + ignore "^5.2.0" imurmurhash "^0.1.4" is-glob "^4.0.0" - js-yaml "^4.1.0" json-stable-stringify-without-jsonify "^1.0.1" - levn "^0.4.1" lodash.merge "^4.6.2" - minimatch "^3.0.4" + minimatch "^3.1.2" natural-compare "^1.4.0" - optionator "^0.9.1" - progress "^2.0.0" - regexpp "^3.2.0" - semver "^7.2.1" - strip-ansi "^6.0.0" - strip-json-comments "^3.1.0" - text-table "^0.2.0" - v8-compile-cache "^2.0.3" - -espree@^9.0.0, espree@^9.4.0: - version "9.6.1" - resolved "https://registry.yarnpkg.com/espree/-/espree-9.6.1.tgz#a2a17b8e434690a5432f2f8018ce71d331a48c6f" - integrity sha512-oruZaFkjorTpF32kDSI5/75ViwGeZginGGy2NoOSg3Q9bnwlnmDm4HLnkl0RE3n+njDXR037aY1+x58Z/zFdwQ== - dependencies: - acorn "^8.9.0" + optionator "^0.9.3" + +espree@^10.0.1, espree@^10.3.0: + version "10.3.0" + resolved "https://registry.yarnpkg.com/espree/-/espree-10.3.0.tgz#29267cf5b0cb98735b65e64ba07e0ed49d1eed8a" + integrity sha512-0QYC8b24HWY8zjRnDTL6RiHfDbAWn63qb4LMj1Z4b076A4une81+z03Kg7l7mn/48PUTqoLptSXez8oknU8Clg== + dependencies: + acorn "^8.14.0" acorn-jsx "^5.3.2" - eslint-visitor-keys "^3.4.1" + eslint-visitor-keys "^4.2.0" -esquery@^1.4.0: +esquery@^1.5.0: version "1.6.0" resolved "https://registry.yarnpkg.com/esquery/-/esquery-1.6.0.tgz#91419234f804d852a82dceec3e16cdc22cf9dae7" integrity sha512-ca9pw9fomFcKPvFLXhBKUK90ZvGibiGOvRJNbjljY7s7uq/5YO4BOzcYtJqExdx99rF6aAcnRxHmcUHcz6sQsg== @@ -632,6 +783,17 @@ fast-deep-equal@^3.1.1, fast-deep-equal@^3.1.3: resolved "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz" integrity sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q== +fast-glob@^3.3.2: + version "3.3.3" + resolved "https://registry.yarnpkg.com/fast-glob/-/fast-glob-3.3.3.tgz#d06d585ce8dba90a16b0505c543c3ccfb3aeb818" + integrity sha512-7MptL8U0cqcFdzIzwOTHoilX9x5BrNqye7Z/LuC7kCMRio1EMSyqRK3BEAUD7sXRq4iT4AzTVuZdhgQ2TCvYLg== + dependencies: + "@nodelib/fs.stat" "^2.0.2" + "@nodelib/fs.walk" "^1.2.3" + glob-parent "^5.1.2" + merge2 "^1.3.0" + micromatch "^4.0.8" + fast-json-stable-stringify@^2.0.0: version "2.1.0" resolved "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz" @@ -642,84 +804,88 @@ fast-levenshtein@^2.0.6: resolved "https://registry.npmjs.org/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz" integrity sha512-DCXu6Ifhqcks7TZKY3Hxp3y6qphY5SJZmrWMDrKcERSOXWQdMhU9Ig/PYrzyw/ul9jOIyh0N4M0tbC5hodg8dw== -file-entry-cache@^6.0.1: - version "6.0.1" - resolved "https://registry.yarnpkg.com/file-entry-cache/-/file-entry-cache-6.0.1.tgz#211b2dd9659cb0394b073e7323ac3c933d522027" - integrity sha512-7Gps/XWymbLk2QLYK4NzpMOrYjMhdIxXuIvy2QBsLE6ljuodKvdkWs/cpyJJ3CVIVpH0Oi1Hvg1ovbMzLdFBBg== +fastq@^1.6.0: + version "1.19.1" + resolved "https://registry.yarnpkg.com/fastq/-/fastq-1.19.1.tgz#d50eaba803c8846a883c16492821ebcd2cda55f5" + integrity sha512-GwLTyxkCXjXbxqIhTsMI2Nui8huMPtnxg7krajPJAjnEG/iiOS7i+zCtWGZR9G0NBKbXKh6X9m9UIsYX/N6vvQ== + dependencies: + reusify "^1.0.4" + +file-entry-cache@^8.0.0: + version "8.0.0" + resolved "https://registry.yarnpkg.com/file-entry-cache/-/file-entry-cache-8.0.0.tgz#7787bddcf1131bffb92636c69457bbc0edd6d81f" + integrity sha512-XXTUwCvisa5oacNGRP9SfNtYBNAMi+RPwBFmblZEF7N7swHYQS6/Zfk7SRwx4D5j3CH211YNRco1DEMNVfZCnQ== + dependencies: + flat-cache "^4.0.0" + +fill-range@^7.1.1: + version "7.1.1" + resolved "https://registry.yarnpkg.com/fill-range/-/fill-range-7.1.1.tgz#44265d3cac07e3ea7dc247516380643754a05292" + integrity sha512-YsGpe3WHLK8ZYi4tWDg2Jy3ebRz2rXowDxnld4bkQB00cc/1Zw9AWnC0i9ztDJitivtQvaI9KaLyKrc+hBW0yg== + dependencies: + to-regex-range "^5.0.1" + +find-up@^5.0.0: + version "5.0.0" + resolved "https://registry.yarnpkg.com/find-up/-/find-up-5.0.0.tgz#4c92819ecb7083561e4f4a240a86be5198f536fc" + integrity sha512-78/PXT1wlLLDgTzDs7sjq9hzz0vXD+zn+7wypEe4fXQxCmdmqfGsEPQxmiCSQI3ajFV91bVSsvNtrJRiW6nGng== dependencies: - flat-cache "^3.0.4" + locate-path "^6.0.0" + path-exists "^4.0.0" -flat-cache@^3.0.4: - version "3.2.0" - resolved "https://registry.yarnpkg.com/flat-cache/-/flat-cache-3.2.0.tgz#2c0c2d5040c99b1632771a9d105725c0115363ee" - integrity sha512-CYcENa+FtcUKLmhhqyctpclsq7QF38pKjZHsGNiSQF5r4FtoKDWabFDl3hzaEQMvT1LHEysw5twgLvpYYb4vbw== +flat-cache@^4.0.0: + version "4.0.1" + resolved "https://registry.yarnpkg.com/flat-cache/-/flat-cache-4.0.1.tgz#0ece39fcb14ee012f4b0410bd33dd9c1f011127c" + integrity sha512-f7ccFPK3SXFHpx15UIGyRJ/FJQctuKZ0zVuN3frBo4HnK3cay9VEW0R6yPYFHC0AgqhukPzKjq22t5DmAyqGyw== dependencies: flatted "^3.2.9" - keyv "^4.5.3" - rimraf "^3.0.2" + keyv "^4.5.4" flatted@^3.2.9: version "3.3.3" resolved "https://registry.npmjs.org/flatted/-/flatted-3.3.3.tgz" integrity sha512-GX+ysw4PBCz0PzosHDepZGANEuFCMLrnRTiEy9McGjmkCQYwRq4A/X786G/fjM/+OjsWSU1ZrY5qyARZmO/uwg== -fs.realpath@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/fs.realpath/-/fs.realpath-1.0.0.tgz#1504ad2523158caa40db4a2787cb01411994ea4f" - integrity sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw== - fsevents@~2.3.2, fsevents@~2.3.3: version "2.3.3" resolved "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz" integrity sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw== -functional-red-black-tree@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/functional-red-black-tree/-/functional-red-black-tree-1.0.1.tgz#1b0ab3bd553b2a0d6399d29c0e3ea0b252078327" - integrity sha512-dsKNQNdj6xA3T+QlADDA7mOSlX0qiMINjn0cgr+eGHGsbSHzTabcIogz2+p/iqP1Xs6EP/sS2SbqH+brGTbq0g== +glob-parent@^5.1.2: + version "5.1.2" + resolved "https://registry.yarnpkg.com/glob-parent/-/glob-parent-5.1.2.tgz#869832c58034fe68a4093c17dc15e8340d8401c4" + integrity sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow== + dependencies: + is-glob "^4.0.1" -glob-parent@^6.0.1: +glob-parent@^6.0.2: version "6.0.2" resolved "https://registry.yarnpkg.com/glob-parent/-/glob-parent-6.0.2.tgz#6d237d99083950c79290f24c7642a3de9a28f9e3" integrity sha512-XxwI8EOhVQgWp6iDL+3b0r86f4d6AX6zSU55HfB4ydCEuXLXc5FcYeOu+nnGftS4TEju/11rt4KJPTMgbfmv4A== dependencies: is-glob "^4.0.3" -glob@^7.1.3: - version "7.2.3" - resolved "https://registry.yarnpkg.com/glob/-/glob-7.2.3.tgz#b8df0fb802bbfa8e89bd1d938b4e16578ed44f2b" - integrity sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q== - dependencies: - fs.realpath "^1.0.0" - inflight "^1.0.4" - inherits "2" - minimatch "^3.1.1" - once "^1.3.0" - path-is-absolute "^1.0.0" +globals@^14.0.0: + version "14.0.0" + resolved "https://registry.yarnpkg.com/globals/-/globals-14.0.0.tgz#898d7413c29babcf6bafe56fcadded858ada724e" + integrity sha512-oahGvuMGQlPw/ivIYBjVSrWAfWLBeku5tpPE2fOPLi+WHffIWbuh2tCjhyQhTBPMf5E9jDEH4FOmTYgYwbKwtQ== -globals@^13.19.0, globals@^13.6.0: - version "13.24.0" - resolved "https://registry.yarnpkg.com/globals/-/globals-13.24.0.tgz#8432a19d78ce0c1e833949c36adb345400bb1171" - integrity sha512-AhO5QUcj8llrbG09iWhPU2B204J1xnPeL8kQmVorSsy+Sjj1sk8gIyh6cUocGmH4L0UuhAJy+hJMRA4mgA4mFQ== - dependencies: - type-fest "^0.20.2" +graphemer@^1.4.0: + version "1.4.0" + resolved "https://registry.yarnpkg.com/graphemer/-/graphemer-1.4.0.tgz#fb2f1d55e0e3a1849aeffc90c4fa0dd53a0e66c6" + integrity sha512-EtKwoO6kxCL9WO5xipiHTZlSzBm7WLT627TqC/uVRd0HKmq8NXyebnNYxDoBi7wt8eTWrUrKXCOVaFq9x1kgag== has-flag@^4.0.0: version "4.0.0" resolved "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz" integrity sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ== -ignore@^4.0.6: - version "4.0.6" - resolved "https://registry.yarnpkg.com/ignore/-/ignore-4.0.6.tgz#750e3db5862087b4737ebac8207ffd1ef27b25fc" - integrity sha512-cyFDKrqc/YdcWFniJhzI42+AzS+gNwmUzOSFcRCQYwySuBBBy/KjuxWLZ/FHEH6Moq1NizMOBWyTcv8O4OZIMg== - -ignore@^5.2.0: +ignore@^5.2.0, ignore@^5.3.1: version "5.3.2" resolved "https://registry.npmjs.org/ignore/-/ignore-5.3.2.tgz" integrity sha512-hsBTNUqQTDwkWtcdYI2i06Y/nUBEsNEDJKjWdigLvegy8kDuJAS8uRlpkkcQpyEXL0Z/pjDy5HBmMjRCJ2gq+g== -import-fresh@^3.0.0, import-fresh@^3.2.1: +import-fresh@^3.2.1: version "3.3.1" resolved "https://registry.yarnpkg.com/import-fresh/-/import-fresh-3.3.1.tgz#9cecb56503c0ada1f2741dbbd6546e4b13b57ccf" integrity sha512-TR3KfrTZTYLPB6jUjfx6MF9WcWrHL9su5TObK4ZkYgBdWKPOFoSoQIdEuTuR82pmtxH2spWG9h6etwfr1pLBqQ== @@ -732,31 +898,23 @@ imurmurhash@^0.1.4: resolved "https://registry.npmjs.org/imurmurhash/-/imurmurhash-0.1.4.tgz" integrity sha512-JmXMZ6wuvDmLiHEml9ykzqO6lwFbof0GG4IkcGaENdCRDDmMVnny7s5HsIgHCbaq0w2MyPhDqkhTUgS2LU2PHA== -inflight@^1.0.4: - version "1.0.6" - resolved "https://registry.yarnpkg.com/inflight/-/inflight-1.0.6.tgz#49bd6331d7d02d0c09bc910a1075ba8165b56df9" - integrity sha512-k92I/b08q4wvFscXCLvqfsHCrjrF7yiXsQuIVvVE7N82W3+aqpzuUdBbfhWcy/FZR3/4IgflMgKLOsvPDrGCJA== - dependencies: - once "^1.3.0" - wrappy "1" - -inherits@2: - version "2.0.4" - resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.4.tgz#0fa2c64f932917c3433a0ded55363aae37416b7c" - integrity sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ== - is-extglob@^2.1.1: version "2.1.1" resolved "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz" integrity sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ== -is-glob@^4.0.0, is-glob@^4.0.3: +is-glob@^4.0.0, is-glob@^4.0.1, is-glob@^4.0.3: version "4.0.3" resolved "https://registry.npmjs.org/is-glob/-/is-glob-4.0.3.tgz" integrity sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg== dependencies: is-extglob "^2.1.1" +is-number@^7.0.0: + version "7.0.0" + resolved "https://registry.yarnpkg.com/is-number/-/is-number-7.0.0.tgz#7535345b896734d5f80c4d06c50955527a14f12b" + integrity sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng== + isexe@^2.0.0: version "2.0.0" resolved "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz" @@ -784,7 +942,7 @@ json-stable-stringify-without-jsonify@^1.0.1: resolved "https://registry.npmjs.org/json-stable-stringify-without-jsonify/-/json-stable-stringify-without-jsonify-1.0.1.tgz" integrity sha512-Bdboy+l7tA3OGW6FjyFHWkP5LuByj1Tk33Ljyq0axyzdk9//JSi2u3fP1QSmd1KNwq6VOKYGlAu87CisVir6Pw== -keyv@^4.5.3: +keyv@^4.5.4: version "4.5.4" resolved "https://registry.yarnpkg.com/keyv/-/keyv-4.5.4.tgz#a879a99e29452f942439f2a405e3af8b31d4de93" integrity sha512-oxVHkHR/EJf2CNXnWxRLW6mg7JyCCUcG0DtEGmL2ctUo1PNTin1PUil+r/+4r5MpVgC/fn1kjsx7mjSujKqIpw== @@ -799,6 +957,13 @@ levn@^0.4.1: prelude-ls "^1.2.1" type-check "~0.4.0" +locate-path@^6.0.0: + version "6.0.0" + resolved "https://registry.yarnpkg.com/locate-path/-/locate-path-6.0.0.tgz#55321eb309febbc59c4801d931a72452a681d286" + integrity sha512-iPZK6eYjbxRu3uB4/WZ3EsEIMJFMqAoopl3R+zuq0UjcAm/MO6KCweDgPfP3elTztoKP3KtnVHxTn2NHBSDVUw== + dependencies: + p-locate "^5.0.0" + lodash.merge@^4.6.2: version "4.6.2" resolved "https://registry.npmjs.org/lodash.merge/-/lodash.merge-4.6.2.tgz" @@ -816,13 +981,33 @@ magic-string@^0.30.17: dependencies: "@jridgewell/sourcemap-codec" "^1.5.0" -minimatch@^3.0.4, minimatch@^3.1.1, minimatch@^3.1.2: +merge2@^1.3.0: + version "1.4.1" + resolved "https://registry.yarnpkg.com/merge2/-/merge2-1.4.1.tgz#4368892f885e907455a6fd7dc55c0c9d404990ae" + integrity sha512-8q7VEgMJW4J8tcfVPy8g09NcQwZdbwFEqhe/WZkoIzjn/3TGDwtOCYtXGxA3O8tPzpczCCDgv+P2P5y00ZJOOg== + +micromatch@^4.0.8: + version "4.0.8" + resolved "https://registry.yarnpkg.com/micromatch/-/micromatch-4.0.8.tgz#d66fa18f3a47076789320b9b1af32bd86d9fa202" + integrity sha512-PXwfBhYu0hBCPw8Dn0E+WDYb7af3dSLVWKi3HGv84IdF4TyFoC0ysxFd0Goxw7nSv4T/PzEJQxsYsEiFCKo2BA== + dependencies: + braces "^3.0.3" + picomatch "^2.3.1" + +minimatch@^3.1.2: version "3.1.2" resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.1.2.tgz#19cd194bfd3e428f049a70817c038d89ab4be35b" integrity sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw== dependencies: brace-expansion "^1.1.7" +minimatch@^9.0.4: + version "9.0.5" + resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-9.0.5.tgz#d74f9dd6b57d83d8e98cfb82133b03978bc929e5" + integrity sha512-G6T0ZX48xgozx7587koeX9Ys2NYy6Gmv//P89sEte9V9whIapMNF4idKxnW2QtCcLiTWlb/wfCabAtAFWhhBow== + dependencies: + brace-expansion "^2.0.1" + ms@^2.1.3: version "2.1.3" resolved "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz" @@ -838,14 +1023,7 @@ natural-compare@^1.4.0: resolved "https://registry.npmjs.org/natural-compare/-/natural-compare-1.4.0.tgz" integrity sha512-OWND8ei3VtNC9h7V60qff3SVobHr996CTwgxubgyQYEpg290h9J0buyECNNJexkFm5sOajh5G116RYA1c8ZMSw== -once@^1.3.0: - version "1.4.0" - resolved "https://registry.yarnpkg.com/once/-/once-1.4.0.tgz#583b1aa775961d4b113ac17d9c50baef9dd76bd1" - integrity sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w== - dependencies: - wrappy "1" - -optionator@^0.9.1: +optionator@^0.9.3: version "0.9.4" resolved "https://registry.yarnpkg.com/optionator/-/optionator-0.9.4.tgz#7ea1c1a5d91d764fb282139c88fe11e182a3a734" integrity sha512-6IpQ7mKUxRcZNLIObR0hz7lxsapSSIYNZJwXPGeF0mTVqGKFIXj1DQcMoT22S3ROcLyY/rz0PWaWZ9ayWmad9g== @@ -857,6 +1035,20 @@ optionator@^0.9.1: type-check "^0.4.0" word-wrap "^1.2.5" +p-limit@^3.0.2: + version "3.1.0" + resolved "https://registry.yarnpkg.com/p-limit/-/p-limit-3.1.0.tgz#e1daccbe78d0d1388ca18c64fea38e3e57e3706b" + integrity sha512-TYOanM3wGwNGsZN2cVTYPArw454xnXj5qmWF1bEoAc4+cU/ol7GVh7odevjp1FNHduHc3KZMcFduxU5Xc6uJRQ== + dependencies: + yocto-queue "^0.1.0" + +p-locate@^5.0.0: + version "5.0.0" + resolved "https://registry.yarnpkg.com/p-locate/-/p-locate-5.0.0.tgz#83c8315c6785005e3bd021839411c9e110e6d834" + integrity sha512-LaNjtRWUBY++zB5nE/NwcaoMylSPk+S+ZHNB1TzdbMJMny6dynpAGt7X/tl/QYq3TIeE6nxHppbo2LGymrG5Pw== + dependencies: + p-limit "^3.0.2" + parent-module@^1.0.0: version "1.0.1" resolved "https://registry.npmjs.org/parent-module/-/parent-module-1.0.1.tgz" @@ -864,10 +1056,10 @@ parent-module@^1.0.0: dependencies: callsites "^3.0.0" -path-is-absolute@^1.0.0: - version "1.0.1" - resolved "https://registry.yarnpkg.com/path-is-absolute/-/path-is-absolute-1.0.1.tgz#174b9268735534ffbc7ace6bf53a5a9e1b5c5f5f" - integrity sha512-AVbw3UJ2e9bq64vSaS9Am0fje1Pa8pbGqTTsmXfaIiMpnr5DlDhfJOuLj9Sf95ZPVDAUerDfEk88MPmPe7UCQg== +path-exists@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/path-exists/-/path-exists-4.0.0.tgz#513bdbe2d3b95d7762e8c1137efa195c6c61b5b3" + integrity sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w== path-key@^3.1.0: version "3.1.1" @@ -889,6 +1081,11 @@ picocolors@^1.1.1: resolved "https://registry.npmjs.org/picocolors/-/picocolors-1.1.1.tgz" integrity sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA== +picomatch@^2.3.1: + version "2.3.1" + resolved "https://registry.yarnpkg.com/picomatch/-/picomatch-2.3.1.tgz#3ba3833733646d9d3e4995946c1365a67fb07a42" + integrity sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA== + postcss@^8.5.3: version "8.5.3" resolved "https://registry.npmjs.org/postcss/-/postcss-8.5.3.tgz" @@ -903,32 +1100,25 @@ prelude-ls@^1.2.1: resolved "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.2.1.tgz" integrity sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g== -progress@^2.0.0: - version "2.0.3" - resolved "https://registry.yarnpkg.com/progress/-/progress-2.0.3.tgz#7e8cf8d8f5b8f239c1bc68beb4eb78567d572ef8" - integrity sha512-7PiHtLll5LdnKIMw100I+8xJXR5gW2QwWYkT6iJva0bXitZKa/XMrSbdmg3r2Xnaidz9Qumd0VPaMrZlF9V9sA== - punycode@^2.1.0: version "2.3.1" resolved "https://registry.npmjs.org/punycode/-/punycode-2.3.1.tgz" integrity sha512-vYt7UD1U9Wg6138shLtLOvdAu+8DsC/ilFtEVHcH+wydcSpNE20AfSOduf6MkRFahL5FY7X1oU7nKVZFtfq8Fg== -regexpp@^3.2.0: - version "3.2.0" - resolved "https://registry.yarnpkg.com/regexpp/-/regexpp-3.2.0.tgz#0425a2768d8f23bad70ca4b90461fa2f1213e1b2" - integrity sha512-pq2bWo9mVD43nbts2wGv17XLiNLya+GklZ8kaDLV2Z08gDCsGpnKn9BFMepvWuHCbyVvY7J5o5+BVvoQbmlJLg== +queue-microtask@^1.2.2: + version "1.2.3" + resolved "https://registry.yarnpkg.com/queue-microtask/-/queue-microtask-1.2.3.tgz#4929228bbc724dfac43e0efb058caf7b6cfb6243" + integrity sha512-NuaNSa6flKT5JaSYQzJok04JzTL1CA6aGhv5rfLW3PgqA+M2ChpZQnAC8h8i4ZFkBS8X5RqkDBHA7r4hej3K9A== resolve-from@^4.0.0: version "4.0.0" resolved "https://registry.npmjs.org/resolve-from/-/resolve-from-4.0.0.tgz" integrity sha512-pb/MYmXstAkysRFx8piNI1tGFNQIFA3vkE3Gq4EuA1dF6gHp/+vgZqsCGJapvy8N3Q+4o7FwvquPJcnZ7RYy4g== -rimraf@^3.0.2: - version "3.0.2" - resolved "https://registry.yarnpkg.com/rimraf/-/rimraf-3.0.2.tgz#f1a5402ba6220ad52cc1282bac1ae3aa49fd061a" - integrity sha512-JZkJMZkAGFFPP2YqXZXPbMlMBgsxzE8ILs4lMIX/2o0L9UBw9O/Y3o6wFw/i9YLapcUJWwqbi3kdxIPdC62TIA== - dependencies: - glob "^7.1.3" +reusify@^1.0.4: + version "1.1.0" + resolved "https://registry.yarnpkg.com/reusify/-/reusify-1.1.0.tgz#0fe13b9522e1473f51b558ee796e08f11f9b489f" + integrity sha512-g6QUff04oZpHs0eG5p83rFLhHeV00ug/Yf9nZM6fLeUrPguBTkTQOdpAWWspMh55TZfVQDPaN3NQJfbVRAxdIw== rollup@^4.30.1: version "4.35.0" @@ -958,7 +1148,14 @@ rollup@^4.30.1: "@rollup/rollup-win32-x64-msvc" "4.35.0" fsevents "~2.3.2" -semver@^7.2.1: +run-parallel@^1.1.9: + version "1.2.0" + resolved "https://registry.yarnpkg.com/run-parallel/-/run-parallel-1.2.0.tgz#66d1368da7bdf921eb9d95bd1a9229e7f21a43ee" + integrity sha512-5l4VyZR86LZ/lDxZTR6jqL8AFE2S0IFLMP26AbjsLVADxHdhB/c0GUsH+y39UfCi3dzz8OlQuPmnaJOMoDHQBA== + dependencies: + queue-microtask "^1.2.2" + +semver@^7.6.0: version "7.7.1" resolved "https://registry.yarnpkg.com/semver/-/semver-7.7.1.tgz#abd5098d82b18c6c81f6074ff2647fd3e7220c9f" integrity sha512-hlq8tAfn0m/61p4BVRcPzIGr6LKiMwo4VM6dGi6pt4qcRkmNzTcWq6eCEjEh+qXjkMDvPlOFFSGwQjoEa6gyMA== @@ -995,14 +1192,7 @@ std-env@^3.8.0: resolved "https://registry.npmjs.org/std-env/-/std-env-3.8.1.tgz" integrity sha512-vj5lIj3Mwf9D79hBkltk5qmkFI+biIKWS2IBxEyEU3AX1tUf7AoL8nSazCOiiqQsGKIq01SClsKEzweu34uwvA== -strip-ansi@^6.0.0, strip-ansi@^6.0.1: - version "6.0.1" - resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9" - integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A== - dependencies: - ansi-regex "^5.0.1" - -strip-json-comments@^3.1.0, strip-json-comments@^3.1.1: +strip-json-comments@^3.1.1: version "3.1.1" resolved "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-3.1.1.tgz" integrity sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig== @@ -1014,11 +1204,6 @@ supports-color@^7.1.0: dependencies: has-flag "^4.0.0" -text-table@^0.2.0: - version "0.2.0" - resolved "https://registry.yarnpkg.com/text-table/-/text-table-0.2.0.tgz#7f5ee823ae805207c00af2df4a84ec3fcfa570b4" - integrity sha512-N+8UisAXDGk8PFXP4HAzVR9nbfmVJ3zYLAWiTIoqC5v5isinhr+r5uaO8+7r3BMfuNIufIsA7RdpVgacC2cSpw== - tinybench@^2.9.0: version "2.9.0" resolved "https://registry.npmjs.org/tinybench/-/tinybench-2.9.0.tgz" @@ -1044,6 +1229,18 @@ tinyspy@^3.0.2: resolved "https://registry.npmjs.org/tinyspy/-/tinyspy-3.0.2.tgz" integrity sha512-n1cw8k1k0x4pgA2+9XrOkFydTerNcJ1zWCO5Nn9scWHTD+5tp8dghT2x1uduQePZTZgd3Tupf+x9BxJjeJi77Q== +to-regex-range@^5.0.1: + version "5.0.1" + resolved "https://registry.yarnpkg.com/to-regex-range/-/to-regex-range-5.0.1.tgz#1648c44aae7c8d988a326018ed72f5b4dd0392e4" + integrity sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ== + dependencies: + is-number "^7.0.0" + +ts-api-utils@^2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/ts-api-utils/-/ts-api-utils-2.0.1.tgz#660729385b625b939aaa58054f45c058f33f10cd" + integrity sha512-dnlgjFSVetynI8nzgJ+qF62efpglpWRk8isUEWZGWlJYySCTD6aKvbUDu+zbPeDakk3bg5H4XpitHukgfL1m9w== + type-check@^0.4.0, type-check@~0.4.0: version "0.4.0" resolved "https://registry.npmjs.org/type-check/-/type-check-0.4.0.tgz" @@ -1051,14 +1248,18 @@ type-check@^0.4.0, type-check@~0.4.0: dependencies: prelude-ls "^1.2.1" -type-fest@^0.20.2: - version "0.20.2" - resolved "https://registry.yarnpkg.com/type-fest/-/type-fest-0.20.2.tgz#1bf207f4b28f91583666cb5fbd327887301cd5f4" - integrity sha512-Ne+eE4r0/iWnpAxD852z3A+N0Bt5RN//NjJwRd2VFHEmrywxf5vsZlh4R6lixl6B+wz/8d+maTSAkN1FIkI3LQ== +typescript-eslint@^8.26.1: + version "8.26.1" + resolved "https://registry.yarnpkg.com/typescript-eslint/-/typescript-eslint-8.26.1.tgz#d17a638a7543bc535157b83cdf5876513c71493b" + integrity sha512-t/oIs9mYyrwZGRpDv3g+3K6nZ5uhKEMt2oNmAPwaY4/ye0+EH4nXIPYNtkYFS6QHm+1DFg34DbglYBz5P9Xysg== + dependencies: + "@typescript-eslint/eslint-plugin" "8.26.1" + "@typescript-eslint/parser" "8.26.1" + "@typescript-eslint/utils" "8.26.1" typescript@^5.8.2: version "5.8.2" - resolved "https://registry.npmjs.org/typescript/-/typescript-5.8.2.tgz" + resolved "https://registry.yarnpkg.com/typescript/-/typescript-5.8.2.tgz#8170b3702f74b79db2e5a96207c15e65807999e4" integrity sha512-aJn6wq13/afZp/jT9QZmwEjDqqvSGp1VT5GVg+f/t6/oVyrgXM6BY1h9BRh/O5p3PlUPAe+WuiEZOmb/49RqoQ== uri-js@^4.2.2: @@ -1068,11 +1269,6 @@ uri-js@^4.2.2: dependencies: punycode "^2.1.0" -v8-compile-cache@^2.0.3: - version "2.4.0" - resolved "https://registry.yarnpkg.com/v8-compile-cache/-/v8-compile-cache-2.4.0.tgz#cdada8bec61e15865f05d097c5f4fd30e94dc128" - integrity sha512-ocyWc3bAHBB/guyqJQVI5o4BZkPhznPYUG2ea80Gond/BgNWpap8TOmLSeeQG7bnh2KMISxskdADG59j7zruhw== - vite-node@3.0.8: version "3.0.8" resolved "https://registry.npmjs.org/vite-node/-/vite-node-3.0.8.tgz" @@ -1141,7 +1337,7 @@ word-wrap@^1.2.5: resolved "https://registry.npmjs.org/word-wrap/-/word-wrap-1.2.5.tgz" integrity sha512-BN22B5eaMMI9UMtjrGd5g5eCYPpCPDUy0FJXbYsaT5zYxjFOckS53SQDE3pWkVoWpHXVb3BrYcEN4Twa55B5cA== -wrappy@1: - version "1.0.2" - resolved "https://registry.yarnpkg.com/wrappy/-/wrappy-1.0.2.tgz#b5243d8f3ec1aa35f1364605bc0d1036e30ab69f" - integrity sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ== +yocto-queue@^0.1.0: + version "0.1.0" + resolved "https://registry.yarnpkg.com/yocto-queue/-/yocto-queue-0.1.0.tgz#0294eb3dee05028d31ee1a5fa2c556a6aaf10a1b" + integrity sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q== From 7d92a4aaa2a418b90fb50ae93c7322556d648e31 Mon Sep 17 00:00:00 2001 From: Wesley Guthrie Date: Mon, 10 Mar 2025 22:26:28 -0500 Subject: [PATCH 10/13] rebuild dist --- dist/src/every.d.ts | 14 +++++++++++++- dist/src/every.js | 16 ++++++++++++++-- dist/src/filter.d.ts | 14 +++++++++++++- dist/src/filter.js | 16 ++++++++++++++-- dist/src/find.d.ts | 14 +++++++++++++- dist/src/find.js | 16 ++++++++++++++-- dist/src/findIndex.d.ts | 14 +++++++++++++- dist/src/findIndex.js | 16 ++++++++++++++-- dist/src/findLast.d.ts | 14 +++++++++++++- dist/src/findLast.js | 18 +++++++++++++++--- dist/src/findLastIndex.d.ts | 14 +++++++++++++- dist/src/findLastIndex.js | 18 +++++++++++++++--- dist/src/map.d.ts | 14 +++++++++++++- dist/src/map.js | 16 ++++++++++++++-- dist/src/mapParallel.d.ts | 6 +++--- dist/src/mapParallel.js | 18 +++++++++--------- dist/src/reduce.d.ts | 15 ++++++++++++++- dist/src/reduce.js | 17 +++++++++++++++-- dist/src/reduceRight.d.ts | 15 ++++++++++++++- dist/src/reduceRight.js | 17 +++++++++++++++-- dist/src/some.d.ts | 14 +++++++++++++- dist/src/some.js | 16 ++++++++++++++-- 22 files changed, 288 insertions(+), 44 deletions(-) diff --git a/dist/src/every.d.ts b/dist/src/every.d.ts index ecfa851..18a6f5d 100644 --- a/dist/src/every.d.ts +++ b/dist/src/every.d.ts @@ -1 +1,13 @@ -export default function every(array: T[], iterator: (value: T, index: number) => Promise): Promise; +/** + * {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/every|MDN Documentation Array.prototype.every} + * + * @static + * @since 1.0.0 + * @param {T[]} array + * @param {(value: T, index: number) => Promise} iteratee + * @returns {Promise} + * @example + * const array = [3, 3, 3]; + * const allThree = await every(array, async (value) => value === 3); + */ +export default function every(array: T[], iteratee: (value: T, index: number) => Promise): Promise; diff --git a/dist/src/every.js b/dist/src/every.js index 47dc6df..bc9f59d 100644 --- a/dist/src/every.js +++ b/dist/src/every.js @@ -1,12 +1,24 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = every; -async function every(array, iterator) { +/** + * {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/every|MDN Documentation Array.prototype.every} + * + * @static + * @since 1.0.0 + * @param {T[]} array + * @param {(value: T, index: number) => Promise} iteratee + * @returns {Promise} + * @example + * const array = [3, 3, 3]; + * const allThree = await every(array, async (value) => value === 3); + */ +async function every(array, iteratee) { if (!Array.isArray(array) || !array?.length) return false; for (let index = 0; index < array.length; index++) { const element = array[index]; - const result = await iterator(element, index); + const result = await iteratee(element, index); if (!result) { return false; } diff --git a/dist/src/filter.d.ts b/dist/src/filter.d.ts index 98b2eaf..2cadb98 100644 --- a/dist/src/filter.d.ts +++ b/dist/src/filter.d.ts @@ -1 +1,13 @@ -export default function filter(array: T[], iterator: (value: T, index: number) => Promise): Promise; +/** + * {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/filter|MDN Documentation Array.prototype.filter} + * + * @static + * @since 1.0.0 + * @param {T[]} array + * @param {(value: T, index: number) => Promise} iteratee + * @returns {Promise} + * @example + * const array = [1, 2, 3]; + * const onlyThree = await filter(array, async (value) => value === 3); + */ +export default function filter(array: T[], iteratee: (value: T, index: number) => Promise): Promise; diff --git a/dist/src/filter.js b/dist/src/filter.js index 26cad7a..a1de383 100644 --- a/dist/src/filter.js +++ b/dist/src/filter.js @@ -1,13 +1,25 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = filter; -async function filter(array, iterator) { +/** + * {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/filter|MDN Documentation Array.prototype.filter} + * + * @static + * @since 1.0.0 + * @param {T[]} array + * @param {(value: T, index: number) => Promise} iteratee + * @returns {Promise} + * @example + * const array = [1, 2, 3]; + * const onlyThree = await filter(array, async (value) => value === 3); + */ +async function filter(array, iteratee) { if (!Array.isArray(array) || !array?.length) return []; const results = []; for (let index = 0; index < array.length; index++) { const element = array[index]; - const result = await iterator(element, index); + const result = await iteratee(element, index); if (result) { results.push(element); } diff --git a/dist/src/find.d.ts b/dist/src/find.d.ts index e3a6985..419c7ae 100644 --- a/dist/src/find.d.ts +++ b/dist/src/find.d.ts @@ -1 +1,13 @@ -export default function find(array: T[], iterator: (value: T, index: number) => Promise): Promise; +/** + * {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/find|MDN Documentation Array.prototype.find} + * + * @static + * @since 1.0.0 + * @param {T[]} array + * @param {(value: T, index: number) => Promise} iteratee + * @returns {Promise} + * @example + * const array = [1, 2, 3]; + * const foundValue = await find(array, async (value) => value === 3); + */ +export default function find(array: T[], iteratee: (value: T, index: number) => Promise): Promise; diff --git a/dist/src/find.js b/dist/src/find.js index dbd9614..3231b16 100644 --- a/dist/src/find.js +++ b/dist/src/find.js @@ -1,12 +1,24 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = find; -async function find(array, iterator) { +/** + * {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/find|MDN Documentation Array.prototype.find} + * + * @static + * @since 1.0.0 + * @param {T[]} array + * @param {(value: T, index: number) => Promise} iteratee + * @returns {Promise} + * @example + * const array = [1, 2, 3]; + * const foundValue = await find(array, async (value) => value === 3); + */ +async function find(array, iteratee) { if (!Array.isArray(array) || !array?.length) return undefined; for (let index = 0; index < array.length; index++) { const element = array[index]; - const result = await iterator(element, index); + const result = await iteratee(element, index); if (result) { return element; } diff --git a/dist/src/findIndex.d.ts b/dist/src/findIndex.d.ts index d431c37..c1d89d3 100644 --- a/dist/src/findIndex.d.ts +++ b/dist/src/findIndex.d.ts @@ -1 +1,13 @@ -export default function findIndex(array: T[], iterator: (value: T, index: number) => Promise): Promise; +/** + * {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/findIndex|MDN Documentation Array.prototype.findIndex} + * + * @static + * @since 1.0.0 + * @param {T[]} array + * @param {(value: T, index: number) => Promise} iteratee + * @returns {Promise} + * @example + * const array = [1, 2, 3]; + * const foundValueIndex = await findIndex(array, async (value) => value === 3); + */ +export default function findIndex(array: T[], iteratee: (value: T, index: number) => Promise): Promise; diff --git a/dist/src/findIndex.js b/dist/src/findIndex.js index 394459b..2f7fa15 100644 --- a/dist/src/findIndex.js +++ b/dist/src/findIndex.js @@ -1,12 +1,24 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = findIndex; -async function findIndex(array, iterator) { +/** + * {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/findIndex|MDN Documentation Array.prototype.findIndex} + * + * @static + * @since 1.0.0 + * @param {T[]} array + * @param {(value: T, index: number) => Promise} iteratee + * @returns {Promise} + * @example + * const array = [1, 2, 3]; + * const foundValueIndex = await findIndex(array, async (value) => value === 3); + */ +async function findIndex(array, iteratee) { if (!Array.isArray(array) || !array?.length) return -1; for (let index = 0; index < array.length; index++) { const element = array[index]; - const result = await iterator(element, index); + const result = await iteratee(element, index); if (result) { return index; } diff --git a/dist/src/findLast.d.ts b/dist/src/findLast.d.ts index 056de06..620a9ba 100644 --- a/dist/src/findLast.d.ts +++ b/dist/src/findLast.d.ts @@ -1 +1,13 @@ -export default function findLast(array: T[], iterator: (value: T, index: number) => Promise): Promise; +/** + * {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/findLast|MDN Documentation Array.prototype.findLast} + * + * @static + * @since 1.0.0 + * @param {T[]} array + * @param {(value: T, index: number) => Promise} iteratee + * @returns {Promise} + * @example + * const array = [1, 2, 3]; + * const foundValue = await findLast(array, async (value) => value === 3); + */ +export default function findLast(array: T[], iteratee: (value: T, index: number) => Promise): Promise; diff --git a/dist/src/findLast.js b/dist/src/findLast.js index a5b9140..f21e07b 100644 --- a/dist/src/findLast.js +++ b/dist/src/findLast.js @@ -1,12 +1,24 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = findLast; -async function findLast(array, iterator) { +/** + * {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/findLast|MDN Documentation Array.prototype.findLast} + * + * @static + * @since 1.0.0 + * @param {T[]} array + * @param {(value: T, index: number) => Promise} iteratee + * @returns {Promise} + * @example + * const array = [1, 2, 3]; + * const foundValue = await findLast(array, async (value) => value === 3); + */ +async function findLast(array, iteratee) { if (!Array.isArray(array) || !array?.length) return undefined; - for (let index = array.length; index >= 0; index--) { + for (let index = array.length - 1; index >= 0; index--) { const element = array[index]; - const result = await iterator(element, index); + const result = await iteratee(element, index); if (result) { return element; } diff --git a/dist/src/findLastIndex.d.ts b/dist/src/findLastIndex.d.ts index cc8b9f3..1191d04 100644 --- a/dist/src/findLastIndex.d.ts +++ b/dist/src/findLastIndex.d.ts @@ -1 +1,13 @@ -export default function findLastIndex(array: T[], iterator: (value: T, index: number) => Promise): Promise; +/** + * {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/findLastIndex|MDN Documentation Array.prototype.findLastIndex} + * + * @static + * @since 1.0.0 + * @param {T[]} array + * @param {(value: T, index: number) => Promise} iteratee + * @returns {Promise} + * @example + * const array = [1, 2, 3]; + * const foundValueIndex = await findLastIndex(array, async (value) => value === 3); + */ +export default function findLastIndex(array: T[], iteratee: (value: T, index: number) => Promise): Promise; diff --git a/dist/src/findLastIndex.js b/dist/src/findLastIndex.js index bd7e400..ef6986c 100644 --- a/dist/src/findLastIndex.js +++ b/dist/src/findLastIndex.js @@ -1,12 +1,24 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = findLastIndex; -async function findLastIndex(array, iterator) { +/** + * {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/findLastIndex|MDN Documentation Array.prototype.findLastIndex} + * + * @static + * @since 1.0.0 + * @param {T[]} array + * @param {(value: T, index: number) => Promise} iteratee + * @returns {Promise} + * @example + * const array = [1, 2, 3]; + * const foundValueIndex = await findLastIndex(array, async (value) => value === 3); + */ +async function findLastIndex(array, iteratee) { if (!Array.isArray(array) || !array?.length) return -1; - for (let index = array.length; index >= 0; index--) { + for (let index = array.length - 1; index >= 0; index--) { const element = array[index]; - const result = await iterator(element, index); + const result = await iteratee(element, index); if (result) { return index; } diff --git a/dist/src/map.d.ts b/dist/src/map.d.ts index 212ceb7..48d9290 100644 --- a/dist/src/map.d.ts +++ b/dist/src/map.d.ts @@ -1 +1,13 @@ -export default function map(array: T[], iterator: (value: T, index: number) => Promise): Promise; +/** + * {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map|MDN Documentation Array.prototype.map} + * + * @static + * @since 1.0.0 + * @param {T[]} array + * @param {(value: T, index: number) => Promise} iteratee + * @returns {Promise} + * @example + * const array = [1, 2, 3]; + * const doubledArray = await map(array, async (value) => value * 2); + */ +export default function map(array: T[], iteratee: (value: T, index: number) => Promise): Promise; diff --git a/dist/src/map.js b/dist/src/map.js index 5e5430c..b864608 100644 --- a/dist/src/map.js +++ b/dist/src/map.js @@ -1,13 +1,25 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = map; -async function map(array, iterator) { +/** + * {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map|MDN Documentation Array.prototype.map} + * + * @static + * @since 1.0.0 + * @param {T[]} array + * @param {(value: T, index: number) => Promise} iteratee + * @returns {Promise} + * @example + * const array = [1, 2, 3]; + * const doubledArray = await map(array, async (value) => value * 2); + */ +async function map(array, iteratee) { if (!Array.isArray(array) || !array?.length) return []; const results = []; for (let index = 0; index < array.length; index++) { const element = array[index]; - results.push(await iterator(element, index)); + results.push(await iteratee(element, index)); } return results; } diff --git a/dist/src/mapParallel.d.ts b/dist/src/mapParallel.d.ts index 45608eb..dddecce 100644 --- a/dist/src/mapParallel.d.ts +++ b/dist/src/mapParallel.d.ts @@ -1,7 +1,7 @@ /** - * iterate over the passed in array in parallel, running the iterator on each element. + * iterate over the passed in array in parallel, running the iteratee on each element. * @param {T[]} array - * @param {(val: T, index?: number) => Promise} iterator + * @param {(val: T, index?: number) => Promise} iteratee * @param {number} [maxParallelBatchSize] */ -export default function mapParallel(array: T[], iterator: (value: T, index: number) => Promise, maxParallelBatchSize?: number): Promise; +export default function mapParallel(array: T[], iteratee: (value: T, index: number) => Promise, maxParallelBatchSize?: number): Promise; diff --git a/dist/src/mapParallel.js b/dist/src/mapParallel.js index 452b58e..8355138 100644 --- a/dist/src/mapParallel.js +++ b/dist/src/mapParallel.js @@ -4,27 +4,27 @@ exports.default = mapParallel; /** * take and complete tasks from a queue until that queue is empty. * @param {{ task: T; index: number }[]} array - * @param {(val: T, index?: number) => Promise} iterator + * @param {(val: T, index?: number) => Promise} iteratee */ -async function takeAndCompleteFromQueueUntilDone(array, iterator) { +async function takeAndCompleteFromQueueUntilDone(array, iteratee) { const item = array.shift(); if (!item) { return []; } - const completedTask = await iterator(item.task, item.index); - const followingCompletedTasks = await takeAndCompleteFromQueueUntilDone(array, iterator); + const completedTask = await iteratee(item.task, item.index); + const followingCompletedTasks = await takeAndCompleteFromQueueUntilDone(array, iteratee); return followingCompletedTasks.concat({ result: completedTask, index: item.index, }); } /** - * iterate over the passed in array in parallel, running the iterator on each element. + * iterate over the passed in array in parallel, running the iteratee on each element. * @param {T[]} array - * @param {(val: T, index?: number) => Promise} iterator + * @param {(val: T, index?: number) => Promise} iteratee * @param {number} [maxParallelBatchSize] */ -async function mapParallel(array, iterator, maxParallelBatchSize) { +async function mapParallel(array, iteratee, maxParallelBatchSize) { if (!Array.isArray(array) || !array?.length) return []; const arrayWithIndexKeys = array.map((item, i) => { @@ -38,9 +38,9 @@ async function mapParallel(array, iterator, maxParallelBatchSize) { effectiveMaxBatchSize = array.length; } const coolEmptyArray = Array(effectiveMaxBatchSize).fill(undefined); - let results = []; + const results = []; await Promise.all(coolEmptyArray.map(async () => { - const resultsWithIndex = await takeAndCompleteFromQueueUntilDone(arrayWithIndexKeys, iterator); + const resultsWithIndex = await takeAndCompleteFromQueueUntilDone(arrayWithIndexKeys, iteratee); resultsWithIndex.forEach((result) => { results[result.index] = result.result; }); diff --git a/dist/src/reduce.d.ts b/dist/src/reduce.d.ts index fbfac32..e59f3b1 100644 --- a/dist/src/reduce.d.ts +++ b/dist/src/reduce.d.ts @@ -1 +1,14 @@ -export default function reduce(array: T[], iterator: (accumulator: V, currentValue: T) => Promise, initialValue: V): Promise; +/** + * {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/reduce|MDN Documentation Array.prototype.reduce} + * + * @static + * @since 1.0.0 + * @param {T[]} array + * @param {(accumulator: V, currentValue: T) => Promise} iteratee + * @param {V} initialValue + * @returns {Promise} + * @example + * const array = [1, 2, 3]; + * const sum = await reduce(array, async (accumulator, current) => accumulator + currect, 0); + */ +export default function reduce(array: T[], iteratee: (accumulator: V, currentValue: T) => Promise, initialValue: V): Promise; diff --git a/dist/src/reduce.js b/dist/src/reduce.js index 497f576..1280444 100644 --- a/dist/src/reduce.js +++ b/dist/src/reduce.js @@ -1,13 +1,26 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = reduce; -async function reduce(array, iterator, initialValue) { +/** + * {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/reduce|MDN Documentation Array.prototype.reduce} + * + * @static + * @since 1.0.0 + * @param {T[]} array + * @param {(accumulator: V, currentValue: T) => Promise} iteratee + * @param {V} initialValue + * @returns {Promise} + * @example + * const array = [1, 2, 3]; + * const sum = await reduce(array, async (accumulator, current) => accumulator + currect, 0); + */ +async function reduce(array, iteratee, initialValue) { if (!Array.isArray(array) || !array?.length) return initialValue; let result = initialValue; for (let index = 0; index < array.length; index++) { const element = array[index]; - result = await iterator(result, element); + result = await iteratee(result, element); } return result; } diff --git a/dist/src/reduceRight.d.ts b/dist/src/reduceRight.d.ts index 3c94cae..e9283d2 100644 --- a/dist/src/reduceRight.d.ts +++ b/dist/src/reduceRight.d.ts @@ -1 +1,14 @@ -export default function reduceRight(array: T[], iterator: (accumulator: V, currentValue: T) => Promise, initialValue: V): Promise; +/** + * {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/reduceRight|MDN Documentation Array.prototype.reduceRight} + * + * @static + * @since 1.0.0 + * @param {T[]} array + * @param {(accumulator: V, currentValue: T) => Promise} iteratee + * @param {V} initialValue + * @returns {Promise} + * @example + * const array = [1, 2, 3]; + * const sum = await reduceRight(array, async (accumulator, current) => accumulator + currect, 0); + */ +export default function reduceRight(array: T[], iteratee: (accumulator: V, currentValue: T) => Promise, initialValue: V): Promise; diff --git a/dist/src/reduceRight.js b/dist/src/reduceRight.js index 7211e99..63fde68 100644 --- a/dist/src/reduceRight.js +++ b/dist/src/reduceRight.js @@ -1,12 +1,25 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = reduceRight; -async function reduceRight(array, iterator, initialValue) { +/** + * {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/reduceRight|MDN Documentation Array.prototype.reduceRight} + * + * @static + * @since 1.0.0 + * @param {T[]} array + * @param {(accumulator: V, currentValue: T) => Promise} iteratee + * @param {V} initialValue + * @returns {Promise} + * @example + * const array = [1, 2, 3]; + * const sum = await reduceRight(array, async (accumulator, current) => accumulator + currect, 0); + */ +async function reduceRight(array, iteratee, initialValue) { if (!Array.isArray(array) || !array?.length) return initialValue; let result = initialValue; for (let index = array.length - 1; index >= 0; index--) { - result = await iterator(result, array[index]); + result = await iteratee(result, array[index]); } return result; } diff --git a/dist/src/some.d.ts b/dist/src/some.d.ts index f65f67c..69241db 100644 --- a/dist/src/some.d.ts +++ b/dist/src/some.d.ts @@ -1 +1,13 @@ -export default function some(array: T[], iterator: (value: T, index: number) => Promise): Promise; +/** + * {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/some|MDN Documentation Array.prototype.some} + * + * @static + * @since 1.0.0 + * @param {T[]} array + * @param {(value: T, index: number) => Promise} iteratee + * @returns {Promise} + * @example + * const array = [1, 2, 3]; + * const hasThree = await some(array, async (value) => value === 3); + */ +export default function some(array: T[], iteratee: (value: T, index: number) => Promise): Promise; diff --git a/dist/src/some.js b/dist/src/some.js index acf7852..542e7e3 100644 --- a/dist/src/some.js +++ b/dist/src/some.js @@ -1,12 +1,24 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = some; -async function some(array, iterator) { +/** + * {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/some|MDN Documentation Array.prototype.some} + * + * @static + * @since 1.0.0 + * @param {T[]} array + * @param {(value: T, index: number) => Promise} iteratee + * @returns {Promise} + * @example + * const array = [1, 2, 3]; + * const hasThree = await some(array, async (value) => value === 3); + */ +async function some(array, iteratee) { if (!Array.isArray(array) || !array?.length) return false; for (let index = 0; index < array.length; index++) { const element = array[index]; - const result = await iterator(element, index); + const result = await iteratee(element, index); if (result) { return true; } From 2025b38a7b407233d716e73c9049f104bc846a5b Mon Sep 17 00:00:00 2001 From: Wesley Guthrie Date: Mon, 10 Mar 2025 23:34:40 -0500 Subject: [PATCH 11/13] refactor mapParallel --- dist/src/mapParallel.d.ts | 10 ++++- dist/src/mapParallel.js | 56 +++++++++++++----------- package.json | 4 +- src/mapParallel.ts | 92 ++++++++++++++++++++++----------------- 4 files changed, 92 insertions(+), 70 deletions(-) diff --git a/dist/src/mapParallel.d.ts b/dist/src/mapParallel.d.ts index dddecce..86d369f 100644 --- a/dist/src/mapParallel.d.ts +++ b/dist/src/mapParallel.d.ts @@ -1,7 +1,13 @@ /** - * iterate over the passed in array in parallel, running the iteratee on each element. + * {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map|MDN Documentation Array.prototype.map} + * + * @static + * @since 1.0.0 * @param {T[]} array * @param {(val: T, index?: number) => Promise} iteratee - * @param {number} [maxParallelBatchSize] + * @param {number} [maxParallelBatchSize=10] + * @example + * const array = [1, 2, 3]; + * const doubledArray = await mapParellel(array, async (value) => value * 2); */ export default function mapParallel(array: T[], iteratee: (value: T, index: number) => Promise, maxParallelBatchSize?: number): Promise; diff --git a/dist/src/mapParallel.js b/dist/src/mapParallel.js index 8355138..74d0f31 100644 --- a/dist/src/mapParallel.js +++ b/dist/src/mapParallel.js @@ -2,29 +2,18 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.default = mapParallel; /** - * take and complete tasks from a queue until that queue is empty. - * @param {{ task: T; index: number }[]} array - * @param {(val: T, index?: number) => Promise} iteratee - */ -async function takeAndCompleteFromQueueUntilDone(array, iteratee) { - const item = array.shift(); - if (!item) { - return []; - } - const completedTask = await iteratee(item.task, item.index); - const followingCompletedTasks = await takeAndCompleteFromQueueUntilDone(array, iteratee); - return followingCompletedTasks.concat({ - result: completedTask, - index: item.index, - }); -} -/** - * iterate over the passed in array in parallel, running the iteratee on each element. + * {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map|MDN Documentation Array.prototype.map} + * + * @static + * @since 1.0.0 * @param {T[]} array * @param {(val: T, index?: number) => Promise} iteratee - * @param {number} [maxParallelBatchSize] + * @param {number} [maxParallelBatchSize=10] + * @example + * const array = [1, 2, 3]; + * const doubledArray = await mapParellel(array, async (value) => value * 2); */ -async function mapParallel(array, iteratee, maxParallelBatchSize) { +async function mapParallel(array, iteratee, maxParallelBatchSize = 10) { if (!Array.isArray(array) || !array?.length) return []; const arrayWithIndexKeys = array.map((item, i) => { @@ -33,13 +22,11 @@ async function mapParallel(array, iteratee, maxParallelBatchSize) { index: i, }; }); - let effectiveMaxBatchSize = maxParallelBatchSize; - if (!effectiveMaxBatchSize || effectiveMaxBatchSize > array.length) { - effectiveMaxBatchSize = array.length; - } - const coolEmptyArray = Array(effectiveMaxBatchSize).fill(undefined); + const effectiveMaxBatchSize = maxParallelBatchSize > array.length ? array.length : maxParallelBatchSize; const results = []; - await Promise.all(coolEmptyArray.map(async () => { + await Promise.all(Array(effectiveMaxBatchSize) + .fill(undefined) + .map(async () => { const resultsWithIndex = await takeAndCompleteFromQueueUntilDone(arrayWithIndexKeys, iteratee); resultsWithIndex.forEach((result) => { results[result.index] = result.result; @@ -47,3 +34,20 @@ async function mapParallel(array, iteratee, maxParallelBatchSize) { })); return results; } +/** + * take and complete tasks from a queue until that queue is empty. + * @param {{ task: T; index: number }[]} array + * @param {(value: T, index: number) => Promise} iteratee + */ +async function takeAndCompleteFromQueueUntilDone(array, iteratee) { + const item = array.shift(); + if (!item) { + return []; + } + const completedTask = await iteratee(item.task, item.index); + const followingCompletedTasks = await takeAndCompleteFromQueueUntilDone(array, iteratee); + return followingCompletedTasks.concat({ + result: completedTask, + index: item.index, + }); +} diff --git a/package.json b/package.json index 70a86de..31b59ab 100644 --- a/package.json +++ b/package.json @@ -22,7 +22,9 @@ "keywords": [ "array", "async", - "iteraor" + "promise", + "iteraor", + "iteration" ], "engines": { "node": ">=18.0.0" diff --git a/src/mapParallel.ts b/src/mapParallel.ts index a4fda6a..d1c41b4 100644 --- a/src/mapParallel.ts +++ b/src/mapParallel.ts @@ -1,37 +1,19 @@ /** - * take and complete tasks from a queue until that queue is empty. - * @param {{ task: T; index: number }[]} array - * @param {(val: T, index?: number) => Promise} iteratee - */ -async function takeAndCompleteFromQueueUntilDone( - array: { task: T; index: number }[], - iteratee: (val: T, index: number) => Promise -): Promise<{ result: V; index: number }[]> { - const item = array.shift(); - if (!item) { - return []; - } - const completedTask = await iteratee(item.task, item.index); - const followingCompletedTasks = await takeAndCompleteFromQueueUntilDone( - array, - iteratee - ); - return followingCompletedTasks.concat({ - result: completedTask, - index: item.index, - }); -} - -/** - * iterate over the passed in array in parallel, running the iteratee on each element. + * {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map|MDN Documentation Array.prototype.map} + * + * @static + * @since 1.0.0 * @param {T[]} array * @param {(val: T, index?: number) => Promise} iteratee - * @param {number} [maxParallelBatchSize] + * @param {number} [maxParallelBatchSize=10] + * @example + * const array = [1, 2, 3]; + * const doubledArray = await mapParellel(array, async (value) => value * 2); */ export default async function mapParallel( array: T[], iteratee: (value: T, index: number) => Promise, - maxParallelBatchSize?: number + maxParallelBatchSize: number = 10 ): Promise { if (!Array.isArray(array) || !array?.length) return []; @@ -41,23 +23,51 @@ export default async function mapParallel( index: i, }; }); - let effectiveMaxBatchSize = maxParallelBatchSize; - if (!effectiveMaxBatchSize || effectiveMaxBatchSize > array.length) { - effectiveMaxBatchSize = array.length; - } - const coolEmptyArray = Array(effectiveMaxBatchSize).fill(undefined); + + const effectiveMaxBatchSize = + maxParallelBatchSize > array.length ? array.length : maxParallelBatchSize; const results: V[] = []; await Promise.all( - coolEmptyArray.map(async () => { - const resultsWithIndex = await takeAndCompleteFromQueueUntilDone( - arrayWithIndexKeys, - iteratee - ); - resultsWithIndex.forEach((result) => { - results[result.index] = result.result; - }); - }) + Array(effectiveMaxBatchSize) + .fill(undefined) + .map(async () => { + const resultsWithIndex = await takeAndCompleteFromQueueUntilDone( + arrayWithIndexKeys, + iteratee + ); + + resultsWithIndex.forEach((result) => { + results[result.index] = result.result; + }); + }) ); + return results; } + +/** + * take and complete tasks from a queue until that queue is empty. + * @param {{ task: T; index: number }[]} array + * @param {(value: T, index: number) => Promise} iteratee + */ +async function takeAndCompleteFromQueueUntilDone( + array: { task: T; index: number }[], + iteratee: (value: T, index: number) => Promise +): Promise<{ result: V; index: number }[]> { + const item = array.shift(); + if (!item) { + return []; + } + + const completedTask = await iteratee(item.task, item.index); + const followingCompletedTasks = await takeAndCompleteFromQueueUntilDone( + array, + iteratee + ); + + return followingCompletedTasks.concat({ + result: completedTask, + index: item.index, + }); +} From e577a6a4a2e6a95dd160569f08c0fd5518e9f9a9 Mon Sep 17 00:00:00 2001 From: Wesley Guthrie Date: Mon, 10 Mar 2025 23:35:11 -0500 Subject: [PATCH 12/13] fix jsdoc --- src/mapParallel.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/mapParallel.ts b/src/mapParallel.ts index d1c41b4..5075f05 100644 --- a/src/mapParallel.ts +++ b/src/mapParallel.ts @@ -6,6 +6,7 @@ * @param {T[]} array * @param {(val: T, index?: number) => Promise} iteratee * @param {number} [maxParallelBatchSize=10] + * @returns {Promise} * @example * const array = [1, 2, 3]; * const doubledArray = await mapParellel(array, async (value) => value * 2); From 3e8c2eaf1ffef17beae1e9a19e9d532b7ba6d0d1 Mon Sep 17 00:00:00 2001 From: Wesley Guthrie Date: Mon, 10 Mar 2025 23:35:28 -0500 Subject: [PATCH 13/13] yarn build --- dist/src/mapParallel.d.ts | 1 + dist/src/mapParallel.js | 1 + 2 files changed, 2 insertions(+) diff --git a/dist/src/mapParallel.d.ts b/dist/src/mapParallel.d.ts index 86d369f..0d098e5 100644 --- a/dist/src/mapParallel.d.ts +++ b/dist/src/mapParallel.d.ts @@ -6,6 +6,7 @@ * @param {T[]} array * @param {(val: T, index?: number) => Promise} iteratee * @param {number} [maxParallelBatchSize=10] + * @returns {Promise} * @example * const array = [1, 2, 3]; * const doubledArray = await mapParellel(array, async (value) => value * 2); diff --git a/dist/src/mapParallel.js b/dist/src/mapParallel.js index 74d0f31..5beabd8 100644 --- a/dist/src/mapParallel.js +++ b/dist/src/mapParallel.js @@ -9,6 +9,7 @@ exports.default = mapParallel; * @param {T[]} array * @param {(val: T, index?: number) => Promise} iteratee * @param {number} [maxParallelBatchSize=10] + * @returns {Promise} * @example * const array = [1, 2, 3]; * const doubledArray = await mapParellel(array, async (value) => value * 2);