import isArrayOf from '../../array/check/isArrayOf'
import isSize from '../../attributes/properties/isSize'
import { PairedArrayOf } from './Pairs.typings'
const isTwo = (size: number) => size === 2
// @TODO can also add "isPairsLike" to just check ONE
// @TODO can also do this
// const firstOfFirst = pipeTwo(first, first)
// isPairs = x =>
// multiDimensionalArray(x) && isStringOrNumber(firstOfFirst(x))
/* prettier-ignore */
/**
* @since 5.0.0-beta.9
* @memberOf is
*
* @name isPairs
* @alias isArrayPairs
* @alias isArrayOfPairs
* @alias isPairedArray
* @alias isMultiDimensionalArray
* @alias isNestedArray
*
* @param {Array<Array> | *} x possible pairs
* @return {boolean} x isPairs
*
* @TODO @FIXME @HACK @TIME remove the `isTwo`
* @see is/arrayOf
* @NOTE could also be written similar to `pipeTwo(first, isArray)`
*
* @example isPairs([[1, 2], [1, 2]]) //=> true
* @example isPairs([[1], [1, 2]]) //=> false
* @example isPairs([]) //=> false
*
*/
function isPairs<Type>(x: any): x is PairedArrayOf<Type> {
return isArrayOf(
isArrayOf(
isSize(isTwo)
)
)
}
export { isPairs }
export default isPairs