智慧水务管理系统 - 精河县供水工程综合管理平台

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. exports.hasOwnProperty = void 0;
  4. exports.isBoolean = isBoolean;
  5. exports.ellipsis = ellipsis;
  6. exports.removeWithPredicate = removeWithPredicate;
  7. exports.assertNever = assertNever;
  8. exports.hasOwnProperty = Object.prototype.hasOwnProperty;
  9. /**
  10. * Simpler helper method to check for a boolean type simply for the benefit of
  11. * gaining better compression when minified by not needing to have multiple
  12. * `typeof` comparisons in the codebase.
  13. */
  14. function isBoolean(value) {
  15. return typeof value === 'boolean';
  16. }
  17. /**
  18. * Truncates the `str` at `len - ellipsisChars.length`, and adds the `ellipsisChars` to the
  19. * end of the string (by default, two periods: '..'). If the `str` length does not exceed
  20. * `len`, the string will be returned unchanged.
  21. *
  22. * @param {String} str The string to truncate and add an ellipsis to.
  23. * @param {Number} truncateLen The length to truncate the string at.
  24. * @param {String} [ellipsisChars=...] The ellipsis character(s) to add to the end of `str`
  25. * when truncated. Defaults to '...'
  26. */
  27. function ellipsis(str, truncateLen, ellipsisChars) {
  28. var ellipsisLength;
  29. if (str.length > truncateLen) {
  30. if (ellipsisChars == null) {
  31. ellipsisChars = '…';
  32. ellipsisLength = 3;
  33. }
  34. else {
  35. ellipsisLength = ellipsisChars.length;
  36. }
  37. str = str.substring(0, truncateLen - ellipsisLength) + ellipsisChars;
  38. }
  39. return str;
  40. }
  41. /**
  42. * Removes array elements based on a filtering function. Mutates the input
  43. * array.
  44. *
  45. * Using this instead of the ES5 Array.prototype.filter() function to prevent
  46. * creating many new arrays in memory for filtering.
  47. *
  48. * @param arr The array to remove elements from. This array is mutated.
  49. * @param fn The predicate function which should return `true` to remove an
  50. * element.
  51. */
  52. function removeWithPredicate(arr, fn) {
  53. for (var i = arr.length - 1; i >= 0; i--) {
  54. if (fn(arr[i]) === true) {
  55. arr.splice(i, 1);
  56. }
  57. }
  58. }
  59. /**
  60. * Function that should never be called but is used to check that every
  61. * enum value is handled using TypeScript's 'never' type.
  62. */
  63. /* istanbul ignore next */
  64. function assertNever(theValue) {
  65. throw new Error("Unhandled case for value: '".concat(theValue, "'"));
  66. }
  67. //# sourceMappingURL=utils.js.map