From 9f03408bb9feeba4e26072101f2f08088bf9ab4e Mon Sep 17 00:00:00 2001 From: "Alex A. Naanou" Date: Thu, 25 Mar 2021 14:40:51 +0300 Subject: [PATCH] more docs... Signed-off-by: Alex A. Naanou --- README.md | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 0d49c48..a99238c 100644 --- a/README.md +++ b/README.md @@ -1091,7 +1091,7 @@ But `Generator()` takes no arguments and thus can not be used as a wrapper. ### Generator instance iteration This is a set of `Array`-like iterator methods that enable chaining of -generators. +generators and `Promise`-like API to handle the generated results. Chained generators handle items depth-first, i.e. the items are passed as they are yielded down the generator chain. @@ -1101,13 +1101,40 @@ Chained generators handle items depth-first, i.e. the items are passed as they a Equivalents to `Array`'s `.map(..)`, `.filter(..)` and `.reduce(..)` but return generators that yield the handler return values. + + #### `.slice(..)` +```bnf +.slice() +.slice() +.slice(, ) + -> +``` + + #### `.at(..)` +```bnf +.at() + -> +``` +Returns a generator that will yield an item at a specific position when it is +available. + + #### `.flat(..)` +```bnf +.flat() +.flat() + -> +``` + + #### `.shift()` / `.pop()` Return a generator yielding the first/last sequence item. @@ -1118,10 +1145,39 @@ need break item processing order. #### `.promise()` +```bnf +.promise() + -> +``` +Return a promise and resolve it with the generator value. + +Note that this will deplete the generator. + + #### `.then(..)` / `.catch(..)` / `.finally(..)` +```bnf +.then(, ) + -> + +.then() + -> + +.finally() + -> +``` +Shorthands to `.promise().then(..)` / `.promise().catch(..)` / `.promise().finally(..)` + + #### `.toArray()` +```bnf +.toArray() + -> +``` + +This is equivalent to `[...]`. + ### Generator constructor iteration