From 41e9b1e14f358d234b386ce8ee122fa30f211a7d Mon Sep 17 00:00:00 2001 From: sergeyampo Date: Fri, 20 Jan 2023 08:29:27 +0300 Subject: [PATCH] Update badges, docs. Refactor. --- README.md | 4 +++- index.d.ts | 4 ++++ lib/async-time-iterator.js | 5 +++-- package.json | 10 ++++++++++ 4 files changed, 20 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 2dfdfd8..aa05c29 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,5 @@ +![Workflow](https://github.com/sergeyampo/array-to-async-iterable/actions/workflows/npm-publish.yml/badge.svg) + # array-to-async-iterable This tiny package with zero-dependencies, typescript .d.ts coverage, full ESM and CJS compatibility helps you to iterate over large collections in **Node.js** truly asynchronously. @@ -55,4 +57,4 @@ It's recommended for an array to be large and have simple operations in a loop. You won't get much profit using small arrays for extremely long operations. -Inspired by @metarhia. +Inspired by [@metarhia](https://github.com/HowProgrammingWorks). diff --git a/index.d.ts b/index.d.ts index fd0e537..ded9457 100644 --- a/index.d.ts +++ b/index.d.ts @@ -1,3 +1,7 @@ export declare class AsyncTimeIterator{ + /** + * @param array Iterable contract. + * @param ms Give a quantum of time to the event loop every n milliseconds. + */ constructor(array: Array, ms?: number); } diff --git a/lib/async-time-iterator.js b/lib/async-time-iterator.js index 9b275a7..94e5aa4 100644 --- a/lib/async-time-iterator.js +++ b/lib/async-time-iterator.js @@ -4,16 +4,17 @@ const DEFAULT_INTERVAL = 500; class AsyncTimeIterator { #arrayRef = []; + #interval; constructor(array, ms = DEFAULT_INTERVAL) { this.#arrayRef = array; - this._interval = ms; + this.#interval = ms; } [Symbol.asyncIterator]() { let time = Date.now(); let i = 0; - const interval = this._interval; + const interval = this.#interval; return { next: () => { const now = Date.now(); diff --git a/package.json b/package.json index a842106..6ec5b6a 100644 --- a/package.json +++ b/package.json @@ -14,6 +14,16 @@ "type": "git", "url": "git+https://github.com/sergeyampo/array-to-async-iterable.git" }, + "keywords": [ + "array-to-async-iterable", + "for await array", + "async iterator array", + "AsyncIterable", + "AsyncTimeIterator", + "nodejs async array", + "nodejs async iterator", + "nodejs array to async iterable" + ], "author": "sergeyampo", "license": "MIT", "bugs": {