Ignore:
Timestamp:
11/25/21 22:08:24 (3 years ago)
Author:
Ema <ema_spirova@…>
Branches:
master
Children:
8d391a1
Parents:
59329aa
Message:

primeNG components

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trip-planner-front/node_modules/ws/lib/sender.js

    r59329aa re29cc2e  
    11'use strict';
    22
    3 const { randomFillSync } = require('crypto');
     3const { randomBytes } = require('crypto');
    44
    55const PerMessageDeflate = require('./permessage-deflate');
     
    88const { mask: applyMask, toBuffer } = require('./buffer-util');
    99
    10 const mask = Buffer.alloc(4);
    11 
    1210/**
    1311 * HyBi Sender implementation.
     
    1816   *
    1917   * @param {net.Socket} socket The connection socket
    20    * @param {Object} [extensions] An object containing the negotiated extensions
     18   * @param {Object} extensions An object containing the negotiated extensions
    2119   */
    2220  constructor(socket, extensions) {
     
    3836   * @param {Object} options Options object
    3937   * @param {Number} options.opcode The opcode
    40    * @param {Boolean} [options.readOnly=false] Specifies whether `data` can be
    41    *     modified
    42    * @param {Boolean} [options.fin=false] Specifies whether or not to set the
    43    *     FIN bit
    44    * @param {Boolean} [options.mask=false] Specifies whether or not to mask
    45    *     `data`
    46    * @param {Boolean} [options.rsv1=false] Specifies whether or not to set the
    47    *     RSV1 bit
     38   * @param {Boolean} options.readOnly Specifies whether `data` can be modified
     39   * @param {Boolean} options.fin Specifies whether or not to set the FIN bit
     40   * @param {Boolean} options.mask Specifies whether or not to mask `data`
     41   * @param {Boolean} options.rsv1 Specifies whether or not to set the RSV1 bit
    4842   * @return {Buffer[]} The framed data as a list of `Buffer` instances
    4943   * @public
     
    5145  static frame(data, options) {
    5246    const merge = options.mask && options.readOnly;
    53     let offset = options.mask ? 6 : 2;
    54     let payloadLength = data.length;
     47    var offset = options.mask ? 6 : 2;
     48    var payloadLength = data.length;
    5549
    5650    if (data.length >= 65536) {
     
    7872    if (!options.mask) return [target, data];
    7973
    80     randomFillSync(mask, 0, 4);
     74    const mask = randomBytes(4);
    8175
    8276    target[1] |= 0x80;
     
    9892   * Sends a close message to the other peer.
    9993   *
    100    * @param {Number} [code] The status code component of the body
    101    * @param {String} [data] The message component of the body
    102    * @param {Boolean} [mask=false] Specifies whether or not to mask the message
    103    * @param {Function} [cb] Callback
     94   * @param {(Number|undefined)} code The status code component of the body
     95   * @param {String} data The message component of the body
     96   * @param {Boolean} mask Specifies whether or not to mask the message
     97   * @param {Function} cb Callback
    10498   * @public
    10599   */
    106100  close(code, data, mask, cb) {
    107     let buf;
     101    var buf;
    108102
    109103    if (code === undefined) {
     
    115109      buf.writeUInt16BE(code, 0);
    116110    } else {
    117       const length = Buffer.byteLength(data);
    118 
    119       if (length > 123) {
    120         throw new RangeError('The message must not be greater than 123 bytes');
    121       }
    122 
    123       buf = Buffer.allocUnsafe(2 + length);
     111      buf = Buffer.allocUnsafe(2 + Buffer.byteLength(data));
    124112      buf.writeUInt16BE(code, 0);
    125113      buf.write(data, 2);
     
    137125   *
    138126   * @param {Buffer} data The message to send
    139    * @param {Boolean} [mask=false] Specifies whether or not to mask `data`
    140    * @param {Function} [cb] Callback
     127   * @param {Boolean} mask Specifies whether or not to mask `data`
     128   * @param {Function} cb Callback
    141129   * @private
    142130   */
     
    158146   *
    159147   * @param {*} data The message to send
    160    * @param {Boolean} [mask=false] Specifies whether or not to mask `data`
    161    * @param {Function} [cb] Callback
     148   * @param {Boolean} mask Specifies whether or not to mask `data`
     149   * @param {Function} cb Callback
    162150   * @public
    163151   */
     
    165153    const buf = toBuffer(data);
    166154
    167     if (buf.length > 125) {
    168       throw new RangeError('The data size must not be greater than 125 bytes');
    169     }
    170 
    171155    if (this._deflating) {
    172156      this.enqueue([this.doPing, buf, mask, toBuffer.readOnly, cb]);
     
    179163   * Frames and sends a ping message.
    180164   *
    181    * @param {Buffer} data The message to send
    182    * @param {Boolean} [mask=false] Specifies whether or not to mask `data`
    183    * @param {Boolean} [readOnly=false] Specifies whether `data` can be modified
    184    * @param {Function} [cb] Callback
     165   * @param {*} data The message to send
     166   * @param {Boolean} mask Specifies whether or not to mask `data`
     167   * @param {Boolean} readOnly Specifies whether `data` can be modified
     168   * @param {Function} cb Callback
    185169   * @private
    186170   */
     
    202186   *
    203187   * @param {*} data The message to send
    204    * @param {Boolean} [mask=false] Specifies whether or not to mask `data`
    205    * @param {Function} [cb] Callback
     188   * @param {Boolean} mask Specifies whether or not to mask `data`
     189   * @param {Function} cb Callback
    206190   * @public
    207191   */
     
    209193    const buf = toBuffer(data);
    210194
    211     if (buf.length > 125) {
    212       throw new RangeError('The data size must not be greater than 125 bytes');
    213     }
    214 
    215195    if (this._deflating) {
    216196      this.enqueue([this.doPong, buf, mask, toBuffer.readOnly, cb]);
     
    223203   * Frames and sends a pong message.
    224204   *
    225    * @param {Buffer} data The message to send
    226    * @param {Boolean} [mask=false] Specifies whether or not to mask `data`
    227    * @param {Boolean} [readOnly=false] Specifies whether `data` can be modified
    228    * @param {Function} [cb] Callback
     205   * @param {*} data The message to send
     206   * @param {Boolean} mask Specifies whether or not to mask `data`
     207   * @param {Boolean} readOnly Specifies whether `data` can be modified
     208   * @param {Function} cb Callback
    229209   * @private
    230210   */
     
    247227   * @param {*} data The message to send
    248228   * @param {Object} options Options object
    249    * @param {Boolean} [options.compress=false] Specifies whether or not to
    250    *     compress `data`
    251    * @param {Boolean} [options.binary=false] Specifies whether `data` is binary
    252    *     or text
    253    * @param {Boolean} [options.fin=false] Specifies whether the fragment is the
    254    *     last one
    255    * @param {Boolean} [options.mask=false] Specifies whether or not to mask
    256    *     `data`
    257    * @param {Function} [cb] Callback
     229   * @param {Boolean} options.compress Specifies whether or not to compress `data`
     230   * @param {Boolean} options.binary Specifies whether `data` is binary or text
     231   * @param {Boolean} options.fin Specifies whether the fragment is the last one
     232   * @param {Boolean} options.mask Specifies whether or not to mask `data`
     233   * @param {Function} cb Callback
    258234   * @public
    259235   */
     
    261237    const buf = toBuffer(data);
    262238    const perMessageDeflate = this._extensions[PerMessageDeflate.extensionName];
    263     let opcode = options.binary ? 2 : 1;
    264     let rsv1 = options.compress;
     239    var opcode = options.binary ? 2 : 1;
     240    var rsv1 = options.compress;
    265241
    266242    if (this._firstFragment) {
     
    309285   *
    310286   * @param {Buffer} data The message to send
    311    * @param {Boolean} [compress=false] Specifies whether or not to compress
    312    *     `data`
     287   * @param {Boolean} compress Specifies whether or not to compress `data`
    313288   * @param {Object} options Options object
    314289   * @param {Number} options.opcode The opcode
    315    * @param {Boolean} [options.readOnly=false] Specifies whether `data` can be
    316    *     modified
    317    * @param {Boolean} [options.fin=false] Specifies whether or not to set the
    318    *     FIN bit
    319    * @param {Boolean} [options.mask=false] Specifies whether or not to mask
    320    *     `data`
    321    * @param {Boolean} [options.rsv1=false] Specifies whether or not to set the
    322    *     RSV1 bit
    323    * @param {Function} [cb] Callback
     290   * @param {Boolean} options.readOnly Specifies whether `data` can be modified
     291   * @param {Boolean} options.fin Specifies whether or not to set the FIN bit
     292   * @param {Boolean} options.mask Specifies whether or not to mask `data`
     293   * @param {Boolean} options.rsv1 Specifies whether or not to set the RSV1 bit
     294   * @param {Function} cb Callback
    324295   * @private
    325296   */
     
    332303    const perMessageDeflate = this._extensions[PerMessageDeflate.extensionName];
    333304
    334     this._bufferedBytes += data.length;
    335305    this._deflating = true;
    336306    perMessageDeflate.compress(data, options.fin, (_, buf) => {
    337       if (this._socket.destroyed) {
    338         const err = new Error(
    339           'The socket was closed while data was being compressed'
    340         );
    341 
    342         if (typeof cb === 'function') cb(err);
    343 
    344         for (let i = 0; i < this._queue.length; i++) {
    345           const callback = this._queue[i][4];
    346 
    347           if (typeof callback === 'function') callback(err);
    348         }
    349 
    350         return;
    351       }
    352 
    353       this._bufferedBytes -= data.length;
    354307      this._deflating = false;
    355308      options.readOnly = false;
     
    369322
    370323      this._bufferedBytes -= params[1].length;
    371       Reflect.apply(params[0], this, params.slice(1));
     324      params[0].apply(this, params.slice(1));
    372325    }
    373326  }
     
    388341   *
    389342   * @param {Buffer[]} list The frame to send
    390    * @param {Function} [cb] Callback
     343   * @param {Function} cb Callback
    391344   * @private
    392345   */
Note: See TracChangeset for help on using the changeset viewer.