source: node_modules/ramda-adjunct/lib/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.4 KB
RevLine 
[d24f17c]1"use strict";
2
3exports.__esModule = true;
4exports["default"] = void 0;
5var _ramda = require("ramda");
6var _isArray = _interopRequireDefault(require("./isArray"));
7function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
8/**
9 * Checks if input value is a sparse Array.
10 * An array with at least one "empty slot" in it is often called a "sparse array."
11 * Empty slot doesn't mean that the slot contains `null` or `undefined` values,
12 * but rather that the slots don't exist.
13 *
14 * @func isSparseArray
15 * @memberOf RA
16 * @since {@link https://char0n.github.io/ramda-adjunct/2.20.0|v2.20.0}
17 * @category Type
18 * @sig * -> Boolean
19 * @param {*} list The list to test
20 * @return {boolean}
21 * @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}
22 * @example
23 *
24 * RA.isSparseArray(new Array(3)); // => true
25 * RA.isSparseArray([1,,3]); // => true
26 *
27 * const list = [1, 2, 3];
28 * delete list[1];
29 * RA.isSparseArray(list); // => true
30 *
31 * RA.isSparseArray([1, 2, 3]); // => false
32 */
33var isSparseArray = (0, _ramda.both)(_isArray["default"], (0, _ramda.converge)((0, _ramda.complement)(_ramda.identical), [(0, _ramda.pipe)(_ramda.values, _ramda.length), _ramda.length]));
34var _default = isSparseArray;
35exports["default"] = _default;
Note: See TracBrowser for help on using the repository browser.