web 3d图形渲染器
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.

31 lines
954 B

  1. "use strict";
  2. var numberIsNaN = require("../../number/is-nan")
  3. , toPosInt = require("../../number/to-pos-integer")
  4. , value = require("../../object/valid-value")
  5. , lastIndexOf = Array.prototype.lastIndexOf
  6. , objHasOwnProperty = Object.prototype.hasOwnProperty
  7. , abs = Math.abs
  8. , floor = Math.floor;
  9. module.exports = function (searchElement/*, fromIndex*/) {
  10. var i, fromIndex, val;
  11. if (!numberIsNaN(searchElement)) {
  12. // Jslint: ignore
  13. return lastIndexOf.apply(this, arguments);
  14. }
  15. value(this);
  16. fromIndex = arguments[1];
  17. if (isNaN(fromIndex)) fromIndex = toPosInt(this.length) - 1;
  18. else if (fromIndex >= 0) fromIndex = floor(fromIndex);
  19. else fromIndex = toPosInt(this.length) - floor(abs(fromIndex));
  20. for (i = fromIndex; i >= 0; --i) {
  21. if (objHasOwnProperty.call(this, i)) {
  22. val = this[i];
  23. if (numberIsNaN(val)) return i; // Jslint: ignore
  24. }
  25. }
  26. return -1;
  27. };