You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

is.js 792B

123456789101112131415161718192021222324252627
  1. "use strict";
  2. var isPrototype = require("../prototype/is");
  3. var isArray;
  4. if (typeof Array.isArray === "function") {
  5. isArray = Array.isArray;
  6. } else {
  7. var objectToString = Object.prototype.toString, objectTaggedString = objectToString.call([]);
  8. isArray = function (value) { return objectToString.call(value) === objectTaggedString; };
  9. }
  10. module.exports = function (value) {
  11. if (!isArray(value)) return false;
  12. // Sanity check (reject objects which do not expose common Array interface)
  13. if (!hasOwnProperty.call(value, "length")) return false;
  14. try {
  15. if (typeof value.length !== "number") return false;
  16. if (typeof value.push !== "function") return false;
  17. if (typeof value.splice !== "function") return false;
  18. } catch (error) {
  19. return false;
  20. }
  21. return !isPrototype(value);
  22. };