Arrays asserts.
- Source:
Methods
(inner) arrayOfBooleans(value) → {*|boolean}
Check if is an array of booleans
Interfaces: all
, any
, not
, err
- Since:
- 1.3.1
- Source:
Parameters:
Name | Type | Description |
---|---|---|
value |
array
|
array |
Returns:
- Type:
-
*
|boolean
Example
be.arrayOfBooleans([true, false]) // true
be.all.arrayOfBooleans([
true,
false,
[1, 2, 3]
]) // false
(inner) arrayOfDates(value) → {*|boolean}
Check if is an array of dates
Interfaces: all
, any
, not
, err
- Since:
- 1.4.0
- Source:
Parameters:
Name | Type | Description |
---|---|---|
value |
array
|
array |
Returns:
- Type:
-
*
|boolean
Example
be.arrayOfDates([new Date(), new Date('2017-07-06')]) // true
be.all.arrayOfDates([
true,
false,
new Date()
]) // false
(inner) arrayOfFunctions(value) → {*|boolean}
Check if is an array of functions
Interfaces: all
, any
, not
, err
- Since:
- 1.4.0
- Source:
Parameters:
Name | Type | Description |
---|---|---|
value |
array
|
array |
Returns:
- Type:
-
*
|boolean
Example
be.arrayOfFunctions([function(){return 1}, function(){return 2}]) // true
be.all.arrayOfFunctions([
true,
false,
function(){return 1}
]) // false
(inner) arrayOfNumbers(value) → {*|boolean}
Check if is an array of numbers
Interfaces: all
, any
, not
, err
- Since:
- 1.4.0
- Source:
Parameters:
Name | Type | Description |
---|---|---|
value |
array
|
array |
Returns:
- Type:
-
*
|boolean
Example
be.arrayOfNumbers([1, 2]) // true
be.all.arrayOfNumbers([
true,
false,
[1, 2, 3]
]) // false
(inner) arrayOfNumeric(value) → {*|boolean}
Check if is an array of numeric
Interfaces: all
, any
, not
, err
- Since:
- 1.13.0
- Source:
Parameters:
Name | Type | Description |
---|---|---|
value |
array
|
array |
Returns:
- Type:
-
*
|boolean
Example
be.arrayOfNumeric([1, "2"]) // true
be.all.arrayOfNumeric([
12,
"two"
]) // false
(inner) arrayOfObjects(value) → {*|boolean}
Check if is an array of objects
Interfaces: all
, any
, not
, err
- Source:
Parameters:
Name | Type | Description |
---|---|---|
value |
array
|
array |
Returns:
- Type:
-
*
|boolean
Example
be.arrayOfObjects([{a:1},{b:2}]) // true
be.all.arrayOfObjects([
{a: 1},
{b: 2},
[1, 2, 3]
]) // false
(inner) arrayOfStrings(value) → {*|boolean}
Check if is an array of strings
Interfaces: all
, any
, not
, err
- Source:
Parameters:
Name | Type | Description |
---|---|---|
value |
array
|
array |
Returns:
- Type:
-
*
|boolean
Example
be.arrayOfStrings(['hello', 'world']) // true
be.all.arrayOfStrings([
['hello', 'world'],
['ciao', 'mondo']
]) // true
(inner) inArray(value, array) → {boolean}
Check if an element is in the array
Interfaces: not
, err
- Source:
Parameters:
Name | Type | Description |
---|---|---|
value |
Mixed
|
element to search |
array |
array
|
array where search |
Returns:
- Type:
-
boolean
Example
be.inArray('hello', ['hello', 'world']) //true
be.inArray('ciao', ['hello', 'world']) //false
be.inArray(1, true) //false
be.not.inArray(1, true) //true
be.Arrays.inArray(1, [1, 2, 3]) //true
(inner) objValueInArray(array, key, value) → {*|boolean}
Check if is a key of an object with determined value is in array
Interfaces: not
, err
- Since:
- 1.10.0
- Source:
Parameters:
Name | Type | Description |
---|---|---|
array |
Array
|
array |
key |
string
|
object key that you are looking for |
value |
any
|
the value of the key that you are looking for |
Returns:
- Type:
-
*
|boolean
Example
be.objValueInArray([{ id: 1, name: '...'}], 'id', 1) // true