版博士V2.0程序
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.

пре 1 година
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. "use strict";
  2. var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
  3. if (k2 === undefined) k2 = k;
  4. var desc = Object.getOwnPropertyDescriptor(m, k);
  5. if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
  6. desc = { enumerable: true, get: function() { return m[k]; } };
  7. }
  8. Object.defineProperty(o, k2, desc);
  9. }) : (function(o, m, k, k2) {
  10. if (k2 === undefined) k2 = k;
  11. o[k2] = m[k];
  12. }));
  13. var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
  14. Object.defineProperty(o, "default", { enumerable: true, value: v });
  15. }) : function(o, v) {
  16. o["default"] = v;
  17. });
  18. var __importStar = (this && this.__importStar) || function (mod) {
  19. if (mod && mod.__esModule) return mod;
  20. var result = {};
  21. if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
  22. __setModuleDefault(result, mod);
  23. return result;
  24. };
  25. Object.defineProperty(exports, "__esModule", { value: true });
  26. exports.showNumber = exports.showString = exports.showBoolean = exports.getStructShow = exports.getTupleShow = exports.tuple = exports.struct = void 0;
  27. /**
  28. * The `Show` type class represents those types which can be converted into
  29. * a human-readable `string` representation.
  30. *
  31. * While not required, it is recommended that for any expression `x`, the
  32. * string `show(x)` be executable TypeScript code which evaluates to the same
  33. * value as the expression `x`.
  34. *
  35. * @since 2.0.0
  36. */
  37. var _ = __importStar(require("./internal"));
  38. // -------------------------------------------------------------------------------------
  39. // combinators
  40. // -------------------------------------------------------------------------------------
  41. /**
  42. * @since 2.10.0
  43. */
  44. var struct = function (shows) { return ({
  45. show: function (a) {
  46. var s = '{';
  47. for (var k in shows) {
  48. if (_.has.call(shows, k)) {
  49. s += " ".concat(k, ": ").concat(shows[k].show(a[k]), ",");
  50. }
  51. }
  52. if (s.length > 1) {
  53. s = s.slice(0, -1) + ' ';
  54. }
  55. s += '}';
  56. return s;
  57. }
  58. }); };
  59. exports.struct = struct;
  60. /**
  61. * @since 2.10.0
  62. */
  63. var tuple = function () {
  64. var shows = [];
  65. for (var _i = 0; _i < arguments.length; _i++) {
  66. shows[_i] = arguments[_i];
  67. }
  68. return ({
  69. show: function (t) { return "[".concat(t.map(function (a, i) { return shows[i].show(a); }).join(', '), "]"); }
  70. });
  71. };
  72. exports.tuple = tuple;
  73. // -------------------------------------------------------------------------------------
  74. // deprecated
  75. // -------------------------------------------------------------------------------------
  76. /**
  77. * Use [`tuple`](#tuple) instead.
  78. *
  79. * @category zone of death
  80. * @since 2.0.0
  81. * @deprecated
  82. */
  83. exports.getTupleShow = exports.tuple;
  84. /**
  85. * Use [`struct`](#struct) instead.
  86. *
  87. * @category zone of death
  88. * @since 2.0.0
  89. * @deprecated
  90. */
  91. exports.getStructShow = exports.struct;
  92. /**
  93. * Use [`Show`](./boolean.ts.html#show) instead.
  94. *
  95. * @category zone of death
  96. * @since 2.0.0
  97. * @deprecated
  98. */
  99. exports.showBoolean = {
  100. show: function (a) { return JSON.stringify(a); }
  101. };
  102. /**
  103. * Use [`Show`](./string.ts.html#show) instead.
  104. *
  105. * @category zone of death
  106. * @since 2.0.0
  107. * @deprecated
  108. */
  109. exports.showString = {
  110. show: function (a) { return JSON.stringify(a); }
  111. };
  112. /**
  113. * Use [`Show`](./number.ts.html#show) instead.
  114. *
  115. * @category zone of death
  116. * @since 2.0.0
  117. * @deprecated
  118. */
  119. exports.showNumber = {
  120. show: function (a) { return JSON.stringify(a); }
  121. };