Showing preview only (4,777K chars total). Download the full file or copy to clipboard to get everything.
Repository: anonyco/FastestSmallestTextEncoderDecoder
Branch: master
Commit: f04c88cf1102
Files: 29
Total size: 69.1 MB
Directory structure:
gitextract_hlw2gjaz/
├── .gitignore
├── EncoderDecoderTogether.src.js
├── LICENSE
├── NodeJS/
│ ├── EncoderAndDecoderNodeJS.min.mjs
│ ├── EncoderAndDecoderNodeJS.min.module.js
│ ├── EncoderAndDecoderNodeJS.src.js
│ ├── EncoderAndDecoderNodeJS.src.module.js
│ └── build-npm-repository.js
├── README.md
├── encodeInto/
│ ├── NodeJS/
│ │ └── EncoderAndDecoderNodeJS.min.mjs
│ ├── README.md
│ └── package.json
├── gh-pages/
│ ├── encoderAndDecoderForced.src.js
│ ├── hexWorker.js
│ ├── index.html
│ ├── install-FastestSmallestTextEncoderDecoder-encodeInto.bat
│ ├── install-FastestSmallestTextEncoderDecoder-encodeInto.sh
│ ├── install-FastestSmallestTextEncoderDecoder-unix.sh
│ └── install-FastestSmallestTextEncoderDecoder-windows.bat
├── individual/
│ ├── FastestTextDecoderPolyfill.src.js
│ └── FastestTextEncoderPolyfill.src.js
├── package.json
└── test/
├── 1876 The Russian Synodal Bible.txt
├── benchmark.js
├── package.json
├── random-ascii-30000000.txt
├── random-test-30000000.txt
├── test.js
└── utils.js
================================================
FILE CONTENTS
================================================
================================================
FILE: .gitignore
================================================
# in case if you have installed node modules
/node_modules
/package-lock.json
/test/node_modules
/test/encoding-indexes.js
# skip the utilities used to build this library
/compiler-latest
/closure-compiler.jar
/zopfli
/npm-repository
# just in case
/.git
/.npmignore
# now for the inner dist:
/dist/src/
/dist/package.json
/dist/LICENSE
/src/src/
# in case if you have installed node modules
/dist/node_modules
/dist/package-lock.json
/dist/README.md
# skip the utilities used to build this library
/dist/closure-compiler.jar
# just in case
/dist/.git
/dist/.npmignore
================================================
FILE: EncoderDecoderTogether.src.js
================================================
/** @define {boolean} */
var ENCODEINTO_BUILD = false;
(function(window){
"use strict";
//var log = Math.log;
//var LN2 = Math.LN2;
//var clz32 = Math.clz32 || function(x) {return 31 - log(x >> 0) / LN2 | 0};
var fromCharCode = String.fromCharCode;
var Object_prototype_toString = ({}).toString;
var sharedArrayBufferString = Object_prototype_toString.call(window["SharedArrayBuffer"]);
var undefinedObjectString = Object_prototype_toString();
var NativeUint8Array = window.Uint8Array;
var patchedU8Array = NativeUint8Array || Array;
var nativeArrayBuffer = NativeUint8Array ? ArrayBuffer : patchedU8Array;
var arrayBuffer_isView = nativeArrayBuffer.isView || function(x) {return x && "length" in x};
var arrayBufferString = Object_prototype_toString.call(nativeArrayBuffer.prototype);
var window_encodeURIComponent = encodeURIComponent;
var window_parseInt = parseInt;
var TextEncoderPrototype = TextEncoder["prototype"];
var GlobalTextEncoder = window["TextEncoder"];
var decoderRegexp = /[\xc0-\xff][\x80-\xbf]+|[\x80-\xff]/g;
var encoderRegexp = /[\x80-\uD7ff\uDC00-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]?/g;
var tmpBufferU16 = new (NativeUint8Array ? Uint16Array : patchedU8Array)(32);
var globalTextEncoderPrototype;
var globalTextEncoderInstance;
/*function decoderReplacer(encoded) {
var cp0 = encoded.charCodeAt(0), codePoint=0x110000, i=0, stringLen=encoded.length|0, result="";
switch(cp0 >> 4) {
// no 1 byte sequences
case 12:
case 13:
codePoint = ((cp0 & 0x1F) << 6) | (encoded.charCodeAt(1) & 0x3F);
i = codePoint < 0x80 ? 0 : 2;
break;
case 14:
codePoint = ((cp0 & 0x0F) << 12) | ((encoded.charCodeAt(1) & 0x3F) << 6) | (encoded.charCodeAt(2) & 0x3F);
i = codePoint < 0x800 ? 0 : 3;
break;
case 15:
if ((cp0 >> 3) === 30) {
codePoint = ((cp0 & 0x07) << 18) | ((encoded.charCodeAt(1) & 0x3F) << 12) | ((encoded.charCodeAt(2) & 0x3F) << 6) | (encoded.charCodeAt(3) & 0x3F);
i = codePoint < 0x10000 ? 0 : 4;
}
}
if (i) {
if (stringLen < i) {
i = 0;
} else if (codePoint < 0x10000) { // BMP code point
result = fromCharCode(codePoint);
} else if (codePoint < 0x110000) {
codePoint = codePoint - 0x10080|0;//- 0x10000|0;
result = fromCharCode(
(codePoint >> 10) + 0xD800|0, // highSurrogate
(codePoint & 0x3ff) + 0xDC00|0 // lowSurrogate
);
} else i = 0; // to fill it in with INVALIDs
}
for (; i < stringLen; i=i+1|0) result += "\ufffd"; // fill rest with replacement character
return result;
}*/
function TextDecoder(){};
TextDecoder["prototype"]["decode"] = function(inputArrayOrBuffer){
var inputAs8 = inputArrayOrBuffer, asObjectString;
if (!arrayBuffer_isView(inputAs8)) {
asObjectString = Object_prototype_toString.call(inputAs8);
if (asObjectString !== arrayBufferString && asObjectString !== sharedArrayBufferString && asObjectString !== undefinedObjectString)
throw TypeError("Failed to execute 'decode' on 'TextDecoder': The provided value is not of type '(ArrayBuffer or ArrayBufferView)'");
inputAs8 = NativeUint8Array ? new patchedU8Array(inputAs8) : inputAs8 || [];
}
var resultingString="", tmpStr="", index=0, len=inputAs8.length|0, lenMinus32=len-32|0, nextEnd=0, nextStop=0, cp0=0, codePoint=0, minBits=0, cp1=0, pos=0, tmp=-1;
// Note that tmp represents the 2nd half of a surrogate pair incase a surrogate gets divided between blocks
for (; index < len; ) {
nextEnd = index <= lenMinus32 ? 32 : len - index|0;
for (; pos < nextEnd; index=index+1|0, pos=pos+1|0) {
cp0 = inputAs8[index] & 0xff;
switch(cp0 >> 4) {
case 15:
cp1 = inputAs8[index=index+1|0] & 0xff;
if ((cp1 >> 6) !== 0b10 || 0b11110111 < cp0) {
index = index - 1|0;
break;
}
codePoint = ((cp0 & 0b111) << 6) | (cp1 & 0b00111111);
minBits = 5; // 20 ensures it never passes -> all invalid replacements
cp0 = 0x100; // keep track of th bit size
case 14:
cp1 = inputAs8[index=index+1|0] & 0xff;
codePoint <<= 6;
codePoint |= ((cp0 & 0b1111) << 6) | (cp1 & 0b00111111);
minBits = (cp1 >> 6) === 0b10 ? minBits + 4|0 : 24; // 24 ensures it never passes -> all invalid replacements
cp0 = (cp0 + 0x100) & 0x300; // keep track of th bit size
case 13:
case 12:
cp1 = inputAs8[index=index+1|0] & 0xff;
codePoint <<= 6;
codePoint |= ((cp0 & 0b11111) << 6) | cp1 & 0b00111111;
minBits = minBits + 7|0;
// Now, process the code point
if (index < len && (cp1 >> 6) === 0b10 && (codePoint >> minBits) && codePoint < 0x110000) {
cp0 = codePoint;
codePoint = codePoint - 0x10000|0;
if (0 <= codePoint/*0xffff < codePoint*/) { // BMP code point
//nextEnd = nextEnd - 1|0;
tmp = (codePoint >> 10) + 0xD800|0; // highSurrogate
cp0 = (codePoint & 0x3ff) + 0xDC00|0; // lowSurrogate (will be inserted later in the switch-statement)
if (pos < 31) { // notice 31 instead of 32
tmpBufferU16[pos] = tmp;
pos = pos + 1|0;
tmp = -1;
} else {// else, we are at the end of the inputAs8 and let tmp0 be filled in later on
// NOTE that cp1 is being used as a temporary variable for the swapping of tmp with cp0
cp1 = tmp;
tmp = cp0;
cp0 = cp1;
}
} else nextEnd = nextEnd + 1|0; // because we are advancing i without advancing pos
} else {
// invalid code point means replacing the whole thing with null replacement characters
cp0 >>= 8;
index = index - cp0 - 1|0; // reset index back to what it was before
cp0 = 0xfffd;
}
// Finally, reset the variables for the next go-around
minBits = 0;
codePoint = 0;
nextEnd = index <= lenMinus32 ? 32 : len - index|0;
/*case 11:
case 10:
case 9:
case 8:
codePoint ? codePoint = 0 : cp0 = 0xfffd; // fill with invalid replacement character
case 7:
case 6:
case 5:
case 4:
case 3:
case 2:
case 1:
case 0:
tmpBufferU16[pos] = cp0;
continue;*/
default:
tmpBufferU16[pos] = cp0; // fill with invalid replacement character
continue;
case 11:
case 10:
case 9:
case 8:
}
tmpBufferU16[pos] = 0xfffd; // fill with invalid replacement character
}
tmpStr += fromCharCode(
tmpBufferU16[ 0], tmpBufferU16[ 1], tmpBufferU16[ 2], tmpBufferU16[ 3], tmpBufferU16[ 4], tmpBufferU16[ 5], tmpBufferU16[ 6], tmpBufferU16[ 7],
tmpBufferU16[ 8], tmpBufferU16[ 9], tmpBufferU16[10], tmpBufferU16[11], tmpBufferU16[12], tmpBufferU16[13], tmpBufferU16[14], tmpBufferU16[15],
tmpBufferU16[16], tmpBufferU16[17], tmpBufferU16[18], tmpBufferU16[19], tmpBufferU16[20], tmpBufferU16[21], tmpBufferU16[22], tmpBufferU16[23],
tmpBufferU16[24], tmpBufferU16[25], tmpBufferU16[26], tmpBufferU16[27], tmpBufferU16[28], tmpBufferU16[29], tmpBufferU16[30], tmpBufferU16[31]
);
if (pos < 32) tmpStr = tmpStr.slice(0, pos-32|0);//-(32-pos));
if (index < len) {
//fromCharCode.apply(0, tmpBufferU16 : NativeUint8Array ? tmpBufferU16.subarray(0,pos) : tmpBufferU16.slice(0,pos));
tmpBufferU16[0] = tmp;
pos = (~tmp) >>> 31;//tmp !== -1 ? 1 : 0;
tmp = -1;
if (tmpStr.length < resultingString.length) continue;
} else if (tmp !== -1) {
tmpStr += fromCharCode(tmp);
}
resultingString += tmpStr;
tmpStr = "";
}
return resultingString;
}
//////////////////////////////////////////////////////////////////////////////////////
function encoderReplacer(nonAsciiChars){
// make the UTF string into a binary UTF-8 encoded string
var point = nonAsciiChars.charCodeAt(0)|0;
if (0xD800 <= point) {
if (point <= 0xDBFF) {
var nextcode = nonAsciiChars.charCodeAt(1)|0; // defaults to 0 when NaN, causing null replacement character
if (0xDC00 <= nextcode && nextcode <= 0xDFFF) {
//point = ((point - 0xD800)<<10) + nextcode - 0xDC00 + 0x10000|0;
point = (point<<10) + nextcode - 0x35fdc00|0;
if (point > 0xffff)
return fromCharCode(
(0x1e/*0b11110*/<<3) | (point>>18),
(0x2/*0b10*/<<6) | ((point>>12)&0x3f/*0b00111111*/),
(0x2/*0b10*/<<6) | ((point>>6)&0x3f/*0b00111111*/),
(0x2/*0b10*/<<6) | (point&0x3f/*0b00111111*/)
);
} else point = 65533/*0b1111111111111101*/;//return '\xEF\xBF\xBD';//fromCharCode(0xef, 0xbf, 0xbd);
} else if (point <= 0xDFFF) {
point = 65533/*0b1111111111111101*/;//return '\xEF\xBF\xBD';//fromCharCode(0xef, 0xbf, 0xbd);
}
}
/*if (point <= 0x007f) return nonAsciiChars;
else */if (point <= 0x07ff) {
return fromCharCode((0x6<<5)|(point>>6), (0x2<<6)|(point&0x3f));
} else return fromCharCode(
(0xe/*0b1110*/<<4) | (point>>12),
(0x2/*0b10*/<<6) | ((point>>6)&0x3f/*0b00111111*/),
(0x2/*0b10*/<<6) | (point&0x3f/*0b00111111*/)
);
}
function TextEncoder(){};
TextEncoderPrototype["encode"] = function(inputString){
// 0xc0 => 0b11000000; 0xff => 0b11111111; 0xc0-0xff => 0b11xxxxxx
// 0x80 => 0b10000000; 0xbf => 0b10111111; 0x80-0xbf => 0b10xxxxxx
var encodedString = inputString === void 0 ? "" : ("" + inputString), len=encodedString.length|0;
var result=new patchedU8Array((len << 1) + 8|0), tmpResult;
var i=0, pos=0, point=0, nextcode=0;
var upgradededArraySize=!NativeUint8Array; // normal arrays are auto-expanding
for (i=0; i<len; i=i+1|0, pos=pos+1|0) {
point = encodedString.charCodeAt(i)|0;
if (point <= 0x007f) {
result[pos] = point;
} else if (point <= 0x07ff) {
result[pos] = (0x6<<5)|(point>>6);
result[pos=pos+1|0] = (0x2<<6)|(point&0x3f);
} else {
widenCheck: {
if (0xD800 <= point) {
if (point <= 0xDBFF) {
nextcode = encodedString.charCodeAt(i=i+1|0)|0; // defaults to 0 when NaN, causing null replacement character
if (0xDC00 <= nextcode && nextcode <= 0xDFFF) {
//point = ((point - 0xD800)<<10) + nextcode - 0xDC00 + 0x10000|0;
point = (point<<10) + nextcode - 0x35fdc00|0;
if (point > 0xffff) {
result[pos] = (0x1e/*0b11110*/<<3) | (point>>18);
result[pos=pos+1|0] = (0x2/*0b10*/<<6) | ((point>>12)&0x3f/*0b00111111*/);
result[pos=pos+1|0] = (0x2/*0b10*/<<6) | ((point>>6)&0x3f/*0b00111111*/);
result[pos=pos+1|0] = (0x2/*0b10*/<<6) | (point&0x3f/*0b00111111*/);
continue;
}
break widenCheck;
}
point = 65533/*0b1111111111111101*/;//return '\xEF\xBF\xBD';//fromCharCode(0xef, 0xbf, 0xbd);
} else if (point <= 0xDFFF) {
point = 65533/*0b1111111111111101*/;//return '\xEF\xBF\xBD';//fromCharCode(0xef, 0xbf, 0xbd);
}
}
if (!upgradededArraySize && (i << 1) < pos && (i << 1) < (pos - 7|0)) {
upgradededArraySize = true;
tmpResult = new patchedU8Array(len * 3);
tmpResult.set( result );
result = tmpResult;
}
}
result[pos] = (0xe/*0b1110*/<<4) | (point>>12);
result[pos=pos+1|0] =(0x2/*0b10*/<<6) | ((point>>6)&0x3f/*0b00111111*/);
result[pos=pos+1|0] =(0x2/*0b10*/<<6) | (point&0x3f/*0b00111111*/);
}
}
return NativeUint8Array ? result.subarray(0, pos) : result.slice(0, pos);
};
function polyfill_encodeInto(inputString, u8Arr) {
var encodedString = inputString === void 0 ? "" : ("" + inputString).replace(encoderRegexp, encoderReplacer);
var len=encodedString.length|0, i=0, char=0, read=0, u8ArrLen = u8Arr.length|0, inputLength=inputString.length|0;
if (u8ArrLen < len) len=u8ArrLen;
putChars: {
for (; i<len; i=i+1|0) {
char = encodedString.charCodeAt(i) |0;
switch(char >> 4) {
case 0:
case 1:
case 2:
case 3:
case 4:
case 5:
case 6:
case 7:
read = read + 1|0;
// extension points:
case 8:
case 9:
case 10:
case 11:
break;
case 12:
case 13:
if ((i+1|0) < u8ArrLen) {
read = read + 1|0;
break;
}
case 14:
if ((i+2|0) < u8ArrLen) {
//if (!(char === 0xEF && encodedString.substr(i+1|0,2) === "\xBF\xBD"))
read = read + 1|0;
break;
}
case 15:
if ((i+3|0) < u8ArrLen) {
read = read + 1|0;
break;
}
default:
break putChars;
}
//read = read + ((char >> 6) !== 2) |0;
u8Arr[i] = char;
}
}
return {"written": i, "read": inputLength < read ? inputLength : read};
// 0xc0 => 0b11000000; 0xff => 0b11111111; 0xc0-0xff => 0b11xxxxxx
// 0x80 => 0b10000000; 0xbf => 0b10111111; 0x80-0xbf => 0b10xxxxxx
/*var encodedString = typeof inputString == "string" ? inputString : inputString === void 0 ? "" : "" + inputString;
var encodedLen = encodedString.length|0, u8LenLeft=u8Arr.length|0;
var i=-1, read=-1, code=0, point=0, nextcode=0;
tryFast: if (2 < encodedLen && encodedLen < (u8LenLeft >> 1)) {
// Skip the normal checks because we can almost certainly fit the string inside the existing buffer
while (1) { // make the UTF string into a binary UTF-8 encoded string
point = encodedString.charCodeAt(read = read + 1|0)|0;
if (point <= 0x007f) {
if (point === 0 && encodedLen <= read) {
read = read - 1|0;
break; // we have reached the end of the string
}
u8Arr[i=i+1|0] = point;
} else if (point <= 0x07ff) {
u8Arr[i=i+1|0] = (0x6<<5)|(point>>6);
u8Arr[i=i+1|0] = (0x2<<6)|(point&0x3f);
} else {
if (0xD800 <= point && point <= 0xDBFF) {
nextcode = encodedString.charCodeAt(read)|0; // defaults to 0 when NaN, causing null replacement character
if (0xDC00 <= nextcode && nextcode <= 0xDFFF) {
read = read + 1|0;
//point = ((point - 0xD800)<<10) + nextcode - 0xDC00 + 0x10000|0;
point = (point<<10) + nextcode - 0x35fdc00|0;
if (point > 0xffff) {
u8Arr[i=i+1|0] = (0x1e<<3) | (point>>18);
u8Arr[i=i+1|0] = (0x2<<6) | ((point>>12)&0x3f);
u8Arr[i=i+1|0] = (0x2<<6) | ((point>>6)&0x3f);
u8Arr[i=i+1|0] = (0x2<<6) | (point&0x3f);
continue;
}
} else if (nextcode === 0 && encodedLen <= read) {
break; // we have reached the end of the string
} else {
point = 65533;//0b1111111111111101; // invalid replacement character
}
}
u8Arr[i=i+1|0] = (0xe<<4) | (point>>12);
u8Arr[i=i+1|0] = (0x2<<6) | ((point>>6)&0x3f);
u8Arr[i=i+1|0] = (0x2<<6) | (point&0x3f);
if (u8LenLeft < (i + ((encodedLen - read) << 1)|0)) {
// These 3x chars are the only way to inflate the size to 3x
u8LenLeft = u8LenLeft - i|0;
break tryFast;
}
}
}
u8LenLeft = 0; // skip the next for-loop
}
for (; 0 < u8LenLeft; ) { // make the UTF string into a binary UTF-8 encoded string
point = encodedString.charCodeAt(read = read + 1|0)|0;
if (point <= 0x007f) {
if (point === 0 && encodedLen <= read) {
read = read - 1|0;
break; // we have reached the end of the string
}
u8LenLeft = u8LenLeft - 1|0;
u8Arr[i=i+1|0] = point;
} else if (point <= 0x07ff) {
u8LenLeft = u8LenLeft - 2|0;
if (0 <= u8LenLeft) {
u8Arr[i=i+1|0] = (0x6<<5)|(point>>6);
u8Arr[i=i+1|0] = (0x2<<6)|(point&0x3f);
}
} else {
if (0xD800 <= point && point <= 0xDBFF) {
nextcode = encodedString.charCodeAt(read = read + 1|0)|0; // defaults to 0 when NaN, causing null replacement character
if (0xDC00 <= nextcode) {
if (nextcode <= 0xDFFF) {
read = read + 1|0;
//point = ((point - 0xD800)<<10) + nextcode - 0xDC00 + 0x10000|0;
point = (point<<10) + nextcode - 0x35fdc00|0;
if (point > 0xffff) {
u8LenLeft = u8LenLeft - 4|0;
if (0 <= u8LenLeft) {
u8Arr[i=i+1|0] = (0x1e<<3) | (point>>18);
u8Arr[i=i+1|0] = (0x2<<6) | ((point>>12)&0x3f);
u8Arr[i=i+1|0] = (0x2<<6) | ((point>>6)&0x3f);
u8Arr[i=i+1|0] = (0x2<<6) | (point&0x3f);
}
continue;
}
} else if (point <= 0xDFFF) {
point = 65533/*0b1111111111111101*\/;//return '\xEF\xBF\xBD';//fromCharCode(0xef, 0xbf, 0xbd);
}
} else if (nextcode === 0 && encodedLen <= read) {
break; // we have reached the end of the string
} else {
point = 65533;//0b1111111111111101; // invalid replacement character
}
}
u8LenLeft = u8LenLeft - 3|0;
if (0 <= u8LenLeft) {
u8Arr[i=i+1|0] = (0xe<<<4) | (point>>12);
u8Arr[i=i+1|0] = (0x2<<6) | ((point>>6)&0x3f);
u8Arr[i=i+1|0] = (0x2<<6) | (point&0x3f);
}
}
}
return {"read": read < 0 ? 0 : u8LenLeft < 0 ? read : read+1|0, "written": i < 0 ? 0 : i+1|0};*/
};
if (ENCODEINTO_BUILD) {
TextEncoderPrototype["encodeInto"] = polyfill_encodeInto;
}
if (!GlobalTextEncoder) {
window["TextDecoder"] = TextDecoder;
window["TextEncoder"] = TextEncoder;
} else if (ENCODEINTO_BUILD && !(globalTextEncoderPrototype = GlobalTextEncoder["prototype"])["encodeInto"]) {
globalTextEncoderInstance = new GlobalTextEncoder;
globalTextEncoderPrototype["encodeInto"] = function(string, u8arr) {
// Unfortunately, there's no way I can think of to quickly extract the number of bits written and the number of bytes read and such
var strLen = string.length|0, u8Len = u8arr.length|0;
if (strLen < (u8Len >> 1)) { // in most circumstances, this means its safe. there are still edge-cases which are possible
// in many circumstances, we can use the faster native TextEncoder
var res8 = globalTextEncoderInstance["encode"](string);
var res8Len = res8.length|0;
if (res8Len < u8Len) { // if we dont have to worry about read/written
u8arr.set( res8 ); // every browser that supports TextEncoder also supports typedarray.prototype.set
return {
"read": strLen,
"written": res8.length|0
};
}
}
return polyfill_encodeInto(string, u8arr);
};
}
})(typeof global == "" + void 0 ? typeof self == "" + void 0 ? this : self : global);
================================================
FILE: LICENSE
================================================
Creative Commons Legal Code
CC0 1.0 Universal
CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE
LEGAL SERVICES. DISTRIBUTION OF THIS DOCUMENT DOES NOT CREATE AN
ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS
INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES
REGARDING THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS
PROVIDED HEREUNDER, AND DISCLAIMS LIABILITY FOR DAMAGES RESULTING FROM
THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS PROVIDED
HEREUNDER.
Statement of Purpose
The laws of most jurisdictions throughout the world automatically confer
exclusive Copyright and Related Rights (defined below) upon the creator
and subsequent owner(s) (each and all, an "owner") of an original work of
authorship and/or a database (each, a "Work").
Certain owners wish to permanently relinquish those rights to a Work for
the purpose of contributing to a commons of creative, cultural and
scientific works ("Commons") that the public can reliably and without fear
of later claims of infringement build upon, modify, incorporate in other
works, reuse and redistribute as freely as possible in any form whatsoever
and for any purposes, including without limitation commercial purposes.
These owners may contribute to the Commons to promote the ideal of a free
culture and the further production of creative, cultural and scientific
works, or to gain reputation or greater distribution for their Work in
part through the use and efforts of others.
For these and/or other purposes and motivations, and without any
expectation of additional consideration or compensation, the person
associating CC0 with a Work (the "Affirmer"), to the extent that he or she
is an owner of Copyright and Related Rights in the Work, voluntarily
elects to apply CC0 to the Work and publicly distribute the Work under its
terms, with knowledge of his or her Copyright and Related Rights in the
Work and the meaning and intended legal effect of CC0 on those rights.
1. Copyright and Related Rights. A Work made available under CC0 may be
protected by copyright and related or neighboring rights ("Copyright and
Related Rights"). Copyright and Related Rights include, but are not
limited to, the following:
i. the right to reproduce, adapt, distribute, perform, display,
communicate, and translate a Work;
ii. moral rights retained by the original author(s) and/or performer(s);
iii. publicity and privacy rights pertaining to a person's image or
likeness depicted in a Work;
iv. rights protecting against unfair competition in regards to a Work,
subject to the limitations in paragraph 4(a), below;
v. rights protecting the extraction, dissemination, use and reuse of data
in a Work;
vi. database rights (such as those arising under Directive 96/9/EC of the
European Parliament and of the Council of 11 March 1996 on the legal
protection of databases, and under any national implementation
thereof, including any amended or successor version of such
directive); and
vii. other similar, equivalent or corresponding rights throughout the
world based on applicable law or treaty, and any national
implementations thereof.
2. Waiver. To the greatest extent permitted by, but not in contravention
of, applicable law, Affirmer hereby overtly, fully, permanently,
irrevocably and unconditionally waives, abandons, and surrenders all of
Affirmer's Copyright and Related Rights and associated claims and causes
of action, whether now known or unknown (including existing as well as
future claims and causes of action), in the Work (i) in all territories
worldwide, (ii) for the maximum duration provided by applicable law or
treaty (including future time extensions), (iii) in any current or future
medium and for any number of copies, and (iv) for any purpose whatsoever,
including without limitation commercial, advertising or promotional
purposes (the "Waiver"). Affirmer makes the Waiver for the benefit of each
member of the public at large and to the detriment of Affirmer's heirs and
successors, fully intending that such Waiver shall not be subject to
revocation, rescission, cancellation, termination, or any other legal or
equitable action to disrupt the quiet enjoyment of the Work by the public
as contemplated by Affirmer's express Statement of Purpose.
3. Public License Fallback. Should any part of the Waiver for any reason
be judged legally invalid or ineffective under applicable law, then the
Waiver shall be preserved to the maximum extent permitted taking into
account Affirmer's express Statement of Purpose. In addition, to the
extent the Waiver is so judged Affirmer hereby grants to each affected
person a royalty-free, non transferable, non sublicensable, non exclusive,
irrevocable and unconditional license to exercise Affirmer's Copyright and
Related Rights in the Work (i) in all territories worldwide, (ii) for the
maximum duration provided by applicable law or treaty (including future
time extensions), (iii) in any current or future medium and for any number
of copies, and (iv) for any purpose whatsoever, including without
limitation commercial, advertising or promotional purposes (the
"License"). The License shall be deemed effective as of the date CC0 was
applied by Affirmer to the Work. Should any part of the License for any
reason be judged legally invalid or ineffective under applicable law, such
partial invalidity or ineffectiveness shall not invalidate the remainder
of the License, and in such case Affirmer hereby affirms that he or she
will not (i) exercise any of his or her remaining Copyright and Related
Rights in the Work or (ii) assert any associated claims and causes of
action with respect to the Work, in either case contrary to Affirmer's
express Statement of Purpose.
4. Limitations and Disclaimers.
a. No trademark or patent rights held by Affirmer are waived, abandoned,
surrendered, licensed or otherwise affected by this document.
b. Affirmer offers the Work as-is and makes no representations or
warranties of any kind concerning the Work, express, implied,
statutory or otherwise, including without limitation warranties of
title, merchantability, fitness for a particular purpose, non
infringement, or the absence of latent or other defects, accuracy, or
the present or absence of errors, whether or not discoverable, all to
the greatest extent permissible under applicable law.
c. Affirmer disclaims responsibility for clearing rights of other persons
that may apply to the Work or any use thereof, including without
limitation any person's Copyright and Related Rights in the Work.
Further, Affirmer disclaims responsibility for obtaining any necessary
consents, permissions or other rights required for any use of the
Work.
d. Affirmer understands and acknowledges that Creative Commons is not a
party to this document and has no duty or obligation with respect to
this CC0 or use of the Work.
================================================
FILE: NodeJS/EncoderAndDecoderNodeJS.min.mjs
================================================
'use strict';var a="undefined"==typeof global?"undefined"===typeof self?{}:self:global,p=String.fromCharCode,q={}.toString,r=a.SharedArrayBuffer,v=r?q.call(r):"",w=a.Uint8Array,x=w?q.call(ArrayBuffer.prototype):"",y=a.Buffer;try{!y&&a.require&&(y=a.require("Buffer"));var z=y.prototype,A=q.call(z)}catch(g){}var B=y.allocUnsafe,C=!!w&&!y,D=new Uint16Array(32),E=!y||!!w&&w.prototype.isPrototypeOf(z),G=F.prototype;function H(){}
function I(g){var h=g&&g.buffer||g,c=q.call(h);if(c!==x&&c!==A&&c!==v&&"[object ArrayBuffer]"!==c&&void 0!==g)throw TypeError("Failed to execute 'decode' on 'TextDecoder': The provided value is not of type '(ArrayBuffer or ArrayBufferView)'");g=E?new w(h):h||[];c=h="";for(var b=0,d=g.length|0,u=d-32|0,f,e,k=0,t=0,m,l=0,n=-1;b<d;){for(f=b<=u?32:d-b|0;l<f;b=b+1|0,l=l+1|0){e=g[b]&255;switch(e>>4){case 15:m=g[b=b+1|0]&255;if(2!==m>>6||247<e){b=b-1|0;break}k=(e&7)<<6|m&63;t=5;e=256;case 14:m=g[b=b+1|0]&
255,k<<=6,k|=(e&15)<<6|m&63,t=2===m>>6?t+4|0:24,e=e+256&768;case 13:case 12:m=g[b=b+1|0]&255,k<<=6,k|=(e&31)<<6|m&63,t=t+7|0,b<d&&2===m>>6&&k>>t&&1114112>k?(e=k,k=k-65536|0,0<=k&&(n=(k>>10)+55296|0,e=(k&1023)+56320|0,31>l?(D[l]=n,l=l+1|0,n=-1):(m=n,n=e,e=m))):(e>>=8,b=b-e-1|0,e=65533),k=t=0,f=b<=u?32:d-b|0;default:D[l]=e;continue;case 11:case 10:case 9:case 8:}D[l]=65533}c+=p(D[0],D[1],D[2],D[3],D[4],D[5],D[6],D[7],D[8],D[9],D[10],D[11],D[12],D[13],D[14],D[15],D[16],D[17],D[18],D[19],D[20],D[21],
D[22],D[23],D[24],D[25],D[26],D[27],D[28],D[29],D[30],D[31]);32>l&&(c=c.slice(0,l-32|0));if(b<d){if(D[0]=n,l=~n>>>31,n=-1,c.length<h.length)continue}else-1!==n&&(c+=p(n));h+=c;c=""}return h}H.prototype.decode=I;function F(){}
function J(g){g=void 0===g?"":""+g;var h=g.length|0,c=C?new w((h<<1)+8|0):B?B((h<<1)+8|0):new y((h<<1)+8|0),b,d=0,u=!1;for(b=0;b<h;b=b+1|0,d=d+1|0){var f=g.charCodeAt(b)|0;if(127>=f)c[d]=f;else{if(2047>=f)c[d]=192|f>>6;else{a:{if(55296<=f)if(56320>f){var e=g.charCodeAt(b=b+1|0)|0;if(56320<=e&&57343>=e){f=(f<<10)+e-56613888|0;if(65535<f){c[d]=240|f>>18;c[d=d+1|0]=128|f>>12&63;c[d=d+1|0]=128|f>>6&63;c[d=d+1|0]=128|f&63;continue}break a}f=65533}else 57343>=f&&(f=65533);!u&&b<<1<d&&b<<1<(d-7|0)&&(u=!0,
e=C?new w(3*h):B?B(3*h):new y(3*h),e.set(c),c=e)}c[d]=224|f>>12;c[d=d+1|0]=128|f>>6&63}c[d=d+1|0]=128|f&63}}return c.subarray(0,d)}G.encode=J;function K(g,h){var c=g[h];return function(){return c.apply(g,arguments)}}var L=a.TextDecoder,M=a.TextEncoder;var TextDecoder=L||H,TextEncoder=M||F,decode=L?K(new L,"decode"):I,encode=M?K(new M,"encode"):J;export{TextDecoder,TextEncoder,decode,encode};//AnonyCo
//# sourceMappingURL=https://cdn.jsdelivr.net/gh/AnonyCo/FastestSmallestTextEncoderDecoder/NodeJS/EncoderAndDecoderNodeJS.min.mjs.map
================================================
FILE: NodeJS/EncoderAndDecoderNodeJS.min.module.js
================================================
'use strict';var e="undefined"==typeof global?"undefined"===typeof self?{}:self:global,f=Math.log,g=Math.LN2,h=Math.clz32||function(b){return 31-f(b>>>0)/g|0},k=String.fromCharCode,l={}.toString,n=e.SharedArrayBuffer,p=n?l.call(n):"",q=e.Uint8Array,r=q?l.call(ArrayBuffer.prototype):"",t=e.Buffer;try{!t&&e.require&&(t=e.require("Buffer"));var u=t.prototype,v=l.call(u)}catch(b){}var x=!!q&&!t,y=!t||!!q&&q.prototype.isPrototypeOf(u),A=z.prototype;
function B(b){var a=b.charCodeAt(0)<<24,c=h(~a)|0,d=0,w=b.length|0,m="";if(5>c&&w>=c){a=a<<c>>>24+c;for(d=1;d<c;d=d+1|0)a<<=6,a|=b.charCodeAt(d)&63;65535>=a?m=k(a):1114111>=a?(a=a-65536|0,m=k((a>>10)+55296|0,(a&1023)+56320|0)):d=0}for(;d<w;d=d+1|0)m+="\ufffd";return m}function C(){}
function D(b){var a=b&&b.buffer||b,c=l.call(a);if(c!==r&&c!==v&&c!==p&&"[object ArrayBuffer]"!==c&&void 0!==b)throw TypeError("Failed to execute 'decode' on 'TextDecoder': The provided value is not of type '(ArrayBuffer or ArrayBufferView)'");b=y?new q(a):a||[];a="";c=0;for(var d=b.length|0;c<d;c=c+32768|0)a+=k.apply(0,b[y?"subarray":"slice"](c,c+32768|0));return a.replace(/[\xc0-\xff][\x80-\xbf]*/g,B)}C.prototype.decode=D;
function E(b){var a=b.charCodeAt(0)|0;if(55296<=a&&56319>=a)if(b=b.charCodeAt(1)|0,56320<=b&&57343>=b){if(a=(a<<10)+b-56613888|0,65535<a)return k(240|a>>>18,128|a>>>12&63,128|a>>>6&63,128|a&63)}else return"\u00ef\u00bf\u00bd";return 2047>=a?k(192|a>>>6,128|a&63):k(224|a>>>12,128|a>>>6&63,128|a&63)}function z(){}
function F(b){b=void 0===b?"":(""+b).replace(/[\x80-\uD7ff\uDC00-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]?/g,E);for(var a=b.length|0,c=x?new q(a):t.allocUnsafe?t.allocUnsafe(a):new t(a),d=0;d<a;d=d+1|0)c[d]=b.charCodeAt(d)|0;return c}A.encode=F;function G(b,a){var c=b[a];return function(){return c.apply(b,arguments)}}var H=e.TextDecoder||C,I=e.TextEncoder;I=I||z;D=H?G(new H,"decode"):D;F=I?G(new I,"encode"):F;
var TextDecoder=H,TextEncoder=I,decode=D,encode=F;export{TextDecoder,TextEncoder,decode,encode,encodeInto};//AnonyCo
//# sourceMappingURL=https://cdn.jsdelivr.net/gh/AnonyCo/fastestsmallesttextencoderdecoder/NodeJS/EncoderAndDecoderNodeJS.min.module.js.map
================================================
FILE: NodeJS/EncoderAndDecoderNodeJS.src.js
================================================
/** @define {boolean} */
var ENCODEINTO_BUILD = false;
(function(global){
"use strict";
// In this NodeJS version, Buffers are supported and used as fallback in versions that do not support Typed Arrays
var log = Math.log;
var LN2 = Math.LN2;
var clz32 = Math.clz32 || function(x) {return 31 - log(x >> 0) / LN2 | 0};
var fromCharCode = String["fromCharCode"];
var Object_prototype_toString = ({})["toString"];
var NativeSharedArrayBuffer = global["SharedArrayBuffer"];
var sharedArrayBufferString = NativeSharedArrayBuffer ? Object_prototype_toString.call(NativeSharedArrayBuffer) : "";
var NativeUint8Array = global["Uint8Array"];
var arrayBufferPrototypeString = NativeUint8Array ? Object_prototype_toString.call(ArrayBuffer.prototype) : "";
var NativeBuffer = global["Buffer"];
var TextEncoderPrototype, NativeBufferPrototype, globalBufferPrototypeString;
var encodeRegExp = /[\x80-\uD7ff\uDC00-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]?/g;
var tmpBufferU16 = new Uint16Array(32);
try {
if (!NativeBuffer && global["require"]) NativeBuffer=global["require"]("Buffer");
NativeBufferPrototype = NativeBuffer.prototype;
globalBufferPrototypeString = NativeBuffer ? Object_prototype_toString.call(NativeBufferPrototype) : "";
} catch(e){}
var NativeBuffer_allocUnsafe = NativeBuffer["allocUnsafe"];
var usingTypedArrays = !!NativeUint8Array && !NativeBuffer;
// NativeBufferHasArrayBuffer is true if there is no global.Buffer or if native global.Buffer instances have a Buffer property for the internal ArrayBuffer
var NativeBufferHasArrayBuffer = !NativeBuffer || (!!NativeUint8Array && NativeUint8Array.prototype.isPrototypeOf(NativeBufferPrototype));
var GlobalTextEncoder = global["TextEncoder"], GlobalTextDecoder = global["TextDecoder"];
var globalTextEncoderInstance, globalTextEncoderEncodeInto;
if (usingTypedArrays || NativeBuffer) {
/** @constructor */
function TextDecoder(){}
function decode(inputArrayOrBuffer){
var buffer = (inputArrayOrBuffer && inputArrayOrBuffer.buffer) || inputArrayOrBuffer;
var asString = Object_prototype_toString.call(buffer);
if (asString !== arrayBufferPrototypeString && asString !== globalBufferPrototypeString && asString !== sharedArrayBufferString && asString !== "[object ArrayBuffer]" && inputArrayOrBuffer !== undefined)
throw TypeError("Failed to execute 'decode' on 'TextDecoder': The provided value is not of type '(ArrayBuffer or ArrayBufferView)'");
var inputAs8 = NativeBufferHasArrayBuffer ? new NativeUint8Array(buffer) : buffer || [];
var resultingString="", tmpStr="", index=0, len=inputAs8.length|0, lenMinus32=len-32|0, nextEnd=0, nextStop=0, cp0=0, codePoint=0, minBits=0, cp1=0, pos=0, tmp=-1;
// Note that tmp represents the 2nd half of a surrogate pair incase a surrogate gets divided between blocks
for (; index < len; ) {
nextEnd = index <= lenMinus32 ? 32 : len - index|0;
for (; pos < nextEnd; index=index+1|0, pos=pos+1|0) {
cp0 = inputAs8[index] & 0xff;
switch(cp0 >> 4) {
case 15:
cp1 = inputAs8[index=index+1|0] & 0xff;
if ((cp1 >> 6) !== 0b10 || 0b11110111 < cp0) {
index = index - 1|0;
break;
}
codePoint = ((cp0 & 0b111) << 6) | (cp1 & 0b00111111);
minBits = 5; // 20 ensures it never passes -> all invalid replacements
cp0 = 0x100; // keep track of th bit size
case 14:
cp1 = inputAs8[index=index+1|0] & 0xff;
codePoint <<= 6;
codePoint |= ((cp0 & 0b1111) << 6) | (cp1 & 0b00111111);
minBits = (cp1 >> 6) === 0b10 ? minBits + 4|0 : 24; // 24 ensures it never passes -> all invalid replacements
cp0 = (cp0 + 0x100) & 0x300; // keep track of th bit size
case 13:
case 12:
cp1 = inputAs8[index=index+1|0] & 0xff;
codePoint <<= 6;
codePoint |= ((cp0 & 0b11111) << 6) | cp1 & 0b00111111;
minBits = minBits + 7|0;
// Now, process the code point
if (index < len && (cp1 >> 6) === 0b10 && (codePoint >> minBits) && codePoint < 0x110000) {
cp0 = codePoint;
codePoint = codePoint - 0x10000|0;
if (0 <= codePoint/*0xffff < codePoint*/) { // BMP code point
//nextEnd = nextEnd - 1|0;
tmp = (codePoint >> 10) + 0xD800|0; // highSurrogate
cp0 = (codePoint & 0x3ff) + 0xDC00|0; // lowSurrogate (will be inserted later in the switch-statement)
if (pos < 31) { // notice 31 instead of 32
tmpBufferU16[pos] = tmp;
pos = pos + 1|0;
tmp = -1;
} else {// else, we are at the end of the inputAs8 and let tmp0 be filled in later on
// NOTE that cp1 is being used as a temporary variable for the swapping of tmp with cp0
cp1 = tmp;
tmp = cp0;
cp0 = cp1;
}
} else nextEnd = nextEnd + 1|0; // because we are advancing i without advancing pos
} else {
// invalid code point means replacing the whole thing with null replacement characters
cp0 >>= 8;
index = index - cp0 - 1|0; // reset index back to what it was before
cp0 = 0xfffd;
}
// Finally, reset the variables for the next go-around
minBits = 0;
codePoint = 0;
nextEnd = index <= lenMinus32 ? 32 : len - index|0;
default:
tmpBufferU16[pos] = cp0; // fill with invalid replacement character
continue;
case 11:
case 10:
case 9:
case 8:
}
tmpBufferU16[pos] = 0xfffd; // fill with invalid replacement character
}
tmpStr += fromCharCode(
tmpBufferU16[ 0], tmpBufferU16[ 1], tmpBufferU16[ 2], tmpBufferU16[ 3], tmpBufferU16[ 4], tmpBufferU16[ 5], tmpBufferU16[ 6], tmpBufferU16[ 7],
tmpBufferU16[ 8], tmpBufferU16[ 9], tmpBufferU16[10], tmpBufferU16[11], tmpBufferU16[12], tmpBufferU16[13], tmpBufferU16[14], tmpBufferU16[15],
tmpBufferU16[16], tmpBufferU16[17], tmpBufferU16[18], tmpBufferU16[19], tmpBufferU16[20], tmpBufferU16[21], tmpBufferU16[22], tmpBufferU16[23],
tmpBufferU16[24], tmpBufferU16[25], tmpBufferU16[26], tmpBufferU16[27], tmpBufferU16[28], tmpBufferU16[29], tmpBufferU16[30], tmpBufferU16[31]
);
if (pos < 32) tmpStr = tmpStr.slice(0, pos-32|0);//-(32-pos));
if (index < len) {
//fromCharCode.apply(0, tmpBufferU16 : NativeUint8Array ? tmpBufferU16.subarray(0,pos) : tmpBufferU16.slice(0,pos));
tmpBufferU16[0] = tmp;
pos = (~tmp) >>> 31;//tmp !== -1 ? 1 : 0;
tmp = -1;
if (tmpStr.length < resultingString.length) continue;
} else if (tmp !== -1) {
tmpStr += fromCharCode(tmp);
}
resultingString += tmpStr;
tmpStr = "";
}
return resultingString;
}
TextDecoder.prototype["decode"] = decode;
//////////////////////////////////////////////////////////////////////////////////////
function encoderReplacer(nonAsciiChars){
// make the UTF string into a binary UTF-8 encoded string
var point = nonAsciiChars.charCodeAt(0)|0;
if (0xD800 <= point) {
if (point <= 0xDBFF) {
var nextcode = nonAsciiChars.charCodeAt(1)|0; // defaults to 0 when NaN, causing null replacement character
if (0xDC00 <= nextcode && nextcode <= 0xDFFF) {
//point = ((point - 0xD800)<<10) + nextcode - 0xDC00 + 0x10000|0;
point = (point<<10) + nextcode - 0x35fdc00|0;
if (point > 0xffff)
return fromCharCode(
(0x1e/*0b11110*/<<3) | (point>>18),
(0x2/*0b10*/<<6) | ((point>>12)&0x3f/*0b00111111*/),
(0x2/*0b10*/<<6) | ((point>>6)&0x3f/*0b00111111*/),
(0x2/*0b10*/<<6) | (point&0x3f/*0b00111111*/)
);
} else point = 65533/*0b1111111111111101*/;//return '\xEF\xBF\xBD';//fromCharCode(0xef, 0xbf, 0xbd);
} else if (point <= 0xDFFF) {
point = 65533/*0b1111111111111101*/;//return '\xEF\xBF\xBD';//fromCharCode(0xef, 0xbf, 0xbd);
}
}
/*if (point <= 0x007f) return nonAsciiChars;
else */if (point <= 0x07ff) {
return fromCharCode((0x6<<5)|(point>>6), (0x2<<6)|(point&0x3f));
} else return fromCharCode(
(0xe/*0b1110*/<<4) | (point>>12),
(0x2/*0b10*/<<6) | ((point>>6)&0x3f/*0b00111111*/),
(0x2/*0b10*/<<6) | (point&0x3f/*0b00111111*/)
);
}
/** @constructor */
function TextEncoder(){}
function encode(inputString){
// 0xc0 => 0b11000000; 0xff => 0b11111111; 0xc0-0xff => 0b11xxxxxx
// 0x80 => 0b10000000; 0xbf => 0b10111111; 0x80-0xbf => 0b10xxxxxx
var encodedString = inputString === void 0 ? "" : ("" + inputString);//.replace(encodeRegExp, encoderReplacer);
var len=encodedString.length|0, result = usingTypedArrays ? new NativeUint8Array((len << 1) + 8|0) : NativeBuffer_allocUnsafe ? NativeBuffer_allocUnsafe((len << 1) + 8|0) : new NativeBuffer((len << 1) + 8|0);
var tmpResult;
var i=0, pos=0, point=0, nextcode=0;
var upgradededArraySize=false; // normal arrays are auto-expanding
for (i=0; i<len; i=i+1|0, pos=pos+1|0) {
point = encodedString.charCodeAt(i)|0;
if (point <= 0x007f) {
result[pos] = point;
} else if (point <= 0x07ff) {
result[pos] = (0x6<<5)|(point>>6);
result[pos=pos+1|0] = (0x2<<6)|(point&0x3f);
} else {
widenCheck: {
if (0xD800 <= point) {
if (point < 0xDC00) {
nextcode = encodedString.charCodeAt(i=i+1|0)|0; // defaults to 0 when NaN, causing null replacement character
if (0xDC00 <= nextcode && nextcode <= 0xDFFF) {
//point = ((point - 0xD800)<<10) + nextcode - 0xDC00 + 0x10000|0;
point = (point<<10) + nextcode - 0x35fdc00|0;
if (point > 0xffff) {
result[pos] = (0x1e/*0b11110*/<<3) | (point>>18);
result[pos=pos+1|0] = (0x2/*0b10*/<<6) | ((point>>12)&0x3f/*0b00111111*/);
result[pos=pos+1|0] = (0x2/*0b10*/<<6) | ((point>>6)&0x3f/*0b00111111*/);
result[pos=pos+1|0] = (0x2/*0b10*/<<6) | (point&0x3f/*0b00111111*/);
continue;
}
break widenCheck;
}
point = 65533/*0b1111111111111101*/;//return '\xEF\xBF\xBD';//fromCharCode(0xef, 0xbf, 0xbd);
} else if (point <= 0xDFFF) {
point = 65533/*0b1111111111111101*/;//return '\xEF\xBF\xBD';//fromCharCode(0xef, 0xbf, 0xbd);
}
}
if (!upgradededArraySize && (i << 1) < pos && (i << 1) < (pos - 7|0)) {
upgradededArraySize = true;
tmpResult = usingTypedArrays ? new NativeUint8Array(len * 3) : NativeBuffer_allocUnsafe ? NativeBuffer_allocUnsafe(len * 3) : new NativeBuffer(len * 3);
tmpResult.set( result );
result = tmpResult;
}
}
result[pos] = (0xe/*0b1110*/<<4) | (point>>12);
result[pos=pos+1|0] =(0x2/*0b10*/<<6) | ((point>>6)&0x3f/*0b00111111*/);
result[pos=pos+1|0] =(0x2/*0b10*/<<6) | (point&0x3f/*0b00111111*/);
}
}
return result.subarray(0, pos);
}
function polyfill_encodeInto(inputString, u8Arr) {
var encodedString = inputString === void 0 ? "" : ("" + inputString).replace(encodeRegExp, encoderReplacer);
var len=encodedString.length|0, i=0, char=0, read=0, u8ArrLen = u8Arr.length|0, inputLength=inputString.length|0;
if (u8ArrLen < len) len=u8ArrLen;
putChars: {
for (; i<len; i=i+1|0) {
char = encodedString.charCodeAt(i) |0;
switch(char >> 4) {
case 0:
case 1:
case 2:
case 3:
case 4:
case 5:
case 6:
case 7:
read = read + 1|0;
// extension points:
case 8:
case 9:
case 10:
case 11:
break;
case 12:
case 13:
if ((i+1|0) < u8ArrLen) {
read = read + 1|0;
break;
}
case 14:
if ((i+2|0) < u8ArrLen) {
read = read + 1|0;
break;
}
case 15:
if ((i+3|0) < u8ArrLen) {
read = read + 1|0;
break;
}
default:
break putChars;
}
//read = read + ((char >> 6) !== 2) |0;
u8Arr[i] = char;
}
}
return {"written": i, "read": inputLength < read ? inputLength : read};
// 0xc0 => 0b11000000; 0xff => 0b11111111; 0xc0-0xff => 0b11xxxxxx
// 0x80 => 0b10000000; 0xbf => 0b10111111; 0x80-0xbf => 0b10xxxxxx
/*var encodedString = typeof inputString == "string" ? inputString : inputString === void 0 ? "" : "" + inputString;
var encodedLen = encodedString.length|0, u8LenLeft=u8Arr.length|0;
var i=-1, read=-1, code=0, point=0, nextcode=0;
tryFast: if (2 < encodedLen && encodedLen < (u8LenLeft >> 1)) {
// Skip the normal checks because we can almost certainly fit the string inside the existing buffer
while (1) { // make the UTF string into a binary UTF-8 encoded string
point = encodedString.charCodeAt(read = read + 1|0)|0;
if (point <= 0x007f) {
if (point === 0 && encodedLen <= read) {
read = read - 1|0;
break; // we have reached the end of the string
}
u8Arr[i=i+1|0] = point;
} else if (point <= 0x07ff) {
u8Arr[i=i+1|0] = (0x6<<5)|(point>>6);
u8Arr[i=i+1|0] = (0x2<<6)|(point&0x3f);
} else {
if (0xD800 <= point && point <= 0xDBFF) {
nextcode = encodedString.charCodeAt(read)|0; // defaults to 0 when NaN, causing null replacement character
if (0xDC00 <= nextcode && nextcode <= 0xDFFF) {
read = read + 1|0;
//point = ((point - 0xD800)<<10) + nextcode - 0xDC00 + 0x10000|0;
point = (point<<10) + nextcode - 0x35fdc00|0;
if (point > 0xffff) {
u8Arr[i=i+1|0] = (0x1e<<3) | (point>>18);
u8Arr[i=i+1|0] = (0x2<<6) | ((point>>12)&0x3f);
u8Arr[i=i+1|0] = (0x2<<6) | ((point>>6)&0x3f);
u8Arr[i=i+1|0] = (0x2<<6) | (point&0x3f);
continue;
}
} else if (nextcode === 0 && encodedLen <= read) {
break; // we have reached the end of the string
} else {
point = 65533;//0b1111111111111101; // invalid replacement character
}
}
u8Arr[i=i+1|0] = (0xe<<4) | (point>>12);
u8Arr[i=i+1|0] = (0x2<<6) | ((point>>6)&0x3f);
u8Arr[i=i+1|0] = (0x2<<6) | (point&0x3f);
if (u8LenLeft < (i + ((encodedLen - read) << 1)|0)) {
// These 3x chars are the only way to inflate the size to 3x
u8LenLeft = u8LenLeft - i|0;
break tryFast;
}
}
}
u8LenLeft = 0; // skip the next for-loop
}
for (; 0 < u8LenLeft; ) { // make the UTF string into a binary UTF-8 encoded string
point = encodedString.charCodeAt(read = read + 1|0)|0;
if (point <= 0x007f) {
if (point === 0 && encodedLen <= read) {
read = read - 1|0;
break; // we have reached the end of the string
}
u8LenLeft = u8LenLeft - 1|0;
u8Arr[i=i+1|0] = point;
} else if (point <= 0x07ff) {
u8LenLeft = u8LenLeft - 2|0;
if (0 <= u8LenLeft) {
u8Arr[i=i+1|0] = (0x6<<5)|(point>>6);
u8Arr[i=i+1|0] = (0x2<<6)|(point&0x3f);
}
} else {
if (0xD800 <= point && point <= 0xDBFF) {
if (nextcode <= 0xDFFF) {
nextcode = encodedString.charCodeAt(read = read + 1|0)|0; // defaults to 0 when NaN, causing null replacement character
if (0xDC00 <= nextcode) {
read = read + 1|0;
//point = ((point - 0xD800)<<10) + nextcode - 0xDC00 + 0x10000|0;
point = (point<<10) + nextcode - 0x35fdc00|0;
if (point > 0xffff) {
u8LenLeft = u8LenLeft - 4|0;
if (0 <= u8LenLeft) {
u8Arr[i=i+1|0] = (0x1e<<3) | (point>>18);
u8Arr[i=i+1|0] = (0x2<<6) | ((point>>12)&0x3f);
u8Arr[i=i+1|0] = (0x2<<6) | ((point>>6)&0x3f);
u8Arr[i=i+1|0] = (0x2<<6) | (point&0x3f);
}
continue;
}
} else if (nextcode === 0 && encodedLen <= read) {
break; // we have reached the end of the string
} else {
point = 65533;//0b1111111111111101; // invalid replacement character
}
} else if (point <= 0xDFFF) {
point = 65533/*0b1111111111111101*\/;//return '\xEF\xBF\xBD';//fromCharCode(0xef, 0xbf, 0xbd);
}
}
u8LenLeft = u8LenLeft - 3|0;
if (0 <= u8LenLeft) {
u8Arr[i=i+1|0] = (0xe<<<4) | (point>>12);
u8Arr[i=i+1|0] = (0x2<<6) | ((point>>6)&0x3f);
u8Arr[i=i+1|0] = (0x2<<6) | (point&0x3f);
}
}
}
return {"read": read < 0 ? 0 : u8LenLeft < 0 ? read : read+1|0, "written": i < 0 ? 0 : i+1|0};*/
}
TextEncoderPrototype = TextEncoder["prototype"];
TextEncoderPrototype["encode"] = encode;
if (ENCODEINTO_BUILD) {
TextEncoderPrototype["encodeInto"] = polyfill_encodeInto;
}
/** bindMethod
* A useful way to bind a method on an instance
* @param {!Object} inst
* @param {!string} name
* @param {!Function=} _
*/
function bindMethod(inst, name, _) {
_ = inst[name];
return function() {
return _.apply(inst, arguments);
};
}
if (ENCODEINTO_BUILD) {
globalTextEncoderEncodeInto = polyfill_encodeInto;
if (GlobalTextEncoder) {
globalTextEncoderInstance = new GlobalTextEncoder;
globalTextEncoderEncodeInto = (
globalTextEncoderInstance["encodeInto"] ?
bindMethod(globalTextEncoderInstance, "encode") :
GlobalTextEncoder["prototype"]["encodeInto"] = function(string, u8arr) {
// Unfortunately, there's no way I can think of to quickly extract the number of bits written and the number of bytes read and such
var strLen = string.length|0, u8Len = u8arr.length|0;
if (strLen < (u8Len >> 1)) { // in most circumstances, this means its safe. there are still edge-cases which are possible
// in many circumstances, we can use the faster native TextEncoder
var res8 = globalTextEncoderInstance["encode"](string);
var res8Len = res8.length|0;
if (res8Len < u8Len) { // if we dont have to worry about read/written
u8arr.set( res8 );
return {
"read": strLen,
"written": res8.length|0
};
}
}
return polyfill_encodeInto(string, u8arr);
}
);
} // else globalTextEncoderEncodeInto is polyfill_encodeInto
}
function factory(obj) {
obj["TextDecoder"] = GlobalTextDecoder || TextDecoder;
obj["TextEncoder"] = GlobalTextEncoder || TextEncoder;
if (obj !== global) {
obj["decode"] = GlobalTextDecoder ? bindMethod(new GlobalTextDecoder, "decode") : decode;
obj["encode"] = GlobalTextEncoder ? bindMethod(ENCODEINTO_BUILD ? globalTextEncoderInstance : new GlobalTextEncoder, "encode") : encode;
if (ENCODEINTO_BUILD) obj["encodeInto"] = globalTextEncoderEncodeInto;
}
return obj;
}
typeof exports === 'object' && typeof module !== 'undefined' ? factory(module["exports"]) :
typeof define == typeof factory && typeof define === "function" && define["amd"] ? define(function(){
return factory({});
}) :
factory(global);
}
})(typeof global == "" + void 0 ? typeof self == "" + void 0 ? this || {} : self : global);
================================================
FILE: NodeJS/EncoderAndDecoderNodeJS.src.module.js
================================================
/*
ALERT: DO NOT USE THIS SOURCE FILE DIRECTLY!!!
- Closure Compiler deals with ES6 exports in an unusual way that has forced me to "export" via the window
object, then run sed on the file after minification to turn it into an es6 module.
*/
/** @define {boolean} */
var ENCODEINTO_BUILD = false;
var window_global = typeof global == "" + void 0 ? typeof self === "" + void 0 ? {} : self : global;
// In this NodeJS version, Buffers are supported and used as fallback in versions that do not support Typed Arrays
var log = Math.log;
var LN2 = Math.LN2;
var clz32 = Math.clz32 || function(x) {return 31 - log(x >> 0) / LN2 | 0};
var fromCharCode = String.fromCharCode;
var Object_prototype_toString = ({}).toString;
var NativeSharedArrayBuffer = window_global["SharedArrayBuffer"];
var sharedArrayBufferString = NativeSharedArrayBuffer ? Object_prototype_toString.call(NativeSharedArrayBuffer) : "";
var NativeUint8Array = window_global["Uint8Array"];
var arrayBufferPrototypeString = NativeUint8Array ? Object_prototype_toString.call(ArrayBuffer.prototype) : "";
var NativeBuffer = window_global["Buffer"];
try {
if (!NativeBuffer && window_global["require"]) NativeBuffer=window_global["require"]("Buffer");
var NativeBufferPrototype = NativeBuffer.prototype;
var globalBufferPrototypeString = Object_prototype_toString.call(NativeBufferPrototype);
} catch(e){}
var NativeBuffer_allocUnsafe = NativeBuffer["allocUnsafe"];
var usingTypedArrays = !!NativeUint8Array && !NativeBuffer;
var encodeRegExp = /[\x80-\uD7ff\uDC00-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]?/g;
var tmpBufferU16 = new Uint16Array(32);
// NativeBufferHasArrayBuffer is true if there is no global.Buffer or if native global.Buffer instances have a Buffer property for the internal ArrayBuffer
var NativeBufferHasArrayBuffer = !NativeBuffer || (!!NativeUint8Array && NativeUint8Array.prototype.isPrototypeOf(NativeBufferPrototype));
var TextEncoderPrototype = TextEncoder_polyfill.prototype;
/** @constructor */
function TextDecoder_polyfill() {}
function decode(inputArrayOrBuffer){
var buffer = (inputArrayOrBuffer && inputArrayOrBuffer.buffer) || inputArrayOrBuffer;
var asString = Object_prototype_toString.call(buffer);
if (asString !== arrayBufferPrototypeString && asString !== globalBufferPrototypeString && asString !== sharedArrayBufferString && asString !== "[object ArrayBuffer]" && inputArrayOrBuffer !== undefined)
throw TypeError("Failed to execute 'decode' on 'TextDecoder': The provided value is not of type '(ArrayBuffer or ArrayBufferView)'");
var inputAs8 = NativeBufferHasArrayBuffer ? new NativeUint8Array(buffer) : buffer || [];
var resultingString="", tmpStr="", index=0, len=inputAs8.length|0, lenMinus32=len-32|0, nextEnd=0, nextStop=0, cp0=0, codePoint=0, minBits=0, cp1=0, pos=0, tmp=-1;
// Note that tmp represents the 2nd half of a surrogate pair incase a surrogate gets divided between blocks
for (; index < len; ) {
nextEnd = index <= lenMinus32 ? 32 : len - index|0;
for (; pos < nextEnd; index=index+1|0, pos=pos+1|0) {
cp0 = inputAs8[index] & 0xff;
switch(cp0 >> 4) {
case 15:
cp1 = inputAs8[index=index+1|0] & 0xff;
if ((cp1 >> 6) !== 0b10 || 0b11110111 < cp0) {
index = index - 1|0;
break;
}
codePoint = ((cp0 & 0b111) << 6) | (cp1 & 0b00111111);
minBits = 5; // 20 ensures it never passes -> all invalid replacements
cp0 = 0x100; // keep track of th bit size
case 14:
cp1 = inputAs8[index=index+1|0] & 0xff;
codePoint <<= 6;
codePoint |= ((cp0 & 0b1111) << 6) | (cp1 & 0b00111111);
minBits = (cp1 >> 6) === 0b10 ? minBits + 4|0 : 24; // 24 ensures it never passes -> all invalid replacements
cp0 = (cp0 + 0x100) & 0x300; // keep track of th bit size
case 13:
case 12:
cp1 = inputAs8[index=index+1|0] & 0xff;
codePoint <<= 6;
codePoint |= ((cp0 & 0b11111) << 6) | cp1 & 0b00111111;
minBits = minBits + 7|0;
// Now, process the code point
if (index < len && (cp1 >> 6) === 0b10 && (codePoint >> minBits) && codePoint < 0x110000) {
cp0 = codePoint;
codePoint = codePoint - 0x10000|0;
if (0 <= codePoint/*0xffff < codePoint*/) { // BMP code point
//nextEnd = nextEnd - 1|0;
tmp = (codePoint >> 10) + 0xD800|0; // highSurrogate
cp0 = (codePoint & 0x3ff) + 0xDC00|0; // lowSurrogate (will be inserted later in the switch-statement)
if (pos < 31) { // notice 31 instead of 32
tmpBufferU16[pos] = tmp;
pos = pos + 1|0;
tmp = -1;
} else {// else, we are at the end of the inputAs8 and let tmp0 be filled in later on
// NOTE that cp1 is being used as a temporary variable for the swapping of tmp with cp0
cp1 = tmp;
tmp = cp0;
cp0 = cp1;
}
} else nextEnd = nextEnd + 1|0; // because we are advancing i without advancing pos
} else {
// invalid code point means replacing the whole thing with null replacement characters
cp0 >>= 8;
index = index - cp0 - 1|0; // reset index back to what it was before
cp0 = 0xfffd;
}
// Finally, reset the variables for the next go-around
minBits = 0;
codePoint = 0;
nextEnd = index <= lenMinus32 ? 32 : len - index|0;
default:
tmpBufferU16[pos] = cp0; // fill with invalid replacement character
continue;
case 11:
case 10:
case 9:
case 8:
}
tmpBufferU16[pos] = 0xfffd; // fill with invalid replacement character
}
tmpStr += fromCharCode(
tmpBufferU16[ 0], tmpBufferU16[ 1], tmpBufferU16[ 2], tmpBufferU16[ 3], tmpBufferU16[ 4], tmpBufferU16[ 5], tmpBufferU16[ 6], tmpBufferU16[ 7],
tmpBufferU16[ 8], tmpBufferU16[ 9], tmpBufferU16[10], tmpBufferU16[11], tmpBufferU16[12], tmpBufferU16[13], tmpBufferU16[14], tmpBufferU16[15],
tmpBufferU16[16], tmpBufferU16[17], tmpBufferU16[18], tmpBufferU16[19], tmpBufferU16[20], tmpBufferU16[21], tmpBufferU16[22], tmpBufferU16[23],
tmpBufferU16[24], tmpBufferU16[25], tmpBufferU16[26], tmpBufferU16[27], tmpBufferU16[28], tmpBufferU16[29], tmpBufferU16[30], tmpBufferU16[31]
);
if (pos < 32) tmpStr = tmpStr.slice(0, pos-32|0);//-(32-pos));
if (index < len) {
//fromCharCode.apply(0, tmpBufferU16 : NativeUint8Array ? tmpBufferU16.subarray(0,pos) : tmpBufferU16.slice(0,pos));
tmpBufferU16[0] = tmp;
pos = (~tmp) >>> 31;//tmp !== -1 ? 1 : 0;
tmp = -1;
if (tmpStr.length < resultingString.length) continue;
} else if (tmp !== -1) {
tmpStr += fromCharCode(tmp);
}
resultingString += tmpStr;
tmpStr = "";
}
return resultingString;
};
TextDecoder_polyfill.prototype["decode"] = decode;
//////////////////////////////////////////////////////////////////////////////////////
function encoderReplacer(nonAsciiChars){
// make the UTF string into a binary UTF-8 encoded string
var point = nonAsciiChars.charCodeAt(0)|0;
if (0xD800 <= point) {
if (point < 0xDC00) {
var nextcode = nonAsciiChars.charCodeAt(1)|0; // defaults to 0 when NaN, causing null replacement character
if (0xDC00 <= nextcode && nextcode <= 0xDFFF) {
//point = ((point - 0xD800)<<10) + nextcode - 0xDC00 + 0x10000|0;
point = (point<<10) + nextcode - 0x35fdc00|0;
if (point > 0xffff)
return fromCharCode(
(0x1e/*0b11110*/<<3) | (point>>18),
(0x2/*0b10*/<<6) | ((point>>12)&0x3f/*0b00111111*/),
(0x2/*0b10*/<<6) | ((point>>6)&0x3f/*0b00111111*/),
(0x2/*0b10*/<<6) | (point&0x3f/*0b00111111*/)
);
} else point = 65533/*0b1111111111111101*/;//return '\xEF\xBF\xBD';//fromCharCode(0xef, 0xbf, 0xbd);
} else if (point <= 0xDFFF) {
point = 65533/*0b1111111111111101*/;//return '\xEF\xBF\xBD';//fromCharCode(0xef, 0xbf, 0xbd);
}
}
/*if (point <= 0x007f) return nonAsciiChars;
else */if (point <= 0x07ff) {
return fromCharCode((0x6<<5)|(point>>6), (0x2<<6)|(point&0x3f));
} else return fromCharCode(
(0xe/*0b1110*/<<4) | (point>>12),
(0x2/*0b10*/<<6) | ((point>>6)&0x3f/*0b00111111*/),
(0x2/*0b10*/<<6) | (point&0x3f/*0b00111111*/)
);
}
/** @constructor */
function TextEncoder_polyfill(){}
function encode(inputString){
// 0xc0 => 0b11000000; 0xff => 0b11111111; 0xc0-0xff => 0b11xxxxxx
// 0x80 => 0b10000000; 0xbf => 0b10111111; 0x80-0xbf => 0b10xxxxxx
var encodedString = inputString === void 0 ? "" : ("" + inputString); //.replace(encodeRegExp, encoderReplacer);
var len=encodedString.length|0, result = usingTypedArrays ? new NativeUint8Array((len << 1) + 8|0) : NativeBuffer_allocUnsafe ? NativeBuffer_allocUnsafe((len << 1) + 8|0) : new NativeBuffer((len << 1) + 8|0);
var tmpResult;
var i=0, pos=0, point=0, nextcode=0;
var upgradededArraySize=false; // normal arrays are auto-expanding
for (i=0; i<len; i=i+1|0, pos=pos+1|0) {
point = encodedString.charCodeAt(i)|0;
if (point <= 0x007f) {
result[pos] = point;
} else if (point <= 0x07ff) {
result[pos] = (0x6<<5)|(point>>6);
result[pos=pos+1|0] = (0x2<<6)|(point&0x3f);
} else {
widenCheck: {
if (0xD800 <= point) {
if (point < 0xDC00) {
nextcode = encodedString.charCodeAt(i=i+1|0)|0; // defaults to 0 when NaN, causing null replacement character
if (0xDC00 <= nextcode && nextcode <= 0xDFFF) {
//point = ((point - 0xD800)<<10) + nextcode - 0xDC00 + 0x10000|0;
point = (point<<10) + nextcode - 0x35fdc00|0;
if (point > 0xffff) {
result[pos] = (0x1e/*0b11110*/<<3) | (point>>18);
result[pos=pos+1|0] = (0x2/*0b10*/<<6) | ((point>>12)&0x3f/*0b00111111*/);
result[pos=pos+1|0] = (0x2/*0b10*/<<6) | ((point>>6)&0x3f/*0b00111111*/);
result[pos=pos+1|0] = (0x2/*0b10*/<<6) | (point&0x3f/*0b00111111*/);
continue;
}
break widenCheck;
}
point = 65533/*0b1111111111111101*/;//return '\xEF\xBF\xBD';//fromCharCode(0xef, 0xbf, 0xbd);
} else if (point <= 0xDFFF) {
point = 65533/*0b1111111111111101*/;//return '\xEF\xBF\xBD';//fromCharCode(0xef, 0xbf, 0xbd);
}
}
if (!upgradededArraySize && (i << 1) < pos && (i << 1) < (pos - 7|0)) {
upgradededArraySize = true;
tmpResult = usingTypedArrays ? new NativeUint8Array(len * 3) : NativeBuffer_allocUnsafe ? NativeBuffer_allocUnsafe(len * 3) : new NativeBuffer(len * 3);
tmpResult.set( result );
result = tmpResult;
}
}
result[pos] = (0xe/*0b1110*/<<4) | (point>>12);
result[pos=pos+1|0] =(0x2/*0b10*/<<6) | ((point>>6)&0x3f/*0b00111111*/);
result[pos=pos+1|0] =(0x2/*0b10*/<<6) | (point&0x3f/*0b00111111*/);
}
}
return result.subarray(0, pos);
};
function polyfill_encodeInto(inputString, u8Arr) {
var encodedString = inputString === void 0 ? "" : ("" + inputString).replace(encodeRegExp, encoderReplacer);
var len=encodedString.length|0, i=0, char=0, read=0, u8ArrLen = u8Arr.length|0, inputLength=inputString.length|0;
if (u8ArrLen < len) len=u8ArrLen;
putChars: {
for (; i<len; i=i+1|0) {
char = encodedString.charCodeAt(i) |0;
switch(char >> 4) {
case 0:
case 1:
case 2:
case 3:
case 4:
case 5:
case 6:
case 7:
read = read + 1|0;
// extension points:
case 8:
case 9:
case 10:
case 11:
break;
case 12:
case 13:
if ((i+1|0) < u8ArrLen) {
read = read + 1|0;
break;
}
case 14:
if ((i+2|0) < u8ArrLen) {
read = read + 1|0;
break;
}
case 15:
if ((i+3|0) < u8ArrLen) {
read = read + 1|0;
break;
}
default:
break putChars;
}
//read = read + ((char >> 6) !== 2) |0;
u8Arr[i] = char;
}
}
return {"written": i, "read": inputLength < read ? inputLength : read};
// 0xc0 => 0b11000000; 0xff => 0b11111111; 0xc0-0xff => 0b11xxxxxx
// 0x80 => 0b10000000; 0xbf => 0b10111111; 0x80-0xbf => 0b10xxxxxx
/*var encodedString = typeof inputString == "string" ? inputString : inputString === void 0 ? "" : "" + inputString;
var encodedLen = encodedString.length|0, u8LenLeft=u8Arr.length|0;
var i=-1, read=-1, code=0, point=0, nextcode=0;
tryFast: if (2 < encodedLen && encodedLen < (u8LenLeft >> 1)) {
// Skip the normal checks because we can almost certainly fit the string inside the existing buffer
while (1) { // make the UTF string into a binary UTF-8 encoded string
point = encodedString.charCodeAt(read = read + 1|0)|0;
if (point <= 0x007f) {
if (point === 0 && encodedLen <= read) {
read = read - 1|0;
break; // we have reached the end of the string
}
u8Arr[i=i+1|0] = point;
} else if (point <= 0x07ff) {
u8Arr[i=i+1|0] = (0x6<<5)|(point>>6);
u8Arr[i=i+1|0] = (0x2<<6)|(point&0x3f);
} else {
if (0xD800 <= point) {
if (point < 0xDC00) {
nextcode = encodedString.charCodeAt(read)|0; // defaults to 0 when NaN, causing null replacement character
if (0xDC00 <= nextcode && nextcode <= 0xDFFF) {
read = read + 1|0;
//point = ((point - 0xD800)<<10) + nextcode - 0xDC00 + 0x10000|0;
point = (point<<10) + nextcode - 0x35fdc00|0;
if (point > 0xffff) {
u8Arr[i=i+1|0] = (0x1e<<3) | (point>>18);
u8Arr[i=i+1|0] = (0x2<<6) | ((point>>12)&0x3f);
u8Arr[i=i+1|0] = (0x2<<6) | ((point>>6)&0x3f);
u8Arr[i=i+1|0] = (0x2<<6) | (point&0x3f);
continue;
}
} else if (nextcode === 0 && encodedLen <= read) {
break; // we have reached the end of the string
} else {
point = 65533;//0b1111111111111101; // invalid replacement character
}
} else if (point <= 0xDFFF) {
point = 65533/*0b1111111111111101*\/;//return '\xEF\xBF\xBD';//fromCharCode(0xef, 0xbf, 0xbd);
}
}
u8Arr[i=i+1|0] = (0xe<<4) | (point>>12);
u8Arr[i=i+1|0] = (0x2<<6) | ((point>>6)&0x3f);
u8Arr[i=i+1|0] = (0x2<<6) | (point&0x3f);
if (u8LenLeft < (i + ((encodedLen - read) << 1)|0)) {
// These 3x chars are the only way to inflate the size to 3x
u8LenLeft = u8LenLeft - i|0;
break tryFast;
}
}
}
u8LenLeft = 0; // skip the next for-loop
}
for (; 0 < u8LenLeft; ) { // make the UTF string into a binary UTF-8 encoded string
point = encodedString.charCodeAt(read = read + 1|0)|0;
if (point <= 0x007f) {
if (point === 0 && encodedLen <= read) {
read = read - 1|0;
break; // we have reached the end of the string
}
u8LenLeft = u8LenLeft - 1|0;
u8Arr[i=i+1|0] = point;
} else if (point <= 0x07ff) {
u8LenLeft = u8LenLeft - 2|0;
if (0 <= u8LenLeft) {
u8Arr[i=i+1|0] = (0x6<<5)|(point>>6);
u8Arr[i=i+1|0] = (0x2<<6)|(point&0x3f);
}
} else {
if (0xD800 <= point && point < 0xDC00) {
nextcode = encodedString.charCodeAt(read = read + 1|0)|0; // defaults to 0 when NaN, causing null replacement character
if (0xDC00 <= nextcode && nextcode <= 0xDFFF) {
read = read + 1|0;
//point = ((point - 0xD800)<<10) + nextcode - 0xDC00 + 0x10000|0;
point = (point<<10) + nextcode - 0x35fdc00|0;
if (point > 0xffff) {
u8LenLeft = u8LenLeft - 4|0;
if (0 <= u8LenLeft) {
u8Arr[i=i+1|0] = (0x1e<<3) | (point>>18);
u8Arr[i=i+1|0] = (0x2<<6) | ((point>>12)&0x3f);
u8Arr[i=i+1|0] = (0x2<<6) | ((point>>6)&0x3f);
u8Arr[i=i+1|0] = (0x2<<6) | (point&0x3f);
}
continue;
}
} else if (nextcode === 0 && encodedLen <= read) {
break; // we have reached the end of the string
} else {
point = 65533;//0b1111111111111101; // invalid replacement character
}
}
u8LenLeft = u8LenLeft - 3|0;
if (0 <= u8LenLeft) {
u8Arr[i=i+1|0] = (0xe<<<4) | (point>>12);
u8Arr[i=i+1|0] = (0x2<<6) | ((point>>6)&0x3f);
u8Arr[i=i+1|0] = (0x2<<6) | (point&0x3f);
}
}
}
return {"read": read < 0 ? 0 : u8LenLeft < 0 ? read : read+1|0, "written": i < 0 ? 0 : i+1|0};*/
}
TextEncoderPrototype["encode"] = encode;
if (ENCODEINTO_BUILD) {
TextEncoderPrototype["encodeInto"] = polyfill_encodeInto;
}
/** bindMethod
* A useful way to bind a method on an instance
* @param {!Object} inst
* @param {!string} name
* @param {!Function=} _
*/
function bindMethod(inst, name, _) {
_ = inst[name];
return function() {
return _.apply(inst, arguments);
};
}
var GlobalTextDecoder = window_global["TextDecoder"];
var GlobalTextEncoder = window_global["TextEncoder"];
if (ENCODEINTO_BUILD) {
var globalTextEncoderInstance;
var globalTextEncoderEncodeInto = polyfill_encodeInto;
if (GlobalTextEncoder) {
globalTextEncoderInstance = new GlobalTextEncoder;
globalTextEncoderEncodeInto = (
globalTextEncoderInstance["encodeInto"] ?
bindMethod(globalTextEncoderInstance, "encodeInto") :
GlobalTextEncoder["prototype"]["encodeInto"] = function(string, u8arr) {
// Unfortunately, there's no way I can think of to quickly extract the number of bits written and the number of bytes read and such
var strLen = string.length|0, u8Len = u8arr.length|0;
if (strLen < (u8Len >> 1)) { // in most circumstances, this means its safe. there are still edge-cases which are possible
// in many circumstances, we can use the faster native TextEncoder
var res8 = globalTextEncoderInstance["encode"](string);
var res8Len = res8.length|0;
if (res8Len < u8Len) { // if we dont have to worry about read/written
u8arr.set( res8 );
return {
"read": strLen,
"written": res8.length|0
};
}
}
return polyfill_encodeInto(string, u8arr);
}
);
} // else globalTextEncoderEncodeInto is polyfill_encodeInto
}
/*window["export_TextEncoder"] = GlobalTextEncoder || TextEncoder_polyfill;
window["export_TextDecoder"] = GlobalTextDecoder || TextDecoder_polyfill;
window["export_encode"] = GlobalTextEncoder ? bindMethod(ENCODEINTO_BUILD ? globalTextEncoderInstance : new GlobalTextEncoder, "encode") : encode;
window["export_decode"] = GlobalTextDecoder ? bindMethod(new GlobalTextDecoder, "decode") : decode;
if (ENCODEINTO_BUILD) {
window["export_encodeInto"] = globalTextEncoderEncodeInto;
}
export default {};*/
/*window["export_default"] = (ENCODEINTO_BUILD ? {
"TextDecoder": GlobalTextDecoder || TextDecoder_polyfill,
"TextEncoder": GlobalTextEncoder || TextEncoder_polyfill,
"decode": GlobalTextDecoder ? bindMethod(new GlobalTextDecoder, "decode") : decode,
"encode": GlobalTextEncoder ? bindMethod(ENCODEINTO_BUILD ? globalTextEncoderInstance : new GlobalTextEncoder, "encode") : encode,
"encodeInto": globalTextEncoderEncodeInto
} : {
"TextDecoder": GlobalTextDecoder || TextDecoder_polyfill,
"TextEncoder": GlobalTextEncoder || TextEncoder_polyfill,
"decode": GlobalTextDecoder ? bindMethod(new GlobalTextDecoder, "decode") : decode,
"encode": GlobalTextEncoder ? bindMethod(ENCODEINTO_BUILD ? globalTextEncoderInstance : new GlobalTextEncoder, "encode") : encode
});*/
/*window["exports"] = (ENCODEINTO_BUILD ? [
GlobalTextDecoder, "_REMOVE as TextDecoderREMOVE_",
GlobalTextEncoder, "_REMOVE as TextEncoderREMOVE_",
decode, "_REMOVE as decodeREMOVE_",
encode, "_REMOVE as encodeREMOVE_",
globalTextEncoderEncodeInto, "_REMOVE as encodeIntoREMOVE_",
"REM_B_"
] : [
GlobalTextDecoder, "_REMOVE as TextDecoder REMOVE_",
GlobalTextEncoder, "_REMOVE as TextEncoder REMOVE_",
decode, "_REMOVE as decode REMOVE_",
encode, "_REMOVE as encode REMOVE_",
"REM_B_"
]);
*/
window["var_gens"] = (ENCODEINTO_BUILD ? [
,
"_REMOVEvar TextDecoder=REMOVE_", GlobalTextDecoder || TextDecoder_polyfill,
"_REMOVE,TextEncoder=REMOVE_", GlobalTextEncoder || TextEncoder_polyfill,
"_REMOVE,decode=REMOVE_", GlobalTextDecoder ? bindMethod(new GlobalTextDecoder, "decode") : decode,
"_REMOVE,encode=REMOVE_", GlobalTextEncoder ? bindMethod(ENCODEINTO_BUILD ? globalTextEncoderInstance : new GlobalTextEncoder, "encode") : encode,
"_REMOVE,encodeInto=REMOVE_", globalTextEncoderEncodeInto,
"_REMOVE;export{TextDecoder,TextEncoder,decode,encode,encodeInto}REM_VAR_"
] : [
,
"_REMOVEvar TextDecoder=REMOVE_", GlobalTextDecoder || TextDecoder_polyfill,
"_REMOVE,TextEncoder=REMOVE_", GlobalTextEncoder || TextEncoder_polyfill,
"_REMOVE,decode=REMOVE_", GlobalTextDecoder ? bindMethod(new GlobalTextDecoder, "decode") : decode,
"_REMOVE,encode=REMOVE_", GlobalTextEncoder ? bindMethod(ENCODEINTO_BUILD ? globalTextEncoderInstance : new GlobalTextEncoder, "encode") : encode,
"_REMOVE;export{TextDecoder,TextEncoder,decode,encode}REM_VAR_"
]);
================================================
FILE: NodeJS/build-npm-repository.js
================================================
// This file is all about optimizing downloads from the npm repository to be as small as possible
/*
"prepublishOnly": "node -e \"E=_=>require('ntb')();try{E()}catch(e){require('child_process').spawnSync('npm',['install','ntb'],{cwd:require('os').homedir()});E()}\" && cd .ntb",
"publish": "cd .."
*/
const fs = require("fs");
const Path = require("path");
const os = require("os");
const pathSep = Path.sep;
os.homedir();
const Object_keys = Object.keys;
const hasOwnProp = ({}).hasOwnProperty;
const Array_isArray = Array.isArray;
///////////////////////////////////////////////////////////////////
//////////////////// Optimize the package.json ////////////////////
///////////////////////////////////////////////////////////////////
var fullPackageJSON = null;
try {
fullPackageJSON = JSON.parse( fs.readFileSync("package.json") );
} catch(e) {
process.chdir(".."); // just in case, give this an attempt
fullPackageJSON = JSON.parse( fs.readFileSync("package.json") );
}
const etbSettings = fullPackageJSON.etb || null;
// minimal package after package downloaded
const new_minimalPackage = {
name: fullPackageJSON.name,
version: fullPackageJSON.version
};
if (hasOwnProp.call(new_minimalPackage, "main")) new_minimalPackage.main = fullPackageJSON.main;
if (hasOwnProp.call(new_minimalPackage, "module")) new_minimalPackage.module = fullPackageJSON.module;
if (hasOwnProp.call(new_minimalPackage, "es2015")) new_minimalPackage.es2015 = fullPackageJSON.es2015;
if (hasOwnProp.call(new_minimalPackage, "browser")) new_minimalPackage.browser = fullPackageJSON.browser;
const minExtraProps = etbSettings && etbSettings.min;
if (minExtraProps) {
if (typeof minExtraProps === "array")for (var i=0; i<minExtraProps.length; i=i+1|0) {
}
}
// smaller package for the package while it is on npm
const new_npmPackageJSON = Object.assign({
license: fullPackageJSON.license
}, new_minimalPackage);
const npmProps = ["name", "homepage", "version", "description", "homepage", "license", "repository", "files"];
const new_minimalPackage_string = JSON.stringify(new_minimalPackage);
const new_npmPackageJSON_string = JSON.stringify(new_npmPackageJSON);
let commonChars=0;
while (new_minimalPackage_string[commonChars] === new_npmPackageJSON_string[commonChars]) commonChars = commonChars+1|0;
new_npmPackageJSON_string.scripts = {
// upon install, we replace the package.json file with a smaller one to save disk space
install: "rm -f LICENSE README.md; a=$(<package.json); echo \"${a:0:"+commonChars+"}\"'" + (
new_minimalPackage_string.substring(0,commonChars).replace(/'/g,"'\\''")
) + "'"
};
///////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////
//////////// Create a mirror with the new package.json ////////////
///////////////////////////////////////////////////////////////////
var filesToIncludeInNpm = {
".npmignore": null,
"README.md": null,
"LICENSE": null//,
//"package.json": null,
/*"EncoderDecoderTogether.min.js": null,
"NodeJS": {
"EncoderAndDecoderNodeJS.min.js": null,
"EncoderAndDecoderNodeJS.min.module.js": null
}*/
};
new_minimalPackage.files.forEach(function() {
});
filesToIncludeInNpm
const npmFolderStats = fs.statSync("npm-repository");
if (npmFolderStats && npmFolderStats.isFile()) {
fs.unlinkSync("npm-repository"); // just in case
}
if (!npmFolderStats || !npmFolderStats.isDirectory()) {
fs.mkdirSync("npm-repository");
}
var originalDir = __dirname;
if (originalDir.slice(-1) === pathSep) originalDir = originalDir.slice(0,-1);
process.chdir("npm-repository"); // CD to the npm-repository
const hasProp = ({}).hasOwnProperty;
(function ensureStructure(path, description) {
const contents = fs.readdirSync(path);
const keysToDo = Object.getOwnPropertyNames(path); // horribly inefficient memory-wise for such a shorted-lived instance, but we don't need performance in this script
contents.forEach(function(name) {
const relPath = (path ? path + pathSep : "") + name;
const curStats = fs.statSync( relPath );
if (hasProp.call(description, name)) {
const keyIndex = keysToDo.indexOf( name );
keyIndex = keyIndex.remove( name );
const valueThere = description[name];
if (valueThere == null) {
// We want a file there
if (curStats && curStats.isDirectory()) {
deleteFolderRecursive( relPath );
}
const fullPathToItem = originalDir + path + pathSep + name;
const fullFileStats = fs.statSync( fullPathToItem );
if (fullPathToItem.ino !== fullFileStats.ino) {
// hardlinked to other undesired resource
fs.unlinkSync( relPath );
keysToDo.add( name );
}
} else {
// We want a folder there
if (curStats && curStats.isFile()) {
fs.unlinkSync( relPath ); // just in case
}
if (!curStats || !curStats.isDirectory()) {
fs.mkdirSync( relPath );
}
ensureStructure(relPath, valueThere);
}
} else if (curStats) {
if (curStats.isFile()) {
fs.unlinkSync( relPath ); // just in case
} else if (curStats.isDirectory()) {
deleteFolderRecursive( relPath );
}
}
});
keysToDo.forEach(function(name) {
if (name !== "") {
const relPath = (path ? path + pathSep : "") + name;
const fullPathToItem = originalDir + path + pathSep + name;
fs.linkSync(fullPathToItem, relPath);
}
});
})("", filesToIncludeInNpm);
///////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////
//////////// Put the new package.json into the mirror /////////////
///////////////////////////////////////////////////////////////////
fs.writeFileSync("package.json", JSON.stringify(new_npmPackageJSON));
///////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////
function applyFilteredCopyToProperties(to, from, filter) {
// max performance apply filter
if (typeof filter !== "object" || filter === null) {
const strFil = "" + filter;
} else if (Array_isArray(filter)) {
for (let i=0, len=filter.length|0, s=""; i !== len; i=i+1|0) {
s = filter[i];
if (typeof s !== "object" || s === null) {
s += "";
let needsToRepeat = false;
do {
for (let start=0, end=0,path=""; ;) {
start = end;
end = s.indexOf(" ", start+1|0);
path = end === -1 ? s.substring(start) : s.substring(start, end)
for (let objTo=to, objFrom=from, k=0, kLen=s.length|0, k !== kLen; )
}
} while (needsToRepeat);
} else {
s = Array_isArray(s) ? s : Object_keys(s), kLen=s.length|0;
repeatingLoop: do {
for (let objTo=to, objFrom=from, k=0, cur=""; k !== kLen; ) {
cur = s[k];
k = k + 1 |0;
if (typeof s !== "object" || s === null) {
s += "";
if (hasOwnProp.call(objFrom, prop)) {
if (k !== kLen) {
objFrom[]
} else {
continue;
}
}
} else {
if (!Array_isArray(cur)) cur = s[k] = Object_keys(cur);
}
break;
}
} while (needsToRepeat);
} else {
applyToProperties(to, from, filter);
}
}
} else {
const keys = Object_keys(filter), keysLen=keys.length|0;
for (let i=0; i<keysLen; i=i+1|0) {
}
}
}
function deleteFolderRecursive(path) {
if (fs.existsSync(path)) {
fs.readdirSync(path).forEach((file, index) => {
const curPath = path + pathSep + file;
if (fs.lstatSync(curPath).isDirectory()) { // recurse
deleteFolderRecursive(curPath);
} else { // delete file
fs.unlinkSync(curPath);
}
});
fs.rmdirSync(path);
}
};
================================================
FILE: README.md
================================================
[](https://npmjs.org/package/fastestsmallesttextencoderdecoder "View this project on npm")
[](https://github.com/anonyco/FastestSmallestTextEncoderDecoder/stargazers "View others who have stared this repository")
[](https://github.com/anonyco/FastestSmallestTextEncoderDecoder/blob/master/EncoderDecoderTogether.min.js "File without gzip")
[](https://github.com/anonyco/FastestSmallestTextEncoderDecoder/blob/master/test/EncoderDecoderTogether.min.js.gz "Gzipped file")
[](https://npmjs.org/package/fastestsmallesttextencoderdecoder "View this project on npm")<!--[]( https://github.com/anonyco/FastestSmallestTextEncoderDecoder/issues )-->
[](https://npmjs.org/package/fastestsmallesttextencoderdecoder "View this project on npm")
[](https://creativecommons.org/share-your-work/public-domain/cc0/ "This project's liscence")
This Javascript library provides the most performant tiny polyfill for [`window.TextEncoder`](https://developer.mozilla.org/en-US/docs/Web/API/TextEncoder), [`TextEncoder.prototype.encodeInto`](https://developer.mozilla.org/en-US/docs/Web/API/TextEncoder/encodeInto), and [`window.TextDecoder`](https://developer.mozilla.org/en-US/docs/Web/API/TextDecoder) for use in [the browser](https://developer.mozilla.org/en-US/docs/Web/API/Window), in [NodeJS](https://nodejs.org/en/docs/), in [RequireJS](https://requirejs.org/docs/whyamd.html), in web [Worker](https://developer.mozilla.org/en-US/docs/Web/API/DedicatedWorkerGlobalScope)s, in [SharedWorker](https://developer.mozilla.org/en-US/docs/Web/API/SharedWorkerGlobalScope)s, and in [ServiceWorker](https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerGlobalScope)s.
## Quick Start
Add the following HTML Code inside the `<head>`:
````HTML
<script src="https://dl.dropboxusercontent.com/s/r55397ld512etib/EncoderDecoderTogether.min.js?dl=0" nomodule="" type="text/javascript"></script>
````
If no script on the page requires this library until the DOMContentLoaded event, then use the the much less blocking version below:
````HTML
<script defer="" src="https://dl.dropboxusercontent.com/s/r55397ld512etib/EncoderDecoderTogether.min.js?dl=0" nomodule="" type="text/javascript"></script>
````
Alternatively, either use `https://dl.dropboxusercontent.com/s/47481btie8pb95h/FastestTextEncoderPolyfill.min.js?dl=0` to polyfill `window.TextEncoder` for converting a `String` into a `Uint8Array` or use `https://dl.dropboxusercontent.com/s/qmoknmp86sytc74/FastestTextDecoderPolyfill.min.js?dl=0` to only polyfill `window.TextDecoder` for converting a `Uint8Array`/`ArrayBuffer`/*\[typedarray\]*/`global.Buffer` into a `String`.
The `nomodule` attribute prevents the script from being needlessly downloaded and executed on browsers which already support `TextEncoder` and `TextDecoder`. `nomodule` does not test for the presence of `TextEncoder` or `TextDecoder`, but it is very safe to assume that browsers advanced enough to support modules also support `TextEncoder` and `TextDecoder`.
## EncodeInto
See the [MDN here](https://developer.mozilla.org/en-US/docs/Web/API/TextEncoder/encodeInto) for documentation. For the TextEncoder.prototype.encodeInto polyfill, please use `https://dl.dropboxusercontent.com/s/i2e2rho1ohtbhfg/EncoderDecoderTogether.min.js?dl=0` for the full package, `https://dl.dropboxusercontent.com/s/nlcgzbr0ayd5pjs/FastestTextEncoderPolyfill.min.js?dl=0` for only TextEncoder and TextEncoder.prototype.encodeInto, and `npm i fastestsmallesttextencoderdecoder-encodeinto` for NodeJS, es6 modules, RequireJS, AngularJS, or whatever it is that floats your boat. The [encodeInto](https://github.com/anonyco/FastestSmallestTextEncoderDecoder/tree/master/encodeInto) folder of this repository contains the auto-generated encodeInto build of the main project. The npm project is [fastestsmallesttextencoderdecoder-encodeinto](https://www.npmjs.com/package/fastestsmallesttextencoderdecoder-encodeinto):
```
npm install fastestsmallesttextencoderdecoder-encodeinto
```
## RequireJS and NodeJS
For dropping into either RequireJS or NodeJS, please use [the `fastestsmallesttextencoderdecoder` npm repository](https://npmjs.org/package/fastestsmallesttextencoderdecoder), [this minified file](https://github.com/anonyco/FastestSmallestTextEncoderDecoder/blob/master/NodeJS/EncoderAndDecoderNodeJS.min.js), or the corresponding [source code file](https://github.com/anonyco/FastestSmallestTextEncoderDecoder/blob/master/NodeJS/EncoderAndDecoderNodeJS.src.js). To install via npm, use the following code.
```Bash
npm install fastestsmallesttextencoderdecoder
```
Alternatively, if one do not know how to use the command line, save the script corresponding to one's operating system to the directory where the nodejs script will run and use the file manager to run the script (on Windows, it's a double-click).
* fastestsmallesttextencoderdecoder
- Microsoft Windows batch: [install-FastestSmallestTextEncoderDecoder-windows.bat](https://raw.githubusercontent.com/anonyco/FastestSmallestTextEncoderDecoder/master/gh-pages/install-FastestSmallestTextEncoderDecoder-windows.bat)
- Bash for Apple MacOS and Linux (e.x. Ubuntu): [install-FastestSmallestTextEncoderDecoder-unix.sh](https://raw.githubusercontent.com/anonyco/FastestSmallestTextEncoderDecoder/master/gh-pages/install-FastestSmallestTextEncoderDecoder-unix.sh)
* fastestsmallesttextencoderdecoder-encodeinto
- Microsoft Windows batch: [install-FastestSmallestTextEncoderDecoder-encodeInto.bat](https://raw.githubusercontent.com/anonyco/FastestSmallestTextEncoderDecoder/master/gh-pages/install-FastestSmallestTextEncoderDecoder-encodeInto.bat)
- Bash for Apple MacOS and Linux (e.x. Ubuntu): [install-FastestSmallestTextEncoderDecoder-encodeInto.sh](https://raw.githubusercontent.com/anonyco/FastestSmallestTextEncoderDecoder/master/gh-pages/install-FastestSmallestTextEncoderDecoder-encodeInto.sh)
After installing via npm, one can use `require("fastestsmallesttextencoderdecoder")`. Alternatively, one can drop the *EncoderAndDecoderNodeJS.min.js* file into the same directory as their NodeJS script and do `require("./EncoderAndDecoderNodeJS.min.js")`. Both methods are functionally equivalent.
## AngularJS
Open a terminal in the project's directory, and install fastestsmallesttextencoderdecoder via npm.
```Bash
npm install fastestsmallesttextencoderdecoder
```
Then, add `import 'fastestsmallesttextencoderdecoder';` to the polyfills.ts file.
## Benchmarks
Don't take my word that FastestSmallestTextEncoderDecoder is the fastest. Instead, check out the benchmarks below. You can run your own benchmarks by cloning this repo and running `npm run benchmark`, but beware that you need a beefy computer with plenty of free RAM, as the NodeJS garbage collector is disabled via `--noconcurrent_sweeping --nouse-idle-notification` so that it does not interfer with the timing of the tests (the GC is runned manually via `global.gc(true)` at the conclusion of the tests).
The tests below were performed on an ascii file. To ensure consistancy, all test results are the mean of the IQR of many many trials. The checkmark "✔" means that the encoder/decoder implementation gave the correct output, whereas a bold "**✗**" indicates an incorrect output. This extra check is signifigant because relying on a faulty encoder/decoder can lead to inconsistant behaviors in code that defaults to using the native implementation where available.
| Library | Decode 32 bytes | Decode 32768 | Decode 16777216 | Encode 32 bytes | Encode 32768 | Encode 16777216 |
| ------- | --------------- | ------------ | --------------- | --------------- | ------------ | --------------- |
| <i>Native</i> | 10201 KB/sec ✔ | 806451 KB/sec ✔ | 907381 KB/sec ✔ | 53415 KB/sec ✔ | 4661211 KB/sec ✔ | 1150916 KB/sec ✔ |
| FastestSmallestTextEncoderDecoder | 18038 KB/sec ✔ | 154839 KB/sec ✔ | 168984 KB/sec ✔ | 21667 KB/sec ✔ | 404279 KB/sec ✔ | 681429 KB/sec ✔ |
| [fast-text-encoding](https://github.com/samthor/fast-text-encoding) | 17518 KB/sec ✔ | 71806 KB/sec ✔ | 99017 KB/sec ✔ | 22713 KB/sec ✔ | 240880 KB/sec ✔ | 445137 KB/sec ✔ |
| [text-encoding-shim](https://gitlab.com/PseudoPsycho/text-encoding-shim) | 10205 KB/sec ✔ | 17503 KB/sec ✔ | 27971 KB/sec ✔ | 14044 KB/sec ✔ | 50007 KB/sec ✔ | 88687 KB/sec ✔ |
| [TextEncoderLite](https://github.com/solderjs/TextEncoderLite) | 12433 KB/sec ✔ | 23456 KB/sec ✔ | 13929 KB/sec ✔ | 24013 KB/sec ✔ | 57034 KB/sec ✔ | 62119 KB/sec ✔ |
| [TextEncoderTextDecoder.js](https://gist.github.com/Yaffle/5458286) | 4469 KB/sec ✔ | 5956 KB/sec ✔ | 5626 KB/sec ✔ | 13576 KB/sec ✔ | 37667 KB/sec ✔ | 57916 KB/sec ✔ |
| [text-encoding](https://github.com/inexorabletash/text-encoding) | 3084 KB/sec ✔ | 6762 KB/sec ✔ | 7925 KB/sec ✔ | 8621 KB/sec ✔ | 26699 KB/sec ✔ | 35755 KB/sec ✔ |
Needless to say, FastestSmallestTextEncoderDecoder outperformed almost every other polyfill out there, with the only exception being fast-text-encoding outperforming fastestsmallesttextencoderdecoder on encoding extremely tiny strings. Infact, it is so fast that it outperformed the native implementation on a set of 32 ascii bytes. The tests below were performed on a mixed ascii-utf8 file.
| Library | Decode 32 bytes | Decode 32768 | Decode 16777216 | Encode 32 bytes | Encode 32768 | Encode 16777216 |
| ------- | --------------- | ------------ | --------------- | --------------- | ------------ | --------------- |
| <i>Native</i> | 24140 KB/sec ✔ | 365043 KB/sec ✔ | 512133 KB/sec ✔ | 54183 KB/sec ✔ | 293455 KB/sec ✔ | 535203 KB/sec ✔ |
| FastestSmallestTextEncoderDecoder | 13932 KB/sec ✔ | 113823 KB/sec ✔ | 141706 KB/sec ✔ | 20755 KB/sec ✔ | 212100 KB/sec ✔ | 443344 KB/sec ✔ |
| [fast-text-encoding](https://github.com/samthor/fast-text-encoding) | 10738 KB/sec ✔ | 62851 KB/sec ✔ | 94031 KB/sec ✔ | 15105 KB/sec ✔ | 104843 KB/sec ✔ | 320778 KB/sec ✔ |
| [TextEncoderLite](https://github.com/solderjs/TextEncoderLite) | 6594 KB/sec ✔ | 9893 KB/sec ✔ | 10470 KB/sec ✔ | 17660 KB/sec **✗** | 53905 KB/sec **✗** | 57862 KB/sec **✗** |
| [text-encoding-shim](https://gitlab.com/PseudoPsycho/text-encoding-shim) | 10778 KB/sec ✔ | 15063 KB/sec ✔ | 24373 KB/sec ✔ | 27296 KB/sec ✔ | 31496 KB/sec ✔ | 42497 KB/sec ✔ |
| [TextEncoderTextDecoder.js](https://gist.github.com/Yaffle/5458286) | 5558 KB/sec ✔ | 5121 KB/sec ✔ | 6580 KB/sec ✔ | 14583 KB/sec ✔ | 32261 KB/sec ✔ | 60183 KB/sec ✔ |
| [text-encoding](https://github.com/inexorabletash/text-encoding) | 3531 KB/sec ✔ | 6669 KB/sec ✔ | 7983 KB/sec ✔ | 7233 KB/sec ✔ | 20343 KB/sec ✔ | 29136 KB/sec ✔ |
FastestSmallestTextEncoderDecoder excells at encoding lots of complex unicode and runs at 83% the speed of the native implementation. In the next test, let's examine a more real world example—the [1876 The Russian Synodal Bible.txt](https://github.com/anonyco/FastestSmallestTextEncoderDecoder/blob/master/test/1876%20The%20Russian%20Synodal%20Bible.txt). It's a whoping 4.4MB rat's-nest of complex Russian UTF-8, sure to give any encoder/decoder a bad day. Let's see how they perform at their worst.
| Library | Decode Russian Bible | Encode Russian Bible |
| ------- | -------------------- | -------------------- |
| <i>Native</i> | 626273 KB/sec ✔ | 951538 KB/sec ✔ |
| FastestSmallestTextEncoderDecoder | 228360 KB/sec ✔ | 428625 KB/sec ✔ |
| [fast-text-encoding](https://github.com/samthor/fast-text-encoding) | 94666 KB/sec ✔ | 289109 KB/sec ✔ |
| [text-encoding-shim](https://gitlab.com/PseudoPsycho/text-encoding-shim) | 29335 KB/sec ✔ | 60508 KB/sec ✔ |
| [TextEncoderLite](https://github.com/solderjs/TextEncoderLite) | 14079 KB/sec ✔ | 61648 KB/sec ✔ |
| [TextEncoderTextDecoder.js](https://gist.github.com/Yaffle/5458286) | 5989 KB/sec ✔ | 54741 KB/sec ✔ |
| [text-encoding](https://github.com/inexorabletash/text-encoding) | 7919 KB/sec ✔ | 28043 KB/sec ✔ |
## Browser Support
This polyfill will bring
support for TextEncoder/TextDecoder to the following browsers.
| Feature | Chrome <img src="https://developer.mozilla.org/static/browsers/chrome.svg" height="14" /> | Firefox <img src="https://developer.mozilla.org/static/browsers/firefox.svg" height="14" /> | Opera <img src="https://developer.mozilla.org/static/browsers/opera.svg" height="14" /> | Edge <img src="https://developer.mozilla.org/static/browsers/edge.svg" height="14" /> | Internet Explorer <img src="https://developer.mozilla.org/static/browsers/internet-explorer.svg" height="14" /> | Safari <img src="https://developer.mozilla.org/static/browsers/safari.svg" height="14" /> | Android <img src="https://developer.mozilla.org/static/platforms/android.svg" height="14" /> | Samsung Internet <img src="https://developer.mozilla.org/static/browsers/samsung-internet.svg" height="14" /> | Node.js <img src="https://nodejs.org/static/favicon.ico" height="14" /> |
| ------------------ | --- | --- | -------------------------------- | ------ | --- | ------------------------- | --- | --- | --- |
| Full Polyfill | [7.0](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray#Browser_compatibility) | [4.0](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray#Browser_compatibility) | [11.6](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray#Browser_compatibility) | [12.0\*\*](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray#Browser_compatibility) | [10](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray#Browser_compatibility) | [5.1](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray#Browser_compatibility) (Desktop) / [4.2](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray#Browser_compatibility) (iOS) | [4.0](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray#Browser_compatibility) | [1.0](https://gist.github.com/poshaughnessy/5718717a04db20a02e9fdb3fc16e2258) | [3.0](https://nodejs.org/docs/latest-v4.x/api/buffer.html#buffer_buffers_and_typedarray) |
| Partial Polyfill\* | [1.0\*\*](https://robertnyman.com/javascript/index.html) | [0.6](https://en.wikipedia.org/wiki/Comparison_of_JavaScript_engines) | [7.0](https://en.wikipedia.org/wiki/Presto_\(browser_engine\)) (Desktop) / [9.5\*\*](https://en.wikipedia.org/wiki/Presto_\(browser_engine\)) (Mobile) | [12.0\*\*](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray#Browser_compatibility) | [4.0](https://en.wikipedia.org/wiki/Comparison_of_JavaScript_engines) | [2.0](https://en.wikipedia.org/wiki/Comparison_of_JavaScript_engines) | 1.0\*\* | [1.0\*\*](https://gist.github.com/poshaughnessy/5718717a04db20a02e9fdb3fc16e2258) | [0.10](https://nodejs.org/docs/latest-v0.10.x/api/index.html) |
Also note that while this polyfill may work in these old browsers, it is very likely that the rest of one's website will not work unless if one makes a concious effort to have their code work in these old browsers.
\* Partial polyfill means that `Array` (or `Buffer` in NodeJS) will be used instead of `Uint8Array`/\[*typedarray*\].
\*\* This is the first public release of the browser
## API Documentation
Please review the MDN at [`window.TextEncoder`](https://developer.mozilla.org/en-US/docs/Web/API/TextEncoder) and [`window.TextDecoder`](https://developer.mozilla.org/en-US/docs/Web/API/TextDecoder) for information on how to use TextEncoder and TextDecoder.
As for NodeJS, calling `require("EncoderAndDecoderNodeJS.min.js")` yields the following object. Note that this polyfill checks for `global.TextEncoder` and `global.TextDecoder` and returns the native implementation if available.
```Javascript
module.exports = {
TextEncoder: function TextEncoder(){/*...*/},
TextDecoder: function TextDecoder(){/*...*/},
encode: TextEncoder.prototype.encode,
decode: TextDecoder.prototype.decode
}
```
In NodeJS, one does not ever have to use `new` just to get the encoder/decoder (although one still can do so if they want to). All of the code snippets below function identically <sub>(aside from unused local variables introduced into the scope)</sub>.
```Javascript
// Variation 1
const {TextEncoder, TextDecoder} = require("fastestsmallesttextencoderdecoder");
const encode = (new TextEncoder).encode;
const decode = (new TextDecoder).decode;
```
```Javascript
// Variation 2
const {encode, decode} = require("fastestsmallesttextencoderdecoder");
```
```Javascript
// Variation 3 (a rewording of Variation 2)
const encodeAndDecodeModule = require("fastestsmallesttextencoderdecoder");
const encode = encodeAndDecodeModule.encode;
const decode = encodeAndDecodeModule.decode;
```
Or, one can use the new and shiny [ES6 module importation](https://developer.mozilla.org/en-US/docs/web/javascript/reference/statements/import) statements.
```Javascript
// Variation 1
import {TextEncoder, TextDecoder} from "fastestsmallesttextencoderdecoder";
const encode = (new TextEncoder).encode;
const decode = (new TextDecoder).decode;
```
```Javascript
// Variation 2
import {encode, decode} from "fastestsmallesttextencoderdecoder";
```
```Javascript
// Variation 3 (a rewording of Variation 2)
import * as encodeAndDecodeModule from "fastestsmallesttextencoderdecoder";
const encode = encodeAndDecodeModule.encode;
const decode = encodeAndDecodeModule.decode;
```
## Demonstration
Visit the [GithubPage](https://anonyco.github.io/FastestSmallestTextEncoderDecoder/gh-pages/) to see a demonstation. As seen in the Web Worker [hexWorker.js](https://github.com/anonyco/FastestSmallestTextEncoderDecoder/blob/master/gh-pages/hexWorker.js), the Github Pages demonstration uses a special [encoderAndDecoderForced.src.js](https://github.com/anonyco/FastestSmallestTextEncoderDecoder/blob/master/gh-pages/encoderAndDecoderForced.src.js) version of this library to forcefully install the TextEncoder and TextDecoder even when there is native support. That way, this demonstraton should serve to truthfully demonstrate this polyfill.
## npm Project
This project can be found on [npm here at this link](https://npmjs.org/package/fastestsmallesttextencoderdecoder).
## Development
On Linux, the project can be developed by cloning it with the following command line. The development scripts are designed to be interpeted by Dash, and whether they work on Mac OS is unknown, but they certainly won't work on Windows.
```Bash
git clone https://github.com/anonyco/FastestSmallestTextEncoderDecoder.git; cd FastestSmallestTextEncoderDecoder; npm run install-dev
```
Emphasize the `npm run install-dev`, which downloads `closure-compiler.jar` into the repository for minifying the files.
Now that the repository is cloned, edit the files as one see fit. Do not edit the files in the `encodeInto` folder. Those are all auto-generated by having Closure Compiler set `ENCODEINTO_BUILD` to true and removing dead code for compactness. Also, do not run `npm run build` in the `encodeInto`. That's done automatically when `npm run build` is runned in the topmost folder. Now that the files have been edited, run the following in the terminal in the root folder of the repository in order to minify the NodeJS JavaScript files.
```Bash
npm run build
```
To edit tests, edit `test/node.js`. These tests are compared against the native implementation to ensure validity. To run tests, do the following.
```Bash
npm run test
```
## Continuity
Feel free to reach out to me at wowzeryest@gmail.com. I am fairly attentive to my github account, but in the unlikely event that issues/pulls start piling up, I of course welcome others to step in and contribute. I am widely open to input and collaboration from anyone on all of my projects.
================================================
FILE: encodeInto/NodeJS/EncoderAndDecoderNodeJS.min.mjs
================================================
'use strict';var e="undefined"==typeof global?"undefined"===typeof self?{}:self:global,q=String.fromCharCode,r={}.toString,t=e.SharedArrayBuffer,v=t?r.call(t):"",w=e.Uint8Array,x=w?r.call(ArrayBuffer.prototype):"",y=e.Buffer;try{!y&&e.require&&(y=e.require("Buffer"));var z=y.prototype,A=r.call(z)}catch(c){}var B=y.allocUnsafe,C=!!w&&!y,D=/[\x80-\uD7ff\uDC00-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]?/g,E=new Uint16Array(32),F=!y||!!w&&w.prototype.isPrototypeOf(z),H=G.prototype;function I(){}
function J(c){var a=c&&c.buffer||c,f=r.call(a);if(f!==x&&f!==A&&f!==v&&"[object ArrayBuffer]"!==f&&void 0!==c)throw TypeError("Failed to execute 'decode' on 'TextDecoder': The provided value is not of type '(ArrayBuffer or ArrayBufferView)'");c=F?new w(a):a||[];f=a="";for(var d=0,b=c.length|0,k=b-32|0,g,h,l=0,u=0,n,m=0,p=-1;d<b;){for(g=d<=k?32:b-d|0;m<g;d=d+1|0,m=m+1|0){h=c[d]&255;switch(h>>4){case 15:n=c[d=d+1|0]&255;if(2!==n>>6||247<h){d=d-1|0;break}l=(h&7)<<6|n&63;u=5;h=256;case 14:n=c[d=d+1|0]&
255,l<<=6,l|=(h&15)<<6|n&63,u=2===n>>6?u+4|0:24,h=h+256&768;case 13:case 12:n=c[d=d+1|0]&255,l<<=6,l|=(h&31)<<6|n&63,u=u+7|0,d<b&&2===n>>6&&l>>u&&1114112>l?(h=l,l=l-65536|0,0<=l&&(p=(l>>10)+55296|0,h=(l&1023)+56320|0,31>m?(E[m]=p,m=m+1|0,p=-1):(n=p,p=h,h=n))):(h>>=8,d=d-h-1|0,h=65533),l=u=0,g=d<=k?32:b-d|0;default:E[m]=h;continue;case 11:case 10:case 9:case 8:}E[m]=65533}f+=q(E[0],E[1],E[2],E[3],E[4],E[5],E[6],E[7],E[8],E[9],E[10],E[11],E[12],E[13],E[14],E[15],E[16],E[17],E[18],E[19],E[20],E[21],
E[22],E[23],E[24],E[25],E[26],E[27],E[28],E[29],E[30],E[31]);32>m&&(f=f.slice(0,m-32|0));if(d<b){if(E[0]=p,m=~p>>>31,p=-1,f.length<a.length)continue}else-1!==p&&(f+=q(p));a+=f;f=""}return a}I.prototype.decode=J;
function K(c){var a=c.charCodeAt(0)|0;if(55296<=a)if(56320>a)if(c=c.charCodeAt(1)|0,56320<=c&&57343>=c){if(a=(a<<10)+c-56613888|0,65535<a)return q(240|a>>18,128|a>>12&63,128|a>>6&63,128|a&63)}else a=65533;else 57343>=a&&(a=65533);return 2047>=a?q(192|a>>6,128|a&63):q(224|a>>12,128|a>>6&63,128|a&63)}function G(){}
function L(c){c=void 0===c?"":""+c;var a=c.length|0,f=C?new w((a<<1)+8|0):B?B((a<<1)+8|0):new y((a<<1)+8|0),d,b=0,k=!1;for(d=0;d<a;d=d+1|0,b=b+1|0){var g=c.charCodeAt(d)|0;if(127>=g)f[b]=g;else{if(2047>=g)f[b]=192|g>>6;else{a:{if(55296<=g)if(56320>g){var h=c.charCodeAt(d=d+1|0)|0;if(56320<=h&&57343>=h){g=(g<<10)+h-56613888|0;if(65535<g){f[b]=240|g>>18;f[b=b+1|0]=128|g>>12&63;f[b=b+1|0]=128|g>>6&63;f[b=b+1|0]=128|g&63;continue}break a}g=65533}else 57343>=g&&(g=65533);!k&&d<<1<b&&d<<1<(b-7|0)&&(k=!0,
h=C?new w(3*a):B?B(3*a):new y(3*a),h.set(f),f=h)}f[b]=224|g>>12;f[b=b+1|0]=128|g>>6&63}f[b=b+1|0]=128|g&63}}return f.subarray(0,b)}
function M(c,a){var f=void 0===c?"":(""+c).replace(D,K),d=f.length|0,b=0,k=0,g=a.length|0,h=c.length|0;g<d&&(d=g);a:for(;b<d;b=b+1|0){c=f.charCodeAt(b)|0;switch(c>>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:k=k+1|0;case 8:case 9:case 10:case 11:break;case 12:case 13:if((b+1|0)<g){k=k+1|0;break}case 14:if((b+2|0)<g){k=k+1|0;break}case 15:if((b+3|0)<g){k=k+1|0;break}default:break a}a[b]=c}return{written:b,read:h<k?h:k}}H.encode=L;H.encodeInto=M;
function N(c,a){var f=c[a];return function(){return f.apply(c,arguments)}}var O=e.TextDecoder,P=e.TextEncoder,Q,R=M;P&&(Q=new P,R=Q.encodeInto?N(Q,"encodeInto"):P.prototype.encodeInto=function(c,a){var f=c.length|0,d=a.length|0;if(f<d>>1){var b=Q.encode(c);if((b.length|0)<d)return a.set(b),{read:f,written:b.length|0}}return M(c,a)});
var TextDecoder=O||I,TextEncoder=P||G,decode=O?N(new O,"decode"):J,encode=P?N(Q,"encode"):L,encodeInto=R;export{TextDecoder,TextEncoder,decode,encode,encodeInto};//AnonyCo
//# sourceMappingURL=https://cdn.jsdelivr.net/gh/AnonyCo/FastestSmallestTextEncoderDecoder/encodeInto/NodeJS/EncoderAndDecoderNodeJS.min.mjs.map
================================================
FILE: encodeInto/README.md
================================================
Please see [fastestsmallesttextencoderdecoder](fastestsmallesttextencoderdecoder) for usage and details
================================================
FILE: encodeInto/package.json
================================================
{
"name": "fastestsmallesttextencoderdecoder-encodeinto",
"version": "1.0.22",
"description": "The fastest smallest Javascript polyfill for the encode of TextEncoder and decode of TextDecoder for UTF-8 only. Made by AnonyCo with ❤️ from 🐕s.",
"keywords": [
"utf-8",
"encoding",
"decoding",
"encoder",
"decoder",
"javascript",
"polyfill",
"js",
"utf8",
"compact",
"cross-browser",
"utf8-string",
"pure-javascript",
"nodejs",
"node-js",
"node-module",
"nodejs-modules",
"performance",
"tiny",
"small"
],
"homepage": "https://github.com/anonyco/FastestSmallestTextEncoderDecoder#quick-start",
"bugs": {
"url": "https://github.com/anonyco/FastestSmallestTextEncoderDecoder/issues",
"email": "wowzeryest@gmail.com"
},
"scripts": {
"install-dev": "mkdir compiler-latest 2> /dev/null; wget -P ./compiler-latest/ 'https://dl.google.com/closure-compiler/compiler-latest.tar.gz'; unlink ./closure-compiler.jar 2> /dev/null; wget -P ./compiler-latest/ 'https://github.com/google/zopfli/archive/zopfli-1.0.3.tar.gz'; cd compiler-latest; tar xvzf compiler-latest.tar.gz 1> /dev/null; tar xvzf compiler-latest.tar.gz 1> /dev/null; bash -c 'for j in closure-compiler-*; do mv -- \"$j\" \"../closure-compiler.jar\" 1> /dev/null; done' 1> /dev/null 2> /dev/null; tar xvzf zopfli-1.0.3.tar.gz 1> /dev/null; cd zopfli-zopfli-1.0.3; make zopfli 1> /dev/null; mv ./zopfli ../../; cd ../..; rm -rf compiler-latest 2> /dev/null; chmod +X ./zopfli; curl -V 1>/dev/null 2>&1 || (echo 'Curl must be installed in order to upload to NPM. Installing...'; if type apk > /dev/null; then sudo apk add --no-cache curl; elif type apt-get > /dev/null; then sudo apt-get install curl; elif type dnf > /dev/null; then sudo dnf install curl; elif type pacman > /dev/null; then pacman -S curl; elif type zypper > /dev/null; then sudo zypper install curl; fi ); wait",
"build": "if [ ! -s 'closure-compiler.jar' ]; then npm run install-dev; fi; npm run build-browser & npm run build-gzip; npm run build-encodeinto & true; npm run build-require & true; npm run build-module & true; wait",
"build-browser": "java -server -Xmx1024M -jar './closure-compiler.jar' --D ENCODEINTO_BUILD=true --js '../EncoderDecoderTogether.src.js' --js_output_file 'EncoderDecoderTogether.min.js' --create_source_map 'EncoderDecoderTogether.min.js.map' --language_out ECMASCRIPT_2017 --compilation_level ADVANCED_OPTIMIZATIONS --output_wrapper '%output%//AnonyCo\n//# sourceMappingURL=https://cdn.jsdelivr.net/gh/AnonyCo/FastestSmallestTextEncoderDecoder/encodeInto/EncoderDecoderTogether.min.js.map' & true; java -server -Xmx1024M -jar './closure-compiler.jar' --D ENCODEINTO_BUILD=true --js '../individual/FastestTextEncoderPolyfill.src.js' --js_output_file 'individual/FastestTextEncoderPolyfill.min.js' --language_out ECMASCRIPT_2017 --compilation_level ADVANCED_OPTIMIZATIONS --output_wrapper '%output%//AnonyCo'; wait; sed -i -e 's/\"undefined\"/\"\"+void 0/g' '../EncoderDecoderTogether.min.js' & true; if [ \"${PWD##*/}\" != 'encodeInto' ]; then java -server -Xmx1024M -jar './closure-compiler.jar' --js './individual/FastestTextDecoderPolyfill.src.js' --js_output_file 'individual/FastestTextDecoderPolyfill.min.js' --language_out ECMASCRIPT_2017 --compilation_level ADVANCED_OPTIMIZATIONS --output_wrapper '%output%//AnonyCo'; fi; wait",
"build-require": "java -server -Xmx1024M -jar './closure-compiler.jar' --D ENCODEINTO_BUILD=true --js '../NodeJS/EncoderAndDecoderNodeJS.src.js' --js_output_file 'NodeJS/EncoderAndDecoderNodeJS.min.js' --create_source_map 'NodeJS/EncoderAndDecoderNodeJS.min.js.map' --compilation_level ADVANCED_OPTIMIZATIONS --output_wrapper '%output%//AnonyCo\n//# sourceMappingURL=https://cdn.jsdelivr.net/gh/AnonyCo/FastestSmallestTextEncoderDecoder/encodeInto/NodeJS/EncoderAndDecoderNodeJS.min.js.map' --language_out ECMASCRIPT_2017",
"build-module": "java -server -Xmx1024M -jar './closure-compiler.jar' --D ENCODEINTO_BUILD=true --js '../NodeJS/EncoderAndDecoderNodeJS.src.module.js' --create_source_map 'NodeJS/EncoderAndDecoderNodeJS.min.mjs.map' --compilation_level ADVANCED_OPTIMIZATIONS --output_wrapper '%output%//AnonyCo\n//# sourceMappingURL=https://cdn.jsdelivr.net/gh/AnonyCo/FastestSmallestTextEncoderDecoder/encodeInto/NodeJS/EncoderAndDecoderNodeJS.min.mjs.map' --language_out ECMASCRIPT_2017 | sed -e 's@window\\.export_default=@export default @g; s@window\\.export_@export let @g; s@window\\.exports=\\[@export{@g; s@window\\.var_gens=\\[@@g; s@,\"_REMOVE@@g; s@REMOVE_\",@@g; s@REMOVE_\"@@g; s@,\"REM_B_\"\\]@}@g; s@,\"REM_VAR_\"\\]@@g; s@\"REM_VAR_\"\\]@@g; s@REM_VAR_\"\\]@@g' > 'NodeJS/EncoderAndDecoderNodeJS.min.mjs'",
"build-es6": "npm run build-module",
"build-gzip": "./zopfli -i20 EncoderDecoderTogether.min.js; mv EncoderDecoderTogether.min.js.gz test 2> /dev/null",
"build-encodeinto": "if [ \"${PWD##*/}\" != 'encodeInto' ]; then mkdir -p encodeInto; cd encodeInto; mkdir -p test individual NodeJS; echo 'Please see [fastestsmallesttextencoderdecoder](fastestsmallesttextencoderdecoder) for usage and details' > README.md; ln -fsT ../LICENSE LICENSE; ln -fsT '../closure-compiler.jar' 'closure-compiler.jar'; ln -fsT ../zopfli zopfli; sed -e 's@\"fastestsmallesttextencoderdecoder\"@\"fastestsmallesttextencoderdecoder-encodeinto\"@; s@E[N]CODEINTO_BUILD=false@ENCODEINTO_BUILD=true@g; s@gh/AnonyCo/[F]astestSmallestTextEncoderDecoder@gh/AnonyCo/FastestSmallestTextEncoderDecoder/encodeInto/encodeInto@g; s@[.]/EncoderDecoderTogether@..\\/EncoderDecoderTogether@g; s@[.]/NodeJS/@..\\/NodeJS/@g; s@[.]/individual/FastestTextEncoderPolyfill@..\\/individual/FastestTextEncoderPolyfill@g' > package.json < '../package.json'; cd test; for f in *; do if [ ! -e \"../../test/$f\" ]; then unlink \"$f\" 2> /dev/null; fi; done; for i in $(dir -Ab1L ../../test); do ln -fsT \"../../test/$i\" \"./$i\"; done; cd ..; npm run build; cd ..; printf '#!/bin/sh\nnpm install fastestsmallesttextencoderdecoder-encodeinto\n' > gh-pages/install-FastestSmallestTextEncoderDecoder-encodeInto.sh; printf '@npm install fastestsmallesttextencoderdecoder-encodeinto\r\n' > gh-pages/install-FastestSmallestTextEncoderDecoder-encodeInto.bat; fi; wait",
"prepublishOnly": "if [ -f './encodeInto/package.json' ]; then cd encodeInto; npm publish; cd ..; fi",
"test": "if [ \"${PWD##*/}\" != 'encodeInto' ]; then cd encodeInto/test; node --preserve-symlinks --preserve-symlinks-main -- 'test.js' -test-encode-into; cd ../..; fi; cd test; node --preserve-symlinks --preserve-symlinks-main -- 'test.js'",
"benchmark": "cd test; node --preserve-symlinks --preserve-symlinks-main --expose-gc --max-old-space-size=10240 --max-semi-space-size=8192 --noconcurrent_sweeping --nouse-idle-notification -- 'benchmark.js'"
},
"license": "CC0-1.0",
"author": {
"name": "Jack Giffin",
"email": "wowzeryest@gmail.com",
"url": "https://jackgiffin.com/"
},
"main": "NodeJS/EncoderAndDecoderNodeJS.min.js",
"module": "NodeJS/EncoderAndDecoderNodeJS.min.mjs",
"es2015": "NodeJS/EncoderAndDecoderNodeJS.min.mjs",
"browser": "EncoderDecoderTogether.min.js",
"repository": {
"type": "git",
"url": "git://github.com/anonyco/FastestSmallestTextEncoderDecoder.git"
},
"files": [
"EncoderDecoderTogether.min.js",
"NodeJS/EncoderAndDecoderNodeJS.min.js",
"NodeJS/EncoderAndDecoderNodeJS.min.mjs"
],
"publishConfig": { "registry": "https://registry.npmjs.org/" }
}
================================================
FILE: gh-pages/encoderAndDecoderForced.src.js
================================================
/** @define {boolean} */
var ENCODEINTO_BUILD = false;
(function(window){
"use strict";
//var log = Math.log;
//var LN2 = Math.LN2;
//var clz32 = Math.clz32 || function(x) {return 31 - log(x >> 0) / LN2 | 0};
var fromCharCode = String.fromCharCode;
var Object_prototype_toString = ({}).toString;
var sharedArrayBufferString = Object_prototype_toString.call(window["SharedArrayBuffer"]);
var undefinedObjectString = Object_prototype_toString();
var NativeUint8Array = window.Uint8Array;
var patchedU8Array = NativeUint8Array || Array;
var nativeArrayBuffer = NativeUint8Array ? ArrayBuffer : patchedU8Array;
var arrayBuffer_isView = nativeArrayBuffer.isView || function(x) {return x && "length" in x};
var arrayBufferString = Object_prototype_toString.call(nativeArrayBuffer.prototype);
var window_encodeURIComponent = encodeURIComponent;
var window_parseInt = parseInt;
var TextEncoderPrototype = TextEncoder["prototype"];
var GlobalTextEncoder = window["TextEncoder"];
var decoderRegexp = /[\xc0-\xff][\x80-\xbf]+|[\x80-\xff]/g;
var encoderRegexp = /[\x80-\uD7ff\uDC00-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]?/g;
var tmpBufferU16 = new (NativeUint8Array ? Uint16Array : patchedU8Array)(32);
var globalTextEncoderPrototype;
var globalTextEncoderInstance;
/*function decoderReplacer(encoded) {
var cp0 = encoded.charCodeAt(0), codePoint=0x110000, i=0, stringLen=encoded.length|0, result="";
switch(cp0 >> 4) {
// no 1 byte sequences
case 12:
case 13:
codePoint = ((cp0 & 0x1F) << 6) | (encoded.charCodeAt(1) & 0x3F);
i = codePoint < 0x80 ? 0 : 2;
break;
case 14:
codePoint = ((cp0 & 0x0F) << 12) | ((encoded.charCodeAt(1) & 0x3F) << 6) | (encoded.charCodeAt(2) & 0x3F);
i = codePoint < 0x800 ? 0 : 3;
break;
case 15:
if ((cp0 >> 3) === 30) {
codePoint = ((cp0 & 0x07) << 18) | ((encoded.charCodeAt(1) & 0x3F) << 12) | ((encoded.charCodeAt(2) & 0x3F) << 6) | (encoded.charCodeAt(3) & 0x3F);
i = codePoint < 0x10000 ? 0 : 4;
}
}
if (i) {
if (stringLen < i) {
i = 0;
} else if (codePoint < 0x10000) { // BMP code point
result = fromCharCode(codePoint);
} else if (codePoint < 0x110000) {
codePoint = codePoint - 0x10080|0;//- 0x10000|0;
result = fromCharCode(
(codePoint >> 10) + 0xD800|0, // highSurrogate
(codePoint & 0x3ff) + 0xDC00|0 // lowSurrogate
);
} else i = 0; // to fill it in with INVALIDs
}
for (; i < stringLen; i=i+1|0) result += "\ufffd"; // fill rest with replacement character
return result;
}*/
function TextDecoder(){};
TextDecoder["prototype"]["decode"] = function(inputArrayOrBuffer){
var inputAs8 = inputArrayOrBuffer, asObjectString;
if (!arrayBuffer_isView(inputAs8)) {
asObjectString = Object_prototype_toString.call(inputAs8);
if (asObjectString !== arrayBufferString && asObjectString !== sharedArrayBufferString && asObjectString !== undefinedObjectString)
throw TypeError("Failed to execute 'decode' on 'TextDecoder': The provided value is not of type '(ArrayBuffer or ArrayBufferView)'");
inputAs8 = NativeUint8Array ? new patchedU8Array(inputAs8) : inputAs8 || [];
}
var resultingString="", tmpStr="", index=0, len=inputAs8.length|0, lenMinus32=len-32|0, nextEnd=0, nextStop=0, cp0=0, codePoint=0, minBits=0, cp1=0, pos=0, tmp=-1;
// Note that tmp represents the 2nd half of a surrogate pair incase a surrogate gets divided between blocks
for (; index < len; ) {
nextEnd = index <= lenMinus32 ? 32 : len - index|0;
for (; pos < nextEnd; index=index+1|0, pos=pos+1|0) {
cp0 = inputAs8[index] & 0xff;
switch(cp0 >> 4) {
case 15:
cp1 = inputAs8[index=index+1|0] & 0xff;
if ((cp1 >> 6) !== 0b10 || 0b11110111 < cp0) {
index = index - 1|0;
break;
}
codePoint = ((cp0 & 0b111) << 6) | (cp1 & 0b00111111);
minBits = 5; // 20 ensures it never passes -> all invalid replacements
cp0 = 0x100; // keep track of th bit size
case 14:
cp1 = inputAs8[index=index+1|0] & 0xff;
codePoint <<= 6;
codePoint |= ((cp0 & 0b1111) << 6) | (cp1 & 0b00111111);
minBits = (cp1 >> 6) === 0b10 ? minBits + 4|0 : 24; // 24 ensures it never passes -> all invalid replacements
cp0 = (cp0 + 0x100) & 0x300; // keep track of th bit size
case 13:
case 12:
cp1 = inputAs8[index=index+1|0] & 0xff;
codePoint <<= 6;
codePoint |= ((cp0 & 0b11111) << 6) | cp1 & 0b00111111;
minBits = minBits + 7|0;
// Now, process the code point
if (index < len && (cp1 >> 6) === 0b10 && (codePoint >> minBits) && codePoint < 0x110000) {
cp0 = codePoint;
codePoint = codePoint - 0x10000|0;
if (0 <= codePoint/*0xffff < codePoint*/) { // BMP code point
//nextEnd = nextEnd - 1|0;
tmp = (codePoint >> 10) + 0xD800|0; // highSurrogate
cp0 = (codePoint & 0x3ff) + 0xDC00|0; // lowSurrogate (will be inserted later in the switch-statement)
if (pos < 31) { // notice 31 instead of 32
tmpBufferU16[pos] = tmp;
pos = pos + 1|0;
tmp = -1;
} else {// else, we are at the end of the inputAs8 and let tmp0 be filled in later on
// NOTE that cp1 is being used as a temporary variable for the swapping of tmp with cp0
cp1 = tmp;
tmp = cp0;
cp0 = cp1;
}
} else nextEnd = nextEnd + 1|0; // because we are advancing i without advancing pos
} else {
// invalid code point means replacing the whole thing with null replacement characters
cp0 >>= 8;
index = index - cp0 - 1|0; // reset index back to what it was before
cp0 = 0xfffd;
}
// Finally, reset the variables for the next go-around
minBits = 0;
codePoint = 0;
nextEnd = index <= lenMinus32 ? 32 : len - index|0;
default:
tmpBufferU16[pos] = cp0; // fill with invalid replacement character
continue;
case 11:
case 10:
case 9:
case 8:
}
tmpBufferU16[pos] = 0xfffd; // fill with invalid replacement character
}
tmpStr += fromCharCode(
tmpBufferU16[ 0], tmpBufferU16[ 1], tmpBufferU16[ 2], tmpBufferU16[ 3], tmpBufferU16[ 4], tmpBufferU16[ 5], tmpBufferU16[ 6], tmpBufferU16[ 7],
tmpBufferU16[ 8], tmpBufferU16[ 9], tmpBufferU16[10], tmpBufferU16[11], tmpBufferU16[12], tmpBufferU16[13], tmpBufferU16[14], tmpBufferU16[15],
tmpBufferU16[16], tmpBufferU16[17], tmpBufferU16[18], tmpBufferU16[19], tmpBufferU16[20], tmpBufferU16[21], tmpBufferU16[22], tmpBufferU16[23],
tmpBufferU16[24], tmpBufferU16[25], tmpBufferU16[26], tmpBufferU16[27], tmpBufferU16[28], tmpBufferU16[29], tmpBufferU16[30], tmpBufferU16[31]
);
if (pos < 32) tmpStr = tmpStr.slice(0, pos-32|0);//-(32-pos));
if (index < len) {
//fromCharCode.apply(0, tmpBufferU16 : NativeUint8Array ? tmpBufferU16.subarray(0,pos) : tmpBufferU16.slice(0,pos));
tmpBufferU16[0] = tmp;
pos = (~tmp) >>> 31;//tmp !== -1 ? 1 : 0;
tmp = -1;
if (tmpStr.length < resultingString.length) continue;
} else if (tmp !== -1) {
tmpStr += fromCharCode(tmp);
}
resultingString += tmpStr;
tmpStr = "";
}
return resultingString;
}
window["TextDecoder"] = TextDecoder;
//////////////////////////////////////////////////////////////////////////////////////
function encoderReplacer(nonAsciiChars){
// make the UTF string into a binary UTF-8 encoded string
var point = nonAsciiChars.charCodeAt(0)|0;
if (0xD800 <= point) {
if (point <= 0xDBFF) {
var nextcode = nonAsciiChars.charCodeAt(1)|0; // defaults to 0 when NaN, causing null replacement character
if (0xDC00 <= nextcode && nextcode <= 0xDFFF) {
//point = ((point - 0xD800)<<10) + nextcode - 0xDC00 + 0x10000|0;
point = (point<<10) + nextcode - 0x35fdc00|0;
if (point > 0xffff)
return fromCharCode(
(0x1e/*0b11110*/<<3) | (point>>18),
(0x2/*0b10*/<<6) | ((point>>12)&0x3f/*0b00111111*/),
(0x2/*0b10*/<<6) | ((point>>6)&0x3f/*0b00111111*/),
(0x2/*0b10*/<<6) | (point&0x3f/*0b00111111*/)
);
} else point = 65533/*0b1111111111111101*/;//return '\xEF\xBF\xBD';//fromCharCode(0xef, 0xbf, 0xbd);
} else if (point <= 0xDFFF) {
point = 65533/*0b1111111111111101*/;//return '\xEF\xBF\xBD';//fromCharCode(0xef, 0xbf, 0xbd);
}
}
/*if (point <= 0x007f) return nonAsciiChars;
else */if (point <= 0x07ff) {
return fromCharCode((0x6<<5)|(point>>6), (0x2<<6)|(point&0x3f));
} else return fromCharCode(
(0xe/*0b1110*/<<4) | (point>>12),
(0x2/*0b10*/<<6) | ((point>>6)&0x3f/*0b00111111*/),
(0x2/*0b10*/<<6) | (point&0x3f/*0b00111111*/)
);
}
function TextEncoder(){};
TextEncoderPrototype["encode"] = function(inputString){
// 0xc0 => 0b11000000; 0xff => 0b11111111; 0xc0-0xff => 0b11xxxxxx
// 0x80 => 0b10000000; 0xbf => 0b10111111; 0x80-0xbf => 0b10xxxxxx
var encodedString = inputString === void 0 ? "" : ("" + inputString), len=encodedString.length|0;
var result=new patchedU8Array((len << 1) + 9|0), tmpResult;
var i=0, pos=0, point=0, nextcode=0;
var upgradededArraySize=!NativeUint8Array; // normal arrays are auto-expanding
for (i=0; i<len; i=i+1|0, pos=pos+1|0) {
point = encodedString.charCodeAt(i)|0;
if (point <= 0x007f) {
result[pos] = point;
} else if (point <= 0x07ff) {
result[pos] = (0x6<<5)|(point>>6);
result[pos=pos+1|0] = (0x2<<6)|(point&0x3f);
} else {
if (0xD800 <= point) {
if (point <= 0xDBFF) {
nextcode = encodedString.charCodeAt(i=i+1|0)|0; // defaults to 0 when NaN, causing null replacement character
if (0xDC00 <= nextcode && nextcode <= 0xDFFF) {
//point = ((point - 0xD800)<<10) + nextcode - 0xDC00 + 0x10000|0;
point = (point<<10) + nextcode - 0x35fdc00|0;
if (point > 0xffff) {
result[pos] = (0x1e/*0b11110*/<<3) | (point>>18);
result[pos=pos+1|0] = (0x2/*0b10*/<<6) | ((point>>12)&0x3f/*0b00111111*/);
result[pos=pos+1|0] = (0x2/*0b10*/<<6) | ((point>>6)&0x3f/*0b00111111*/);
result[pos=pos+1|0] = (0x2/*0b10*/<<6) | (point&0x3f/*0b00111111*/);
continue;
}
} else point = 65533/*0b1111111111111101*/;//return '\xEF\xBF\xBD';//fromCharCode(0xef, 0xbf, 0xbd);
} else if (point <= 0xDFFF) {
point = 65533/*0b1111111111111101*/;//return '\xEF\xBF\xBD';//fromCharCode(0xef, 0xbf, 0xbd);
}
} else if (!upgradededArraySize && (i << 1) < pos && (i << 1) < (pos - 9|0)) {
upgradededArraySize = true;
tmpResult = new patchedU8Array(len * 3);
tmpResult.set( result );
result = tmpResult;
}
result[pos] = (0xe/*0b1110*/<<4) | (point>>12);
result[pos=pos+1|0] =(0x2/*0b10*/<<6) | ((point>>6)&0x3f/*0b00111111*/);
result[pos=pos+1|0] =(0x2/*0b10*/<<6) | (point&0x3f/*0b00111111*/);
}
}
return NativeUint8Array ? result.subarray(0, pos) : result.slice(0, pos);
};
function polyfill_encodeInto(inputString, u8Arr) {
var encodedString = inputString === void 0 ? "" : ("" + inputString).replace(encoderRegexp, encoderReplacer);
var len=encodedString.length|0, i=0, char=0, read=0, u8ArrLen = u8Arr.length|0, inputLength=inputString.length|0;
if (u8ArrLen < len) len=u8ArrLen;
putChars: for (; i<len; i=i+1|0) {
char = encodedString.charCodeAt(i) |0;
switch(char >> 4) {
case 0:
case 1:
case 2:
case 3:
case 4:
case 5:
case 6:
case 7:
read = read + 1|0;
// extension points:
case 8:
case 9:
case 10:
case 11:
break;
case 12:
case 13:
if ((i+1|0) < u8ArrLen) {
read = read + 1|0;
break;
}
case 14:
if ((i+2|0) < u8ArrLen) {
//if (!(char === 0xEF && encodedString.substr(i+1|0,2) === "\xBF\xBD"))
read = read + 1|0;
break;
}
case 15:
if ((i+3|0) < u8ArrLen) {
read = read + 1|0;
break;
}
default:
break putChars;
}
//read = read + ((char >> 6) !== 2) |0;
u8Arr[i] = char;
}
return {"written": i, "read": inputLength < read ? inputLength : read};
};
if (ENCODEINTO_BUILD) {
TextEncoderPrototype["encodeInto"] = polyfill_encodeInto;
}
window["TextEncoder"] = TextEncoder;
})(typeof global == "" + void 0 ? typeof self == "" + void 0 ? this : self : global);
================================================
FILE: gh-pages/hexWorker.js
================================================
importScripts("encoderAndDecoderForced.src.js");
onmessage= (function() {
var timingOut = false, binaryDataString="", hexadecimalString="", currentTextBuffer=null, currentHexBuffer=null;
const Uint8Array = self.Uint8Array;
const Object_prototype_toString = ({}).toString;
const ArrayBufferString = Object_prototype_toString.call(ArrayBuffer.prototype);
const setTimeout = self.setTimeout;
const TextEncoder_encode = (new TextEncoder).encode;
const TextDecoder_decode = (new TextDecoder).decode;
function convertToOrFromHex(){
timingOut = false;
if (currentHexBuffer !== null) {
hexadecimalString = TextDecoder_decode(currentHexBuffer);
currentHexBuffer = null;
postMessage({
"type": "hex",
"value": hexadecimalString
});
}
if (currentTextBuffer !== null) {
postMessage({
"type": "text",
"value": TextDecoder_decode(currentTextBuffer)
});
const inputAsU8Array = new Uint8Array(currentTextBuffer);
const len = inputAsU8Array.length|0;
currentTextBuffer = null; // reset it
let resultingString = "";
for (let i=0; i<len; i=i+1|0) resultingString += (
(i === 0 ? (inputAsU8Array[i]|0) < 16 ? "0" : "" : (inputAsU8Array[i]|0) < 16 ? " 0" : " ") +
(inputAsU8Array[i]|0).toString(16)
);
postMessage({
"type": "hex",
"value": resultingString
});
} else if (binaryDataString !== "") {
const inputAsU8Array = TextEncoder_encode(binaryDataString);
const len = inputAsU8Array.length|0;
binaryDataString = ""; // reset it
let resultingString = "";
for (let i=0; i<len; i=i+1|0) resultingString += (
(i === 0 ? (inputAsU8Array[i]|0) < 16 ? "0" : "" : (inputAsU8Array[i]|0) < 16 ? " 0" : " ") +
(inputAsU8Array[i]|0).toString(16)
);
postMessage({
"type": "hex",
"value": resultingString
});
} else if (hexadecimalString !== "") {
const strLen = hexadecimalString.length|0;
let hexadecimals = 0;
for (let i=0, code=0; i<strLen; i=i+1|0) {
code = hexadecimalString.charCodeAt(i)|0;
hexadecimals = hexadecimals + (
(48 <= code && code <= 57) | (
65 <= (code & 0xffdf/*0b11011111*/) &&
(code & 0xffdf/*0b11011111*/) <= 90
)
)|0;
}
const arrayLength = (hexadecimals+1) >> 1;
const resultingArray = new Uint8Array(arrayLength);
let resultingIndex = 0;
for (let i=0, code=0, lo=0, hi=0; i<strLen; ) {
code = hexadecimalString.charCodeAt(i)|0;
i = i + 1|0;
if (48 <= code && code <= 57) {
hi = code - 48 |0;
} else if (
65 <= (code & 0xffdf/*0b11011111*/) &&
(code & 0xffdf/*0b11011111*/) <= 90
) {
hi = (code & 0xffdf/*0b11011111*/) - 65 + 10 |0;
} else {
continue;
}
while (i < strLen) {
code = hexadecimalString.charCodeAt(i)|0;
i = i + 1|0;
if (48 <= code && code <= 57) {
hi <<= 4;
lo = code - 48|0;
break;
} else if (
65 <= (code & 0xffdf/*0b11011111*/) &&
(code & 0xffdf/*0b11011111*/) <= 90
) {
hi <<= 4;
lo = (code & 0xffdf/*0b11011111*/) - 65 + 10|0;
break;
}
}
resultingArray[resultingIndex] = hi | lo;
resultingIndex = resultingIndex + 1|0;
}
postMessage({
"type": "text",
"value": TextDecoder_decode(resultingArray)
});
}
binaryDataString = hexadecimalString = "";
currentTextBuffer = currentHexBuffer = null;
}
return function(evt){
var data = evt.data;
if (data && data["type"] === "text-buffer" && ArrayBufferString === Object_prototype_toString.call(data["value"])) {
binaryDataString = hexadecimalString = "";
currentHexBuffer = null;
currentTextBuffer = data["value"];
} else if (data && data["type"] === "hex-buffer" && ArrayBufferString === Object_prototype_toString.call(data["value"])) {
binaryDataString = hexadecimalString = "";
currentHexBuffer = null;
currentTextBuffer = data["value"];
} else if (data && data["type"] === "text" && typeof data["value"] === "string") {
currentTextBuffer = currentHexBuffer = null;
hexadecimalString = "";
binaryDataString = data["value"];
} else if (data && data["type"] === "hex" && typeof data["value"] === "string") {
currentTextBuffer = currentHexBuffer = null;
binaryDataString = "";
hexadecimalString = data["value"];
}
if (!timingOut) {
setTimeout(convertToOrFromHex, 1);
timingOut = true;
}
};
})();
================================================
FILE: gh-pages/index.html
================================================
<!doctype html>
<html lang="en"><head>
<link rel="preload" as="script" href="encoderAndDecoderForced.src.js" />
<link rel="preload" as="worker" href="hexWorker.js" />
<title>Fastest Smallest Text Encoder Demo</title>
</head><body>
<center><h1>Fastest Smallest Text Encoder Decoder Demo</h1></center>
<div class="flex-sliced-parent" id="horizontal-textareas">
<textarea id="rawText" class="flex-half-side">Example text content goes right here
╔══════════════════════════════════════════╗
║ ║
║ • ‘single’ and “double” quotes ║
║ ║
║ • Curly apostrophes: “We’ve been here” ║
║ ║
║ • Latin-1 apostrophe and accents: '´` ║
║ ║
║ • ‚deutsche‘ „Anführungszeichen“ ║
║ ║
║ • †, ‡, ‰, •, 3–4, —, −5/+5, ™, … ║
║ ║
║ • ASCII safety test: 1lI|, 0OD, 8B ║
║ ╭─────────╮ ║
║ • the euro symbol: │ 14.95 € │ ║
║ ╰─────────╯ ║
╚══════════════════════════════════════════╝</textarea>
<!--Source: https://www.w3.org/2001/06/utf-8-test/UTF-8-demo.html-->
<textarea id="hexaDecimal" class="flex-half-side"></textarea>
</div>
<div class="flex-sliced-parent">
<center class="flex-half-side"><input type="file" id="upload-text"/><button><label for="upload-text">Upload Text</label></button> <input type="button" value="Download Text" id="download-text"/></center>
<center class="flex-half-side"><input type="file" id="upload-hex"/><button><label for="upload-hex">Upload Hex</label></button> <input type="button" value="Download Hex" id="download-hex"/></center>
</div>
<style>
body {
display: -ms-flexbox;
display: flex;
-ms-flex-direction: column;
flex-direction: column;
min-height: calc(100vh - 1px);
width: calc(100vw - 1px);
margin: 0;
}
#horizontal-textareas {
/*Fill remaining vertical space*/
-ms-flex: 1;
flex-grow: 1;
}
.flex-sliced-parent {
display: -ms-flexbox;
display: flex;
-ms-flex-direction: row;
flex-direction: row;
-ms-flex-wrap: wrap;
flex-wrap: wrap;
}
.flex-half-side {
min-height: 1.4em;
-ms-flex: 1;
flex-grow: 1;
width: 50%;
min-width: 16em;
display: inline-block;
box-sizing: border-box;
margin: 0;
}
center.flex-half-side {
text-align: newspaper; /*internet explorer*/
text-align-last: justify;
}
textarea.flex-half-side {
white-space: pre-wrap;
resize: none!important;
}
#upload-text, #upload-hex {
position: fixed;
visibility: hidden;
}
</style>
<script>
(function(window, document){
"use strict";
const hexWorker = new Worker("hexWorker.js");
const rawTextElement = document.getElementById("rawText");
const hexaDecimalElement = document.getElementById("hexaDecimal");
hexWorker.addEventListener("message", function(evt) {
var data = evt && evt.data;
if (data && data["type"] === "text" && typeof data["value"] === "string") {
rawTextElement.value = "" + data["value"];
} else if (data && data["type"] === "hex" && typeof data["value"] === "string") {
hexaDecimalElement.value = "" + data["value"];
}
}, {passive: 1});
function whenTextChanges() {
if (rawTextElement.value !== "") {
hexWorker.postMessage({
"type": "text",
"value": ""+rawTextElement.value
});
} else {
hexaDecimalElement.value = "";
}
}
rawTextElement.addEventListener("change", whenTextChanges); // for IE
rawTextElement.addEventListener("input", whenTextChanges);
function whenHexChanges() {
if (hexaDecimalElement.value !== "") {
hexWorker.postMessage({
"type": "hex",
"value": ""+hexaDecimalElement.value
});
} else {
rawTextElement.value = "";
}
};
hexaDecimalElement.addEventListener("change", whenHexChanges); // for IE
hexaDecimalElement.addEventListener("input", whenHexChanges);
const uploadTextInput = document.getElementById("upload-text");
const downloadTextButton = document.getElementById("download-text");
uploadTextInput.addEventListener("change", function(){
var reader = new FileReader;
reader.onload = function(){
hexWorker.postMessage({
"type": "text-buffer",
"value": reader.result
}, [reader.result]);
};
reader.readAsArrayBuffer(uploadTextInput.files[0]);
uploadTextInput.value = null;
});
downloadTextButton.addEventListener("click", function(){
window["saveAs"](new Blob([rawTextElement.value], {"type":"text/plain"}), "text-view-FastestSmallestTextEncoderDecoder.txt");
});
const uploadHexInput = document.getElementById("upload-hex");
const downloadHexButton = document.getElementById("download-hex");
uploadHexInput.addEventListener("change", function(){
var reader = new FileReader;
reader.onload = function(){
hexWorker.postMessage({
"type": "hex-buffer",
"value": reader.result
}, [reader.result]);
};
reader.readAsArrayBuffer(uploadHexInput.files[0]);
uploadTextInput.value = null;
});
downloadHexButton.addEventListener("click", function(){
window["saveAs"](new Blob([hexaDecimalElement.value], {"type":"text/plain"}), "hex-view-FastestSmallestTextEncoderDecoder.txt");
});
whenTextChanges(); // present the hexadecimal to the user
})(window, document);
</script>
<a target="_blank" href="https://github.com/anonyco/FastestSmallestTextEncoderDecoder" class="github-corner" aria-label="View source on GitHub"><svg width="80" height="80" viewBox="0 0 250 250" style="fill:#151513; color:#fff; position: absolute; top: 0; border: 0; right: 0;" aria-hidden="true"><path d="M0,0 L115,115 L130,115 L142,142 L250,250 L250,0 Z"></path><path d="M128.3,109.0 C113.8,99.7 119.0,89.6 119.0,89.6 C122.0,82.7 120.5,78.6 120.5,78.6 C119.2,72.0 123.4,76.3 123.4,76.3 C127.3,80.9 125.5,87.3 125.5,87.3 C122.9,97.6 130.6,101.9 134.4,103.2" fill="currentColor" style="transform-origin: 130px 106px;" class="octo-arm"></path><path d="M115.0,115.0 C114.9,115.1 118.7,116.5 119.8,115.4 L133.7,101.6 C136.9,99.2 139.9,98.4 142.2,98.6 C133.8,88.0 127.5,74.4 143.8,58.0 C148.5,53.4 154.0,51.2 159.7,51.0 C160.3,49.4 163.2,43.6 171.4,40.1 C171.4,40.1 176.1,42.5 178.8,56.2 C183.1,58.6 187.2,61.8 190.9,65.4 C194.5,69.0 197.7,73.2 200.1,77.6 C213.8,80.2 216.3,84.9 216.3,84.9 C212.7,93.1 206.9,96.0 205.4,96.6 C205.1,102.4 203.0,107.8 198.3,112.5 C181.9,128.9 168.3,122.5 157.7,114.1 C157.9,116.9 156.7,120.9 152.7,124.9 L141.0,136.5 C139.8,137.7 141.6,141.9 141.8,141.8 Z" fill="currentColor" class="octo-body"></path></svg></a><style>.github-corner:hover .octo-arm{animation:octocat-wave 560ms ease-in-out}@keyframes octocat-wave{0%,100%{transform:rotate(0)}20%,60%{transform:rotate(-25deg)}40%,80%{transform:rotate(10deg)}}@media (max-width:500px){.github-corner:hover .octo-arm{animation:none}.github-corner .octo-arm{animation:octocat-wave 560ms ease-in-out}}</style>
<script src="https://cdnjs.cloudflare.com/ajax/libs/FileSaver.js/1.3.8/FileSaver.min.js" async="" defer=""></script>
</body></html>
================================================
FILE: gh-pages/install-FastestSmallestTextEncoderDecoder-encodeInto.bat
================================================
@npm install fastestsmallesttextencoderdecoder-encodeinto
================================================
FILE: gh-pages/install-FastestSmallestTextEncoderDecoder-encodeInto.sh
================================================
#!/bin/sh
npm install fastestsmallesttextencoderdecoder-encodeinto
================================================
FILE: gh-pages/install-FastestSmallestTextEncoderDecoder-unix.sh
================================================
#!/bin/sh
npm install fastestsmallesttextencoderdecoder
================================================
FILE: gh-pages/install-FastestSmallestTextEncoderDecoder-windows.bat
================================================
@npm install fastestsmallesttextencoderdecoder
================================================
FILE: individual/FastestTextDecoderPolyfill.src.js
================================================
(function(window){
"use strict";
var log = Math.log;
var LN2 = Math.LN2;
var clz32 = Math.clz32 || function(x) {return 31 - log(x >>> 0) / LN2 | 0};
var fromCharCode = String.fromCharCode;
var Object_prototype_toString = ({}).toString;
var NativeSharedArrayBuffer = window["SharedArrayBuffer"];
var sharedArrayBufferString = NativeSharedArrayBuffer ? Object_prototype_toString.call(NativeSharedArrayBuffer) : "";
var NativeUint8Array = window.Uint8Array;
var patchedU8Array = NativeUint8Array || Array;
var arrayBufferString = Object_prototype_toString.call((NativeUint8Array ? ArrayBuffer : patchedU8Array).prototype);
function decoderReplacer(encoded){
var cp0 = encoded.charCodeAt(0), codePoint=0x110000, i=0, stringLen=encoded.length|0, result="";
switch(cp0 >>> 4) {
// no 1 byte sequences
case 12:
case 13:
codePoint = ((cp0 & 0x1F) << 6) | (encoded.charCodeAt(1) & 0x3F);
i = codePoint < 0x80 ? 0 : 2;
break;
case 14:
codePoint = ((cp0 & 0x0F) << 12) | ((encoded.charCodeAt(1) & 0x3F) << 6) | (encoded.charCodeAt(2) & 0x3F);
i = codePoint < 0x800 ? 0 : 3;
break;
case 15:
if ((cp0 >>> 3) === 30) {
codePoint = ((cp0 & 0x07) << 18) | ((encoded.charCodeAt(1) & 0x3F) << 12) | ((encoded.charCodeAt(2) & 0x3F) << 6) | encoded.charCodeAt(3);
i = codePoint < 0x10000 ? 0 : 4;
}
}
if (i) {
if (stringLen < i) {
i = 0;
} else if (codePoint < 0x10000) { // BMP code point
result = fromCharCode(codePoint);
} else if (codePoint < 0x110000) {
codePoint = codePoint - 0x10080|0;//- 0x10000|0;
result = fromCharCode(
(codePoint >>> 10) + 0xD800|0, // highSurrogate
(codePoint & 0x3ff) + 0xDC00|0 // lowSurrogate
);
} else i = 0; // to fill it in with INVALIDs
}
for (; i < stringLen; i=i+1|0) result += "\ufffd"; // fill rest with replacement character
return result;
}
function TextDecoder(_, opts){/*this["ignoreBOM"] = !!opts && !!opts["ignoreBOM"]*/};
TextDecoder["prototype"]["decode"] = function(inputArrayOrBuffer){
var buffer = (inputArrayOrBuffer && inputArrayOrBuffer.buffer) || inputArrayOrBuffer;
var asObjectString = Object_prototype_toString.call(buffer);
if (asObjectString !== arrayBufferString && asObjectString !== sharedArrayBufferString && inputArrayOrBuffer !== undefined)
throw TypeError("Failed to execute 'decode' on 'TextDecoder': The provided value is not of type '(ArrayBuffer or ArrayBufferView)'");
var inputAs8 = NativeUint8Array ? new patchedU8Array(buffer) : buffer;
var resultingString = "";
for (var index=0/*inputAs8[0]!==0xEF||inputAs8[1]!==0xBB||inputAs8[2]!==0xBF||this["ignoreBOM"]?0:3*/,len=inputAs8.length|0; index<len; index=index+32768|0)
resultingString += fromCharCode.apply(0, inputAs8[NativeUint8Array ? "subarray" : "slice"](index,index+32768|0));
return resultingString.replace(/[\xc0-\xff][\x80-\xbf]+|[\x80-\xff]/g, decoderReplacer);
}
if (!window["TextDecoder"]) window["TextDecoder"] = TextDecoder;
})(typeof global == "" + void 0 ? typeof self == "" + void 0 ? this : self : global);
================================================
FILE: individual/FastestTextEncoderPolyfill.src.js
================================================
/** @define {boolean} */
var ENCODEINTO_BUILD = true;
(function(window){
"use strict";
var log = Math.log;
var LN2 = Math.LN2;
var clz32 = Math.clz32 || function(x) {return 31 - log(x >>> 0) / LN2 | 0};
var fromCharCode = String.fromCharCode;
var patchedU8Array = window.Uint8Array || Array;
var TextEncoderPrototype = TextEncoder["prototype"];
var GlobalTextEncoder = window["TextEncoder"];
var globalTextEncoderPrototype;
var globalTextEncoderInstance;
//////////////////////////////////////////////////////////////////////////////////////
function encoderReplacer(nonAsciiChars){
// make the UTF string into a binary UTF-8 encoded string
var point = nonAsciiChars.charCodeAt(0)|0;
if (0xD800 <= point) {
if (point < 0xDC00) {
var nextcode = nonAsciiChars.charCodeAt(1)|0; // defaults to 0 when NaN, causing null replacement character
if (0xDC00 <= nextcode && nextcode <= 0xDFFF) {
//point = ((point - 0xD800)<<10) + nextcode - 0xDC00 + 0x10000|0;
point = (point<<10) + nextcode - 0x35fdc00|0;
if (point > 0xffff)
return fromCharCode(
(0x1e/*0b11110*/<<3) | (point>>>18),
(0x2/*0b10*/<<6) | ((point>>>12)&0x3f/*0b00111111*/),
(0x2/*0b10*/<<6) | ((point>>>6)&0x3f/*0b00111111*/),
(0x2/*0b10*/<<6) | (point&0x3f/*0b00111111*/)
);
} else point = 65533/*0b1111111111111101*/;//return '\xEF\xBF\xBD';//fromCharCode(0xef, 0xbf, 0xbd);
} else if (point <= 0xDFFF) {
point = 65533/*0b1111111111111101*/;//return '\xEF\xBF\xBD';//fromCharCode(0xef, 0xbf, 0xbd);
}
}
/*if (point <= 0x007f) return nonAsciiChars;
else */if (point <= 0x07ff) {
return fromCharCode((0x6<<5)|(point>>>6), (0x2<<6)|(point&0x3f));
} else return fromCharCode(
(0xe/*0b1110*/<<4) | (point>>>12),
(0x2/*0b10*/<<6) | ((point>>>6)&0x3f/*0b00111111*/),
(0x2/*0b10*/<<6) | (point&0x3f/*0b00111111*/)
);
}
function TextEncoder(){};
TextEncoderPrototype["encode"] = function(inputString) {
// 0xc0 => 0b11000000; 0xff => 0b11111111; 0xc0-0xff => 0b11xxxxxx
// 0x80 => 0b10000000; 0xbf => 0b10111111; 0x80-0xbf => 0b10xxxxxx
var encodedString = inputString === void 0 ? "" : ("" + inputString).replace(/[\x80-\uD7ff\uDC00-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]?/g, encoderReplacer);
var len=encodedString.length|0, result = new patchedU8Array(len);
var i=0;
for (; i<len; i=i+1|0)
result[i] = encodedString.charCodeAt(i) |0;
return result;
};
function polyfill_encodeInto(inputString, u8Arr) {
var encodedString = inputString === void 0 ? "" : ("" + inputString).replace(/[\x80-\uD7ff\uDC00-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]?/g, encoderReplacer);
var len=encodedString.length|0, i=0, char=0, read=0, u8ArrLen = u8Arr.length|0, inputLength=inputString.length|0;
if (u8ArrLen < len) len=u8ArrLen;
putChars: {
for (; i<len; i=i+1|0) {
char = encodedString.charCodeAt(i) |0;
switch(char >>> 4) {
case 0:
case 1:
case 2:
case 3:
case 4:
case 5:
case 6:
case 7:
read = read + 1|0;
// extension points:
case 8:
case 9:
case 10:
case 11:
break;
case 12:
case 13:
if ((i+1|0) < u8ArrLen) {
read = read + 1|0;
break;
}
case 14:
if ((i+2|0) < u8ArrLen) {
read = read + 1|0;
break;
}
case 15:
if ((i+3|0) < u8ArrLen) {
read = read + 1|0;
break;
}
default:
break putChars;
}
//read = read + ((char >>> 6) !== 2) |0;
u8Arr[i] = char;
}
}
return {"written": i, "read": inputLength < read ? inputLength : read};
// 0xc0 => 0b11000000; 0xff => 0b11111111; 0xc0-0xff => 0b11xxxxxx
// 0x80 => 0b10000000; 0xbf => 0b10111111; 0x80-0xbf => 0b10xxxxxx
/*var encodedString = typeof inputString == "string" ? inputString : inputString === void 0 ? "" : "" + inputString;
var encodedLen = encodedString.length|0, u8LenLeft=u8Arr.length|0;
var i=-1, read=-1, code=0, point=0, nextcode=0;
tryFast: if (2 < encodedLen && encodedLen < (u8LenLeft >> 1)) {
// Skip the normal checks because we can almost certainly fit the string inside the existing buffer
while (1) { // make the UTF string into a binary UTF-8 encoded string
point = encodedString.charCodeAt(read = read + 1|0)|0;
if (point <= 0x007f) {
if (point === 0 && encodedLen <= read) {
read = read - 1|0;
break; // we have reached the end of the string
}
u8Arr[i=i+1|0] = point;
} else if (point <= 0x07ff) {
u8Arr[i=i+1|0] = (0x6<<5)|(point>>>6);
u8Arr[i=i+1|0] = (0x2<<6)|(point&0x3f);
} else {
if (0xD800 <= point && point < 0xDC00) {
nextcode = encodedString.charCodeAt(read)|0; // defaults to 0 when NaN, causing null replacement character
if (0xDC00 <= nextcode && nextcode <= 0xDFFF) {
read = read + 1|0;
//point = ((point - 0xD800)<<10) + nextcode - 0xDC00 + 0x10000|0;
point = (point<<10) + nextcode - 0x35fdc00|0;
if (point > 0xffff) {
u8Arr[i=i+1|0] = (0x1e<<3) | (point>>>18);
u8Arr[i=i+1|0] = (0x2<<6) | ((point>>>12)&0x3f);
u8Arr[i=i+1|0] = (0x2<<6) | ((point>>>6)&0x3f);
u8Arr[i=i+1|0] = (0x2<<6) | (point&0x3f);
continue;
}
} else if (nextcode === 0 && encodedLen <= read) {
break; // we have reached the end of the string
} else {
point = 65533;//0b1111111111111101; // invalid replacement character
}
}
u8Arr[i=i+1|0] = (0xe<<4) | (point>>>12);
u8Arr[i=i+1|0] = (0x2<<6) | ((point>>>6)&0x3f);
u8Arr[i=i+1|0] = (0x2<<6) | (point&0x3f);
if (u8LenLeft < (i + ((encodedLen - read) << 1)|0)) {
// These 3x chars are the only way to inflate the size to 3x
u8LenLeft = u8LenLeft - i|0;
break tryFast;
}
}
}
u8LenLeft = 0; // skip the next for-loop
}
for (; 0 < u8LenLeft; ) { // make the UTF string into a binary UTF-8 encoded string
point = encodedString.charCodeAt(read = read + 1|0)|0;
if (point <= 0x007f) {
if (point === 0 && encodedLen <= read) {
read = read - 1|0;
break; // we have reached the end of the string
}
u8LenLeft = u8LenLeft - 1|0;
u8Arr[i=i+1|0] = point;
} else if (point <= 0x07ff) {
u8LenLeft = u8LenLeft - 2|0;
if (0 <= u8LenLeft) {
u8Arr[i=i+1|0] = (0x6<<5)|(point>>>6);
u8Arr[i=i+1|0] = (0x2<<6)|(point&0x3f);
}
} else {
if (0xD800 <= point) {
if (point < 0xDC00) {
nextcode = encodedString.charCodeAt(read = read + 1|0)|0; // defaults to 0 when NaN, causing null replacement character
if (0xDC00 <= nextcode && nextcode <= 0xDFFF) {
read = read + 1|0;
//point = ((point - 0xD800)<<10) + nextcode - 0xDC00 + 0x10000|0;
point = (point<<10) + nextcode - 0x35fdc00|0;
if (point > 0xffff) {
u8LenLeft = u8LenLeft - 4|0;
if (0 <= u8LenLeft) {
u8Arr[i=i+1|0] = (0x1e<<3) | (point>>>18);
u8Arr[i=i+1|0] = (0x2<<6) | ((point>>>12)&0x3f);
u8Arr[i=i+1|0] = (0x2<<6) | ((point>>>6)&0x3f);
u8Arr[i=i+1|0] = (0x2<<6) | (point&0x3f);
}
continue;
}
} else if (nextcode === 0 && encodedLen <= read) {
break; // we have reached the end of the string
} else {
point = 65533;//0b1111111111111101; // invalid replacement character
}
} else if (point <= 0xDFFF) {
point = 65533/*0b1111111111111101*\/;//return '\xEF\xBF\xBD';//fromCharCode(0xef, 0xbf, 0xbd);
}
}
u8LenLeft = u8LenLeft - 3|0;
if (0 <= u8LenLeft) {
u8Arr[i=i+1|0] = (0xe<<<4) | (point>>>12);
u8Arr[i=i+1|0] = (0x2<<6) | ((point>>>6)&0x3f);
u8Arr[i=i+1|0] = (0x2<<6) | (point&0x3f);
}
}
}
return {"read": read < 0 ? 0 : u8LenLeft < 0 ? read : read+1|0, "written": i < 0 ? 0 : i+1|0};*/
};
if (ENCODEINTO_BUILD) {
TextEncoderPrototype["encodeInto"] = polyfill_encodeInto;
}
if (!GlobalTextEncoder) {
window["TextEncoder"] = TextEncoder;
} else if (ENCODEINTO_BUILD && !(globalTextEncoderPrototype = GlobalTextEncoder["prototype"])["encodeInto"]) {
globalTextEncoderInstance = new GlobalTextEncoder;
globalTextEncoderPrototype["encodeInto"] = function(string, u8arr) {
// Unfortunately, there's no way I can think of to quickly extract the number of bits written and the number of bytes read and such
var strLen = string.length|0, u8Len = u8arr.length|0;
if (strLen < ((u8Len >> 1) + 3|0)) { // in most circumstances, this means its safe. there are still edge-cases which are possible
// in many circumstances, we can use the faster native TextEncoder
var res8 = globalTextEncoderInstance["encode"](string);
var res8Len = res8.length|0;
if (res8Len < u8Len) { // if we dont have to worry about read/written
u8arr.set( res8 );
return {
"read": strLen,
"written": res8.length|0
};
}
}
return polyfill_encodeInto(string, u8arr);
};
}
})(typeof global == "" + void 0 ? typeof self == "" + void 0 ? this : self : global);
================================================
FILE: package.json
================================================
{
"name": "fastestsmallesttextencoderdecoder",
"version": "1.0.22",
"description": "The fastest smallest Javascript polyfill for the encode of TextEncoder and decode of TextDecoder for UTF-8 only. Made by AnonyCo with ❤️ from 🐕s.",
"keywords": [
"utf-8",
"encoding",
"decoding",
"encoder",
"decoder",
"javascript",
"polyfill",
"js",
"utf8",
"compact",
"cross-browser",
"utf8-string",
"pure-javascript",
"nodejs",
"node-js",
"node-module",
"nodejs-modules",
"performance",
"tiny",
"small"
],
"homepage": "https://github.com/anonyco/FastestSmallestTextEncoderDecoder#quick-start",
"bugs": {
"url": "https://github.com/anonyco/FastestSmallestTextEncoderDecoder/issues",
"email": "wowzeryest@gmail.com"
},
"scripts": {
"install-dev": "mkdir compiler-latest 2> /dev/null; wget -P ./compiler-latest/ 'https://dl.google.com/closure-compiler/compiler-latest.tar.gz'; unlink ./closure-compiler.jar 2> /dev/null; wget -P ./compiler-latest/ 'https://github.com/google/zopfli/archive/zopfli-1.0.3.tar.gz'; cd compiler-latest; tar xvzf compiler-latest.tar.gz 1> /dev/null; tar xvzf compiler-latest.tar.gz 1> /dev/null; bash -c 'for j in closure-compiler-*; do mv -- \"$j\" \"../closure-compiler.jar\" 1> /dev/null; done' 1> /dev/null 2> /dev/null; tar xvzf zopfli-1.0.3.tar.gz 1> /dev/null; cd zopfli-zopfli-1.0.3; make zopfli 1> /dev/null; mv ./zopfli ../../; cd ../..; rm -rf compiler-latest 2> /dev/null; chmod +X ./zopfli; curl -V 1>/dev/null 2>&1 || (echo 'Curl must be installed in order to upload to NPM. Installing...'; if type apk > /dev/null; then sudo apk add --no-cache curl; elif type apt-get > /dev/null; then sudo apt-get install curl; elif type dnf > /dev/null; then sudo dnf install curl; elif type pacman > /dev/null; then pacman -S curl; elif type zypper > /dev/null; then sudo zypper install curl; fi ); wait",
"build": "if [ ! -s 'closure-compiler.jar' ]; then npm run install-dev; fi; npm run build-browser & npm run build-gzip; npm run build-encodeinto & true; npm run build-require & true; npm run build-module & true; wait",
"build-browser": "java -server -Xmx1024M -jar './closure-compiler.jar' --D ENCODEINTO_BUILD=false --js './EncoderDecoderTogether.src.js' --js_output_file 'EncoderDecoderTogether.min.js' --create_source_map 'EncoderDecoderTogether.min.js.map' --language_out ECMASCRIPT_2017 --compilation_level ADVANCED_OPTIMIZATIONS --output_wrapper '%output%//AnonyCo\n//# sourceMappingURL=https://cdn.jsdelivr.net/gh/AnonyCo/FastestSmallestTextEncoderDecoder/EncoderDecoderTogether.min.js.map' & true; java -server -Xmx1024M -jar './closure-compiler.jar' --D ENCODEINTO_BUILD=false --js './individual/FastestTextEncoderPolyfill.src.js' --js_output_file 'individual/FastestTextEncoderPolyfill.min.js' --language_out ECMASCRIPT_2017 --compilation_level ADVANCED_OPTIMIZATIONS --output_wrapper '%output%//AnonyCo'; wait; sed -i -e 's/\"undefined\"/\"\"+void 0/g' './EncoderDecoderTogether.min.js' & true; if [ \"${PWD##*/}\" != 'encodeInto' ]; then java -server -Xmx1024M -jar './closure-compiler.jar' --js './individual/FastestTextDecoderPolyfill.src.js' --js_output_file 'individual/FastestTextDecoderPolyfill.min.js' --language_out ECMASCRIPT_2017 --compilation_level ADVANCED_OPTIMIZATIONS --output_wrapper '%output%//AnonyCo'; fi; wait",
"build-require": "java -server -Xmx1024M -jar './closure-compiler.jar' --D ENCODEINTO_BUILD=false --js './NodeJS/EncoderAndDecoderNodeJS.src.js' --js_output_file 'NodeJS/EncoderAndDecoderNodeJS.min.js' --create_source_map 'NodeJS/EncoderAndDecoderNodeJS.min.js.map' --compilation_level ADVANCED_OPTIMIZATIONS --output_wrapper '%output%//AnonyCo\n//# sourceMappingURL=https://cdn.jsdelivr.net/gh/AnonyCo/FastestSmallestTextEncoderDecoder/NodeJS/EncoderAndDecoderNodeJS.min.js.map' --language_out ECMASCRIPT_2017",
"build-module": "java -server -Xmx1024M -jar './closure-compiler.jar' --D ENCODEINTO_BUILD=false --js './NodeJS/EncoderAndDecoderNodeJS.src.module.js' --create_source_map 'NodeJS/EncoderAndDecoderNodeJS.min.mjs.map' --compilation_level ADVANCED_OPTIMIZATIONS --output_wrapper '%output%//AnonyCo\n//# sourceMappingURL=https://cdn.jsdelivr.net/gh/AnonyCo/FastestSmallestTextEncoderDecoder/NodeJS/EncoderAndDecoderNodeJS.min.mjs.map' --language_out ECMASCRIPT_2017 | sed -e 's@window\\.export_default=@export default @g; s@window\\.export_@export let @g; s@window\\.exports=\\[@export{@g; s@window\\.var_gens=\\[@@g; s@,\"_REMOVE@@g; s@REMOVE_\",@@g; s@REMOVE_\"@@g; s@,\"REM_B_\"\\]@}@g; s@,\"REM_VAR_\"\\]@@g; s@\"REM_VAR_\"\\]@@g; s@REM_VAR_\"\\]@@g' > 'NodeJS/EncoderAndDecoderNodeJS.min.mjs'",
"build-es6": "npm run build-module",
"build-gzip": "./zopfli -i20 EncoderDecoderTogether.min.js; mv EncoderDecoderTogether.min.js.gz test 2> /dev/null",
"build-encodeinto": "if [ \"${PWD##*/}\" != 'encodeInto' ]; then mkdir -p encodeInto; cd encodeInto; mkdir -p test individual NodeJS; echo 'Please see [fastestsmallesttextencoderdecoder](fastestsmallesttextencoderdecoder) for usage and details' > README.md; ln -fsT ../LICENSE LICENSE; ln -fsT '../closure-compiler.jar' 'closure-compiler.jar'; ln -fsT ../zopfli zopfli; sed -e 's@\"fastestsmallesttextencoderdecoder\"@\"fastestsmallesttextencoderdecoder-encodeinto\"@; s@E[N]CODEINTO_BUILD=false@ENCODEINTO_BUILD=true@g; s@gh/AnonyCo/[F]astestSmallestTextEncoderDecoder@gh/AnonyCo/FastestSmallestTextEncoderDecoder/encodeInto@g; s@[.]/EncoderDecoderTogether@..\\/EncoderDecoderTogether@g; s@[.]/NodeJS/@..\\/NodeJS/@g; s@[.]/individual/FastestTextEncoderPolyfill@..\\/individual/FastestTextEncoderPolyfill@g' > package.json < '../package.json'; cd test; for f in *; do if [ ! -e \"../../test/$f\" ]; then unlink \"$f\" 2> /dev/null; fi; done; for i in $(dir -Ab1L ../../test); do ln -fsT \"../../test/$i\" \"./$i\"; done; cd ..; npm run build; cd ..; printf '#!/bin/sh\nnpm install fastestsmallesttextencoderdecoder-encodeinto\n' > gh-pages/install-FastestSmallestTextEncoderDecoder-encodeInto.sh; printf '@npm install fastestsmallesttextencoderdecoder-encodeinto\r\n' > gh-pages/install-FastestSmallestTextEncoderDecoder-encodeInto.bat; fi; wait",
"prepublishOnly": "if [ -f './encodeInto/package.json' ]; then cd encodeInto; npm publish; cd ..; fi",
"test": "if [ \"${PWD##*/}\" != 'encodeInto' ]; then cd encodeInto/test; node --preserve-symlinks --preserve-symlinks-main -- 'test.js' -test-encode-into; cd ../..; fi; cd test; node --preserve-symlinks --preserve-symlinks-main -- 'test.js'",
"benchmark": "cd test; node --preserve-symlinks --preserve-symlinks-main --expose-gc --max-old-space-size=10240 --max-semi-space-size=8192 --noconcurrent_sweeping --nouse-idle-notification -- 'benchmark.js'"
},
"license": "CC0-1.0",
"author": {
"name": "Jack Giffin",
"email": "wowzeryest@gmail.com",
"url": "https://jackgiffin.com/"
},
"main": "NodeJS/EncoderAndDecoderNodeJS.min.js",
"module": "NodeJS/EncoderAndDecoderNodeJS.min.mjs",
"es2015": "NodeJS/EncoderAndDecoderNodeJS.min.mjs",
"browser": "EncoderDecoderTogether.min.js",
"repository": {
"type": "git",
"url": "git://github.com/anonyco/FastestSmallestTextEncoderDecoder.git"
},
"files": [
"EncoderDecoderTogether.min.js",
"NodeJS/EncoderAndDecoderNodeJS.min.js",
"NodeJS/EncoderAndDecoderNodeJS.min.mjs"
],
"publishConfig": { "registry": "https://registry.npmjs.org/" }
}
================================================
FILE: test/1876 The Russian Synodal Bible.txt
================================================
Skip to main content
This banner text can have markup.
web
books
video
audio
software
images
Toggle navigation
ABOUT
CONTACT
BLOG
PROJECTS
HELP
DONATE
JOBS
VOLUNTEER
PEOPLE
search
Search metadata
Search text contents
Search TV news captions
Search archived web sites
Advanced Search
uploadUPLOAD
person
Sign up for free
Log in
SIGN UP
/
LOG IN
ABOUT
CONTACT
BLOG
PROJECTS
HELP
DONATE
JOBS
VOLUNTEER
PEOPLE
Search the history of over 424 billion web pages on the Internet.
search Search the Wayback Machine
Featured
texts All Books
All Texts
latest This Just In
Smithsonian Libraries FEDLINK (US) Genealogy Lincoln Collection
National EmergencyLibrary
Top
American Libraries Canadian Libraries Universal Library Community Texts Project Gutenberg Biodiversity Heritage Library Children's Library
Open Library
Featured
movies All video
latest This Just In
Prelinger Archives Democracy Now! Occupy Wall Street TV NSA Clip Library
TV News
Top
Animation & Cartoons Arts & Music Computers & Technology Cultural & Academic Films Ephemeral Films Movies News & Public Affairs
Understanding 9/11
Spirituality & Religion Sports Videos Television Videogame Videos Vlogs Youth Media
Featured
audio All audio
latest This Just In
Grateful Dead Netlabels Old Time Radio 78 RPMs and Cylinder Recordings
Live Music Archive
Top
Audio Books & Poetry Community Audio Computers, Technology and Science Music, Arts & Culture News & Public Affairs Non-English Audio Spirituality & Religion
Librivox Free Audiobook
Sharp Darts Radio Amazing Discoveries Africa Rediscover America Audio Podcast Sports Show 1204 PC实验室 Holy Cross Catholic Church
Featured
software All software
latest This Just In
Old School Emulation MS-DOS Games Historical Software Classic PC Games Software Library
Internet Arcade
Top
Kodi Archive and Support File Community Software Vintage Software APK MS-DOS CD-ROM Software CD-ROM Software Library
Console Living Room
Software Sites Tucows Software Library Shareware CD-ROMs Software Capsules Compilation CD-ROM Images ZX Spectrum DOOM Level CD
Featured
image All images
latest This Just In
Flickr Commons Occupy Wall Street Flickr Cover Art USGS Maps
Metropolitan Museum
Top
NASA Images Solar System Collection Ames Research Center
Brooklyn Museum
Full text of "1876 The Russian Synodal Bible"
See other formats
Eh6jihh
Kmim CBHii^eHHoro IlHcaHHH
BeTxoro h Hoeoro 3aeeTa
CHHOAaJIbHblH TeKCT
Bibles.org.uk, London.
Bmopoe U3danue
Bee npaBa 3amnmeHbi. © 2002-2006 Bibles.org.uk.
3jieKTpoHHbiH TeKCT noflroTOBHJiu BjiaflHMup Bojiobhh m TurpaH AiiBa3HH
Ha ocHOBe MaTepnajioB, npeflCTaBJieHHbix Ha caiiTe
H3flaTejibCTBa Mockobckoh IlaTpHapxHH, http : //www . jmp . ru.
KHHra HabpaHa c noMoiubio pdflATp^K b CHCteMe Linux 29 Mapta 2006 r.
All rights reserved. Copyright © 2002-2006 Bibles.org.uk.
Electronic text prepared by Vladimir Volovich and Tigran Aivazian,
based on the sources provided by
The Publishing House of the Moscow Patriarchate, http : //www . jmp . ru.
Typeset with pdft/Ij^X under Linux 29 Mar, 2006.
BBEflEHHE*
B 1804 roqy 6biao ocHOBaHO EpumancKoe u Hmcmpamoe Eu6jieuawe 06tnecmeo
(BFBS), nojiy-aBTOHOMHbiM <j)HJiHajioM KOToporo CTajio PoccuucKoe Eu6jieucKoe 06-
mecmeo (PBO), ocHOBaHHoe 6 qeKaOpa 1812 roqa. B CBoeM pa6oTe PBO onnpaaocb Ha
noqqepaiKy papa AaeKcaHqpa I, a npeqceqaTeaeM OOiqecTBa 6bia H36paH KHa3b AaeK-
caHqp roanqbiH (1773-1844), KOTopbiH Torqa 6bm oOep-npoxypopoM CBaTeflmero
IIpaBHTeabCTByioiqero CHHoqa PyccKoii IlpaBocaaBHOH I)epKBH, a no3)Ke Mhhhctpom
PeanrHH h HapoqHoro 06pa30BaHHa — TaK Ha3biBaeMoro «cyry6oro MHHHCTepcTBa».
OOipecTBO 6biao OTKpbiTO noq HMeHeM CaHKT-IleTep6yprcKoro, a b cemaOpe 1814
roqa nepeHMeHOBaHO Ha PoccHHCKoe.
O pyccKOM OnOaeii ckom nepeBoqe BnepBbie OTKpbiTO 3aroBopnaH b 1816 ropy.
KHa3b roaHpbiH, KaK npeqceqaTeab PBO, noayana BbicoaaHinee H3ycTHoe noBeaeHHe,
«qa6bi npeqaoiKHTb CBHTeHineMy CHHoqy HCKpeHHee h ToaHoe aceaaHHe Ero Bean-
aecTBa qocTaBHTb h poccnaHaM cnoco6 amaTb CaoBO EoiKHe Ha npHpoqHOM CBoeM
poccHHCKOM a3biKe, aKO Bpa3yMHTeabHeHmeM qaa hhx caaBaHCKoro Hapeana, Ha KoeM
KHHrH CBaipeHHoro IlHcaHHa y Hac H3qai0Tca». Ilpeqnoaaraaocb npn stom, hto ho-
bhh nepeBoq 6yqeT H3qaBaTbca co caaBHHCKHM tckctom coBOKynHO, KaK eiqe paHbine
yace 6biao BbinyiqeHO nocaaHHe k PmviaaHaM, c qo3BoaeHHa CHHoqa (HMeaacb b BHqy
KHHra apxnenHCKona MecjioqHa CMHpHOBa, nepeBoq h ToaKOBaHHe; nepBoe H3qaHHe b
1794 r„ TpeTbe b 1815 r.).
roanqbiH b onpaBqaHHe npeqaoiKeHHoro nepeBoqa Ha coBpeMeHHbiH pyccKHH a3biK
ccbiaaaca Ha to, hto rpeaecKOH naTpnapmeH rpaMOTOH oqoOpeHO Hapoqy HTeHHe cbh-
rqeHHoro nncaHHa Hoboto 3aBeTa Ha HOBeiuneM rpeaecKOM HapeaHH BMecTO qpeBHero
(caMa rpaMOTa naTp. KnpHaaa 6biaa npraienaTaHa b OTaeTe PBO 3a 1814 roq).
Chhoa He npHHaa Ha ce6a pyKOBoqcTBa OnfiaeiicKHM nepeBoqoM h He B3aa 3a
Hero OTBeTCTBeHHOCTH Ha ce6a. nepeBoq 6bia OTqaH b BeqeHHe Komhcchh qyxoBHbix
yananiq, KOTopon Haqaeacaao H36paTb HaqeiKHbix nepeBoqaHKOB b MecmoH HyxoBHOH
AKaqeMHH.
IlepeBoq 6bia nocTaBaeH noq oxpaHy BbicoaaHinero HMeHH. 3aMbicea cefi npHHaq-
aeacaa caMOMy rocyqapro, nan 6bia eMy npraincaH: «He tokmo oqoSpaeT Bee cnocne-
mecTByroiqee ceMy cnacHTeabHOMy qeay, ho h oqymeBaaeT qeaTeabHOCTb OOiqecTBa
BHynieHHaMH coOcTBeHHoro cepqqa. Oh caM CHHMaeT neaaTb HeBpa3yMHTeabHoro Ha-
peana, 3arpa>KqaBmyio qoHbme ot MHorax H3 PoccnaH eBaHreane HncycoBO, h ot-
KpbiBaeT chk) KHHry qaa caMbix MaaqeHqeB Hapoqa, ot KOTopbix He ea Ha3HaaeHHe,
ho eqHHCTBeHHO MpaK BpeMeH 3aKpbia OHyio.» HeBpa3yMHTeabHoe Hapeane 3aKpbi-
Baao BnOaHK) He CToabKO ot Hapoqa, CKoabKO hmchho ot Bbicmero Kpyra, ot caMoro
HMnepaTopa, npexcqe Bcero, oh caM npHBbiK amaTb Hobmh 3aBeT no-(j)paHqy3CKH (b
H3BecTHOM nepeBoqe He-Cacn), h He H3MeHHa stoh npHBbiaKe h c H3qaHneM pocom-
ckoto nepeBoqa.
BeqeHHe nepeBoqa ot Komhcchh qyxoBHbix yaHaniq 6biao nopyaeHO OnaapeTy,
Torqa apxHMaHqpHTy h peKTopy CaHKT-IleTep6yprcKOH AKaqeMHH, h oh HMea H36paTb
nepeBoqaHKOB no CBoeMy ycMOTpeHHio. CaHTaaocb, hto nepeBoq npoH3BoqHTca npn
AKaqeMHH. OnaapeT caM B3aa Ha ce6a EBaHreane ot HoaHHa. Ot MaTfJiea nepeBoqna
IlaBCKHH, ot MapKa apxHM. IloaHKapn (raHTaHHHKOB), Torqa peKTop CaHKT-IleTep-
6yprcKOH ceMHHapHH, a BCKope h Mockobckoh AKaqeMHH, h ot JlyKH apxHM. Monceii
(AHTHnoB-IlaaTOHOB), peKTop KneBCKOH ceMHHapHH, a noTOM h AKaqeMHH, ObiBinHH
nepeq TeM OaKaaaBpoM b CaHKT-IleTep6ypre, BnocaeqcTBHH OK3apx Tpy3HH. Pa6o-
Ta OTqeabHbix coTpyqHHKOB nepecMaTpHBaaacb h CBepaaacb b oco6om KOMHTeTe H3
aaeHOB EHOaencKoro oOiqecTBa. B HeM yaacTBOBaan: MHTp. Mnxana (HecHHqKHH),
*no MaTepaaaaM KHHrH T. OaopoBCKoro «nyTH PyccKoro EorocaoBHH».
BBEflEHME
IV
BnocjieflCTBHH MHTponojiHT CaHKT-IIeTep6yprcKHH; Cepa<J)HM (EaaroaeBCKHH), Toace
OyayiqHH MHTponojiHT; OnaapeT; JIa63HH; B. M. IlonoB, anpeKTop aenapTaMenra b
ABOhhom MMHMCTepcTBe h ceKpeTapb EnOaeHCKoro o6mecTBa — neaoBeK KpaHHHX
MHCTHHeCKHX B3rjIHflOB, nepeBOflHHK JlHHflJIH H ToCHepa, HJieH Kpy)KKa TaTapHHOBOH,
OKOHHHBIIIHH a(H3Hb CBOK) B 3njiaHTOBOM MOHaCTbipe B Ka3aHH, KaK 3aTOHeHHbIH,
KpoTKHM H3yBep, KaK ero ocTpoyMHO Ha3biBaeT Bnrejib.
IlpaBHJia aaa nepeBoaa 6bum cocTaBJieHbi OnaapeTOM, sto cpa3y nyBCTByeTca yace
b hx cnuie. IlepeBOflHTb Haaaeacaao c rpeneacoro, KaK nepBOHaaaabHoro, npeHMyme-
CTBeHHO nepea caaBaHCKHM, c TeM, hto6h b nepeBoae yaepacmaTb vum ynoTpeOaaTb
caoBa cjiaBHHCKne, ecan ohh 6anace pyccKHX noaxoaaT k rpenecKHM, He npoH3Boaa b
penn TeMHOTbi vum HecTpoHHOCTH, vum ecan cooTBeTCTBeHHbie pyccKHe He npHHaaae-
acaT k HHCTOMy KHHacHOMy H3biKy. B nepeBoae Bcero BaacHee TOHHOCTb, 3aTeM acHOCTb,
HaKOHeq, HHCTOTa. OneHb xapaKTepHbi HeKOTopbie craaHCTHHecKHe anpeKTHBbi. Be-
jimvie CBHineHHoro IlHcaHHa coctoht b cnae, a He b 6aecxe caoB; H3 cero caeayeT,
hto He aoaacHO caniiiKOM npnBH3biBaTbca k caaBaHCKHM caoBaM h BbipaaceHHaM, pa-
an mhhmoh hx BaacHocra. Eme BaacHee apyroe 3aMeaaHHe. TiqaTeabHO Ha6aioaaTb
aoaacHO ayx peHH, aa6bi pa3roBop nepeaaraTb caoroM pa3roBopHbiM, noBecTBOBaHHe
noBecTBOBaTeabHbiM, h Tax aaaee.
3th noaoaceHHa aHTepaTypHbiM apxaHCTaM noKa3aaHCb aypHOH CTHancTHaecKOH
epecbKD, h 3to 6bia oaHH H3 pemaromHX momchtob B3BoaHOBaHHoro BoccTaHHa vum
HHTpHTH npoTHB pyccKOH BH6aHH b 20-x roaax.
B 3tot nepnoa 6bian nepeBeaeHbi Ha pyccKHH H3biK h b coTpyaHHnecTBe c BFBS
ony6aHKOBaHbi: EBaHreane (1819), Hobhh 3aBeT (1820) h IlcaaTHpb (1822). B to
ace BpeMa Haaaaacb paOoTa Haa IlHTHKHHacHeM. OnaapeT b cbohx 3anHCKax Ha KHHry
BbiTHH (nepBoe H3aaHHe yace b 1816 r.) Bcioay aaeT 6H6aeHCKHH tckct b pyccxoM nepe-
Boae, c eBpeHCKoro. K nepeBoanecKHM paOoTaM 6biaH npHBaeneHbi h BHOBb OTKpbiTbie
AKaaeMHH: MocKOBCKaa h KneBCKaa, TaKace h HeKOTopbie ceMHHapHH. Cpa3y ace BCTaa
TpyaHbiH h caoacHbiH Bonpoc o cooTHomeHHH eBpeHCKoro h rpeneocoro tckctob, o ao-
CTOHHCTBe H aOCTOHHCTBaX nepeBOaa CeMHaeCHTH, 0 3HaneHHH MaCCOpeTCKHX HTeHHH,
h 3th Bonpocbi oOocTpaaHCb TeM, hto BCHKoe OTCTynaeHHe ot CeMHaecara 03Hanaao
npaKTHaecKH h pacxoacaeHHe co caaBHHCKOH BnOaHeH, ocTaBaBmenca b 6orocayace6-
hom ynoTpeOaeHHH, a noTOMy Hyacaaaocb b HaponHTbix onpaBaaHHax h oroBopKax.
flaa Haaaaa Bonpoc 6bia pemeH npocTO. B ocHOBy 6bia noaoaceH eBpeHCKHH (Mac-
copeTCKHH) TeKCT, KaK noaaHHHbiH, a b oObacHeHHe pacxoacaeHHH co caaBHHCKOH
BnOaHeH 6biao cocTaBaeHO oco6oe npeancaoBHe, yOeaHTeabHoe h aaa He3HaiomHX
apeBHHX a3biK0B. CocTaBHa ero OnaapeT, h noanncaHO oho 6biao MHTp. MnxaHaoM,
MHTp. Cepa<|)HMOM, Toraa eiqe Mockobckhm, h cbmhm OnaapeTOM, Toraa apxnenHCKO-
noM HpocaaBCKHM.
OKOHaaTeabHaa KoppeKTypa IlaTHKHHacHa 6biaa nopyaeHa TepacHMy IlaBCKOMy.
IleaaTaHHe 6biao 3aKOHaeHO b 1825 roay, ho no H3MeHHBiiiHMca oOeroHTeabCTBaM
H3aaHHe He ToabKO He 6biao BbinymeHO b cbct, ho 6biao apecTOBaHO h BCKope coacace-
ho. CaMO OnOaencKoe aeao 6biao ocTaHOBaeHO h BnOaeMCKoe oOiqecTBO 3aKpbiTO h
3anpemeHO 12 anpeaa 1826 roaa, b ochobhom 6aaroaapa HHTpnrpaM apxHMaHapHTa
OoTHa, aaMHpaaa IHnajKOBa h ApaKaeeBa.
B 1840-x roaax npocjieccop IlaBCKHH BnepBbie nepeBea Ha pyccKHH a3biK Becb
BeTXHH 3aBeT HenocpeacTBeHHO c eBpeircKHX opHrHHaaoB, 3a hto 6bia OTaaH noa cya
h pe3yabTaTbi ero crapaHHH 6bian yHHHToaceHbi.
C npnxoaoM k BaacTH papa AaeKcaHapa II paOoTa PBO 6biaa B03o6HOBaeHa noa
pyKOBoacTBOM MHTponoaHTa MocKOBKoro OnaapeTa. B aexaOpe 1857 roaa 6n6aeH-
CKoe aeao noayaHao ofjjHqHaabHoe aBHaceHHe. CHHoaaabHoe onpeaeaeHHe cocToa-
aocb 20 MapTa 1858 roaa, a Bbiconaiimee noBeaeHHe o B03o6HOBaeHHH pyccKoro
V
BBEflEHME
nepeBO/ia 6biJio onyOjiHKOBaHO b Mae.
IlepeBOfl 6bin B03o6HOBJieH c Hoboto 3aBeTa, k ynacTHio b pa6oTax CHOBa 6 mjih
npHBJieneHbi Bee aKaqeMHH, a peqaKrapoBaHHe nopyneHO neTep6yprcKOMy npo<j)ec-
copy E. H. JIoBarnHy. Bbicmee HaOjnoqeHHe h nocjieflHHH npocMOTp 6 mjih qoBepeHbi
OmiapeTy. HecMOTpa Ha cboh npeKJioHHbiH B03pacr, oh oneHb qeflTejibHO ynacTBOBaji
b pa6oTe, co BHHMaHHeM nepeHHTbmafl h npoBepaa Becb MaTepnaji.
B 1860 roqy 6biJio mp,ano pyccKoe HeTBepoeBaHrejme, a b 1862 h nojiHbiH Hobmh
3aBeT.
IlepeBOfl BeTxoro 3aBeTa noTpeOoBaji 6ojibme BpeMeHH. Y>Ke c caMoro Hanajia 60-x
roflOB b pa3JiHHHbix flyxoBHbix *ypHajiax CTajiH noaBJiHTbca nacTHbie onbiTbi nepeBO-
qa OT^ejibHbix KHHr. M, npeayje Bcero, Ohjih onyOjiHKOBaHbi sth TaK He3a/jo:iro nepea;
TeM 3anpeTHbie nepeBoqbi IlaBCKoro (b >KypHane Hyx XpHCTHaHHHa 3a 1862 h 1863
roflbi) h apx. MaKapna (b IlpaBocJiaBHOM 06o3peHHH c 1860-ro no 1867-oir, oco6mm
npHJio)KeHHeM). 3to 6biJi oneHb jkhboh h apKHH chmhtom cqBHra h noBopoTa. BbiJio
npH3HaHO nojie3HbiM h Hy>KHbiM npeqaTb rjiacHOCTH sth onbiTbi, hto6m nepe3 CBoOofl-
Hoe oOcyaiqeHHe b nenaTH noqroTOBHTb OKOHHaTejibHoe H3qaHHe. C stoh qejibio 6biJio
npeqjioaceHO h npocjieccopaM aKafleMHH 3aHHTbCH nepeBOflaMH OTqejibHbix KHHr, c TeM
HToObI 3TH HOBbie OnbiTbi 6bIJIH B CBOe BpeMfl HCn0JIb30BaHbI CHHOflajIbHOH komhc-
CHeft. HenTO noqoOHoe npe/yiaraji b CBoe BpeMH o. ManapHH TjiyxapeB, H3qaBaTb npn
neTepOyprcKOH AKaqeMHH oco6mh >KypHaji: OnbiTbi b nepeBoqe c eBpeiicKoro h rpe-
necKoro, h paccbuiaTb no aKaqeMHHM h ceMHHapHHM, c npHMenaHHHMH h CHoenaMH,
noTOM stot MaTepnaJi npHroqHTCH.
B aKa/ieMHHecKHX H3^aHHax, b XpHcraaHCKOM HTeHHH h b Tpyaax KneBCKOH ny-
xobhoh aKafleMHH b 3th roqbi noHBjmeTCH nepeBOfl mhothx KHHr. B KneBe ocoOeHHO
noTpyflHJicfl npocj). M. C. ryjiaeB, a b IleTepOypre npotj). M. A. IcuiyOeB b coTpya;-
HHHeCTBe C n. H. CaBBaHTOBbIM, H. A. XBOJIbCOHOM H flp. IlOflBHJIHCb H OTfleJIbHbie
H3flaHHH. H3flaBaji cboh 6n6jieHCKHe nepeBOflbi c rpenecKoro nopejiHpHH YcneHCKHH,
Torqa enncKon Hhthphhckhh. 3to 6biJi nojiHbiH pa3pbiB c peacHMOM npeqbiqymero
papCTBOBaHHfl.
Ho BCTpenajiHCb h TpyqHOCTH. He cpa3y yaajiocb peniHTb Bonpoc o npHHqnnax
nepeBoqa. BbiJio 3anBJieHO MHeHHe, hto h BeTXHH 3aBeT nepeBO/qrrb HyiKHO c rpene-
CKoro, k 3TOMy MHeHHio yqajiocb CKJiOHHTb h MHTp. rpHropHU. OHJiapeT Mockobckhh
H acTOHJi, hto6m nepeBoq qejiajica no cjmneHHio o6ohx TeKCTOB. h pacxoayjeHHe b
B aaiHeHiuHX MecTax 6biJio OTMenaeMO noq nepTOH. CnepBa npeqjioweHO 6buio HanaTb
c ncaJiMOB; Haq HcnpaBJieHHeM nepeBoqa ncajiMOB <t>HJiapeT pa6oTa:i b cboh nocjiefl-
HHe roqbi. Ho 3aTeM oh caM npeqjioaiHJi H3qaBaTb b nopaqKe oObiHHoro TeKCTa, t. k.
niiTHKHH>KHe Jierne ncajiMOB no H3biKy. CHHoqajibHbiH nepeBoq Hanaji BbixoqHTb c
1868 roqa OTqejibHbiMH tom3mh, a Bee H3qaHHe 3aKOHHHJiocb b 1875 co BKjnoneHHeM
H KHHr HeKaHOHHHeCKHX.
OcoOeHHO pe3KHM npoTHBHHKOM eBpeHCKoro TeKCTa 6bin enncKon OeotjiaH Tobo-
poB, Torqa yace BbimeHCKHH 33tbophhk. Hobmh pyccKHH nepeBoq BeTxoro 3aBeTa oh
Ha3biBaji CHHoqajibHbiM conHHeHHeM, coBceM KaK A<j)aHacHH, h MenTaji, hto 3Ty Bh6-
jihkd HOBOMOflHyio qoBeqeT qo coacaieHHa Ha HcaaKHeBCKOH njioiqaqH. YnoTpe6jieHHe
eBpeiicKoro TeKCTa, HHKorqa He ObiBinero b qepKOBHOM ynoTpeOjieHHH, 03HaHajio b ero
noHHMaHHH npaMoe OTCTynHHHecTBO. EBpencKaa 6h6jmh k HaM HeiifleT, noTOMy hto
HHKorfla He 6mjio ee b U,epKBH h b qepKOBHOM ynoTpeOaeHHH. nosTOMy npHHHMaTb
ee 3H3HHT OTCTynaTb ot toto, hto Bcerqa 6mjio b IlepKBH, t. e. cflBHraTbca c KopeHHO-
ro ocHOBaHHa npaBocjiaBHH. OeoijiaH BnojiHe npH3HaBaji Hyaiqy b pyccKOM nepeBOfle,
oh B03paa<aji TOJibKO npoTHB eBpeiicKoro o6pa3ii;a. H CHHoqajibHbiH nepeBoq CHHTaji
nosTOMy co6jia3HHTejibHbiM h BpeqHbiM. IlepKOBb BoaiHH He 3Hajia qpyroro CaoBa
BoaiHH, KpoMe 70-th tojikobhhkob, h Korqa roBopnaa, hto nncaHHe OoroqyxHOBeH-
BBEflEHME
VI
ho, pa3yMejia IlHcaHHe hmchho b stom nepeBoqe. 06 stom oh oneHb pe3K0 nncaji b
flymenojie3HOM HTeHHH (1875 h 1876), eMy OTBenaji b IlpaBOCJiaBHOM 06o3peHHH
npocj). n. H. ropcKHH-IljiaTOHOB c HeMeHbiiieH pe3KOCTbio. Ho OeocjiaH He orpaHH-
HHBajICH KpHTHKOH. Oh IipeflJiaraJI 3aHHTbCfl H3flaHHeM o6meflOCTynHbIX TOJIKOBaHHH
Eh6jihh no cjiaBUHCKOMy TeKCTy (h oco6eHHO KHHr ynHTejibHbix h npoponecKHx) , hto-
6bi npnyHHTb hmchho k 3T0My TeKCTy, t. e. k CeMHqeoiTH. BbmqeT, hto, HecMOTpa Ha
cymecTBOBaHHe Eh6jihh b nepeBoqe c eBpeiicKoro, 3HaTb ee h noHHMaTb h HHTaTb Bee
6y«yT no CeMHflecHTH, no npHHHHe cero TOJIKOBaHHH. npoeKT stot He 6 hji ocyiqecTB-
neH, caM OeoiJiaH H3qaji ToubKO TOJiKOBaHHe Ha ncajioM Cto OcMbHaqqaTbiH (cto
B oceMHaflqaTbm). Bo3HHKJia y Hero h Mbicjib cecTb 3a nepeBOfl Been Eh6jihh c rpene-
CKoro, c 3aMenaHHHMH b onpaBqaHHe rpeneacoro TeKCTa h b ocyacqeHHe eBpeiicKoro.
3 to HaMepeHHe ocTaJiocb Toace 6e3 HcnojiHeHHn. yace ToubKO mhoto no3ace HexoTopbie
KHHrH BeTxoro 3aBeTa 6bum nepeBeqeHbi c rpeneacoro Ka33HCKHM npocjieccopoM n. A.
lOHrepoBbiM (npopoKH, ncanrapb, npHTHH, Ebrrae, khhth HeKaHOHHnecKHe).
B npoqecce pa6oTbi Haq nepeBoqoM BeTxoro 3aBeTa CHOBa h CHOBa OTKpbmajiocb,
hto cooTHomeHHe MaccopeTCKOH peqaxqHH h CeMHflecHTH cjihuikom cnoacHO, hto6bi
mo)kho 6biJio CTaBHTb Bonpoc o Bbi6ope Meacqy hhmh b o6iqeM BHqe. MoacHO cnpaniH-
BaTb TOJibKO O npeqnOHTHTejIbHOM HJIH HafleaCHOM HTeHHH OTflejIbHblX OTpbIBKOB HJIH
cthxob, h npHxoflHTCH BbiEnpaTb HHorqa eBpencKyK) HCTHHy, HHorqa ace rpenecKoe
HTeHHe. OHJiojiorHnecKH jiyniiiHM 6yqeT HMeHHO CBoqHbiH TeKCT. EorocJioBCKOMy 3a-
KjnoneHHK) o qorMaTHnecKOM qocTOHHCTBe onpeqejieHHoro TeKCTa, bo bchkom cjiynae,
qojiacHO npeqmecTBOBaTb noqpo6Hoe HccneqoBaHHe OTqejibHbix KHHr. npHMepoM Ta-
koh pa6oTbi b Te roqbi 6biJia qHccepTaqHa H. C. Hkhmobb o KHHre npopoxa HepeMHH
(1874). CaeqyeT ynoMHHyTb h pa6oTbi R. A. XBOJibcoHa h H. A. OjiecHHqKoro.
06HapyacHBajiacb h apyraa TpyqHOCTb. OKa3biBajiocb, hto h CjiaBHHCKyio Eh6jihio
H e npHxoqHTCH b qejioM npHpaBHHBaTb k CeMHqecaTH, hto h caM cji3bhhckhh TeKCT
ecTb yace CBoqHbift, b H3BecTH0M CMbicjie h npeqejiax. B stom h 6biJia npHHqHnHajibHan
BaacHOCTb onHcaHHH 6 h6ji6hckhx pyKonnceH IopcKHM h HeBOCTpyeBbiM b Mockob-
ckoh CHHoqaabHOH 6H6jmoTeKe. HanHHaeTca HCTopHnecKoe H3yneHHe Cji3bhhckoh
Eh6jihh. H yace Heab3a Tax ynpoiqeHHO cnpauiHBaTb o BbiOope Meacqy cjiaBHHCKHM h
pyccKHM.
OacHBaeT HHTepec h k BonpocaM 6 h6ji6hckoh kphthkh. EojibuiHHCTBO pyccKnx hc-
caeqoBaTejieH npHqepacHBajiHCb yMepeHHbix B3rjiaqoB, ho h y hhx BJiHHHHe 3anaqH0H
KpuTunecKOH jiHTepaTypbi CKa3biBajiocb oneHb 3aMeTH0. HocTaTOHHO Ha3BaTb pa6oTbi
apxHM. OnaapeTa <J>HJiapeTOBa (peKTopa KneBCKOH axafleMHH, BnocjieqcTBHH enHCKO-
na PnaccKoro, 1824-1882). B ero qnccepTaqHH o npoHcxoacqeHHH khhth HoBa (1872)
oh He TOJibKO npHHHMaji no3qHioio nocjienjieHHyio qaTHpoBKy khhth, ho h pa36npaji
ee CKopee, xax naMHTHHK jiHTepaTypbi, Heacejm xax KHHry CBHiqeHHoro xaHOHa. K TOMy
ace Bee HccjieqoBaHHe 6bmo npoBeqeHO no eBpencKOMy TeKCTy, 6e30 bchkoto BHHMa-
hhh k cjiaBHHCKHM HTeHHHM. MHTp. ApceHHH KHeBCKHH Hauieji caM toh qHccepTaqHH
HecooTBeTCTByioiqHM 6oroqyxHOBeHHOMy xapaKTepy 6H6aeHCKOH KHiirn, h ny6jiHH-
Haa 3aiqHTa qHccepTaqHH 6biJia 3anpeiqeHa CBHTeHiiiHM Chho^om. A b cjieqyioiqeM
(1873) roqy b Tpyqax KneBCKOH AxaqeMHH 6bum HanenaTaHbi ycrapeBniHe aexqHH
no BBeqeHHio b CBHiqeHHbie khm™ BeTxoro 3aBeTa, HHTaHHbie caMHM MHTp. ApceHHeM
b neTep6yprcK0H axaqeMHH eiqe b 1823-1825 roqax. BnponeM, b KpaTKOM npeqH-
caoBHH ot peflaxqHH 6biJio oroBopeHO, hto HHTaTejib caM CMoaceT cyqHTb, HacKOJibKO
Bnepefl noqBHHyjmcb y Hac 6H6jiHOJioranecKafl Hayxa c Toro BpeMeHH flo HacToaiqero.
TaKHM o6pa30M, nepeBOflbi, BbinojiHeHHbie b 1810-25 rr. h OTpeqaKrapoBaHHbie b
1860-70 rr., cocTaBHJiH KHHry HMeHyeMyio Pycacou CuHodajibHou Eu6meu. OqHaxo He
Bee OTHecjmcb 6jiarocKJioHHO k noaBJieHHio Eh6jihh Ha pyccxoM H3biKe, npeqnonHTaa
CTapo-cjiaBHHCKHH nepeBoq Hcnoab3yeMbiH h no ceil qeHb b qepKOBHOM cnyaceHHH.
Vll
BBEflEHME
flaace CBHTeHiiiHH Chhop OaarocaoBHa Bh6jihk) 1876 roqa ucKJiwnumenbHO qaa npn-
BaTHoro ynoTpeSaeHHa, qaa HTeHHa qoMa, ho He qaa qepKOBHoro cayaceHHa.
B nocaeqcTBHH, tckct PyccKoil CHHopaJibHOH Bh6jihh 6bia cyipecTBeHHO H3MeHeH
c qeabio pacnocTpaHeHHH «npoTecTaHTH3Ma». A hmchho, caoBa h qeabie cj)pa3bi coot-
BeTCTByiotpHe TeKCTaM rpenecKOH CenTyaraHTbi h jiaTiiHCKOH ByjibraTbi Bhjih yqaae-
Hbi, xoth h He nojiHOCTbro h c MHoroHHCJieHHbiMH oiHH6KaMH, hto6m noqqepaoTb MU(p
0 TOM, HTO, HKo6bI, Bor HyflOfleHCTBeHHblM o6pa30M «COXpaHHJI» CBOe Cjiobo B OqHOM
epHHCTBeHHOM BapwaHTe h ecTecTBeHHO Bbi6op TaKoro «HqeaabHoro» BapnaHTa naji
Ha MaccopeTCKHH TeKCT. B qaHHOM H3qaHHH Mbi He qeaaeM nqoaa H3 CjioBa EowHero
h, noceMy, npHBoqHM TeKCT CHHoqaabHoro H3qaHHa b ero H3HanaabHOH <j)opMe ( 3 a
HCKjnoneHHeM Hcnojib30BaHHH apxaHHHoro npaBonHcaHHH h 6yKB) , BKaroaaa HeKaHO-
HHHecKHe khhth b tom nopaqxe h BHqe, b KaKOM ohh 6bum npHBeqeHbi b Eh6jihh 1876
roqa.
TeKCTbi Khht CBHineHHoro IlHcaHHa BeTxoro h Hoboto 3aBeTa h npmio)KeHHH, hc-
n0Pb30BaHHbie B qaHHOM H3qaHHH, B3HTbI C CaHTa H3flaTeJIbCTBa MOCKOBCKOH riaTpH-
apxHH, http : //www . jmp . ru, h cooTBeTCTByioT CHHoqaabHOMy nepeBoqy H3qaHHa
Mockobckoh IlaTpHapxHH KpoMe 70-h cthxob HaxoqaiqHxca Meacqy 35 h 36 craxaMH
7-h rjiaBbi 3-h Khhth E3qpbi, B3HTbix hbmh H3 “Tojikoboh Eh6jihh” A. n. JIonyxH-
Ha (IleTep6ypr, 1904) h HMeroiqHxca TaioKe b EprocceabCKoii Bh6jihh (Bpiocceab,
1973). 3aeKTpoHHbie TeKCTbi 6 bum nepeBeqeHbi b (jjopMaT THnorpa<f)CKOH CHCTeMbi,
Hcnojib3yeMOH qua Bcex Bh6jihh, H3qaBaeMbix Bibles.org.uk, ochob3hhoh Ha TgX h
pdflXT^X b CHCTeMe Linux. Mbi 6yqeM oaeHb npH3HaTejibHbi, ecan HadqeHHbie Ba-
mh b 3tom H3paHHH oneaaTKH, 6yqyT OTnpaBJieHbi no BJieKTpoHHOH nouTe no aqpecy
info@bibles.org.uk.
0(j)opMJieHHe TeKCTa BhSjihh b qaHHOM H3qaHHH HMeeT caeqyioiqHe ocodeHHOcra:
• Hjih odaeraeHHa cchjiok h HTeHHa HyMepaqna cthxob BbraeqeHa Ha noaa.
• CaoBa, HanenaTaHHbie KypcueoM, npHBeqeHbi qaa hchocth h OTcyrcTByioT b opn-
nmaaax.
• B TeKCTe BeTxoro 3aBeTa b KBaqpaTHbie cko6kh 3aKJHoneHbi caoBa, 33HMCTB0-
BaHHbie H3 rpeuecKoro nepeBoqa 70-th tojikobhhkob (III b. qo P. X.) — Cemy-
arHHTbi.
HecMOTpa Ha «qo-IlymKHHCKHH» H3biK PyccKoil CHHopaJibHoii Bh6jihh, OHa npo-
pojDKaeT ycnemHO cayiKHTb MHJUiHOHaM aroqeii Ha njiaHeTe KaK caMbiii qocTOBepHbiH
h HHTaeMbiH nepeBoq CBaiqeHHoro IlHcaHHa Ha pyccKHH a3biK.
Ra SaarocaoBHT rocnoqb Bor Baiue H3yueHHe Ero CaoBa, qadbi noqaHHHTb Cbmy
CBoeMy Hncycy XpHCTy rocnoqy HameMy BcaKyio Mbicab Bamero cepqqa h Bcanoe
caoBO, ncxoqaiqee H3 ycT Bamnx. AMHHb.
BnaduMup Bojioem,
BopoHeM, Poccun.
Tuzpau Auea3siH,
JIondoH, Anzjim.
EHEJIEHCKHH KAJIEHflAPE
CneT MecHqeB
Ha3BaHna MecaqeB flPEBHHE h
ACCHPO-BABHJIOHCKHE ,
hhcjio qHeii b Mecnqe h oco6bie q hh
CooTBeTCTByeT
MecHuaM
coBpeMeHHoro
KajieH/japfl
B CBfl-
meH-
HOM
rosy
b rpa>K-
fl aH-
CKOM
roAy
i
7
ABHB. HMCAH. 30 qHeii. 14. nacxa
(Hex. tji. 12; JleB 23:5; Hue 28:16).
16. IIpHHeceHHe nepBoro CHona *aT-
bh HHMeHH (JleB 23:10-14).
MapT — anpejib
ii
8
3HG>, HAP. 29 qHeii. 14. BTopaa nac-
xa — qjia Tex, kto He mot coBepniHTb
nepByio (Hhc 9:10-12).
anpejib — Man
hi
9
CMBAH. 30 qHeii. 6. IlHTHqecaT-
HHqa (JleB 23:16) hjih npa3qHHK
ceqMHq (Brap 16:9-10). IlpHHece-
HHe HanaTKOB >KaTBbi nmeHHqbi (JleB
23:15-21) m HanaTKOB Bcex nqoqoB
3eMJin (Hhc 28:26; Btop 26:2,10).
MaH — HKDHb
IV
10
c PAMMY3. 29 qHeii. 17. IIoct. B3HTne
Hepyca;iHMa (3ax 8:19).
HIOHb — mojib
V
11
AB. 30 qHeii. 9. IIoct. Pa3pymeHne
xpaMa HepycaJiHMCKoro (3ax 8:19).
mo Jib — aBrycT
VI
12
djiyjl. 29 qHeii.
aBrycT — ceHTflOpb
VII
1
AOAHHM, THUIPH. 30 qHeii. 1.
IIpa3qHHK Tpy6 (Hue 29:1). HoBbiii
roq. 10. fleHb OHHiqeHHH (JleB 16:29;
25:9). 15-22. IIpa3qHHK Kyiqeii (JleB
23:34-36; Hhc 29:12-35).
ceHTflOpb — OKTaOpb
VIII
2
BYJI, MAPXEUIBAH. 29 qHeii.
OKTaOpb — HoaOpb
IX
3
KMCJIEB. 30 qHeii. 25. IIpa3q-
hhk oOHOBJieHHa (1 Max 4:52-59;
Hh 10:22).
HoaOpb — qexaOpb
X
4
TEEE0. 29 qHeii.
qeKaOpb — HHBapb
XI
5
IUEBAT. 30 qHeii.
HHBapb — (fieBpajib
XII
6
ARAP. 29 qHeii. 11. nocT Ec<finpn
(Eccjj 4:16). 14-15. npa3qHHKnypnM
(Ec<J> 9:17-32).
(jjeBpajib — MapT
ix EHEJIEHCKHH KAJIEHflAPE
B Bh6jihh CBHineHHbiH rofl co BpeMeHH ncxofla m Erama HanHHaeTca c BecHbi,
c Mecaqa bbhb, hto 3H3HHT Mecaq 3pejioro xoaoca (Hex 13:4; 12:2). 3to 6bm Mecaq
BeceHHero paBHOfleHCTBHa h BpeMa co3peBaHHa anMeHa (JleB 23:10-14). Ilo3)Ke oh
CTaji Ha3biBaTbCH HHcaHOM. B 14-h fleHb 3Toro Mecaqa, xoTopbiii npnxoflHTca b noa-
HOJiyHHe, npa3flHOBajiH riacxy (Hex. tji. 12). Hpyrne Mecaqbi Ha3B3HHH He HMejiH, o
hhx roBopnaH: BTopoft Mecaq, flecaTbiH Mecaq h t. fl. Jlnnib b paccKa3e o noerponxe
xpaMa CoJiOMOHa npn ynacTHH JiHHHXHHqeB TpH Mecaqa Ha3BaHbi oco6o: 3H(j) (Mecaq
qBeTeHHa) — 3 IJap 6:1, aiJaHHM (Mecaq OypHbix BeTpoB) — 3 IJap 8:2, h 6ya (Mecaq
npoH3pacTaHHa) — 3 IJap 6:38: 3to (jiHHHXHHCXHe Ha3BaHHH. nocjie naeHa b3bhjioh-
CKoro noaBHJiHCb aecHpo-BaBHJioHCKHe Ha3BaHH« MecaqeB: HHcaH (HeeM 2:1), nap,
CHBaH (EccJ) 8:9), <J>aMMy3 Han TaMMy3, aB, aaya (HeeM 6:15), THinpn, MapxemBaH,
KHcaeB mm xacaeB (HeeM 1:1; 3ax 7:1), Te6e<J) (Ec<j) 2:16), rneBaT (3ax 1:7) h aqap
(EccJ) 3:7). Te H3 hhx, KOTopbie He BCTpenaioTca b Eh6jihh, H3BecTHbi no conHHeHHaM
HocHiJa OjiaBHa (I BeK no P. X.) h flpyrHM flpeBHHM HCTOHHHxaM.
IpaixflaHCXHH rofl HanHHaaca h xoHnaaca oceHbio (cp. Hex 23:16; 34:22), nocae
yOopxn ypo>Kaa (b Mecaqe THiupn). B En6mm BerpenaeTca cneT MecaqeB h no CBa-
njeHHOMy h no rpaacflaHcxoMy rofly.
Hanano Mecaqa onpefleaaaocb no noaBaeHHio bhahmoto cepna hoboh ayHbi; stot
fleHb, HOBOMecBHHe, 6bia npa3flHHHHbiM (Hhc 10:10; 28:11). Ot oflHoro HOBoayHHa flo
qpyroro npoxoflHT 29 1/2 cyTOK, nosTOMy Mecaqbi hm ean npofloroxHTeabHOCTb b 29 h
30 qHeft nonepeMeHHO. 12 nyHHbix MecaqeB cocTaBJiaioT rofl b 354 flHa, hto Ha 11 flHeii
MeHbine coaHenHoro rofla. 3a Tpn rofla pa3HHqa Meatfly ayHHHbiM h cojmenHbiM roflOM
cocTaBHT qejibiH Mecaq, noaTOMy npHMepHO pa3 b Tpn rofla floOaBaaaca 13-ii Mecaq h
noaynaaca rofl npofloaacHTeabHOCTbio b 384 flHa. 3 to fleaaaocb rji a Toro, hto6m 3bhb
ocTaBanca BeceHHHM MecaqeM.
B npHJiaraeMOH TaOanqe yKa3aHbi Ha3B3HHa MecaqeB b rpaatflaHcxoM h CBaiqeH-
hom rofly (t. e. nepBbiii Mecaq, BTopon h t. fl.), a Taxace qpeBHHe (xaHaaHCKHe h <|>h-
HHKHHCKHe) h nocaenaeHHbie (accHpo-BaBHjioHCKHe) H33BaHHa b tom BHfle, b xaxoM
ohh npHBeqeHbi b pyeexon BhOjihh. 06o3HaneHO xoaHnecTBO flHeft b Mecaqe, nepenne-
aeHbi 6n6ae Hcxne npa3flHHXH h nocTbi h noxa3aHO npH6aH3HTeabHoe cooTBeTCTBHe
6n6aeHCXHX MecaqeB coBpeMeHHbiM.
Hhh HeflejiH, xpoMe cy66oTbi (rnaOaT), ocoObix HaHMeHOBaHHH He hm ejiH, earn
He cnHTaTb cyiqecTBOBaBinero b saaHHHCTHnecxyio snoxy rpeneexoro H33BaHHa ahh
nepeq cy66oTOH — napacxeBH, hto 3H3hht «npHTOTOBaeHHe» (x ahio noxoa — cy6-
6oTe). Hefleaa 3aBepina;iacb cy66oTOH, nosTOMy «qeHb nepBbiii* (nocae cy66oTbi, cm.
Mc|> 28:1) cooTBeTCTByeT HameMy Bocxpec
gitextract_hlw2gjaz/
├── .gitignore
├── EncoderDecoderTogether.src.js
├── LICENSE
├── NodeJS/
│ ├── EncoderAndDecoderNodeJS.min.mjs
│ ├── EncoderAndDecoderNodeJS.min.module.js
│ ├── EncoderAndDecoderNodeJS.src.js
│ ├── EncoderAndDecoderNodeJS.src.module.js
│ └── build-npm-repository.js
├── README.md
├── encodeInto/
│ ├── NodeJS/
│ │ └── EncoderAndDecoderNodeJS.min.mjs
│ ├── README.md
│ └── package.json
├── gh-pages/
│ ├── encoderAndDecoderForced.src.js
│ ├── hexWorker.js
│ ├── index.html
│ ├── install-FastestSmallestTextEncoderDecoder-encodeInto.bat
│ ├── install-FastestSmallestTextEncoderDecoder-encodeInto.sh
│ ├── install-FastestSmallestTextEncoderDecoder-unix.sh
│ └── install-FastestSmallestTextEncoderDecoder-windows.bat
├── individual/
│ ├── FastestTextDecoderPolyfill.src.js
│ └── FastestTextEncoderPolyfill.src.js
├── package.json
└── test/
├── 1876 The Russian Synodal Bible.txt
├── benchmark.js
├── package.json
├── random-ascii-30000000.txt
├── random-test-30000000.txt
├── test.js
└── utils.js
SYMBOL INDEX (73 symbols across 14 files)
FILE: EncoderDecoderTogether.src.js
function TextDecoder (line 65) | function TextDecoder(){}
function encoderReplacer (line 187) | function encoderReplacer(nonAsciiChars){
function TextEncoder (line 218) | function TextEncoder(){}
function polyfill_encodeInto (line 270) | function polyfill_encodeInto(inputString, u8Arr) {
FILE: NodeJS/EncoderAndDecoderNodeJS.min.mjs
function H (line 1) | function H(){}
function I (line 2) | function I(g){var h=g&&g.buffer||g,c=q.call(h);if(c!==x&&c!==A&&c!==v&&"...
function F (line 4) | function F(){}
function J (line 5) | function J(g){g=void 0===g?"":""+g;var h=g.length|0,c=C?new w((h<<1)+8|0...
function K (line 6) | function K(g,h){var c=g[h];return function(){return c.apply(g,arguments)}}
FILE: NodeJS/EncoderAndDecoderNodeJS.min.module.js
function B (line 2) | function B(b){var a=b.charCodeAt(0)<<24,c=h(~a)|0,d=0,w=b.length|0,m="";...
function C (line 2) | function C(){}
function D (line 3) | function D(b){var a=b&&b.buffer||b,c=l.call(a);if(c!==r&&c!==v&&c!==p&&"...
function E (line 4) | function E(b){var a=b.charCodeAt(0)|0;if(55296<=a&&56319>=a)if(b=b.charC...
function z (line 4) | function z(){}
function F (line 5) | function F(b){b=void 0===b?"":(""+b).replace(/[\x80-\uD7ff\uDC00-\uFFFF]...
function G (line 5) | function G(b,a){var c=b[a];return function(){return c.apply(b,arguments)}}
FILE: NodeJS/EncoderAndDecoderNodeJS.src.js
function TextDecoder (line 39) | function TextDecoder(){}
function decode (line 40) | function decode(inputArrayOrBuffer){
function encoderReplacer (line 145) | function encoderReplacer(nonAsciiChars){
function TextEncoder (line 177) | function TextEncoder(){}
function encode (line 178) | function encode(inputString){
function polyfill_encodeInto (line 231) | function polyfill_encodeInto(inputString, u8Arr) {
function bindMethod (line 398) | function bindMethod(inst, name, _) {
function factory (line 434) | function factory(obj) {
FILE: NodeJS/EncoderAndDecoderNodeJS.src.module.js
function TextDecoder_polyfill (line 40) | function TextDecoder_polyfill() {}
function decode (line 41) | function decode(inputArrayOrBuffer){
function encoderReplacer (line 146) | function encoderReplacer(nonAsciiChars){
function TextEncoder_polyfill (line 178) | function TextEncoder_polyfill(){}
function encode (line 179) | function encode(inputString){
function polyfill_encodeInto (line 232) | function polyfill_encodeInto(inputString, u8Arr) {
function bindMethod (line 398) | function bindMethod(inst, name, _) {
FILE: NodeJS/build-npm-repository.js
function applyFilteredCopyToProperties (line 181) | function applyFilteredCopyToProperties(to, from, filter) {
function deleteFolderRecursive (line 241) | function deleteFolderRecursive(path) {
FILE: encodeInto/NodeJS/EncoderAndDecoderNodeJS.min.mjs
function I (line 1) | function I(){}
function J (line 2) | function J(c){var a=c&&c.buffer||c,f=r.call(a);if(f!==x&&f!==A&&f!==v&&"...
function K (line 5) | function K(c){var a=c.charCodeAt(0)|0;if(55296<=a)if(56320>a)if(c=c.char...
function G (line 5) | function G(){}
function L (line 6) | function L(c){c=void 0===c?"":""+c;var a=c.length|0,f=C?new w((a<<1)+8|0...
function M (line 8) | function M(c,a){var f=void 0===c?"":(""+c).replace(D,K),d=f.length|0,b=0...
function N (line 9) | function N(c,a){var f=c[a];return function(){return f.apply(c,arguments)}}
FILE: gh-pages/encoderAndDecoderForced.src.js
function TextDecoder (line 65) | function TextDecoder(){}
function encoderReplacer (line 173) | function encoderReplacer(nonAsciiChars){
function TextEncoder (line 204) | function TextEncoder(){}
function polyfill_encodeInto (line 251) | function polyfill_encodeInto(inputString, u8Arr) {
FILE: gh-pages/hexWorker.js
function convertToOrFromHex (line 13) | function convertToOrFromHex(){
FILE: individual/FastestTextDecoderPolyfill.src.js
function decoderReplacer (line 13) | function decoderReplacer(encoded){
function TextDecoder (line 50) | function TextDecoder(_, opts){/*this["ignoreBOM"] = !!opts && !!opts["ig...
FILE: individual/FastestTextEncoderPolyfill.src.js
function encoderReplacer (line 16) | function encoderReplacer(nonAsciiChars){
function TextEncoder (line 47) | function TextEncoder(){}
function polyfill_encodeInto (line 58) | function polyfill_encodeInto(inputString, u8Arr) {
FILE: test/benchmark.js
function averageTimeUnit (line 101) | function averageTimeUnit(bencher, f, v, count, expectation) {
function runTest (line 130) | async function runTest(name, tableStart) {
function reduceSortTable (line 197) | function reduceSortTable(sum, acc) {
function sortStringTable (line 200) | function sortStringTable(asciiSnippet) {
function benchmarkSmall (line 214) | function benchmarkSmall(f, v) {
function benchmarkMedium (line 249) | function benchmarkMedium(f, v) {
function benchmarkLarge (line 276) | function benchmarkLarge(f, v) {
function httpGet (line 297) | function httpGet(uriLocation) {
function readFile (line 306) | function readFile(name, binary) {
function allAssoc (line 314) | function allAssoc(object) { // https://stackoverflow.com/a/45043545/5601591
function evalEncoderDecoder (line 322) | function evalEncoderDecoder(text/*, isRequire*/) {
function getEncodeAndDecode (line 340) | function getEncodeAndDecode(inObject) {
function download (line 361) | function download(url, dest, cb) {
FILE: test/test.js
function bindMethod (line 22) | function bindMethod(inst, name, _) {
function loadTestScript (line 82) | async function loadTestScript(path, isBrowser) {
function asyncRequire (line 160) | function asyncRequire() {
FILE: test/utils.js
function objAsString (line 9) | function objAsString(x) {
function _equals (line 85) | function _equals( a, b ) {
function reference_equals (line 200) | function reference_equals( a, b ) {
function Handle (line 221) | function Handle(otherHandles, handle, baselineId, source, method, thisAr...
function TestUnit (line 243) | function TestUnit(name, defaultGroupName) {
function SubGroup (line 271) | function SubGroup() {
function deepEnoughEquals (line 286) | function deepEnoughEquals(a, b) {
Condensed preview — 29 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (4,882K chars).
[
{
"path": ".gitignore",
"chars": 578,
"preview": "# in case if you have installed node modules\n/node_modules\n/package-lock.json\n/test/node_modules\n/test/encoding-indexes."
},
{
"path": "EncoderDecoderTogether.src.js",
"chars": 18112,
"preview": "/** @define {boolean} */\nvar ENCODEINTO_BUILD = false;\n\n(function(window){\n\t\"use strict\";\n\t//var log = Math.log;\n\t//var "
},
{
"path": "LICENSE",
"chars": 7049,
"preview": "Creative Commons Legal Code\n\nCC0 1.0 Universal\n\n CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE\n"
},
{
"path": "NodeJS/EncoderAndDecoderNodeJS.min.mjs",
"chars": 2703,
"preview": "'use strict';var a=\"undefined\"==typeof global?\"undefined\"===typeof self?{}:self:global,p=String.fromCharCode,q={}.toStri"
},
{
"path": "NodeJS/EncoderAndDecoderNodeJS.min.module.js",
"chars": 2144,
"preview": "'use strict';var e=\"undefined\"==typeof global?\"undefined\"===typeof self?{}:self:global,f=Math.log,g=Math.LN2,h=Math.clz3"
},
{
"path": "NodeJS/EncoderAndDecoderNodeJS.src.js",
"chars": 18966,
"preview": "/** @define {boolean} */\nvar ENCODEINTO_BUILD = false;\n\n(function(global){\n\t\"use strict\";\n\t// In this NodeJS version, Bu"
},
{
"path": "NodeJS/EncoderAndDecoderNodeJS.src.module.js",
"chars": 20418,
"preview": "/*\n\tALERT: DO NOT USE THIS SOURCE FILE DIRECTLY!!!\n\t\t- Closure Compiler deals with ES6 exports in an unusual way that ha"
},
{
"path": "NodeJS/build-npm-repository.js",
"chars": 7838,
"preview": "// This file is all about optimizing downloads from the npm repository to be as small as possible\n/*\n\t\t\"prepublishOnly\":"
},
{
"path": "README.md",
"chars": 20989,
"preview": "\n\n[](https://npmjs.org/pa"
},
{
"path": "encodeInto/NodeJS/EncoderAndDecoderNodeJS.min.mjs",
"chars": 3779,
"preview": "'use strict';var e=\"undefined\"==typeof global?\"undefined\"===typeof self?{}:self:global,q=String.fromCharCode,r={}.toStri"
},
{
"path": "encodeInto/README.md",
"chars": 104,
"preview": "Please see [fastestsmallesttextencoderdecoder](fastestsmallesttextencoderdecoder) for usage and details\n"
},
{
"path": "encodeInto/package.json",
"chars": 7446,
"preview": "{\n\t\"name\": \"fastestsmallesttextencoderdecoder-encodeinto\",\n\t\"version\": \"1.0.22\",\n\t\"description\": \"The fastest smallest J"
},
{
"path": "gh-pages/encoderAndDecoderForced.src.js",
"chars": 12376,
"preview": "/** @define {boolean} */\nvar ENCODEINTO_BUILD = false;\n\n(function(window){\n\t\"use strict\";\n\t//var log = Math.log;\n\t//var "
},
{
"path": "gh-pages/hexWorker.js",
"chars": 5291,
"preview": "importScripts(\"encoderAndDecoderForced.src.js\");\nonmessage= (function() {\n var timingOut = false, binaryDataString=\"\", "
},
{
"path": "gh-pages/index.html",
"chars": 7899,
"preview": "<!doctype html>\n<html lang=\"en\"><head>\n<link rel=\"preload\" as=\"script\" href=\"encoderAndDecoderForced.src.js\" />\n<link re"
},
{
"path": "gh-pages/install-FastestSmallestTextEncoderDecoder-encodeInto.bat",
"chars": 59,
"preview": "@npm install fastestsmallesttextencoderdecoder-encodeinto\r\n"
},
{
"path": "gh-pages/install-FastestSmallestTextEncoderDecoder-encodeInto.sh",
"chars": 67,
"preview": "#!/bin/sh\nnpm install fastestsmallesttextencoderdecoder-encodeinto\n"
},
{
"path": "gh-pages/install-FastestSmallestTextEncoderDecoder-unix.sh",
"chars": 56,
"preview": "#!/bin/sh\nnpm install fastestsmallesttextencoderdecoder\n"
},
{
"path": "gh-pages/install-FastestSmallestTextEncoderDecoder-windows.bat",
"chars": 47,
"preview": "@npm install fastestsmallesttextencoderdecoder\n"
},
{
"path": "individual/FastestTextDecoderPolyfill.src.js",
"chars": 3122,
"preview": "(function(window){\n \"use strict\";\n var log = Math.log;\n var LN2 = Math.LN2;\n var clz32 = Math.clz32 || function(x) {"
},
{
"path": "individual/FastestTextEncoderPolyfill.src.js",
"chars": 9102,
"preview": "/** @define {boolean} */\nvar ENCODEINTO_BUILD = true;\n\n(function(window){\n\t\"use strict\";\n\tvar log = Math.log;\n\tvar LN2 ="
},
{
"path": "package.json",
"chars": 7390,
"preview": "{\n\t\"name\": \"fastestsmallesttextencoderdecoder\",\n\t\"version\": \"1.0.22\",\n\t\"description\": \"The fastest smallest Javascript p"
},
{
"path": "test/1876 The Russian Synodal Bible.txt",
"chars": 4560214,
"preview": "\n Skip to main content\n\n \n \n \n \n This banner text can have markup.\n "
},
{
"path": "test/benchmark.js",
"chars": 24568,
"preview": "\"use strict\";\nlet Table;\ntry {Table = require('tty-table')} catch(e) {\n\trequire(\"child_process\").spawnSync(\"npm\", [\"i\"],"
},
{
"path": "test/package.json",
"chars": 275,
"preview": "{\n \"name\": \"test\",\n \"version\": \"1.0.0\",\n \"description\": \"\",\n \"main\": \"test.js\",\n \"dependencies\": {\n \"tty-table\":"
},
{
"path": "test/test.js",
"chars": 5353,
"preview": "'use strict';\n\n(async function() {\n\nconst TestUnit = require(\"./utils\");\n\nconst testEncodeInto = process.argv.includes(\""
},
{
"path": "test/utils.js",
"chars": 13182,
"preview": "let Table;\ntry {Table = require('tty-table')} catch(e) {\n\trequire(\"child_process\").spawnSync(\"npm\", [\"i\"], {windowsHide:"
}
]
// ... and 2 more files (download for full content)
About this extraction
This page contains the full source code of the anonyco/FastestSmallestTextEncoderDecoder GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 29 files (69.1 MB), approximately 1.2M tokens, and a symbol index with 73 extracted functions, classes, methods, constants, and types. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.
Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.