ensure-array.js 663 B

1234567891011121314151617181920212223
  1. "use strict";
  2. module.exports = function (t, a) {
  3. var arr = [];
  4. a(t(arr), arr, "Array");
  5. a(t(""), "", "String");
  6. var args = (function () { return arguments; })();
  7. a(t(args), args, "Arguments");
  8. var arrayLike = { length: 0 };
  9. a(t(arrayLike), arrayLike, "Array like");
  10. a.throws(
  11. function () {
  12. t(function () {});
  13. },
  14. TypeError,
  15. "Function"
  16. );
  17. a.throws(function () { t({}); }, TypeError, "Plain object");
  18. a.throws(function () { t(/raz/); }, TypeError, "Regexp");
  19. a.throws(function () { t(); }, TypeError, "No argument");
  20. a.throws(function () { t(null); }, TypeError, "Null");
  21. a.throws(function () { t(undefined); }, TypeError, "Undefined");
  22. };