tor-browser

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

string.js (1089B)


      1 /* This Source Code Form is subject to the terms of the Mozilla Public
      2 * License, v. 2.0. If a copy of the MPL was not distributed with this
      3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
      4 
      5 "use strict";
      6 
      7 const { Actor } = require("resource://devtools/shared/protocol.js");
      8 const {
      9  longStringSpec,
     10 } = require("resource://devtools/shared/specs/string.js");
     11 
     12 const {
     13  DevToolsServer,
     14 } = require("resource://devtools/server/devtools-server.js");
     15 
     16 exports.LongStringActor = class LongStringActor extends Actor {
     17  constructor(conn, str) {
     18    super(conn, longStringSpec);
     19    this.str = str;
     20    this.short = this.str.length < DevToolsServer.LONG_STRING_LENGTH;
     21  }
     22 
     23  destroy() {
     24    this.str = null;
     25    super.destroy();
     26  }
     27 
     28  form() {
     29    if (this.short) {
     30      return this.str;
     31    }
     32    return {
     33      type: "longString",
     34      actor: this.actorID,
     35      length: this.str.length,
     36      initial: this.str.substring(0, DevToolsServer.LONG_STRING_INITIAL_LENGTH),
     37    };
     38  }
     39 
     40  substring(start, end) {
     41    return this.str.substring(start, end);
     42  }
     43 
     44  release() {}
     45 };