source: node_modules/ramda-adjunct/es/isSparseArray.js@ d24f17c

main
Last change on this file since d24f17c was d24f17c, checked in by Aleksandar Panovski <apano77@…>, 15 months ago

Initial commit

  • Property mode set to 100644
File size: 1.1 KB
Line 
1import { values, both, complement, pipe, converge, identical, length } from 'ramda';
2import isArray from './isArray';
3
4/**
5 * Checks if input value is a sparse Array.
6 * An array with at least one "empty slot" in it is often called a "sparse array."
7 * Empty slot doesn't mean that the slot contains `null` or `undefined` values,
8 * but rather that the slots don't exist.
9 *
10 * @func isSparseArray
11 * @memberOf RA
12 * @since {@link https://char0n.github.io/ramda-adjunct/2.20.0|v2.20.0}
13 * @category Type
14 * @sig * -> Boolean
15 * @param {*} list The list to test
16 * @return {boolean}
17 * @see {@link https://github.com/getify/You-Dont-Know-JS/blob/f0d591b6502c080b92e18fc470432af8144db610/types%20%26%20grammar/ch3.md#array|Sparse Arrays}, {@link RA.isArray|isArray}
18 * @example
19 *
20 * RA.isSparseArray(new Array(3)); // => true
21 * RA.isSparseArray([1,,3]); // => true
22 *
23 * const list = [1, 2, 3];
24 * delete list[1];
25 * RA.isSparseArray(list); // => true
26 *
27 * RA.isSparseArray([1, 2, 3]); // => false
28 */
29var isSparseArray = both(isArray, converge(complement(identical), [pipe(values, length), length]));
30export default isSparseArray;
Note: See TracBrowser for help on using the repository browser.