static frame(data, options) {
        const merge = options.mask && options.readOnly;
        let offset = options.mask ? 6 : 2;
        let payloadLength = data.length;
        if (data.length >= 65536) {
            offset += 8;
            payloadLength = 127;
        } else if (data.length > 125) {
            offset += 2;
            payloadLength = 126;
        }
        const target = Buffer.allocUnsafe(merge ? data.length + offset : offset);
        target[0] = options.fin ? options.opcode | 128 : options.opcode;
        if (options.rsv1) target[0] |= 64;
        target[1] = payloadLength;
        if (payloadLength === 126) target.writeUInt16BE(data.length, 2);
        else if (payloadLength === 127) {
            target.writeUInt32BE(0, 2);
            target.writeUInt32BE(data.length, 6);
        }
        if (!options.mask) return [
            target,
            data
        ];
        $246d272a9ba49ed8$require$randomFillSync($246d272a9ba49ed8$var$mask, 0, 4);
        target[1] |= 128;
        target[offset - 4] = $246d272a9ba49ed8$var$mask[0];
        target[offset - 3] = $246d272a9ba49ed8$var$mask[1];
        target[offset - 2] = $246d272a9ba49ed8$var$mask[2];
        target[offset - 1] = $246d272a9ba49ed8$var$mask[3];
        if (merge) {
            $246d272a9ba49ed8$require$applyMask(data, $246d272a9ba49ed8$var$mask, target, offset, data.length);
            return [
                target
            ];
        }
        $246d272a9ba49ed8$require$applyMask(data, $246d272a9ba49ed8$var$mask, data, 0, data.length);
        return [
            target,
            data
        ];
    }
/**
   * Frames a piece of data according to the HyBi WebSocket protocol.
   *
   * @param {Buffer} data The data to frame
   * @param {Object} options Options object
   * @param {Number} options.opcode The opcode
   * @param {Boolean} [options.readOnly=false] Specifies whether `data` can be
   *     modified
   * @param {Boolean} [options.fin=false] Specifies whether or not to set the
   *     FIN bit
   * @param {Boolean} [options.mask=false] Specifies whether or not to mask
   *     `data`
   * @param {Boolean} [options.rsv1=false] Specifies whether or not to set the
   *     RSV1 bit
   * @return {Buffer[]} The framed data as a list of `Buffer` instances
   * @public
   */
Frames a piece of data according to the HyBi WebSocket protocol.
Frames a piece of data according to the HyBi WebSocket protocol .
static frame(data, options) {
        const merge = options.mask && options.readOnly;
        let offset = options.mask ? 6 : 2;
        let payloadLength = data.length;
        if (data.length >= 65536) {
            offset += 8;
            payloadLength = 127;
        } else if (data.length > 125) {
            offset += 2;
            payloadLength = 126;
        }
        const target = Buffer.allocUnsafe(merge ? data.length + offset : offset);
        target[0] = options.fin ? options.opcode | 128 : options.opcode;
        if (options.rsv1) target[0] |= 64;
        target[1] = payloadLength;
        if (payloadLength === 126) target.writeUInt16BE(data.length, 2);
        else if (payloadLength === 127) {
            target.writeUInt32BE(0, 2);
            target.writeUInt32BE(data.length, 6);
        }
        if (!options.mask) return [
            target,
            data
        ];
        $246d272a9ba49ed8$require$randomFillSync($246d272a9ba49ed8$var$mask, 0, 4);
        target[1] |= 128;
        target[offset - 4] = $246d272a9ba49ed8$var$mask[0];
        target[offset - 3] = $246d272a9ba49ed8$var$mask[1];
        target[offset - 2] = $246d272a9ba49ed8$var$mask[2];
        target[offset - 1] = $246d272a9ba49ed8$var$mask[3];
        if (merge) {
            $246d272a9ba49ed8$require$applyMask(data, $246d272a9ba49ed8$var$mask, target, offset, data.length);
            return [
                target
            ];
        }
        $246d272a9ba49ed8$require$applyMask(data, $246d272a9ba49ed8$var$mask, data, 0, data.length);
        return [
            target,
            data
        ];
    }
static frame ( data , options ) { const merge = options . mask && options . readOnly ; let offset = options . mask ? 6 : 2 ; let payloadLength = data . length ; if ( data . length >= 65536 ) { offset += 8 ; payloadLength = 127 ; } else if ( data . length > 125 ) { offset += 2 ; payloadLength = 126 ; } const target = Buffer . allocUnsafe ( merge ? data . length + offset : offset ) ; target [ 0 ] = options . fin ? options . opcode | 128 : options . opcode ; if ( options . rsv1 ) target [ 0 ] |= 64 ; target [ 1 ] = payloadLength ; if ( payloadLength === 126 ) target . writeUInt16BE ( data . length , 2 ) ; else if ( payloadLength === 127 ) { target . writeUInt32BE ( 0 , 2 ) ; target . writeUInt32BE ( data . length , 6 ) ; } if ( ! options . mask ) return [ target , data ] ; $246d272a9ba49ed8$require$randomFillSync ( $246d272a9ba49ed8$var$mask , 0 , 4 ) ; target [ 1 ] |= 128 ; target [ offset - 4 ] = $246d272a9ba49ed8$var$mask [ 0 ] ; target [ offset - 3 ] = $246d272a9ba49ed8$var$mask [ 1 ] ; target [ offset - 2 ] = $246d272a9ba49ed8$var$mask [ 2 ] ; target [ offset - 1 ] = $246d272a9ba49ed8$var$mask [ 3 ] ; if ( merge ) { $246d272a9ba49ed8$require$applyMask ( data , $246d272a9ba49ed8$var$mask , target , offset , data . length ) ; return [ target ] ; } $246d272a9ba49ed8$require$applyMask ( data , $246d272a9ba49ed8$var$mask , data , 0 , data . length ) ; return [ target , data ] ; }
Frames a piece of data according to the HyBi WebSocket protocol.
Frames a piece of data according to the HyBi WebSocket protocol .