Skip to content

Commit

Permalink
Publish the dist folder
Browse files Browse the repository at this point in the history
  • Loading branch information
EddiG committed Aug 23, 2024
1 parent 2796aef commit 5c88f17
Show file tree
Hide file tree
Showing 90 changed files with 6,450 additions and 2 deletions.
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
node_modules/
dist/
dist.*/
# dist/
# dist.*/
build/
.nyc_output/
coverage/
Expand Down
64 changes: 64 additions & 0 deletions dist.es5+esm/CachedKeyDecoder.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
import { utf8DecodeJs } from "./utils/utf8.mjs";
var DEFAULT_MAX_KEY_LENGTH = 16;
var DEFAULT_MAX_LENGTH_PER_KEY = 16;
var CachedKeyDecoder = /** @class */ (function () {
function CachedKeyDecoder(maxKeyLength, maxLengthPerKey) {
if (maxKeyLength === void 0) { maxKeyLength = DEFAULT_MAX_KEY_LENGTH; }
if (maxLengthPerKey === void 0) { maxLengthPerKey = DEFAULT_MAX_LENGTH_PER_KEY; }
this.maxKeyLength = maxKeyLength;
this.maxLengthPerKey = maxLengthPerKey;
this.hit = 0;
this.miss = 0;
// avoid `new Array(N)`, which makes a sparse array,
// because a sparse array is typically slower than a non-sparse array.
this.caches = [];
for (var i = 0; i < this.maxKeyLength; i++) {
this.caches.push([]);
}
}
CachedKeyDecoder.prototype.canBeCached = function (byteLength) {
return byteLength > 0 && byteLength <= this.maxKeyLength;
};
CachedKeyDecoder.prototype.find = function (bytes, inputOffset, byteLength) {
var records = this.caches[byteLength - 1];
FIND_CHUNK: for (var _i = 0, records_1 = records; _i < records_1.length; _i++) {
var record = records_1[_i];
var recordBytes = record.bytes;
for (var j = 0; j < byteLength; j++) {
if (recordBytes[j] !== bytes[inputOffset + j]) {
continue FIND_CHUNK;
}
}
return record.str;
}
return null;
};
CachedKeyDecoder.prototype.store = function (bytes, value) {
var records = this.caches[bytes.length - 1];
var record = { bytes: bytes, str: value };
if (records.length >= this.maxLengthPerKey) {
// `records` are full!
// Set `record` to an arbitrary position.
records[(Math.random() * records.length) | 0] = record;
}
else {
records.push(record);
}
};
CachedKeyDecoder.prototype.decode = function (bytes, inputOffset, byteLength) {
var cachedValue = this.find(bytes, inputOffset, byteLength);
if (cachedValue != null) {
this.hit++;
return cachedValue;
}
this.miss++;
var str = utf8DecodeJs(bytes, inputOffset, byteLength);
// Ensure to copy a slice of bytes because the byte may be NodeJS Buffer and Buffer#slice() returns a reference to its internal ArrayBuffer.
var slicedCopyOfBytes = Uint8Array.prototype.slice.call(bytes, inputOffset, inputOffset + byteLength);
this.store(slicedCopyOfBytes, str);
return str;
};
return CachedKeyDecoder;
}());
export { CachedKeyDecoder };
//# sourceMappingURL=CachedKeyDecoder.mjs.map
1 change: 1 addition & 0 deletions dist.es5+esm/CachedKeyDecoder.mjs.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

33 changes: 33 additions & 0 deletions dist.es5+esm/DecodeError.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
var DecodeError = /** @class */ (function (_super) {
__extends(DecodeError, _super);
function DecodeError(message) {
var _this = _super.call(this, message) || this;
// fix the prototype chain in a cross-platform way
var proto = Object.create(DecodeError.prototype);
Object.setPrototypeOf(_this, proto);
Object.defineProperty(_this, "name", {
configurable: true,
enumerable: false,
value: DecodeError.name,
});
return _this;
}
return DecodeError;
}(Error));
export { DecodeError };
//# sourceMappingURL=DecodeError.mjs.map
1 change: 1 addition & 0 deletions dist.es5+esm/DecodeError.mjs.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 5c88f17

Please sign in to comment.