From abf91a13dc760302a0dfe98fec82e80650b6ed4e Mon Sep 17 00:00:00 2001 From: Tyler <26290074+thegitduck@users.noreply.github.com> Date: Sat, 21 Dec 2024 18:41:52 -0800 Subject: [PATCH] update docs --- README.md | 27 ++++++++------------------- deno.json | 2 +- 2 files changed, 9 insertions(+), 20 deletions(-) diff --git a/README.md b/README.md index be09d40..6c51312 100644 --- a/README.md +++ b/README.md @@ -17,10 +17,7 @@ This helper is unique to duckhawk. We support easily running a large list of pro ```ts import { allChunked } from "duckhawk"; -const result = await allChunked( - [Promise.resolve(1), Promise.resolve(2), Promise.resolve(3)], - 2 -); +const result = await allChunked([1, 2, 3], 2); console.log(result); // [1, 2, 3] ``` @@ -35,10 +32,7 @@ returned as an array. ```ts import { map } from "duckhawk"; -const result = await map( - [Promise.resolve(1), Promise.resolve(2), Promise.resolve(3)], - (item) => item + 1 -); +const result = await map([1, 2, 3], (item) => Promise.resolve(item + 1)); ``` concurrency can be passed to limit the number of promises to run in parallel. @@ -46,11 +40,9 @@ concurrency can be passed to limit the number of promises to run in parallel. ```ts import { map } from "duckhawk"; -const result = await map( - [Promise.resolve(1), Promise.resolve(2), Promise.resolve(3)], - (item) => item + 1, - { concurrency: 2 } -); +const result = await map([1, 2, 3], (item) => Promise.resolve(item + 1), { + concurrency: 2, +}); ``` ### mapSeries @@ -63,10 +55,7 @@ returned as an array. ```ts import { mapSeries } from "duckhawk"; -const result = await mapSeries( - [Promise.resolve(1), Promise.resolve(2), Promise.resolve(3)], - (item) => item + 1 -); +const result = await mapSeries([1, 2, 3], (item) => Promise.resolve(item + 1)); console.log(result); // [2, 3, 4] ``` @@ -98,8 +87,8 @@ This awaits each promise in series and passes the result to the iterator. The fi import { reduce } from "duckhawk"; const result = await reduce( - [Promise.resolve(1), Promise.resolve(2), Promise.resolve(3)], - (acc, item) => acc + item, + [1, 2, 3], + (acc, item) => Promise.resolve(acc + item), 0 ); diff --git a/deno.json b/deno.json index 3392645..7c25b8f 100644 --- a/deno.json +++ b/deno.json @@ -1,6 +1,6 @@ { "name": "@tyler/duckhawk", - "version": "0.1.5", + "version": "0.1.6", "description": "native Promise based implementations of bluebird utilities", "exports": "./src/index.ts", "repository": { -- 2.51.2