1 | "use strict";
|
---|
2 |
|
---|
3 | exports.__esModule = true;
|
---|
4 | exports["default"] = void 0;
|
---|
5 | var _ramda = require("ramda");
|
---|
6 | var _isArray = _interopRequireDefault(require("./isArray"));
|
---|
7 | var _isString = _interopRequireDefault(require("./isString"));
|
---|
8 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
---|
9 | function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
---|
10 | /* eslint-disable max-len */
|
---|
11 | /**
|
---|
12 | * Tests whether or not an object is similar to an array.
|
---|
13 | *
|
---|
14 | * @func isArrayLike
|
---|
15 | * @memberOf RA
|
---|
16 | * @since {@link https://char0n.github.io/ramda-adjunct/1.9.0|v1.9.0}
|
---|
17 | * @licence https://github.com/ramda/ramda/blob/master/LICENSE.txt
|
---|
18 | * @category List
|
---|
19 | * @category Type
|
---|
20 | * @sig * -> Boolean
|
---|
21 | * @param {*} val The value to test
|
---|
22 | * @returns {boolean} `true` if `val` has a numeric length property and extreme indices defined; `false` otherwise.
|
---|
23 | * @see {@link RA.isNotArrayLike|isNotArrayLike}
|
---|
24 |
|
---|
25 | * @example
|
---|
26 | *
|
---|
27 | * RA.isArrayLike([]); //=> true
|
---|
28 | * RA.isArrayLike(true); //=> false
|
---|
29 | * RA.isArrayLike({}); //=> false
|
---|
30 | * RA.isArrayLike({length: 10}); //=> false
|
---|
31 | * RA.isArrayLike({0: 'zero', 9: 'nine', length: 10}); //=> true
|
---|
32 | */
|
---|
33 | /* eslint-enable max-len */
|
---|
34 | var isArrayLike = (0, _ramda.curryN)(1, function (val) {
|
---|
35 | if ((0, _isArray["default"])(val)) {
|
---|
36 | return true;
|
---|
37 | }
|
---|
38 | if (!val) {
|
---|
39 | return false;
|
---|
40 | }
|
---|
41 | if ((0, _isString["default"])(val)) {
|
---|
42 | return false;
|
---|
43 | }
|
---|
44 | if (_typeof(val) !== 'object') {
|
---|
45 | return false;
|
---|
46 | }
|
---|
47 | if (val.nodeType === 1) {
|
---|
48 | return !!val.length;
|
---|
49 | }
|
---|
50 | if (val.length === 0) {
|
---|
51 | return true;
|
---|
52 | }
|
---|
53 | if (val.length > 0) {
|
---|
54 | return (0, _ramda.has)(0, val) && (0, _ramda.has)(val.length - 1, val);
|
---|
55 | }
|
---|
56 | return false;
|
---|
57 | });
|
---|
58 | var _default = isArrayLike;
|
---|
59 | /**
|
---|
60 | The MIT License (MIT)
|
---|
61 |
|
---|
62 | Copyright (c) 2013-2016 Scott Sauyet and Michael Hurley
|
---|
63 |
|
---|
64 | Permission is hereby granted, free of charge, to any person obtaining a copy
|
---|
65 | of this software and associated documentation files (the "Software"), to deal
|
---|
66 | in the Software without restriction, including without limitation the rights
|
---|
67 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
---|
68 | copies of the Software, and to permit persons to whom the Software is
|
---|
69 | furnished to do so, subject to the following conditions:
|
---|
70 |
|
---|
71 | The above copyright notice and this permission notice shall be included in
|
---|
72 | all copies or substantial portions of the Software.
|
---|
73 |
|
---|
74 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
---|
75 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
---|
76 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
---|
77 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
---|
78 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
---|
79 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
---|
80 | THE SOFTWARE.
|
---|
81 | */
|
---|
82 | exports["default"] = _default; |
---|