# arrays.js

    /**
     * @fileOverview Arrays checks.
     * @module Array
     */

    const Types = require('./types');
    const Interface = require('../interface');
    let Arrays = {};

    /**
     * Check if an element is in the array
     *
     * **Interface**: `not`
     *
     * @param value {Mixed} element to search
     * @param array {array} array where search
     * @function
     * @name inArray
     * @return {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
     */
    Arrays.inArray = (value, array) => {
        if(!Types.array(array)) return false;
        for(let i in array){
            if(array.hasOwnProperty(i) && array[i] === value)
                return true;
        }
        return false;
    };

    Arrays.inArray.multiple = false;

    /**
     * Check if is an array of strings
     *
     * **Interfaces**: `all`, `any`, `not`
     *
     * @param value {array} array
     * @function
     * @name arrayOfStrings
     * @returns {*|boolean}
     * @example
     * be.arrayOfStrings(['hello', 'world']) // true
     * be.all.arrayOfStrings([
     *     ['hello', 'world'],
     *     ['ciao', 'mondo']
     * ]) // true
     */
    Arrays.arrayOfStrings = (value) => {
        return Types.all.string(value);
    };

    /**
     * Check if is an array of objects
     *
     * **Interfaces**: `all`, `any`, `not`
     *
     * @function
     * @name arrayOfObjects
     * @param value {array} array
     * @returns {*|boolean}
     * @example
     * be.arrayOfObjects({a:1},{b:2}) // true
     * be.all.arrayOfObjects([
     *      {a: 1},
     *      {b: 2},
     *      [1, 2, 3]
     * ]) // false
     */
    Arrays.arrayOfObjects = (value) => {
        return Types.all.object(value);
    };

    Arrays = Interface.create(Arrays);

    module.exports = Arrays;