utils.js 832 B

123456789101112131415161718192021222324252627282930313233
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. function isDef(value) {
  4. return value !== undefined && value !== null;
  5. }
  6. exports.isDef = isDef;
  7. function isObj(x) {
  8. var type = typeof x;
  9. return x !== null && (type === 'object' || type === 'function');
  10. }
  11. exports.isObj = isObj;
  12. function isNumber(value) {
  13. return /^\d+$/.test(value);
  14. }
  15. exports.isNumber = isNumber;
  16. function range(num, min, max) {
  17. return Math.min(Math.max(num, min), max);
  18. }
  19. exports.range = range;
  20. function nextTick(fn) {
  21. setTimeout(function () {
  22. fn();
  23. }, 1000 / 30);
  24. }
  25. exports.nextTick = nextTick;
  26. var systemInfo = null;
  27. function getSystemInfoSync() {
  28. if (systemInfo == null) {
  29. systemInfo = wx.getSystemInfoSync();
  30. }
  31. return systemInfo;
  32. }
  33. exports.getSystemInfoSync = getSystemInfoSync;