https://project.mdnd-it.cc/work_packages/94
This commit is contained in:
2025-08-23 04:25:28 +02:00
parent 725516ad6c
commit 19cfa031d0
25823 changed files with 1095587 additions and 2801760 deletions
@@ -0,0 +1,22 @@
import { Stream } from "../../common/Stream";
/**
* @constructor
* @implements {Decoder}
* @param {!Array.<number>} index The encoding index.
* @param {{fatal: boolean}} options
*/
export declare class SingleByteDecoder {
private readonly index;
readonly fatal: boolean;
constructor(index: Array<number>, options: {
fatal: boolean;
});
/**
* @param {Stream} stream The stream of bytes being decoded.
* @param {number} bite The next byte read from the stream.
* @return {?(number|!Array.<number>)} The next code point(s)
* decoded, or null if not enough data exists in the input
* stream to decode a complete code point.
*/
handler(stream: Stream, bite: number): (number | Array<number>) | null;
}
@@ -0,0 +1,42 @@
import { decoderError } from "../../encoding/encodings";
import { finished } from "../../encoding/finished";
import { end_of_stream, isASCIIByte } from "../../encoding/terminology";
/**
* @constructor
* @implements {Decoder}
* @param {!Array.<number>} index The encoding index.
* @param {{fatal: boolean}} options
*/
var SingleByteDecoder = /** @class */ (function () {
function SingleByteDecoder(index, options) {
this.index = index;
this.fatal = options.fatal;
}
/**
* @param {Stream} stream The stream of bytes being decoded.
* @param {number} bite The next byte read from the stream.
* @return {?(number|!Array.<number>)} The next code point(s)
* decoded, or null if not enough data exists in the input
* stream to decode a complete code point.
*/
SingleByteDecoder.prototype.handler = function (stream, bite) {
// 1. If byte is end-of-stream, return finished.
if (bite === end_of_stream)
return finished;
// 2. If byte is an ASCII byte, return a code point whose value
// is byte.
if (isASCIIByte(bite))
return bite;
// 3. Let code point be the index code point for byte 0x80 in
// index single-byte.
var code_point = this.index[bite - 0x80];
// 4. If code point is null, return error.
if (!code_point)
return decoderError(this.fatal);
// 5. Return a code point whose value is code point.
return code_point;
};
return SingleByteDecoder;
}());
export { SingleByteDecoder };
//# sourceMappingURL=SingleByteDecoder.js.map
@@ -0,0 +1 @@
{"version":3,"file":"SingleByteDecoder.js","sourceRoot":"","sources":["../../../../src/coders/single-byte/SingleByteDecoder.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AACxD,OAAO,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AACnD,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAExE;;;;;GAKG;AACH;IAIE,2BAA6B,KAAoB,EAAE,OAA4B;QAAlD,UAAK,GAAL,KAAK,CAAe;QAC/C,IAAI,CAAC,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC;IAC7B,CAAC;IAED;;;;;;OAMG;IACH,mCAAO,GAAP,UAAQ,MAAc,EAAE,IAAY;QAClC,gDAAgD;QAChD,IAAI,IAAI,KAAK,aAAa;YACxB,OAAO,QAAQ,CAAC;QAElB,+DAA+D;QAC/D,WAAW;QACX,IAAI,WAAW,CAAC,IAAI,CAAC;YACnB,OAAO,IAAI,CAAC;QAEd,+DAA+D;QAC/D,qBAAqB;QACrB,IAAM,UAAU,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,GAAG,IAAI,CAAC,CAAC;QAE3C,0CAA0C;QAC1C,IAAI,CAAC,UAAU;YACb,OAAO,YAAY,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QAElC,oDAAoD;QACpD,OAAO,UAAU,CAAC;IACpB,CAAC;IACH,wBAAC;AAAD,CAAC,AApCD,IAoCC"}
@@ -0,0 +1,20 @@
import { Stream } from "../../common";
/**
* @constructor
* @implements {Encoder}
* @param {!Array.<?number>} index The encoding index.
* @param {{fatal: boolean}} options
*/
export declare class SingleByteEncoder {
private index;
readonly fatal: boolean;
constructor(index: (number | null)[], options: {
fatal: boolean;
});
/**
* @param {Stream} stream Input stream.
* @param {number} code_point Next code point read from the stream.
* @return {(number|!Array.<number>)} Byte(s) to emit.
*/
handler(stream: Stream, code_point: number): (number | Array<number>);
}
@@ -0,0 +1,41 @@
import { encoderError } from "../../encoding/encodings";
import { finished } from "../../encoding/finished";
import { indexPointerFor } from "../../encoding/indexes";
import { end_of_stream, isASCIICodePoint } from "../../encoding/terminology";
/**
* @constructor
* @implements {Encoder}
* @param {!Array.<?number>} index The encoding index.
* @param {{fatal: boolean}} options
*/
var SingleByteEncoder = /** @class */ (function () {
function SingleByteEncoder(index, options) {
this.index = index;
this.fatal = options.fatal;
}
/**
* @param {Stream} stream Input stream.
* @param {number} code_point Next code point read from the stream.
* @return {(number|!Array.<number>)} Byte(s) to emit.
*/
SingleByteEncoder.prototype.handler = function (stream, code_point) {
// 1. If code point is end-of-stream, return finished.
if (code_point === end_of_stream)
return finished;
// 2. If code point is an ASCII code point, return a byte whose
// value is code point.
if (isASCIICodePoint(code_point))
return code_point;
// 3. Let pointer be the index pointer for code point in index
// single-byte.
var pointer = indexPointerFor(code_point, this.index);
// 4. If pointer is null, return error with code point.
if (pointer === null)
encoderError(code_point);
// 5. Return a byte whose value is pointer + 0x80.
return pointer + 0x80;
};
return SingleByteEncoder;
}());
export { SingleByteEncoder };
//# sourceMappingURL=SingleByteEncoder.js.map
@@ -0,0 +1 @@
{"version":3,"file":"SingleByteEncoder.js","sourceRoot":"","sources":["../../../../src/coders/single-byte/SingleByteEncoder.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AACxD,OAAO,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AACnD,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAE7E;;;;;GAKG;AACH;IAIE,2BAAoB,KAAwB,EAAE,OAA4B;QAAtD,UAAK,GAAL,KAAK,CAAmB;QAC1C,IAAI,CAAC,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC;IAC7B,CAAC;IAED;;;;OAIG;IACH,mCAAO,GAAP,UAAQ,MAAc,EAAE,UAAkB;QACxC,sDAAsD;QACtD,IAAI,UAAU,KAAK,aAAa;YAC9B,OAAO,QAAQ,CAAC;QAElB,+DAA+D;QAC/D,uBAAuB;QACvB,IAAI,gBAAgB,CAAC,UAAU,CAAC;YAC9B,OAAO,UAAU,CAAC;QAEpB,8DAA8D;QAC9D,eAAe;QACf,IAAM,OAAO,GAAG,eAAe,CAAC,UAAU,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC;QAExD,uDAAuD;QACvD,IAAI,OAAO,KAAK,IAAI;YAClB,YAAY,CAAC,UAAU,CAAC,CAAC;QAE3B,kDAAkD;QAClD,OAAO,OAAO,GAAG,IAAI,CAAC;IACxB,CAAC;IACH,wBAAC;AAAD,CAAC,AAlCD,IAkCC"}
@@ -0,0 +1,2 @@
export * from './SingleByteDecoder';
export * from './SingleByteEncoder';
@@ -0,0 +1,3 @@
export * from './SingleByteDecoder';
export * from './SingleByteEncoder';
//# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/coders/single-byte/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC"}