Repository URL to install this package:
|
Version:
1.1.21 ▾
|
"use strict";
const isArrayOf = require("./arrayOf");
const isSize = require("./size");
const isTwo = size => 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
*
*/
module.exports = function isPairs(x) {
return isArrayOf(isArrayOf(isSize(isTwo)));
};