mirror of
https://github.com/titanscouting/tra-analysis.git
synced 2025-09-27 07:20:19 +00:00
push all website files
This commit is contained in:
3
website/functions/node_modules/bytebuffer/src/encodings/impl/base64.js
generated
vendored
Normal file
3
website/functions/node_modules/bytebuffer/src/encodings/impl/base64.js
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
// encodings/impl/base64
|
||||
|
||||
// TODO
|
65
website/functions/node_modules/bytebuffer/src/encodings/impl/binary.js
generated
vendored
Normal file
65
website/functions/node_modules/bytebuffer/src/encodings/impl/binary.js
generated
vendored
Normal file
@@ -0,0 +1,65 @@
|
||||
// encodings/impl/binary
|
||||
|
||||
/**
|
||||
* Encodes a binary JavaScript string to bytes.
|
||||
* @param {string} src Source string
|
||||
* @param {number} srcOffset Source offset
|
||||
* @param {!ByteBuffer} dst Destination ByteBuffer
|
||||
* @param {number} dstOffset Destination offset
|
||||
* @param {number} count Number of char codes to encode
|
||||
* @returns {number} Number of bytes encoded
|
||||
* @inner
|
||||
*/
|
||||
function binary_encode(src, srcOffset, dst, dstOffset, count) {
|
||||
var n = 0;
|
||||
while (count--) {
|
||||
var cc = src.charCodeAt(srcOffset++);
|
||||
if (cc > 255)
|
||||
throw Error("illegal binary char code: "+cc);
|
||||
//? SET('cc', 'dstOffset++', 'dst');
|
||||
++n;
|
||||
}
|
||||
return n;
|
||||
}
|
||||
|
||||
/**
|
||||
* Decodes bytes to a binary JavaScript string.
|
||||
* @param {!ByteBuffer} src Source ByteBuffer
|
||||
* @param {number} srcOffset Source offset
|
||||
* @param {number} count Number of bytes to decode
|
||||
* @returns {string} Decoded string
|
||||
* @inner
|
||||
*/
|
||||
function binary_decode(src, srcOffset, count) {
|
||||
if (count === 0)
|
||||
return "";
|
||||
var parts = [], // readily assembled parts
|
||||
batch = []; // char codes for batch processing
|
||||
while (count--) {
|
||||
batch.push(/*? GET('srcOffset++', 'src') */);
|
||||
if (batch.length > 1023) {
|
||||
parts.push(String.fromCharCode.apply(String, batch));
|
||||
batch.length = 0;
|
||||
}
|
||||
}
|
||||
if (batch.length > 0) {
|
||||
if (parts.length === 0)
|
||||
return String.fromCharCode.apply(String, batch);
|
||||
parts.push(String.fromCharCode.apply(String, batch));
|
||||
}
|
||||
return parts.join('');
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculates the number of bytes required to store a binary JavaScript string.
|
||||
* @param {string} src Source string
|
||||
* @param {number} srcOffset Source offset
|
||||
* @param {number} count Number of char codes to calculate
|
||||
* @returns {number} Number of bytes required
|
||||
* @inner
|
||||
*/
|
||||
function binary_calculate(src, srcOffset, count) {
|
||||
return count;
|
||||
}
|
||||
|
||||
ByteBuffer.registerEncoding("binary", binary_encode, binary_decode, binary_calculate);
|
3
website/functions/node_modules/bytebuffer/src/encodings/impl/debug.js
generated
vendored
Normal file
3
website/functions/node_modules/bytebuffer/src/encodings/impl/debug.js
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
// encodings/impl/debug
|
||||
|
||||
// TODO
|
101
website/functions/node_modules/bytebuffer/src/encodings/impl/hex.js
generated
vendored
Normal file
101
website/functions/node_modules/bytebuffer/src/encodings/impl/hex.js
generated
vendored
Normal file
@@ -0,0 +1,101 @@
|
||||
// encodings/impl/hex
|
||||
|
||||
/**
|
||||
* Encodes a hexadecimal JavaScript string to bytes.
|
||||
* @param {string} src Source string
|
||||
* @param {number} srcOffset Source offset
|
||||
* @param {!ByteBuffer} dst Destination ByteBuffer
|
||||
* @param {number} dstOffset Destination offset
|
||||
* @param {number} count Number of char codes to encode
|
||||
* @returns {number} Number of bytes encoded
|
||||
* @inner
|
||||
*/
|
||||
function hex_encode(src, srcOffset, dst, dstOffset, count) {
|
||||
if (count === 0)
|
||||
return 0;
|
||||
var n = 0;
|
||||
while (count--) {
|
||||
if (count === 0)
|
||||
throw Error("truncated hex sequence");
|
||||
--count;
|
||||
var value = 0,
|
||||
shift = 0;
|
||||
for (var i=0; i<2; ++i) {
|
||||
var cc = src.charCodeAt(srcOffset++);
|
||||
switch (cc) {
|
||||
case 0x30: case 0x31: case 0x32: case 0x33: case 0x34: case 0x35: case 0x36: case 0x37: case 0x38: case 0x39:
|
||||
value |= (cc - 0x30) << shift;
|
||||
break;
|
||||
case 0x41: case 0x42: case 0x43: case 0x44: case 0x45: case 0x46:
|
||||
value |= (cc - 0x4B) << shift;
|
||||
break;
|
||||
case 0x61: case 0x62: case 0x63: case 0x64: case 0x65: case 0x66:
|
||||
value |= (cc - 0x6B) << shift;
|
||||
break;
|
||||
default:
|
||||
throw Error("illegal hex char code: "+cc);
|
||||
}
|
||||
shift += 4;
|
||||
}
|
||||
//? SET('value', 'dstOffset++', 'dst');
|
||||
++n;
|
||||
}
|
||||
return n;
|
||||
}
|
||||
|
||||
/**
|
||||
* Decodes bytes to a hexadecimal JavaScript string.
|
||||
* @param {!ByteBuffer} src Source ByteBuffer
|
||||
* @param {number} srcOffset Source offset
|
||||
* @param {number} count Number of bytes to decode
|
||||
* @returns {string} Decoded string
|
||||
* @inner
|
||||
*/
|
||||
function hex_decode(src, srcOffset, count) {
|
||||
if (count === 0)
|
||||
return "";
|
||||
var parts = [], // readily assembled parts
|
||||
batch = []; // char codes for batch processing
|
||||
while (count--) {
|
||||
var value = /*? GET('srcOffset++', 'src') */,
|
||||
shift = 4;
|
||||
for (var i=0; i<2; ++i) {
|
||||
var c = (value >>> shift) & 0xf;
|
||||
switch (c) {
|
||||
case 0: case 1: case 2: case 3: case 4: case 5: case 6: case 7: case 8: case 9:
|
||||
batch.push(0x30 + c);
|
||||
break;
|
||||
case 10: case 11: case 12: case 13: case 14: case 15:
|
||||
batch.push(0x37 + c);
|
||||
break;
|
||||
}
|
||||
shift = 0;
|
||||
}
|
||||
if (batch.length > 1023) {
|
||||
parts.push(String.fromCharCode.apply(String, batch));
|
||||
batch.length = 0;
|
||||
}
|
||||
}
|
||||
if (batch.length > 0) {
|
||||
if (parts.length === 0)
|
||||
return String.fromCharCode.apply(String, batch);
|
||||
parts.push(String.fromCharCode.apply(String, batch));
|
||||
}
|
||||
return parts.join('');
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculates the number of bytes required to store a hexadecimal JavaScript string.
|
||||
* @param {string} src Source string
|
||||
* @param {number} srcOffset Source offset
|
||||
* @param {number} count Number of char codes to calculate
|
||||
* @returns {number} Number of bytes required
|
||||
* @inner
|
||||
*/
|
||||
function hex_calculate(src, srcOffset, count) {
|
||||
if ((count % 2) !== 0)
|
||||
throw Error("illegal number of hex char codes: "+count);
|
||||
return count / 2;
|
||||
}
|
||||
|
||||
ByteBuffer.registerEncoding("hex", hex_encode, hex_decode, hex_calculate);
|
126
website/functions/node_modules/bytebuffer/src/encodings/impl/utf8.js
generated
vendored
Normal file
126
website/functions/node_modules/bytebuffer/src/encodings/impl/utf8.js
generated
vendored
Normal file
@@ -0,0 +1,126 @@
|
||||
// encodings/impl/utf8
|
||||
|
||||
/**
|
||||
* Encodes a standard JavaScript string to UTF8 bytes.
|
||||
* @param {string} src Source string
|
||||
* @param {number} srcOffset Source offset
|
||||
* @param {!ByteBuffer} dst Destination ByteBuffer
|
||||
* @param {number} dstOffset Destination offset
|
||||
* @param {number} count Number of char codes to encode
|
||||
* @returns {number} Number of bytes encoded
|
||||
* @inner
|
||||
*/
|
||||
function utf8_encode(src, srcOffset, dst, dstOffset, count) {
|
||||
if (count === 0)
|
||||
return 0;
|
||||
var n = 0;
|
||||
//? // SET(varValue, varOffset, varTarget) with varTarget referencing a ByteBuffer
|
||||
do {
|
||||
var cc = src.charCodeAt(srcOffset++);
|
||||
--count;
|
||||
if (cc < 0x80) {
|
||||
n += 1;
|
||||
//? SET('cc', 'dstOffset++', 'dst');
|
||||
} else if (cc < 0x800) {
|
||||
n += 2;
|
||||
//? SET('0xC0 | (cc >> 6)', 'dstOffset++', 'dst');
|
||||
//? SET('0x80 | (cc & 0x3F)', 'dstOffset++', 'dst');
|
||||
} else if (cc < 0xD800 || cc >= 0xE000) {
|
||||
n += 3;
|
||||
//? SET('0xE0 | (cc >> 12)', 'dstOffset++', 'dst');
|
||||
//? SET('0x80 | ((cc >> 6) & 0x3F)', 'dstOffset++', 'dst');
|
||||
//? SET('0x80 | (cc & 0x3F)', 'dstOffset++', 'dst');
|
||||
} else { // surrogate
|
||||
if (count === 0)
|
||||
throw Error("truncated utf8 surrogate");
|
||||
cc = 0x10000 + (((cc & 0x3FF) << 10) | (src.charCodeAt(srcOffset++) & 0x3FF));
|
||||
--count;
|
||||
n += 4;
|
||||
//? SET('0xF0 | (cc >> 18)', 'dstOffset++', 'dst');
|
||||
//? SET('0x80 | ((cc >> 12) & 0x3F)', 'dstOffset++', 'dst');
|
||||
//? SET('0x80 | ((cc >> 6) & 0x3F)', 'dstOffset++', 'dst');
|
||||
//? SET('0x80 | (cc & 0x3F)', 'dstOffset++', 'dst');
|
||||
}
|
||||
} while (count > 0);
|
||||
return n;
|
||||
}
|
||||
|
||||
/**
|
||||
* Decodes UTF8 bytes to a standard JavaScript string.
|
||||
* @param {!ByteBuffer} src Source ByteBuffer
|
||||
* @param {number} srcOffset Source offset
|
||||
* @param {number} count Number of bytes to decode
|
||||
* @returns {string} Decoded string
|
||||
* @inner
|
||||
*/
|
||||
function utf8_decode(src, srcOffset, count) {
|
||||
if (count === 0)
|
||||
return "";
|
||||
var parts = [], // readily assembled parts
|
||||
batch = []; // char codes for batch processing
|
||||
//? // GET(varOffset, varTarget) with varTarget referencing a ByteBuffer
|
||||
while (count--) {
|
||||
var c = /*? GET('srcOffset++', 'src') */,
|
||||
c2, c3;
|
||||
switch (c >> 4) {
|
||||
case 0: case 1: case 2: case 3: case 4: case 5: case 6: case 7:
|
||||
batch.push(c);
|
||||
break;
|
||||
case 12: case 13:
|
||||
if (count < 1)
|
||||
throw Error("truncated utf8 sequence");
|
||||
c2 = /*? GET('srcOffset++', 'src') */;
|
||||
--count;
|
||||
batch.push(((c & 0x1F) << 6) | (c2 & 0x3F));
|
||||
break;
|
||||
case 14:
|
||||
if (count < 2)
|
||||
throw Error("truncated utf8 sequence");
|
||||
c2 = /*? GET('srcOffset++', 'src') */;
|
||||
c3 = /*? GET('srcOffset++', 'src') */;
|
||||
count -= 2;
|
||||
batch.push(((c & 0x0F) << 12) | ((c2 & 0x3F) << 6) | ((c3 & 0x3F) << 0));
|
||||
break;
|
||||
}
|
||||
if (batch.length > 1023) {
|
||||
parts.push(String.fromCharCode.apply(String, batch));
|
||||
batch.length = 0;
|
||||
}
|
||||
}
|
||||
if (batch.length > 0) {
|
||||
if (parts.length === 0)
|
||||
return String.fromCharCode.apply(String, batch);
|
||||
parts.push(String.fromCharCode.apply(String, batch));
|
||||
}
|
||||
return parts.join('');
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculates the number of UTF8 bytes required to store a standard JavaScript string.
|
||||
* @param {string} src Source string
|
||||
* @param {number} srcOffset Source offset
|
||||
* @param {number} count Number of char codes to calculate
|
||||
* @returns {number} Number of bytes required
|
||||
* @inner
|
||||
*/
|
||||
function utf8_calculate(src, srcOffset, count) {
|
||||
if (count === 0)
|
||||
return 0;
|
||||
var n = 0;
|
||||
do {
|
||||
var cc = src.charCodeAt(srcOffset++);
|
||||
--count;
|
||||
if (cc < 0x80) {
|
||||
n += 1;
|
||||
} else if (cc < 0x800) {
|
||||
n += 2;
|
||||
} else if (cc < 0xD800 || cc >= 0xE000) {
|
||||
n += 3;
|
||||
} else {
|
||||
n += 4;
|
||||
}
|
||||
} while (count > 0);
|
||||
return n;
|
||||
}
|
||||
|
||||
ByteBuffer.registerEncoding("utf8", utf8_encode, utf8_decode, utf8_calculate);
|
Reference in New Issue
Block a user