BlocklyFunction.js 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. import Blockly from "blockly";
  2. // import googObject from "../goog/googObject";
  3. const goog = Blockly || {}
  4. goog.array = {};
  5. // goog.
  6. goog.typeOf = function(a) {
  7. var b = typeof a;
  8. if ("object" == b)
  9. if (a) {
  10. if (a instanceof Array)
  11. return "array";
  12. if (a instanceof Object)
  13. return b;
  14. var c = Object.prototype.toString.call(a);
  15. if ("[object Window]" == c)
  16. return "object";
  17. if ("[object Array]" == c || "number" == typeof a.length && "undefined" != typeof a.splice && "undefined" != typeof a.propertyIsEnumerable && !a.propertyIsEnumerable("splice"))
  18. return "array";
  19. if ("[object Function]" == c || "undefined" != typeof a.call && "undefined" != typeof a.propertyIsEnumerable && !a.propertyIsEnumerable("call"))
  20. return "function"
  21. } else
  22. return "null";
  23. else if ("function" == b && "undefined" == typeof a.call)
  24. return "object";
  25. return b
  26. };
  27. goog.isArrayLike = function(a) {
  28. var b = goog.typeOf(a);
  29. return "array" == b || "object" == b && "number" == typeof a.length
  30. };
  31. goog.array.equals = function(a, b, c) {
  32. if (!goog.isArrayLike(a) || !goog.isArrayLike(b) || a.length != b.length)
  33. return !1;
  34. var d = a.length;
  35. c = c || goog.array.defaultCompareEquality;
  36. for (var e = 0; e < d; e++)
  37. if (!c(a[e], b[e]))
  38. return !1;
  39. return !0
  40. };
  41. goog.array.defaultCompareEquality = function(a, b) {
  42. return a === b
  43. };
  44. export default goog;