WXL
4 天以前 3bd962a6d7f61239c020e2dbbeb7341e5b842dd1
node_modules/webpack/lib/serialization/BinaryMiddleware.js
@@ -114,6 +114,7 @@
/** @typedef {typeof MEASURE_END_OPERATION} MEASURE_END_OPERATION_TYPE */
/**
 * Returns type of number for serialization.
 * @param {number} n number
 * @returns {0 | 1 | 2} type of number for serialization
 */
@@ -126,6 +127,7 @@
};
/**
 * Returns type of bigint for serialization.
 * @param {bigint} n bigint
 * @returns {0 | 1 | 2} type of bigint for serialization
 */
@@ -140,16 +142,19 @@
/** @typedef {{ retainedBuffer?: (x: Buffer) => Buffer }} Context} */
/**
 * Defines the lazy function type used by this module.
 * @template LazyInputValue
 * @template LazyOutputValue
 * @typedef {import("./SerializerMiddleware").LazyFunction<LazyInputValue, LazyOutputValue, BinaryMiddleware, undefined>} LazyFunction
 */
/**
 * Represents BinaryMiddleware.
 * @extends {SerializerMiddleware<DeserializedType, SerializedType, Context>}
 */
class BinaryMiddleware extends SerializerMiddleware {
   /**
    * Serializes this instance into the provided serializer context.
    * @param {DeserializedType} data data
    * @param {Context} context context object
    * @returns {SerializedType | Promise<SerializedType> | null} serialized data
@@ -159,6 +164,7 @@
   }
   /**
    * Returns new lazy.
    * @param {LazyFunction<DeserializedType, SerializedType>} fn lazy function
    * @param {Context} context serialize function
    * @returns {LazyFunction<SerializedType, DeserializedType>} new lazy
@@ -170,6 +176,7 @@
   }
   /**
    * Returns serialized data.
    * @param {DeserializedType} data data
    * @param {Context} context context object
    * @param {{ leftOverBuffer: Buffer | null, allocationSize: number, increaseCounter: number }} allocationScope allocation scope
@@ -196,6 +203,7 @@
         currentBuffer = Buffer.allocUnsafe(allocationScope.allocationSize);
      }
      /**
       * Processes the provided bytes needed.
       * @param {number} bytesNeeded bytes needed
       */
      const allocate = (bytesNeeded) => {
@@ -246,6 +254,7 @@
         }
      };
      /**
       * Processes the provided byte.
       * @param {number} byte byte
       */
      const writeU8 = (byte) => {
@@ -253,6 +262,7 @@
         (currentBuffer).writeUInt8(byte, currentPosition++);
      };
      /**
       * Processes the provided ui32.
       * @param {number} ui32 ui32
       */
      const writeU32 = (ui32) => {
@@ -266,6 +276,7 @@
         measureStack.push(buffers.length, currentPosition);
      };
      /**
       * Returns size.
       * @returns {number} size
       */
      const measureEnd = () => {
@@ -313,6 +324,7 @@
               /** @type {number[]} */
               const lengths = [];
               for (const item of serializedData) {
                  /** @type {undefined | number} */
                  let last;
                  if (typeof item === "function") {
                     lengths.push(0);
@@ -490,8 +502,10 @@
            }
            case "boolean": {
               let lastByte = thing === true ? 1 : 0;
               /** @type {number[]} */
               const bytes = [];
               let count = 1;
               /** @type {undefined | number} */
               let n;
               for (n = 1; n < 0xffffffff && i + n < data.length; n++) {
                  const item = data[i + n];
@@ -541,6 +555,7 @@
            }
            case "object": {
               if (thing === null) {
                  /** @type {number} */
                  let n;
                  for (n = 1; n < 0x100000104 && i + n < data.length; n++) {
                     const item = data[i + n];
@@ -649,6 +664,7 @@
   }
   /**
    * Restores this instance from the provided deserializer context.
    * @param {SerializedType} data data
    * @param {Context} context context object
    * @returns {DeserializedType | Promise<DeserializedType>} deserialized data
@@ -658,6 +674,7 @@
   }
   /**
    * Create lazy deserialized.
    * @private
    * @param {SerializedType} content content
    * @param {Context} context context object
@@ -673,6 +690,7 @@
   }
   /**
    * Returns new lazy.
    * @private
    * @param {LazyFunction<SerializedType, DeserializedType>} fn lazy function
    * @param {Context} context context object
@@ -685,6 +703,7 @@
   }
   /**
    * Returns deserialized data.
    * @param {SerializedType} data data
    * @param {Context} context context object
    * @returns {DeserializedType} deserialized data
@@ -708,6 +727,7 @@
         }
      };
      /**
       * Checks whether this binary middleware is in current buffer.
       * @param {number} n n
       * @returns {boolean} true when in current buffer, otherwise false
       */
@@ -724,7 +744,7 @@
         }
      };
      /**
       * Reads n bytes
       * Returns buffer with bytes.
       * @param {number} n amount of bytes to read
       * @returns {Buffer} buffer with bytes
       */
@@ -775,6 +795,7 @@
         return res;
      };
      /**
       * Returns u8.
       * @returns {number} U8
       */
      const readU8 = () => {
@@ -791,10 +812,12 @@
         return byte;
      };
      /**
       * Returns u32.
       * @returns {number} U32
       */
      const readU32 = () => read(I32_SIZE).readUInt32LE(0);
      /**
       * Processes the provided data.
       * @param {number} data data
       * @param {number} n n
       */