@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.$_$.b;
var copyOfRange = kotlin_kotlin.$_$.v3;
var protoOf = kotlin_kotlin.$_$.j8;
var objectCreate = kotlin_kotlin.$_$.i8;
var toCharArray = kotlin_kotlin.$_$.za;
var initMetadataForCompanion = kotlin_kotlin.$_$.u7;
var getKClassFromExpression = kotlin_kotlin.$_$.v8;
var THROW_CCE = kotlin_kotlin.$_$.bc;
var Unit_instance = kotlin_kotlin.$_$.v2;
var contentEquals = kotlin_kotlin.$_$.s3;
var contentHashCode = kotlin_kotlin.$_$.t3;
var IndexOutOfBoundsException_init_$Create$ = kotlin_kotlin.$_$.p1;
var _UByte___init__impl__g9hnc4 = kotlin_kotlin.$_$.n2;
var _UByte___get_data__impl__jof9qr = kotlin_kotlin.$_$.o2;
var compareTo = kotlin_kotlin.$_$.k7;
var StringBuilder_init_$Create$ = kotlin_kotlin.$_$.w;
var _Char___init__impl__6a9atx = kotlin_kotlin.$_$.b2;
var Comparable = kotlin_kotlin.$_$.ob;
var initMetadataForClass = kotlin_kotlin.$_$.t7;
var decodeToString = kotlin_kotlin.$_$.o9;
var initMetadataForObject = kotlin_kotlin.$_$.z7;
//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.y14_1 = new ByteString(new Int8Array(0), null);
this.z14_1 = toCharArray('0123456789abcdef');
}
protoOf(Companion).a15 = 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.b15_1 = data;
this.c15_1 = 0;
}
protoOf(ByteString).a1 = function () {
return this.b15_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.b15_1.length === this.b15_1.length))
return false;
if (!(other.c15_1 === 0) && !(this.c15_1 === 0) && !(other.c15_1 === this.c15_1))
return false;
return contentEquals(this.b15_1, other.b15_1);
};
protoOf(ByteString).hashCode = function () {
var hc = this.c15_1;
if (hc === 0) {
hc = contentHashCode(this.b15_1);
this.c15_1 = hc;
}
return hc;
};
protoOf(ByteString).b1 = function (index) {
if (index < 0 || index >= this.a1())
throw IndexOutOfBoundsException_init_$Create$('index (' + index + ') is out of byte string bounds: [0..' + this.a1() + ')');
return this.b15_1[index];
};
protoOf(ByteString).d15 = function (startIndex, endIndex) {
var tmp;
if (startIndex === endIndex) {
tmp = Companion_getInstance().y14_1;
} else {
tmp = ByteString_init_$Create$(this.b15_1, startIndex, endIndex);
}
return tmp;
};
protoOf(ByteString).e15 = function (startIndex, endIndex, $super) {
endIndex = endIndex === VOID ? this.a1() : endIndex;
return $super === VOID ? this.d15(startIndex, endIndex) : $super.d15.call(this, startIndex, endIndex);
};
protoOf(ByteString).f15 = function (other) {
if (other === this)
return 0;
var localData = this.b15_1;
var otherData = other.b15_1;
var inductionVariable = 0;
var tmp0 = this.a1();
// Inline function 'kotlin.math.min' call
var b = other.a1();
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.a1(), other.a1());
};
protoOf(ByteString).d = function (other) {
return this.f15(other instanceof ByteString ? other : THROW_CCE());
};
protoOf(ByteString).toString = function () {
if (isEmpty(this)) {
return 'ByteString(size=0)';
}
var sizeStr = this.a1().toString();
var len = (22 + sizeStr.length | 0) + imul(this.a1(), 2) | 0;
// Inline function 'kotlin.with' call
var $this$with = StringBuilder_init_$Create$(len);
$this$with.n('ByteString(size=');
$this$with.n(sizeStr);
$this$with.n(' hex=');
var localData = this.b15_1;
var inductionVariable = 0;
var last = this.a1();
if (inductionVariable < last)
do {
var i = inductionVariable;
inductionVariable = inductionVariable + 1 | 0;
var b = localData[i];
$this$with.p(Companion_getInstance().z14_1[(b >>> 4 | 0) & 15]);
$this$with.p(Companion_getInstance().z14_1[b & 15]);
}
while (inductionVariable < last);
return $this$with.p(_Char___init__impl__6a9atx(41)).toString();
};
protoOf(ByteString).g15 = function () {
return this.b15_1;
};
function ByteString_0(bytes) {
var tmp;
// Inline function 'kotlin.collections.isEmpty' call
if (bytes.length === 0) {
tmp = Companion_getInstance().y14_1;
} else {
tmp = Companion_getInstance().a15(bytes);
}
return tmp;
}
function decodeToString_0(_this__u8e3s4) {
return decodeToString(_this__u8e3s4.g15());
}
function isEmpty(_this__u8e3s4) {
return _this__u8e3s4.a1() === 0;
}
function UnsafeByteStringOperations() {
}
protoOf(UnsafeByteStringOperations).h15 = function (array) {
return Companion_getInstance().a15(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