]> gerrit.simantics Code Review - simantics/district.git/blob - is-array-like.js
b8beed225b05ad6f6b4ea70a5f8b21f4f8af2daa
[simantics/district.git] / is-array-like.js
1 'use strict';
2
3 var isFunction = require('../function/is-function')
4   , isObject   = require('./is-object');
5
6 module.exports = function (x) {
7         return ((x != null) && (typeof x.length === 'number') &&
8
9                 // Just checking ((typeof x === 'object') && (typeof x !== 'function'))
10                 // won't work right for some cases, e.g.:
11                 // type of instance of NodeList in Safari is a 'function'
12
13                 ((isObject(x) && !isFunction(x)) || (typeof x === "string"))) || false;
14 };