Class: ArgumentStream
Constructors
new ArgumentStream()
new ArgumentStream(
results:ParserResult):ArgumentStream
Parameters
| Parameter | Type |
|---|---|
results | ParserResult |
Returns
Defined in
Properties
results
readonlyresults:ParserResult
Defined in
state
state:
State
Defined in
Accessors
finished
Get Signature
get finished():
boolean
Whether or not all ordered parameters were used.
Returns
boolean
Defined in
length
Get Signature
get length():
number
The amount of ordered parameters.
Returns
number
Defined in
remaining
Get Signature
get remaining():
number
The remaining amount of ordered parameters.
Returns
number
Defined in
used
Get Signature
get used():
number
The amount of ordered parameters that have been used.
Returns
number
Defined in
Methods
filter()
filter(
predicate: (value:string) =>boolean,from:number):Option<string[],boolean>
Parameters
| Parameter | Type |
|---|---|
predicate | (value: string) => boolean |
from | number |
Returns
Option<string[], boolean>
Defined in
filterAsync()
filterAsync(
predicate: (value:string) =>Promise<boolean>,from:number):Promise<Option<string[],boolean>>
Parameters
| Parameter | Type |
|---|---|
predicate | (value: string) => Promise<boolean> |
from | number |
Returns
Promise<Option<string[], boolean>>
Defined in
filterMap()
filterMap<
T>(predicate: (value:string) =>Option<T,boolean>,from:number):Option<T[],boolean>
Type Parameters
| Type Parameter |
|---|
T |
Parameters
| Parameter | Type |
|---|---|
predicate | (value: string) => Option<T, boolean> |
from | number |
Returns
Option<T[], boolean>
Defined in
filterMapAsync()
filterMapAsync<
T>(predicate: (value:string) =>Promise<Option<T,boolean>>,from:number):Promise<Option<T[],boolean>>
Type Parameters
| Type Parameter |
|---|
T |
Parameters
| Parameter | Type |
|---|---|
predicate | (value: string) => Promise<Option<T, boolean>> |
from | number |
Returns
Promise<Option<T[], boolean>>
Defined in
find()
find(
predicate: (value:string) =>boolean,from:number):Option<string,boolean>
Returns the value of the first element in the array within Option.some where predicate returns true, and
Option.none otherwise.
Parameters
| Parameter | Type | Description |
|---|---|---|
predicate | (value: string) => boolean | find calls predicate once for each unused ordered parameter, in ascending order, until it finds one where predicate returns true. If such an element is found, find immediately returns a Option.some with that element value. Otherwise, find returns Option.none. |
from | number | The position where to start looking for unused parameters, defaults to current position. |
Returns
Option<string, boolean>
The found parameter's value.
Note
This does not support asynchronous results, refer to findAsync.
Example
// Suppose args are from 'ba aa cc'.
console.log(args.find((value) => value.startsWith('a')));
// Some { value: 'aa' }
Defined in
findAsync()
findAsync(
predicate: (value:string) =>Promise<boolean>,from:number):Promise<Option<string,boolean>>
Returns the value of the first element in the array within Option.some where predicate returns true, and
Option.none otherwise.
Parameters
| Parameter | Type | Description |
|---|---|---|
predicate | (value: string) => Promise<boolean> | find calls predicate once for each unused ordered parameter, in ascending order, until it finds one where predicate returns true. If such an element is found, find immediately returns a Option.some with that element value. Otherwise, find returns Option.none. |
from | number | The position where to start looking for unused parameters, defaults to current position. |
Returns
Promise<Option<string, boolean>>
The found parameter's value.
Note
This is an asynchronous variant of find.
Example
// Suppose args are from 'ba aa cc'.
console.log(args.find((value) => value.startsWith('a')));
// Some { value: 'aa' }
Defined in
findMap()
findMap<
T>(predicate: (value:string) =>Option<T,boolean>,from:number):Option<T,boolean>
Returns the value of the first element in the array within Option.some where predicate returns Some, and
Option.none otherwise.
Type Parameters
| Type Parameter |
|---|
T |
Parameters
| Parameter | Type | Description |
|---|---|---|
predicate | (value: string) => Option<T, boolean> | find calls predicate once for each unused ordered parameter, in ascending order, until it finds one where predicate returns Some. If such an element is found, find immediately returns the returned value. Otherwise, find returns Option.none. |
from | number | The position where to start looking for unused parameters, defaults to current position. |
Returns
Option<T, boolean>
The found parameter's value.
Note
This does not support asynchronous results, refer to findMapAsync.
Example
// Suppose args are from 'ba aa cc'.
console.log(args.find((value) => value.startsWith('a')));
// Some { value: 'aa' }
Typeparam
T The output type.
Defined in
findMapAsync()
findMapAsync<
T>(predicate: (value:string) =>Promise<Option<T,boolean>>,from:number):Promise<Option<T,boolean>>
Returns the value of the first element in the array within Option.some where predicate returns Some, and
Option.none otherwise.
Type Parameters
| Type Parameter |
|---|
T |
Parameters
| Parameter | Type | Description |
|---|---|---|
predicate | (value: string) => Promise<Option<T, boolean>> | find calls predicate once for each unused ordered parameter, in ascending order, until it finds one where predicate returns Some. If such an element is found, find immediately returns the returned value. Otherwise, find returns Option.none. |
from | number | The position where to start looking for unused parameters, defaults to current position. |
Returns
Promise<Option<T, boolean>>
The found parameter's value.
Note
This is an asynchronous variant of findMap.
Example
// Suppose args are from 'ba aa cc'.
console.log(args.find((value) => value.startsWith('a')));
// Some { value: 'aa' }
Typeparam
T The output type.