format: prettify entire project

This commit is contained in:
Rim
2025-04-02 06:50:39 -04:00
parent 86f0782a98
commit 7ccc0be712
1711 changed files with 755867 additions and 235931 deletions

330
node_modules/bl/BufferList.js generated vendored
View File

@ -1,350 +1,354 @@
'use strict'
'use strict';
const { Buffer } = require('buffer')
const symbol = Symbol.for('BufferList')
const { Buffer } = require('buffer');
const symbol = Symbol.for('BufferList');
function BufferList (buf) {
function BufferList(buf) {
if (!(this instanceof BufferList)) {
return new BufferList(buf)
return new BufferList(buf);
}
BufferList._init.call(this, buf)
BufferList._init.call(this, buf);
}
BufferList._init = function _init (buf) {
Object.defineProperty(this, symbol, { value: true })
BufferList._init = function _init(buf) {
Object.defineProperty(this, symbol, { value: true });
this._bufs = []
this.length = 0
this._bufs = [];
this.length = 0;
if (buf) {
this.append(buf)
this.append(buf);
}
}
};
BufferList.prototype._new = function _new (buf) {
return new BufferList(buf)
}
BufferList.prototype._new = function _new(buf) {
return new BufferList(buf);
};
BufferList.prototype._offset = function _offset (offset) {
BufferList.prototype._offset = function _offset(offset) {
if (offset === 0) {
return [0, 0]
return [0, 0];
}
let tot = 0
let tot = 0;
for (let i = 0; i < this._bufs.length; i++) {
const _t = tot + this._bufs[i].length
const _t = tot + this._bufs[i].length;
if (offset < _t || i === this._bufs.length - 1) {
return [i, offset - tot]
return [i, offset - tot];
}
tot = _t
tot = _t;
}
}
};
BufferList.prototype._reverseOffset = function (blOffset) {
const bufferId = blOffset[0]
let offset = blOffset[1]
const bufferId = blOffset[0];
let offset = blOffset[1];
for (let i = 0; i < bufferId; i++) {
offset += this._bufs[i].length
offset += this._bufs[i].length;
}
return offset
}
return offset;
};
BufferList.prototype.get = function get (index) {
BufferList.prototype.get = function get(index) {
if (index > this.length || index < 0) {
return undefined
return undefined;
}
const offset = this._offset(index)
const offset = this._offset(index);
return this._bufs[offset[0]][offset[1]]
}
return this._bufs[offset[0]][offset[1]];
};
BufferList.prototype.slice = function slice (start, end) {
BufferList.prototype.slice = function slice(start, end) {
if (typeof start === 'number' && start < 0) {
start += this.length
start += this.length;
}
if (typeof end === 'number' && end < 0) {
end += this.length
end += this.length;
}
return this.copy(null, 0, start, end)
}
return this.copy(null, 0, start, end);
};
BufferList.prototype.copy = function copy (dst, dstStart, srcStart, srcEnd) {
BufferList.prototype.copy = function copy(dst, dstStart, srcStart, srcEnd) {
if (typeof srcStart !== 'number' || srcStart < 0) {
srcStart = 0
srcStart = 0;
}
if (typeof srcEnd !== 'number' || srcEnd > this.length) {
srcEnd = this.length
srcEnd = this.length;
}
if (srcStart >= this.length) {
return dst || Buffer.alloc(0)
return dst || Buffer.alloc(0);
}
if (srcEnd <= 0) {
return dst || Buffer.alloc(0)
return dst || Buffer.alloc(0);
}
const copy = !!dst
const off = this._offset(srcStart)
const len = srcEnd - srcStart
let bytes = len
let bufoff = (copy && dstStart) || 0
let start = off[1]
const copy = !!dst;
const off = this._offset(srcStart);
const len = srcEnd - srcStart;
let bytes = len;
let bufoff = (copy && dstStart) || 0;
let start = off[1];
// copy/slice everything
if (srcStart === 0 && srcEnd === this.length) {
if (!copy) {
// slice, but full concat if multiple buffers
return this._bufs.length === 1
? this._bufs[0]
: Buffer.concat(this._bufs, this.length)
return this._bufs.length === 1 ?
this._bufs[0]
: Buffer.concat(this._bufs, this.length);
}
// copy, need to copy individual buffers
for (let i = 0; i < this._bufs.length; i++) {
this._bufs[i].copy(dst, bufoff)
bufoff += this._bufs[i].length
this._bufs[i].copy(dst, bufoff);
bufoff += this._bufs[i].length;
}
return dst
return dst;
}
// easy, cheap case where it's a subset of one of the buffers
if (bytes <= this._bufs[off[0]].length - start) {
return copy
? this._bufs[off[0]].copy(dst, dstStart, start, start + bytes)
: this._bufs[off[0]].slice(start, start + bytes)
return copy ?
this._bufs[off[0]].copy(dst, dstStart, start, start + bytes)
: this._bufs[off[0]].slice(start, start + bytes);
}
if (!copy) {
// a slice, we need something to copy in to
dst = Buffer.allocUnsafe(len)
dst = Buffer.allocUnsafe(len);
}
for (let i = off[0]; i < this._bufs.length; i++) {
const l = this._bufs[i].length - start
const l = this._bufs[i].length - start;
if (bytes > l) {
this._bufs[i].copy(dst, bufoff, start)
bufoff += l
this._bufs[i].copy(dst, bufoff, start);
bufoff += l;
} else {
this._bufs[i].copy(dst, bufoff, start, start + bytes)
bufoff += l
break
this._bufs[i].copy(dst, bufoff, start, start + bytes);
bufoff += l;
break;
}
bytes -= l
bytes -= l;
if (start) {
start = 0
start = 0;
}
}
// safeguard so that we don't return uninitialized memory
if (dst.length > bufoff) return dst.slice(0, bufoff)
if (dst.length > bufoff) return dst.slice(0, bufoff);
return dst
}
return dst;
};
BufferList.prototype.shallowSlice = function shallowSlice (start, end) {
start = start || 0
end = typeof end !== 'number' ? this.length : end
BufferList.prototype.shallowSlice = function shallowSlice(start, end) {
start = start || 0;
end = typeof end !== 'number' ? this.length : end;
if (start < 0) {
start += this.length
start += this.length;
}
if (end < 0) {
end += this.length
end += this.length;
}
if (start === end) {
return this._new()
return this._new();
}
const startOffset = this._offset(start)
const endOffset = this._offset(end)
const buffers = this._bufs.slice(startOffset[0], endOffset[0] + 1)
const startOffset = this._offset(start);
const endOffset = this._offset(end);
const buffers = this._bufs.slice(startOffset[0], endOffset[0] + 1);
if (endOffset[1] === 0) {
buffers.pop()
buffers.pop();
} else {
buffers[buffers.length - 1] = buffers[buffers.length - 1].slice(0, endOffset[1])
buffers[buffers.length - 1] = buffers[buffers.length - 1].slice(
0,
endOffset[1]
);
}
if (startOffset[1] !== 0) {
buffers[0] = buffers[0].slice(startOffset[1])
buffers[0] = buffers[0].slice(startOffset[1]);
}
return this._new(buffers)
}
return this._new(buffers);
};
BufferList.prototype.toString = function toString (encoding, start, end) {
return this.slice(start, end).toString(encoding)
}
BufferList.prototype.toString = function toString(encoding, start, end) {
return this.slice(start, end).toString(encoding);
};
BufferList.prototype.consume = function consume (bytes) {
BufferList.prototype.consume = function consume(bytes) {
// first, normalize the argument, in accordance with how Buffer does it
bytes = Math.trunc(bytes)
bytes = Math.trunc(bytes);
// do nothing if not a positive number
if (Number.isNaN(bytes) || bytes <= 0) return this
if (Number.isNaN(bytes) || bytes <= 0) return this;
while (this._bufs.length) {
if (bytes >= this._bufs[0].length) {
bytes -= this._bufs[0].length
this.length -= this._bufs[0].length
this._bufs.shift()
bytes -= this._bufs[0].length;
this.length -= this._bufs[0].length;
this._bufs.shift();
} else {
this._bufs[0] = this._bufs[0].slice(bytes)
this.length -= bytes
break
this._bufs[0] = this._bufs[0].slice(bytes);
this.length -= bytes;
break;
}
}
return this
}
return this;
};
BufferList.prototype.duplicate = function duplicate () {
const copy = this._new()
BufferList.prototype.duplicate = function duplicate() {
const copy = this._new();
for (let i = 0; i < this._bufs.length; i++) {
copy.append(this._bufs[i])
copy.append(this._bufs[i]);
}
return copy
}
return copy;
};
BufferList.prototype.append = function append (buf) {
BufferList.prototype.append = function append(buf) {
if (buf == null) {
return this
return this;
}
if (buf.buffer) {
// append a view of the underlying ArrayBuffer
this._appendBuffer(Buffer.from(buf.buffer, buf.byteOffset, buf.byteLength))
this._appendBuffer(Buffer.from(buf.buffer, buf.byteOffset, buf.byteLength));
} else if (Array.isArray(buf)) {
for (let i = 0; i < buf.length; i++) {
this.append(buf[i])
this.append(buf[i]);
}
} else if (this._isBufferList(buf)) {
// unwrap argument into individual BufferLists
for (let i = 0; i < buf._bufs.length; i++) {
this.append(buf._bufs[i])
this.append(buf._bufs[i]);
}
} else {
// coerce number arguments to strings, since Buffer(number) does
// uninitialized memory allocation
if (typeof buf === 'number') {
buf = buf.toString()
buf = buf.toString();
}
this._appendBuffer(Buffer.from(buf))
this._appendBuffer(Buffer.from(buf));
}
return this
}
return this;
};
BufferList.prototype._appendBuffer = function appendBuffer (buf) {
this._bufs.push(buf)
this.length += buf.length
}
BufferList.prototype._appendBuffer = function appendBuffer(buf) {
this._bufs.push(buf);
this.length += buf.length;
};
BufferList.prototype.indexOf = function (search, offset, encoding) {
if (encoding === undefined && typeof offset === 'string') {
encoding = offset
offset = undefined
encoding = offset;
offset = undefined;
}
if (typeof search === 'function' || Array.isArray(search)) {
throw new TypeError('The "value" argument must be one of type string, Buffer, BufferList, or Uint8Array.')
throw new TypeError(
'The "value" argument must be one of type string, Buffer, BufferList, or Uint8Array.'
);
} else if (typeof search === 'number') {
search = Buffer.from([search])
search = Buffer.from([search]);
} else if (typeof search === 'string') {
search = Buffer.from(search, encoding)
search = Buffer.from(search, encoding);
} else if (this._isBufferList(search)) {
search = search.slice()
search = search.slice();
} else if (Array.isArray(search.buffer)) {
search = Buffer.from(search.buffer, search.byteOffset, search.byteLength)
search = Buffer.from(search.buffer, search.byteOffset, search.byteLength);
} else if (!Buffer.isBuffer(search)) {
search = Buffer.from(search)
search = Buffer.from(search);
}
offset = Number(offset || 0)
offset = Number(offset || 0);
if (isNaN(offset)) {
offset = 0
offset = 0;
}
if (offset < 0) {
offset = this.length + offset
offset = this.length + offset;
}
if (offset < 0) {
offset = 0
offset = 0;
}
if (search.length === 0) {
return offset > this.length ? this.length : offset
return offset > this.length ? this.length : offset;
}
const blOffset = this._offset(offset)
let blIndex = blOffset[0] // index of which internal buffer we're working on
let buffOffset = blOffset[1] // offset of the internal buffer we're working on
const blOffset = this._offset(offset);
let blIndex = blOffset[0]; // index of which internal buffer we're working on
let buffOffset = blOffset[1]; // offset of the internal buffer we're working on
// scan over each buffer
for (; blIndex < this._bufs.length; blIndex++) {
const buff = this._bufs[blIndex]
const buff = this._bufs[blIndex];
while (buffOffset < buff.length) {
const availableWindow = buff.length - buffOffset
const availableWindow = buff.length - buffOffset;
if (availableWindow >= search.length) {
const nativeSearchResult = buff.indexOf(search, buffOffset)
const nativeSearchResult = buff.indexOf(search, buffOffset);
if (nativeSearchResult !== -1) {
return this._reverseOffset([blIndex, nativeSearchResult])
return this._reverseOffset([blIndex, nativeSearchResult]);
}
buffOffset = buff.length - search.length + 1 // end of native search window
buffOffset = buff.length - search.length + 1; // end of native search window
} else {
const revOffset = this._reverseOffset([blIndex, buffOffset])
const revOffset = this._reverseOffset([blIndex, buffOffset]);
if (this._match(revOffset, search)) {
return revOffset
return revOffset;
}
buffOffset++
buffOffset++;
}
}
buffOffset = 0
buffOffset = 0;
}
return -1
}
return -1;
};
BufferList.prototype._match = function (offset, search) {
if (this.length - offset < search.length) {
return false
return false;
}
for (let searchOffset = 0; searchOffset < search.length; searchOffset++) {
if (this.get(offset + searchOffset) !== search[searchOffset]) {
return false
return false;
}
}
return true
}
;(function () {
return true;
};
(function () {
const methods = {
readDoubleBE: 8,
readDoubleLE: 8,
@ -363,34 +367,34 @@ BufferList.prototype._match = function (offset, search) {
readIntBE: null,
readIntLE: null,
readUIntBE: null,
readUIntLE: null
}
readUIntLE: null,
};
for (const m in methods) {
(function (m) {
if (methods[m] === null) {
BufferList.prototype[m] = function (offset, byteLength) {
return this.slice(offset, offset + byteLength)[m](0, byteLength)
}
return this.slice(offset, offset + byteLength)[m](0, byteLength);
};
} else {
BufferList.prototype[m] = function (offset = 0) {
return this.slice(offset, offset + methods[m])[m](0)
}
return this.slice(offset, offset + methods[m])[m](0);
};
}
}(m))
})(m);
}
}())
})();
// Used internally by the class and also as an indicator of this object being
// a `BufferList`. It's not possible to use `instanceof BufferList` in a browser
// environment because there could be multiple different copies of the
// BufferList class and some `BufferList`s might be `BufferList`s.
BufferList.prototype._isBufferList = function _isBufferList (b) {
return b instanceof BufferList || BufferList.isBufferList(b)
}
BufferList.prototype._isBufferList = function _isBufferList(b) {
return b instanceof BufferList || BufferList.isBufferList(b);
};
BufferList.isBufferList = function isBufferList (b) {
return b != null && b[symbol]
}
BufferList.isBufferList = function isBufferList(b) {
return b != null && b[symbol];
};
module.exports = BufferList
module.exports = BufferList;

