main
Last change
on this file was d24f17c, checked in by Aleksandar Panovski <apano77@…>, 15 months ago |
Initial commit
|
-
Property mode
set to
100644
|
File size:
1.2 KB
|
Rev | Line | |
---|
[d24f17c] | 1 | var _curry1 =
|
---|
| 2 | /*#__PURE__*/
|
---|
| 3 | require("./_curry1.js");
|
---|
| 4 |
|
---|
| 5 | var _isArray =
|
---|
| 6 | /*#__PURE__*/
|
---|
| 7 | require("./_isArray.js");
|
---|
| 8 |
|
---|
| 9 | var _isString =
|
---|
| 10 | /*#__PURE__*/
|
---|
| 11 | require("./_isString.js");
|
---|
| 12 | /**
|
---|
| 13 | * Tests whether or not an object is similar to an array.
|
---|
| 14 | *
|
---|
| 15 | * @private
|
---|
| 16 | * @category Type
|
---|
| 17 | * @category List
|
---|
| 18 | * @sig * -> Boolean
|
---|
| 19 | * @param {*} x The object to test.
|
---|
| 20 | * @return {Boolean} `true` if `x` has a numeric length property and extreme indices defined; `false` otherwise.
|
---|
| 21 | * @example
|
---|
| 22 | *
|
---|
| 23 | * _isArrayLike([]); //=> true
|
---|
| 24 | * _isArrayLike(true); //=> false
|
---|
| 25 | * _isArrayLike({}); //=> false
|
---|
| 26 | * _isArrayLike({length: 10}); //=> false
|
---|
| 27 | * _isArrayLike({0: 'zero', 9: 'nine', length: 10}); //=> true
|
---|
| 28 | * _isArrayLike({nodeType: 1, length: 1}) // => false
|
---|
| 29 | */
|
---|
| 30 |
|
---|
| 31 |
|
---|
| 32 | var _isArrayLike =
|
---|
| 33 | /*#__PURE__*/
|
---|
| 34 | _curry1(function isArrayLike(x) {
|
---|
| 35 | if (_isArray(x)) {
|
---|
| 36 | return true;
|
---|
| 37 | }
|
---|
| 38 |
|
---|
| 39 | if (!x) {
|
---|
| 40 | return false;
|
---|
| 41 | }
|
---|
| 42 |
|
---|
| 43 | if (typeof x !== 'object') {
|
---|
| 44 | return false;
|
---|
| 45 | }
|
---|
| 46 |
|
---|
| 47 | if (_isString(x)) {
|
---|
| 48 | return false;
|
---|
| 49 | }
|
---|
| 50 |
|
---|
| 51 | if (x.length === 0) {
|
---|
| 52 | return true;
|
---|
| 53 | }
|
---|
| 54 |
|
---|
| 55 | if (x.length > 0) {
|
---|
| 56 | return x.hasOwnProperty(0) && x.hasOwnProperty(x.length - 1);
|
---|
| 57 | }
|
---|
| 58 |
|
---|
| 59 | return false;
|
---|
| 60 | });
|
---|
| 61 |
|
---|
| 62 | module.exports = _isArrayLike; |
---|
Note:
See
TracBrowser
for help on using the repository browser.