swc/crates/swc_bundler/tests/.cache/deno/ebb89421583483600946712fe2d2f62a5690df3f.ts
2021-11-09 20:42:49 +09:00

39 lines
1.1 KiB
TypeScript

// Loaded from https://deno.land/x/ramda@v0.27.2/source/internal/_isArrayLike.js
import _curry1 from './_curry1.js';
import _isArray from './_isArray.js';
import _isString from './_isString.js';
/**
* Tests whether or not an object is similar to an array.
*
* @private
* @category Type
* @category List
* @sig * -> Boolean
* @param {*} x The object to test.
* @return {Boolean} `true` if `x` has a numeric length property and extreme indices defined; `false` otherwise.
* @example
*
* _isArrayLike([]); //=> true
* _isArrayLike(true); //=> false
* _isArrayLike({}); //=> false
* _isArrayLike({length: 10}); //=> false
* _isArrayLike({0: 'zero', 9: 'nine', length: 10}); //=> true
* _isArrayLike({nodeType: 1, length: 1}) // => false
*/
var _isArrayLike = _curry1(function isArrayLike(x) {
if (_isArray(x)) { return true; }
if (!x) { return false; }
if (typeof x !== 'object') { return false; }
if (_isString(x)) { return false; }
if (x.length === 0) { return true; }
if (x.length > 0) {
return x.hasOwnProperty(0) && x.hasOwnProperty(x.length - 1);
}
return false;
});
export default _isArrayLike;