108
node_modules/bl/bl.js generated vendored
View File

@ -1,84 +1,88 @@
'use strict'
'use strict';
const DuplexStream = require('readable-stream').Duplex
const inherits = require('inherits')
const BufferList = require('./BufferList')
const DuplexStream = require('readable-stream').Duplex;
const inherits = require('inherits');
const BufferList = require('./BufferList');
function BufferListStream (callback) {
function BufferListStream(callback) {
if (!(this instanceof BufferListStream)) {
return new BufferListStream(callback)
return new BufferListStream(callback);
}
if (typeof callback === 'function') {
this._callback = callback
this._callback = callback;
const piper = function piper (err) {
const piper = function piper(err) {
if (this._callback) {
this._callback(err)
this._callback = null
this._callback(err);
this._callback = null;
}
}.bind(this)
}.bind(this);
this.on('pipe', function onPipe (src) {
src.on('error', piper)
})
this.on('unpipe', function onUnpipe (src) {
src.removeListener('error', piper)
})
this.on('pipe', function onPipe(src) {
src.on('error', piper);
});
this.on('unpipe', function onUnpipe(src) {
src.removeListener('error', piper);
});
callback = null
callback = null;
}
BufferList._init.call(this, callback)
DuplexStream.call(this)
BufferList._init.call(this, callback);
DuplexStream.call(this);
}
inherits(BufferListStream, DuplexStream)
Object.assign(BufferListStream.prototype, BufferList.prototype)
inherits(BufferListStream, DuplexStream);
Object.assign(BufferListStream.prototype, BufferList.prototype);
BufferListStream.prototype._new = function _new (callback) {
return new BufferListStream(callback)
}
BufferListStream.prototype._new = function _new(callback) {
return new BufferListStream(callback);
};
BufferListStream.prototype._write = function _write (buf, encoding, callback) {
this._appendBuffer(buf)
BufferListStream.prototype._write = function _write(buf, encoding, callback) {
this._appendBuffer(buf);
if (typeof callback === 'function') {
callback()
callback();
}
}
};
BufferListStream.prototype._read = function _read (size) {
BufferListStream.prototype._read = function _read(size) {
if (!this.length) {
return this.push(null)
return this.push(null);
}
size = Math.min(size, this.length)
this.push(this.slice(0, size))
this.consume(size)
}
size = Math.min(size, this.length);
this.push(this.slice(0, size));
this.consume(size);
};
BufferListStream.prototype.end = function end (chunk) {
DuplexStream.prototype.end.call(this, chunk)
BufferListStream.prototype.end = function end(chunk) {
DuplexStream.prototype.end.call(this, chunk);
if (this._callback) {
this._callback(null, this.slice())
this._callback = null
this._callback(null, this.slice());
this._callback = null;
}
}
};
BufferListStream.prototype._destroy = function _destroy (err, cb) {
this._bufs.length = 0
this.length = 0
cb(err)
}
BufferListStream.prototype._destroy = function _destroy(err, cb) {
this._bufs.length = 0;
this.length = 0;
cb(err);
};
BufferListStream.prototype._isBufferList = function _isBufferList (b) {
return b instanceof BufferListStream || b instanceof BufferList || BufferListStream.isBufferList(b)
}
BufferListStream.prototype._isBufferList = function _isBufferList(b) {
return (
b instanceof BufferListStream ||
b instanceof BufferList ||
BufferListStream.isBufferList(b)
);
};
BufferListStream.isBufferList = BufferList.isBufferList
BufferListStream.isBufferList = BufferList.isBufferList;
module.exports = BufferListStream
module.exports.BufferListStream = BufferListStream
module.exports.BufferList = BufferList
module.exports = BufferListStream;
module.exports.BufferListStream = BufferListStream;
module.exports.BufferList = BufferList;