TextMessageFormat.js 795 B

1234567891011121314151617181920
  1. // Licensed to the .NET Foundation under one or more agreements.
  2. // The .NET Foundation licenses this file to you under the MIT license.
  3. // Not exported from index
  4. /** @private */
  5. export class TextMessageFormat {
  6. static write(output) {
  7. return `${output}${TextMessageFormat.RecordSeparator}`;
  8. }
  9. static parse(input) {
  10. if (input[input.length - 1] !== TextMessageFormat.RecordSeparator) {
  11. throw new Error("Message is incomplete.");
  12. }
  13. const messages = input.split(TextMessageFormat.RecordSeparator);
  14. messages.pop();
  15. return messages;
  16. }
  17. }
  18. TextMessageFormat.RecordSeparatorCode = 0x1e;
  19. TextMessageFormat.RecordSeparator = String.fromCharCode(TextMessageFormat.RecordSeparatorCode);
  20. //# sourceMappingURL=TextMessageFormat.js.map