TextMessageFormat.js 1004 B

123456789101112131415161718192021222324
  1. // Copyright (c) .NET Foundation. All rights reserved.
  2. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
  3. // Not exported from index
  4. /** @private */
  5. var TextMessageFormat = /** @class */ (function () {
  6. function TextMessageFormat() {
  7. }
  8. TextMessageFormat.write = function (output) {
  9. return "" + output + TextMessageFormat.RecordSeparator;
  10. };
  11. TextMessageFormat.parse = function (input) {
  12. if (input[input.length - 1] !== TextMessageFormat.RecordSeparator) {
  13. throw new Error("Message is incomplete.");
  14. }
  15. var messages = input.split(TextMessageFormat.RecordSeparator);
  16. messages.pop();
  17. return messages;
  18. };
  19. TextMessageFormat.RecordSeparatorCode = 0x1e;
  20. TextMessageFormat.RecordSeparator = String.fromCharCode(TextMessageFormat.RecordSeparatorCode);
  21. return TextMessageFormat;
  22. }());
  23. export { TextMessageFormat };
  24. //# sourceMappingURL=TextMessageFormat.js.map