mirror of
https://github.com/x1xhlol/system-prompts-and-models-of-ai-tools.git
synced 2026-02-04 14:00:49 +00:00
nhj
more
This commit is contained in:
145
unified-ai-platform/node_modules/@webassemblyjs/leb128/esm/bits.js
generated
vendored
Normal file
145
unified-ai-platform/node_modules/@webassemblyjs/leb128/esm/bits.js
generated
vendored
Normal file
@@ -0,0 +1,145 @@
|
||||
// Copyright 2012 The Obvious Corporation.
|
||||
|
||||
/*
|
||||
* bits: Bitwise buffer utilities. The utilities here treat a buffer
|
||||
* as a little-endian bigint, so the lowest-order bit is bit #0 of
|
||||
* `buffer[0]`, and the highest-order bit is bit #7 of
|
||||
* `buffer[buffer.length - 1]`.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Modules used
|
||||
*/
|
||||
"use strict";
|
||||
/*
|
||||
* Exported bindings
|
||||
*/
|
||||
|
||||
/**
|
||||
* Extracts the given number of bits from the buffer at the indicated
|
||||
* index, returning a simple number as the result. If bits are requested
|
||||
* that aren't covered by the buffer, the `defaultBit` is used as their
|
||||
* value.
|
||||
*
|
||||
* The `bitLength` must be no more than 32. The `defaultBit` if not
|
||||
* specified is taken to be `0`.
|
||||
*/
|
||||
|
||||
export function extract(buffer, bitIndex, bitLength, defaultBit) {
|
||||
if (bitLength < 0 || bitLength > 32) {
|
||||
throw new Error("Bad value for bitLength.");
|
||||
}
|
||||
|
||||
if (defaultBit === undefined) {
|
||||
defaultBit = 0;
|
||||
} else if (defaultBit !== 0 && defaultBit !== 1) {
|
||||
throw new Error("Bad value for defaultBit.");
|
||||
}
|
||||
|
||||
var defaultByte = defaultBit * 0xff;
|
||||
var result = 0; // All starts are inclusive. The {endByte, endBit} pair is exclusive, but
|
||||
// if endBit !== 0, then endByte is inclusive.
|
||||
|
||||
var lastBit = bitIndex + bitLength;
|
||||
var startByte = Math.floor(bitIndex / 8);
|
||||
var startBit = bitIndex % 8;
|
||||
var endByte = Math.floor(lastBit / 8);
|
||||
var endBit = lastBit % 8;
|
||||
|
||||
if (endBit !== 0) {
|
||||
// `(1 << endBit) - 1` is the mask of all bits up to but not including
|
||||
// the endBit.
|
||||
result = get(endByte) & (1 << endBit) - 1;
|
||||
}
|
||||
|
||||
while (endByte > startByte) {
|
||||
endByte--;
|
||||
result = result << 8 | get(endByte);
|
||||
}
|
||||
|
||||
result >>>= startBit;
|
||||
return result;
|
||||
|
||||
function get(index) {
|
||||
var result = buffer[index];
|
||||
return result === undefined ? defaultByte : result;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Injects the given bits into the given buffer at the given index. Any
|
||||
* bits in the value beyond the length to set are ignored.
|
||||
*/
|
||||
|
||||
export function inject(buffer, bitIndex, bitLength, value) {
|
||||
if (bitLength < 0 || bitLength > 32) {
|
||||
throw new Error("Bad value for bitLength.");
|
||||
}
|
||||
|
||||
var lastByte = Math.floor((bitIndex + bitLength - 1) / 8);
|
||||
|
||||
if (bitIndex < 0 || lastByte >= buffer.length) {
|
||||
throw new Error("Index out of range.");
|
||||
} // Just keeping it simple, until / unless profiling shows that this
|
||||
// is a problem.
|
||||
|
||||
|
||||
var atByte = Math.floor(bitIndex / 8);
|
||||
var atBit = bitIndex % 8;
|
||||
|
||||
while (bitLength > 0) {
|
||||
if (value & 1) {
|
||||
buffer[atByte] |= 1 << atBit;
|
||||
} else {
|
||||
buffer[atByte] &= ~(1 << atBit);
|
||||
}
|
||||
|
||||
value >>= 1;
|
||||
bitLength--;
|
||||
atBit = (atBit + 1) % 8;
|
||||
|
||||
if (atBit === 0) {
|
||||
atByte++;
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Gets the sign bit of the given buffer.
|
||||
*/
|
||||
|
||||
export function getSign(buffer) {
|
||||
return buffer[buffer.length - 1] >>> 7;
|
||||
}
|
||||
/**
|
||||
* Gets the zero-based bit number of the highest-order bit with the
|
||||
* given value in the given buffer.
|
||||
*
|
||||
* If the buffer consists entirely of the other bit value, then this returns
|
||||
* `-1`.
|
||||
*/
|
||||
|
||||
export function highOrder(bit, buffer) {
|
||||
var length = buffer.length;
|
||||
var fullyWrongByte = (bit ^ 1) * 0xff; // the other-bit extended to a full byte
|
||||
|
||||
while (length > 0 && buffer[length - 1] === fullyWrongByte) {
|
||||
length--;
|
||||
}
|
||||
|
||||
if (length === 0) {
|
||||
// Degenerate case. The buffer consists entirely of ~bit.
|
||||
return -1;
|
||||
}
|
||||
|
||||
var byteToCheck = buffer[length - 1];
|
||||
var result = length * 8 - 1;
|
||||
|
||||
for (var i = 7; i > 0; i--) {
|
||||
if ((byteToCheck >> i & 1) === bit) {
|
||||
break;
|
||||
}
|
||||
|
||||
result--;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
228
unified-ai-platform/node_modules/@webassemblyjs/leb128/esm/bufs.js
generated
vendored
Normal file
228
unified-ai-platform/node_modules/@webassemblyjs/leb128/esm/bufs.js
generated
vendored
Normal file
@@ -0,0 +1,228 @@
|
||||
// Copyright 2012 The Obvious Corporation.
|
||||
|
||||
/*
|
||||
* bufs: Buffer utilities.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Module variables
|
||||
*/
|
||||
|
||||
/** Pool of buffers, where `bufPool[x].length === x`. */
|
||||
var bufPool = [];
|
||||
/** Maximum length of kept temporary buffers. */
|
||||
|
||||
var TEMP_BUF_MAXIMUM_LENGTH = 20;
|
||||
/** Minimum exactly-representable 64-bit int. */
|
||||
|
||||
var MIN_EXACT_INT64 = -0x8000000000000000;
|
||||
/** Maximum exactly-representable 64-bit int. */
|
||||
|
||||
var MAX_EXACT_INT64 = 0x7ffffffffffffc00;
|
||||
/** Maximum exactly-representable 64-bit uint. */
|
||||
|
||||
var MAX_EXACT_UINT64 = 0xfffffffffffff800;
|
||||
/**
|
||||
* The int value consisting just of a 1 in bit #32 (that is, one more
|
||||
* than the maximum 32-bit unsigned value).
|
||||
*/
|
||||
|
||||
var BIT_32 = 0x100000000;
|
||||
/**
|
||||
* The int value consisting just of a 1 in bit #64 (that is, one more
|
||||
* than the maximum 64-bit unsigned value).
|
||||
*/
|
||||
|
||||
var BIT_64 = 0x10000000000000000;
|
||||
/*
|
||||
* Helper functions
|
||||
*/
|
||||
|
||||
/**
|
||||
* Masks off all but the lowest bit set of the given number.
|
||||
*/
|
||||
|
||||
function lowestBit(num) {
|
||||
return num & -num;
|
||||
}
|
||||
/**
|
||||
* Gets whether trying to add the second number to the first is lossy
|
||||
* (inexact). The first number is meant to be an accumulated result.
|
||||
*/
|
||||
|
||||
|
||||
function isLossyToAdd(accum, num) {
|
||||
if (num === 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
var lowBit = lowestBit(num);
|
||||
var added = accum + lowBit;
|
||||
|
||||
if (added === accum) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (added - lowBit !== accum) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
/*
|
||||
* Exported functions
|
||||
*/
|
||||
|
||||
/**
|
||||
* Allocates a buffer of the given length, which is initialized
|
||||
* with all zeroes. This returns a buffer from the pool if it is
|
||||
* available, or a freshly-allocated buffer if not.
|
||||
*/
|
||||
|
||||
|
||||
export function alloc(length) {
|
||||
var result = bufPool[length];
|
||||
|
||||
if (result) {
|
||||
bufPool[length] = undefined;
|
||||
} else {
|
||||
result = new Uint8Array(length);
|
||||
}
|
||||
|
||||
result.fill(0);
|
||||
return result;
|
||||
}
|
||||
/**
|
||||
* Releases a buffer back to the pool.
|
||||
*/
|
||||
|
||||
export function free(buffer) {
|
||||
var length = buffer.length;
|
||||
|
||||
if (length < TEMP_BUF_MAXIMUM_LENGTH) {
|
||||
bufPool[length] = buffer;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Resizes a buffer, returning a new buffer. Returns the argument if
|
||||
* the length wouldn't actually change. This function is only safe to
|
||||
* use if the given buffer was allocated within this module (since
|
||||
* otherwise the buffer might possibly be shared externally).
|
||||
*/
|
||||
|
||||
export function resize(buffer, length) {
|
||||
if (length === buffer.length) {
|
||||
return buffer;
|
||||
}
|
||||
|
||||
var newBuf = alloc(length);
|
||||
|
||||
for (var i = 0; i <= buffer.length; i++) {
|
||||
newBuf[i] = buffer[i];
|
||||
}
|
||||
|
||||
free(buffer);
|
||||
return newBuf;
|
||||
}
|
||||
/**
|
||||
* Reads an arbitrary signed int from a buffer.
|
||||
*/
|
||||
|
||||
export function readInt(buffer) {
|
||||
var length = buffer.length;
|
||||
var positive = buffer[length - 1] < 0x80;
|
||||
var result = positive ? 0 : -1;
|
||||
var lossy = false; // Note: We can't use bit manipulation here, since that stops
|
||||
// working if the result won't fit in a 32-bit int.
|
||||
|
||||
if (length < 7) {
|
||||
// Common case which can't possibly be lossy (because the result has
|
||||
// no more than 48 bits, and loss only happens with 54 or more).
|
||||
for (var i = length - 1; i >= 0; i--) {
|
||||
result = result * 0x100 + buffer[i];
|
||||
}
|
||||
} else {
|
||||
for (var _i = length - 1; _i >= 0; _i--) {
|
||||
var one = buffer[_i];
|
||||
result *= 0x100;
|
||||
|
||||
if (isLossyToAdd(result, one)) {
|
||||
lossy = true;
|
||||
}
|
||||
|
||||
result += one;
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
value: result,
|
||||
lossy: lossy
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Reads an arbitrary unsigned int from a buffer.
|
||||
*/
|
||||
|
||||
export function readUInt(buffer) {
|
||||
var length = buffer.length;
|
||||
var result = 0;
|
||||
var lossy = false; // Note: See above in re bit manipulation.
|
||||
|
||||
if (length < 7) {
|
||||
// Common case which can't possibly be lossy (see above).
|
||||
for (var i = length - 1; i >= 0; i--) {
|
||||
result = result * 0x100 + buffer[i];
|
||||
}
|
||||
} else {
|
||||
for (var _i2 = length - 1; _i2 >= 0; _i2--) {
|
||||
var one = buffer[_i2];
|
||||
result *= 0x100;
|
||||
|
||||
if (isLossyToAdd(result, one)) {
|
||||
lossy = true;
|
||||
}
|
||||
|
||||
result += one;
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
value: result,
|
||||
lossy: lossy
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Writes a little-endian 64-bit signed int into a buffer.
|
||||
*/
|
||||
|
||||
export function writeInt64(value, buffer) {
|
||||
if (value < MIN_EXACT_INT64 || value > MAX_EXACT_INT64) {
|
||||
throw new Error("Value out of range.");
|
||||
}
|
||||
|
||||
if (value < 0) {
|
||||
value += BIT_64;
|
||||
}
|
||||
|
||||
writeUInt64(value, buffer);
|
||||
}
|
||||
/**
|
||||
* Writes a little-endian 64-bit unsigned int into a buffer.
|
||||
*/
|
||||
|
||||
export function writeUInt64(value, buffer) {
|
||||
if (value < 0 || value > MAX_EXACT_UINT64) {
|
||||
throw new Error("Value out of range.");
|
||||
}
|
||||
|
||||
var lowWord = value % BIT_32;
|
||||
var highWord = Math.floor(value / BIT_32);
|
||||
buffer[0] = lowWord & 0xff;
|
||||
buffer[1] = lowWord >> 8 & 0xff;
|
||||
buffer[2] = lowWord >> 16 & 0xff;
|
||||
buffer[3] = lowWord >> 24 & 0xff;
|
||||
buffer[4] = highWord & 0xff;
|
||||
buffer[5] = highWord >> 8 & 0xff;
|
||||
buffer[6] = highWord >> 16 & 0xff;
|
||||
buffer[7] = highWord >> 24 & 0xff;
|
||||
}
|
||||
156
unified-ai-platform/node_modules/@webassemblyjs/leb128/lib/bits.js
generated
vendored
Normal file
156
unified-ai-platform/node_modules/@webassemblyjs/leb128/lib/bits.js
generated
vendored
Normal file
@@ -0,0 +1,156 @@
|
||||
// Copyright 2012 The Obvious Corporation.
|
||||
|
||||
/*
|
||||
* bits: Bitwise buffer utilities. The utilities here treat a buffer
|
||||
* as a little-endian bigint, so the lowest-order bit is bit #0 of
|
||||
* `buffer[0]`, and the highest-order bit is bit #7 of
|
||||
* `buffer[buffer.length - 1]`.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Modules used
|
||||
*/
|
||||
"use strict";
|
||||
/*
|
||||
* Exported bindings
|
||||
*/
|
||||
|
||||
/**
|
||||
* Extracts the given number of bits from the buffer at the indicated
|
||||
* index, returning a simple number as the result. If bits are requested
|
||||
* that aren't covered by the buffer, the `defaultBit` is used as their
|
||||
* value.
|
||||
*
|
||||
* The `bitLength` must be no more than 32. The `defaultBit` if not
|
||||
* specified is taken to be `0`.
|
||||
*/
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.extract = extract;
|
||||
exports.inject = inject;
|
||||
exports.getSign = getSign;
|
||||
exports.highOrder = highOrder;
|
||||
|
||||
function extract(buffer, bitIndex, bitLength, defaultBit) {
|
||||
if (bitLength < 0 || bitLength > 32) {
|
||||
throw new Error("Bad value for bitLength.");
|
||||
}
|
||||
|
||||
if (defaultBit === undefined) {
|
||||
defaultBit = 0;
|
||||
} else if (defaultBit !== 0 && defaultBit !== 1) {
|
||||
throw new Error("Bad value for defaultBit.");
|
||||
}
|
||||
|
||||
var defaultByte = defaultBit * 0xff;
|
||||
var result = 0; // All starts are inclusive. The {endByte, endBit} pair is exclusive, but
|
||||
// if endBit !== 0, then endByte is inclusive.
|
||||
|
||||
var lastBit = bitIndex + bitLength;
|
||||
var startByte = Math.floor(bitIndex / 8);
|
||||
var startBit = bitIndex % 8;
|
||||
var endByte = Math.floor(lastBit / 8);
|
||||
var endBit = lastBit % 8;
|
||||
|
||||
if (endBit !== 0) {
|
||||
// `(1 << endBit) - 1` is the mask of all bits up to but not including
|
||||
// the endBit.
|
||||
result = get(endByte) & (1 << endBit) - 1;
|
||||
}
|
||||
|
||||
while (endByte > startByte) {
|
||||
endByte--;
|
||||
result = result << 8 | get(endByte);
|
||||
}
|
||||
|
||||
result >>>= startBit;
|
||||
return result;
|
||||
|
||||
function get(index) {
|
||||
var result = buffer[index];
|
||||
return result === undefined ? defaultByte : result;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Injects the given bits into the given buffer at the given index. Any
|
||||
* bits in the value beyond the length to set are ignored.
|
||||
*/
|
||||
|
||||
|
||||
function inject(buffer, bitIndex, bitLength, value) {
|
||||
if (bitLength < 0 || bitLength > 32) {
|
||||
throw new Error("Bad value for bitLength.");
|
||||
}
|
||||
|
||||
var lastByte = Math.floor((bitIndex + bitLength - 1) / 8);
|
||||
|
||||
if (bitIndex < 0 || lastByte >= buffer.length) {
|
||||
throw new Error("Index out of range.");
|
||||
} // Just keeping it simple, until / unless profiling shows that this
|
||||
// is a problem.
|
||||
|
||||
|
||||
var atByte = Math.floor(bitIndex / 8);
|
||||
var atBit = bitIndex % 8;
|
||||
|
||||
while (bitLength > 0) {
|
||||
if (value & 1) {
|
||||
buffer[atByte] |= 1 << atBit;
|
||||
} else {
|
||||
buffer[atByte] &= ~(1 << atBit);
|
||||
}
|
||||
|
||||
value >>= 1;
|
||||
bitLength--;
|
||||
atBit = (atBit + 1) % 8;
|
||||
|
||||
if (atBit === 0) {
|
||||
atByte++;
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Gets the sign bit of the given buffer.
|
||||
*/
|
||||
|
||||
|
||||
function getSign(buffer) {
|
||||
return buffer[buffer.length - 1] >>> 7;
|
||||
}
|
||||
/**
|
||||
* Gets the zero-based bit number of the highest-order bit with the
|
||||
* given value in the given buffer.
|
||||
*
|
||||
* If the buffer consists entirely of the other bit value, then this returns
|
||||
* `-1`.
|
||||
*/
|
||||
|
||||
|
||||
function highOrder(bit, buffer) {
|
||||
var length = buffer.length;
|
||||
var fullyWrongByte = (bit ^ 1) * 0xff; // the other-bit extended to a full byte
|
||||
|
||||
while (length > 0 && buffer[length - 1] === fullyWrongByte) {
|
||||
length--;
|
||||
}
|
||||
|
||||
if (length === 0) {
|
||||
// Degenerate case. The buffer consists entirely of ~bit.
|
||||
return -1;
|
||||
}
|
||||
|
||||
var byteToCheck = buffer[length - 1];
|
||||
var result = length * 8 - 1;
|
||||
|
||||
for (var i = 7; i > 0; i--) {
|
||||
if ((byteToCheck >> i & 1) === bit) {
|
||||
break;
|
||||
}
|
||||
|
||||
result--;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
Reference in New Issue
Block a user