tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

TextMessageFormat.js (963B)


      1 /*
      2 * Copyright (c) .NET Foundation. All rights reserved.
      3 *
      4 * This source code is licensed under the Apache License, Version 2.0,
      5 * found in the LICENSE.txt file in the root directory of the library
      6 * source tree.
      7 *
      8 * https://github.com/aspnet/AspNetCore
      9 */
     10 
     11 "use strict";
     12 
     13 Object.defineProperty(exports, "__esModule", { value: true });
     14 // Not exported from index
     15 /** @private */
     16 class TextMessageFormat {
     17  static write(output) {
     18    return `${output}${TextMessageFormat.RecordSeparator}`;
     19  }
     20  static parse(input) {
     21    if (input[input.length - 1] !== TextMessageFormat.RecordSeparator) {
     22      throw new Error("Message is incomplete.");
     23    }
     24    const messages = input.split(TextMessageFormat.RecordSeparator);
     25    messages.pop();
     26    return messages;
     27  }
     28 }
     29 exports.TextMessageFormat = TextMessageFormat;
     30 TextMessageFormat.RecordSeparatorCode = 0x1e;
     31 TextMessageFormat.RecordSeparator = String.fromCharCode(
     32  TextMessageFormat.RecordSeparatorCode
     33 );