Wiki
Clone wikiimmutable-box / Home
Box
Immutable Box
Construction
Box(value, mutable)
Create a new box
Param | Type | Description |
---|---|---|
value | * |
The box' value |
mutable | bool |
Should the box be mutable? |
Static methods
Box.isBox(maybeBox)
Check if the given value is a box
Param | Type | Description |
---|---|---|
maybeBox | * |
The value to check |
Members
size
The box' size
Instance methods
toArray()
Convert the box to an array
Returns: Array
- The array
toJS()
Convert the box to JS
Returns: *
- The box' value
toJSON()
Convert the box to JS
Returns: *
- The box' value
asMutable()
Make the box mutable
Returns: Box
- The box
asImmutable()
Make the box immutable
Returns: Box
- The box
withMutations(fn)
Apply the given mutator, return an immutable box
Returns: Box
- The box
Param | Type | Description |
---|---|---|
fn | function |
The function |
equals(value)
Check the box for equality
Param | Type | Description |
---|---|---|
value | Box |
The box to check against |
get()
Get the box' value
Returns: *
- The value
includes(value)
Check if the box' includes a value
Param | Type | Description |
---|---|---|
value | * |
The value to check against |
set(value)
Set the box' value
Returns: Box
- The box
Param | Type | Description |
---|---|---|
value | * |
The new value |
clear()
Clear the box
Returns: Box
- The box
map(fn)
Update the box' value (map)
Returns: Box
- The box
Param | Type | Description |
---|---|---|
fn | function |
The updater (mapper) function |
update(fn)
Update the box (pipe to function)
Returns: Box
- The box
Param | Type | Description |
---|---|---|
fn | function |
The updater function |
filter(fn)
Filter the box' value
Returns: Box
- The box
Param | Type | Description |
---|---|---|
fn | function |
The qualifying function |
filterNot(fn)
Filter the box' value
Returns: Box
- The box
Param | Type | Description |
---|---|---|
fn | function |
The qualifying function |
forEach(fn)
Pass the box' value to a function
Returns: Box
- The box
Param | Type |
---|---|
fn | function |
isEmpty()
Check if the box is empty
Updated