@earth-app/shovel
Version:
Kotlin Multiplatform Web Scraping Framework
215 lines (213 loc) • 8.14 kB
JavaScript
(function (factory) {
if (typeof define === 'function' && define.amd)
define(['exports', './kotlin-kotlin-stdlib.js'], factory);
else if (typeof exports === 'object')
factory(module.exports, require('./kotlin-kotlin-stdlib.js'));
else {
if (typeof globalThis['kotlin-kotlin-stdlib'] === 'undefined') {
throw new Error("Error loading module 'kotlinx-io-kotlinx-io-bytestring'. Its dependency 'kotlin-kotlin-stdlib' was not found. Please, check whether 'kotlin-kotlin-stdlib' is loaded prior to 'kotlinx-io-kotlinx-io-bytestring'.");
}
globalThis['kotlinx-io-kotlinx-io-bytestring'] = factory(typeof globalThis['kotlinx-io-kotlinx-io-bytestring'] === 'undefined' ? {} : globalThis['kotlinx-io-kotlinx-io-bytestring'], globalThis['kotlin-kotlin-stdlib']);
}
}(function (_, kotlin_kotlin) {
'use strict';
//region block: imports
var imul = Math.imul;
var VOID = kotlin_kotlin.$_$.h;
var copyOfRange = kotlin_kotlin.$_$.a4;
var protoOf = kotlin_kotlin.$_$.z7;
var objectCreate = kotlin_kotlin.$_$.y7;
var toCharArray = kotlin_kotlin.$_$.ja;
var initMetadataForCompanion = kotlin_kotlin.$_$.j7;
var getKClassFromExpression = kotlin_kotlin.$_$.d;
var THROW_CCE = kotlin_kotlin.$_$.lb;
var Unit_instance = kotlin_kotlin.$_$.a3;
var contentEquals = kotlin_kotlin.$_$.x3;
var contentHashCode = kotlin_kotlin.$_$.y3;
var IndexOutOfBoundsException_init_$Create$ = kotlin_kotlin.$_$.v1;
var _UByte___init__impl__g9hnc4 = kotlin_kotlin.$_$.t2;
var _UByte___get_data__impl__jof9qr = kotlin_kotlin.$_$.u2;
var compareTo = kotlin_kotlin.$_$.z6;
var StringBuilder_init_$Create$ = kotlin_kotlin.$_$.c1;
var _Char___init__impl__6a9atx = kotlin_kotlin.$_$.h2;
var Comparable = kotlin_kotlin.$_$.ya;
var initMetadataForClass = kotlin_kotlin.$_$.i7;
var decodeToString = kotlin_kotlin.$_$.y8;
var initMetadataForObject = kotlin_kotlin.$_$.o7;
//endregion
//region block: pre-declaration
initMetadataForCompanion(Companion);
initMetadataForClass(ByteString, 'ByteString', VOID, VOID, [Comparable]);
initMetadataForObject(UnsafeByteStringOperations, 'UnsafeByteStringOperations');
//endregion
function ByteString_init_$Init$(data, startIndex, endIndex, $this) {
startIndex = startIndex === VOID ? 0 : startIndex;
endIndex = endIndex === VOID ? data.length : endIndex;
ByteString.call($this, copyOfRange(data, startIndex, endIndex), null);
return $this;
}
function ByteString_init_$Create$(data, startIndex, endIndex) {
return ByteString_init_$Init$(data, startIndex, endIndex, objectCreate(protoOf(ByteString)));
}
function Companion() {
Companion_instance = this;
this.c16_1 = new ByteString(new Int8Array(0), null);
this.d16_1 = toCharArray('0123456789abcdef');
}
protoOf(Companion).e16 = function (byteArray) {
return new ByteString(byteArray, null);
};
var Companion_instance;
function Companion_getInstance() {
if (Companion_instance == null)
new Companion();
return Companion_instance;
}
function ByteString(data, dummy) {
Companion_getInstance();
this.f16_1 = data;
this.g16_1 = 0;
}
protoOf(ByteString).j = function () {
return this.f16_1.length;
};
protoOf(ByteString).equals = function (other) {
if (this === other)
return true;
if (other == null || !getKClassFromExpression(this).equals(getKClassFromExpression(other)))
return false;
if (!(other instanceof ByteString))
THROW_CCE();
if (!(other.f16_1.length === this.f16_1.length))
return false;
if (!(other.g16_1 === 0) && !(this.g16_1 === 0) && !(other.g16_1 === this.g16_1))
return false;
return contentEquals(this.f16_1, other.f16_1);
};
protoOf(ByteString).hashCode = function () {
var hc = this.g16_1;
if (hc === 0) {
hc = contentHashCode(this.f16_1);
this.g16_1 = hc;
}
return hc;
};
protoOf(ByteString).o = function (index) {
if (index < 0 || index >= this.j())
throw IndexOutOfBoundsException_init_$Create$('index (' + index + ') is out of byte string bounds: [0..' + this.j() + ')');
return this.f16_1[index];
};
protoOf(ByteString).h16 = function (startIndex, endIndex) {
var tmp;
if (startIndex === endIndex) {
tmp = Companion_getInstance().c16_1;
} else {
tmp = ByteString_init_$Create$(this.f16_1, startIndex, endIndex);
}
return tmp;
};
protoOf(ByteString).i16 = function (startIndex, endIndex, $super) {
endIndex = endIndex === VOID ? this.j() : endIndex;
return $super === VOID ? this.h16(startIndex, endIndex) : $super.h16.call(this, startIndex, endIndex);
};
protoOf(ByteString).j16 = function (other) {
if (other === this)
return 0;
var localData = this.f16_1;
var otherData = other.f16_1;
var inductionVariable = 0;
var tmp0 = this.j();
// Inline function 'kotlin.math.min' call
var b = other.j();
var last = Math.min(tmp0, b);
if (inductionVariable < last)
do {
var i = inductionVariable;
inductionVariable = inductionVariable + 1 | 0;
// Inline function 'kotlin.toUByte' call
var this_0 = localData[i];
var tmp0_0 = _UByte___init__impl__g9hnc4(this_0);
// Inline function 'kotlin.toUByte' call
var this_1 = otherData[i];
// Inline function 'kotlin.UByte.compareTo' call
var other_0 = _UByte___init__impl__g9hnc4(this_1);
// Inline function 'kotlin.UByte.toInt' call
var tmp = _UByte___get_data__impl__jof9qr(tmp0_0) & 255;
// Inline function 'kotlin.UByte.toInt' call
var tmp$ret$4 = _UByte___get_data__impl__jof9qr(other_0) & 255;
var cmp = compareTo(tmp, tmp$ret$4);
if (!(cmp === 0))
return cmp;
}
while (inductionVariable < last);
return compareTo(this.j(), other.j());
};
protoOf(ByteString).d = function (other) {
return this.j16(other instanceof ByteString ? other : THROW_CCE());
};
protoOf(ByteString).toString = function () {
if (isEmpty(this)) {
return 'ByteString(size=0)';
}
var sizeStr = this.j().toString();
var len = (22 + sizeStr.length | 0) + imul(this.j(), 2) | 0;
// Inline function 'kotlin.with' call
var $this$with = StringBuilder_init_$Create$(len);
$this$with.e8('ByteString(size=');
$this$with.e8(sizeStr);
$this$with.e8(' hex=');
var localData = this.f16_1;
var inductionVariable = 0;
var last = this.j();
if (inductionVariable < last)
do {
var i = inductionVariable;
inductionVariable = inductionVariable + 1 | 0;
var b = localData[i];
$this$with.f8(Companion_getInstance().d16_1[(b >>> 4 | 0) & 15]);
$this$with.f8(Companion_getInstance().d16_1[b & 15]);
}
while (inductionVariable < last);
return $this$with.f8(_Char___init__impl__6a9atx(41)).toString();
};
protoOf(ByteString).k16 = function () {
return this.f16_1;
};
function ByteString_0(bytes) {
var tmp;
// Inline function 'kotlin.collections.isEmpty' call
if (bytes.length === 0) {
tmp = Companion_getInstance().c16_1;
} else {
tmp = Companion_getInstance().e16(bytes);
}
return tmp;
}
function isEmpty(_this__u8e3s4) {
return _this__u8e3s4.j() === 0;
}
function decodeToString_0(_this__u8e3s4) {
return decodeToString(_this__u8e3s4.k16());
}
function UnsafeByteStringOperations() {
}
protoOf(UnsafeByteStringOperations).l16 = function (array) {
return Companion_getInstance().e16(array);
};
var UnsafeByteStringOperations_instance;
function UnsafeByteStringOperations_getInstance() {
return UnsafeByteStringOperations_instance;
}
//region block: init
UnsafeByteStringOperations_instance = new UnsafeByteStringOperations();
//endregion
//region block: exports
_.$_$ = _.$_$ || {};
_.$_$.a = ByteString_init_$Create$;
_.$_$.b = UnsafeByteStringOperations_instance;
_.$_$.c = ByteString_0;
_.$_$.d = decodeToString_0;
//endregion
return _;
}));
//# sourceMappingURL=kotlinx-io-kotlinx-io-bytestring.js.map