From 963ff338215e1321dbd8838b7adc9364e2865148 Mon Sep 17 00:00:00 2001 From: "Alex A. Naanou" Date: Tue, 11 May 2021 19:10:45 +0300 Subject: [PATCH] docs (experimental)... Signed-off-by: Alex A. Naanou --- README.md | 63 +++++++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 52 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index c7c220a..6f886f4 100644 --- a/README.md +++ b/README.md @@ -77,15 +77,15 @@ A library of JavaScript type extensions, types and type utilities. - [Generator instance iteration](#generator-instance-iteration) - [`.map(..)` / `.filter(..)` / `.reduce(..)`](#generatormap--generatorfilter--generatorreduce) - [`.slice(..)`](#generatorslice) - - [`.at(..)`](#generatorat) + - [`.at(..)` / `.gat(..)`](#generatorat--generatorgat) - [`.flat(..)`](#generatorflat) - [`.shift()` / `.pop()`](#generatorshift--generatorpop) - [`.promise()`](#generatorpromise) - [`.then(..)` / `.catch(..)` / `.finally(..)`](#generatorthen--generatorcatch--generatorfinally) - [`.toArray()`](#generatortoarray) - [Generator constructor iteration](#generator-constructor-iteration) - - [`.at(..)`](#generatorat-1) - - [`.shift()` / `.pop()`](#generatorshift--generatorpop-1) + - [`.at(..)` / `.gat(..)`](#generatorat--generatorgat-1) + - [`.shift()` / `.pop()` / `.gshift()` / `.gpop()`](#generatorshift--generatorpop--generatorgshift--generatorgpop) - [`.slice(..)`](#generatorslice-1) - [`.map(..)` / `.filter(..)` / `.reduce(..)` / `.flat()`](#generatormap--generatorfilter--generatorreduce--generatorflat) - [`.toArray()`](#generatortoarray-1) @@ -1662,14 +1662,17 @@ instead of an array, for more info see: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/slice -#### `.at(..)` +#### `.at(..)` / `.gat(..)` ```bnf .at() + -> + -> undefined + +.gat() -> ``` -Returns a generator that will yield an item at a specific position when it is -available. + #### `.flat(..)` @@ -1778,37 +1781,75 @@ console.log(sumOdds([1, 2, 3])) // -> 4 console.log(sumOdds([1, 2, 3, 4, 5, 6, 7])) // -> 16 ``` + + + +`` methods fall into two categories: +- `` + create a new chained `` object that when called will return + a `` +- `` + create a chained _function_ that when called will return a ``/`undefined` + +```bnf +.(..) + -> + +.(..) + -> + +() + -> + +() + -> + -> undefined +``` + -#### `.at(..)` +#### `.at(..)` / `.gat(..)` ```bnf .at() + -> + +.gat() -> ``` -#### `.shift()` / `.pop()` +#### `.shift()` / `.pop()` / `.gshift()` / `.gpop()` ```bnf .shift() .pop() -> + +.gshift() +.gpop() + -> ``` -Note that `.shift()` will get the element the generator is at currently which may -not be the first element in the sequence. +Note that `.shift()`/`.gshift()` will get the element the generator is at +currently which may not be the first element in the sequence. #### `.slice(..)` +```bnf +.slice() +.slice(, ) + -> +``` + This is like `Array`'s `.slice(..)` but does not support negative indexes.