Generators
In @fluentfixture, streams cannot be initialized directly. To take advantage of the stream's fluent interface, we can use generator functions.
Boolean
bool()
Returns a BooleanStream
that produces a boolean value.
Parameter | Type | Default | Description |
---|---|---|---|
|
|
| chance causing it to be |
truthy()
Returns a BooleanStream
that always produces true
.
falsy()
Returns a BooleanStream
that always produces false
.
Number
int()
Returns an NumberStream
that produces an integer value.
Parameter | Type | Default | Description |
---|---|---|---|
|
|
| lower boundary |
|
|
| upper boundary |
real()
Returns an NumberStream
that produces a float value.
Parameter | Type | Default | Description |
---|---|---|---|
|
|
| lower boundary |
|
|
| upper boundary |
num()
Returns an NumberStream
that always produces the given number.
Parameter | Type | Default | Description |
---|---|---|---|
|
| value |
zero()
Returns an NumberStream
that always produces zero
.
one()
Returns an NumberStream
that always produces one
.
String
text()
Returns a StringStream
that always produces the given value.
Parameter | Type | Default | Description |
---|---|---|---|
|
| string |
str()
Returns a StringStream
that produces a string.
Parameter | Type | Default | Description |
---|---|---|---|
|
| included characters | |
|
|
| target length |
hex()
Returns a StringStream
that produces a hex string.
Parameter | Type | Default | Description |
---|---|---|---|
|
|
| target length |
binary()
Returns a StringStream
that produces a binary string.
Parameter | Type | Default | Description |
---|---|---|---|
|
|
| target length |
octal()
Returns a StringStream
that produces an octal string.
Parameter | Type | Default | Description |
---|---|---|---|
|
|
| target length |
numeric()
Returns a StringStream
that produces a numeric string.
Parameter | Type | Default | Description |
---|---|---|---|
|
|
| target length |
alphabetic()
Returns a StringStream
that produces an alphabetic string.
Parameter | Type | Default | Description |
---|---|---|---|
|
|
| target length |
alphanumeric()
Returns a StringStream
that produces an alphanumeric string.
Parameter | Type | Default | Description |
---|---|---|---|
|
|
| target length |
Date
date()
Returns a DateStream
that produces a date.
Parameter | Type | Default | Description |
---|---|---|---|
|
|
| lower boundary |
|
|
| upper boundary |
now()
Returns a DateStream
that produces the current date.
Object
obj()
Returns an ObjectStream
that produces an object.
Parameter | Type | Default | Description |
---|---|---|---|
|
| object model |
Utilities
nil()
Returns a Stream
that always produces null.
undef()
Returns a Stream
that always produces undefined.
val()
Returns a Stream
that always produces the given value.
Parameter | Type | Default | Description |
---|---|---|---|
|
| value |
from()
Returns a Stream
that produces the result of the given function.
Parameter | Type | Default | Description |
---|---|---|---|
|
| function |
list()
Returns an ArrayStream
that produces that contains the given list.
Parameter | Type | Default | Description |
---|---|---|---|
|
| array |
pick()
Returns a Stream
that picks an item from the given list.
sample()
Returns an ArrayStream
that takes items from the given list.
Parameter | Type | Default | Description |
---|---|---|---|
|
| count |
shuffle()
Returns an ArrayStream
that shuffles the given list.
Last updated