diff options
| author | altaf-creator <dev@altafcreator.com> | 2025-11-09 11:15:19 +0800 |
|---|---|---|
| committer | altaf-creator <dev@altafcreator.com> | 2025-11-09 11:15:19 +0800 |
| commit | 8eff962cab608341a6f2fedc640a0e32d96f26e2 (patch) | |
| tree | 05534d1a720ddc3691d346c69b4972555820a061 /frontend-old/node_modules/@protobufjs/pool | |
pain
Diffstat (limited to 'frontend-old/node_modules/@protobufjs/pool')
7 files changed, 176 insertions, 0 deletions
diff --git a/frontend-old/node_modules/@protobufjs/pool/.npmignore b/frontend-old/node_modules/@protobufjs/pool/.npmignore new file mode 100644 index 0000000..ce75de4 --- /dev/null +++ b/frontend-old/node_modules/@protobufjs/pool/.npmignore @@ -0,0 +1,3 @@ +npm-debug.*
+node_modules/
+coverage/
diff --git a/frontend-old/node_modules/@protobufjs/pool/LICENSE b/frontend-old/node_modules/@protobufjs/pool/LICENSE new file mode 100644 index 0000000..2a2d560 --- /dev/null +++ b/frontend-old/node_modules/@protobufjs/pool/LICENSE @@ -0,0 +1,26 @@ +Copyright (c) 2016, Daniel Wirtz All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are
+met:
+
+* Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+* Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+* Neither the name of its author, nor the names of its contributors
+ may be used to endorse or promote products derived from this software
+ without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
diff --git a/frontend-old/node_modules/@protobufjs/pool/README.md b/frontend-old/node_modules/@protobufjs/pool/README.md new file mode 100644 index 0000000..3955ae0 --- /dev/null +++ b/frontend-old/node_modules/@protobufjs/pool/README.md @@ -0,0 +1,13 @@ +@protobufjs/pool
+================
+[](https://www.npmjs.com/package/@protobufjs/pool)
+
+A general purpose buffer pool.
+
+API
+---
+
+* **pool(alloc: `function(size: number): Uint8Array`, slice: `function(this: Uint8Array, start: number, end: number): Uint8Array`, [size=8192: `number`]): `function(size: number): Uint8Array`**<br />
+ Creates a pooled allocator.
+
+**License:** [BSD 3-Clause License](https://opensource.org/licenses/BSD-3-Clause)
diff --git a/frontend-old/node_modules/@protobufjs/pool/index.d.ts b/frontend-old/node_modules/@protobufjs/pool/index.d.ts new file mode 100644 index 0000000..465559c --- /dev/null +++ b/frontend-old/node_modules/@protobufjs/pool/index.d.ts @@ -0,0 +1,32 @@ +export = pool;
+
+/**
+ * An allocator as used by {@link util.pool}.
+ * @typedef PoolAllocator
+ * @type {function}
+ * @param {number} size Buffer size
+ * @returns {Uint8Array} Buffer
+ */
+type PoolAllocator = (size: number) => Uint8Array;
+
+/**
+ * A slicer as used by {@link util.pool}.
+ * @typedef PoolSlicer
+ * @type {function}
+ * @param {number} start Start offset
+ * @param {number} end End offset
+ * @returns {Uint8Array} Buffer slice
+ * @this {Uint8Array}
+ */
+type PoolSlicer = (this: Uint8Array, start: number, end: number) => Uint8Array;
+
+/**
+ * A general purpose buffer pool.
+ * @memberof util
+ * @function
+ * @param {PoolAllocator} alloc Allocator
+ * @param {PoolSlicer} slice Slicer
+ * @param {number} [size=8192] Slab size
+ * @returns {PoolAllocator} Pooled allocator
+ */
+declare function pool(alloc: PoolAllocator, slice: PoolSlicer, size?: number): PoolAllocator;
diff --git a/frontend-old/node_modules/@protobufjs/pool/index.js b/frontend-old/node_modules/@protobufjs/pool/index.js new file mode 100644 index 0000000..9556f5a --- /dev/null +++ b/frontend-old/node_modules/@protobufjs/pool/index.js @@ -0,0 +1,48 @@ +"use strict";
+module.exports = pool;
+
+/**
+ * An allocator as used by {@link util.pool}.
+ * @typedef PoolAllocator
+ * @type {function}
+ * @param {number} size Buffer size
+ * @returns {Uint8Array} Buffer
+ */
+
+/**
+ * A slicer as used by {@link util.pool}.
+ * @typedef PoolSlicer
+ * @type {function}
+ * @param {number} start Start offset
+ * @param {number} end End offset
+ * @returns {Uint8Array} Buffer slice
+ * @this {Uint8Array}
+ */
+
+/**
+ * A general purpose buffer pool.
+ * @memberof util
+ * @function
+ * @param {PoolAllocator} alloc Allocator
+ * @param {PoolSlicer} slice Slicer
+ * @param {number} [size=8192] Slab size
+ * @returns {PoolAllocator} Pooled allocator
+ */
+function pool(alloc, slice, size) {
+ var SIZE = size || 8192;
+ var MAX = SIZE >>> 1;
+ var slab = null;
+ var offset = SIZE;
+ return function pool_alloc(size) {
+ if (size < 1 || size > MAX)
+ return alloc(size);
+ if (offset + size > SIZE) {
+ slab = alloc(SIZE);
+ offset = 0;
+ }
+ var buf = slice.call(slab, offset, offset += size);
+ if (offset & 7) // align to 32 bit
+ offset = (offset | 7) + 1;
+ return buf;
+ };
+}
diff --git a/frontend-old/node_modules/@protobufjs/pool/package.json b/frontend-old/node_modules/@protobufjs/pool/package.json new file mode 100644 index 0000000..f025e03 --- /dev/null +++ b/frontend-old/node_modules/@protobufjs/pool/package.json @@ -0,0 +1,21 @@ +{ + "name": "@protobufjs/pool", + "description": "A general purpose buffer pool.", + "version": "1.1.0", + "author": "Daniel Wirtz <dcode+protobufjs@dcode.io>", + "repository": { + "type": "git", + "url": "https://github.com/dcodeIO/protobuf.js.git" + }, + "license": "BSD-3-Clause", + "main": "index.js", + "types": "index.d.ts", + "devDependencies": { + "istanbul": "^0.4.5", + "tape": "^4.6.3" + }, + "scripts": { + "test": "tape tests/*.js", + "coverage": "istanbul cover node_modules/tape/bin/tape tests/*.js" + } +} diff --git a/frontend-old/node_modules/@protobufjs/pool/tests/index.js b/frontend-old/node_modules/@protobufjs/pool/tests/index.js new file mode 100644 index 0000000..dc488b8 --- /dev/null +++ b/frontend-old/node_modules/@protobufjs/pool/tests/index.js @@ -0,0 +1,33 @@ +var tape = require("tape");
+
+var pool = require("..");
+
+if (typeof Uint8Array !== "undefined")
+tape.test("pool", function(test) {
+
+ var alloc = pool(function(size) { return new Uint8Array(size); }, Uint8Array.prototype.subarray);
+
+ var buf1 = alloc(0);
+ test.equal(buf1.length, 0, "should allocate a buffer of size 0");
+
+ var buf2 = alloc(1);
+ test.equal(buf2.length, 1, "should allocate a buffer of size 1 (initializes slab)");
+
+ test.notEqual(buf2.buffer, buf1.buffer, "should not reference the same backing buffer if previous buffer had size 0");
+ test.equal(buf2.byteOffset, 0, "should allocate at byteOffset 0 when using a new slab");
+
+ buf1 = alloc(1);
+ test.equal(buf1.buffer, buf2.buffer, "should reference the same backing buffer when allocating a chunk fitting into the slab");
+ test.equal(buf1.byteOffset, 8, "should align slices to 32 bit and this allocate at byteOffset 8");
+
+ var buf3 = alloc(4097);
+ test.notEqual(buf3.buffer, buf2.buffer, "should not reference the same backing buffer when allocating a buffer larger than half the backing buffer's size");
+
+ buf2 = alloc(4096);
+ test.equal(buf2.buffer, buf1.buffer, "should reference the same backing buffer when allocating a buffer smaller or equal than half the backing buffer's size");
+
+ buf1 = alloc(4096);
+ test.notEqual(buf1.buffer, buf2.buffer, "should not reference the same backing buffer when the slab is exhausted (initializes new slab)");
+
+ test.end();
+});
\ No newline at end of file |
