Last active
February 15, 2019 09:44
-
-
Save e5l/d935c84bcda1cc4f8547ba10d3075b0a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function(root, factory) { | |
if (typeof define === 'function' && define.amd) | |
define(['exports', 'kotlin', 'ktor-utils', 'kotlinx-io', 'kotlinx-coroutines-core', 'ktor-http', 'kotlinx-coroutines-io'], factory); | |
else if (typeof exports === 'object') | |
factory(module.exports, require('kotlin'), require('ktor-utils'), require('kotlinx-io'), require('kotlinx-coroutines-core'), require('ktor-http'), require('kotlinx-coroutines-io')); | |
else { | |
if (typeof kotlin === 'undefined') { | |
throw new Error("Error loading module 'ktor-client-core'. Its dependency 'kotlin' was not found. Please, check whether 'kotlin' is loaded prior to 'ktor-client-core'."); | |
} | |
if (typeof this['ktor-utils'] === 'undefined') { | |
throw new Error("Error loading module 'ktor-client-core'. Its dependency 'ktor-utils' was not found. Please, check whether 'ktor-utils' is loaded prior to 'ktor-client-core'."); | |
} | |
if (typeof this['kotlinx-io'] === 'undefined') { | |
throw new Error("Error loading module 'ktor-client-core'. Its dependency 'kotlinx-io' was not found. Please, check whether 'kotlinx-io' is loaded prior to 'ktor-client-core'."); | |
} | |
if (false) { | |
} | |
if (typeof this['kotlinx-coroutines-core'] === 'undefined') { | |
throw new Error("Error loading module 'ktor-client-core'. Its dependency 'kotlinx-coroutines-core' was not found. Please, check whether 'kotlinx-coroutines-core' is loaded prior to 'ktor-client-core'."); | |
} | |
if (typeof this['ktor-http'] === 'undefined') { | |
throw new Error("Error loading module 'ktor-client-core'. Its dependency 'ktor-http' was not found. Please, check whether 'ktor-http' is loaded prior to 'ktor-client-core'."); | |
} | |
if (typeof this['kotlinx-coroutines-io'] === 'undefined') { | |
throw new Error("Error loading module 'ktor-client-core'. Its dependency 'kotlinx-coroutines-io' was not found. Please, check whether 'kotlinx-coroutines-io' is loaded prior to 'ktor-client-core'."); | |
} | |
root['ktor-client-core'] = factory(typeof this['ktor-client-core'] === 'undefined' ? {} : this['ktor-client-core'], kotlin, this['ktor-utils'], this['kotlinx-io'], this['kotlinx-coroutines-core'], this['ktor-http'], this['kotlinx-coroutines-io']); | |
} | |
}(this, function(_, Kotlin, $module$ktor_utils, $module$kotlinx_io, $module$kotlinx_coroutines_core, $module$ktor_http, $module$kotlinx_coroutines_io) { | |
'use strict'; | |
var $$importsForInline$$ = _.$$importsForInline$$ || (_.$$importsForInline$$ = {}); | |
var Unit = Kotlin.kotlin.Unit; | |
var COROUTINE_SUSPENDED = Kotlin.kotlin.coroutines.intrinsics.COROUTINE_SUSPENDED; | |
var CoroutineImpl = Kotlin.kotlin.coroutines.CoroutineImpl; | |
var throwCCE = Kotlin.throwCCE; | |
var AttributeKey = $module$ktor_utils.io.ktor.util.AttributeKey; | |
var Closeable = $module$kotlinx_io.kotlinx.io.core.Closeable; | |
var Job = $module$kotlinx_coroutines_core.kotlinx.coroutines.Job; | |
var ensureNotNull = Kotlin.ensureNotNull; | |
var CompletableDeferred = $module$kotlinx_coroutines_core.kotlinx.coroutines.CompletableDeferred; | |
var Attributes = $module$ktor_utils.io.ktor.util.AttributesJsFn; | |
var Kind_CLASS = Kotlin.Kind.CLASS; | |
var CoroutineScope = $module$kotlinx_coroutines_core.kotlinx.coroutines.CoroutineScope; | |
var http = $module$ktor_http.io.ktor.http; | |
var UnsafeHeaderException = $module$ktor_http.io.ktor.http.UnsafeHeaderException; | |
var Annotation = Kotlin.kotlin.Annotation; | |
var throwUPAE = Kotlin.throwUPAE; | |
var Throwable = Error; | |
var defineInlineFunction = Kotlin.defineInlineFunction; | |
var wrapFunction = Kotlin.wrapFunction; | |
var IllegalStateException_init = Kotlin.kotlin.IllegalStateException_init; | |
var IllegalStateException = Kotlin.kotlin.IllegalStateException; | |
var IllegalStateException_init_0 = Kotlin.kotlin.IllegalStateException_init_pdl1vj$; | |
var UnsupportedOperationException_init = Kotlin.kotlin.UnsupportedOperationException_init; | |
var UnsupportedOperationException = Kotlin.kotlin.UnsupportedOperationException; | |
var IllegalArgumentException_init = Kotlin.kotlin.IllegalArgumentException_init_pdl1vj$; | |
var IllegalArgumentException = Kotlin.kotlin.IllegalArgumentException; | |
var takeFrom = $module$ktor_http.io.ktor.http.takeFrom_jl1sg7$; | |
var takeFrom_0 = $module$ktor_http.io.ktor.http.takeFrom_wol2ee$; | |
var Kind_INTERFACE = Kotlin.Kind.INTERFACE; | |
var equals = Kotlin.equals; | |
var joinToString = Kotlin.kotlin.collections.joinToString_fmv235$; | |
var Kind_OBJECT = Kotlin.Kind.OBJECT; | |
var OutgoingContent$ByteArrayContent = $module$ktor_http.io.ktor.http.content.OutgoingContent.ByteArrayContent; | |
var toLong = Kotlin.kotlin.text.toLong_pdl1vz$; | |
var Long$Companion$MAX_VALUE = Kotlin.Long.MAX_VALUE; | |
var cancel = $module$kotlinx_coroutines_io.kotlinx.coroutines.io.cancel_ep79e2$; | |
var getKClass = Kotlin.getKClass; | |
var kotlin = Kotlin.kotlin; | |
var ByteReadChannel = $module$kotlinx_coroutines_io.kotlinx.coroutines.io.ByteReadChannel; | |
var readRemaining = $module$kotlinx_coroutines_io.kotlinx.coroutines.io.readRemaining_5joj65$; | |
var readBytes = $module$kotlinx_io.kotlinx.io.core.readBytes_3lionn$; | |
var PrimitiveClasses$byteArrayClass = Kotlin.kotlin.reflect.js.internal.PrimitiveClasses.byteArrayClass; | |
var charsets = $module$kotlinx_io.kotlinx.io.charsets; | |
var ContentType = $module$ktor_http.io.ktor.http.ContentType; | |
var withCharset = $module$ktor_http.io.ktor.http.withCharset_p1my6q$; | |
var TextContent = $module$ktor_http.io.ktor.http.content.TextContent; | |
var PrimitiveClasses$stringClass = Kotlin.kotlin.reflect.js.internal.PrimitiveClasses.stringClass; | |
var HttpStatusCode = $module$ktor_http.io.ktor.http.HttpStatusCode; | |
var OutgoingContent = $module$ktor_http.io.ktor.http.content.OutgoingContent; | |
var GMTDate = $module$ktor_utils.io.ktor.util.date.GMTDate_mts6q2$; | |
var isBlank = Kotlin.kotlin.text.isBlank_gw00vp$; | |
var removeAll = Kotlin.kotlin.collections.removeAll_qafx1e$; | |
var L0 = Kotlin.Long.ZERO; | |
var Lock = $module$ktor_utils.io.ktor.util.Lock; | |
var URLBuilder = $module$ktor_http.io.ktor.http.URLBuilder; | |
var toList = Kotlin.kotlin.collections.toList_7wnvza$; | |
var Url = $module$ktor_http.io.ktor.http.Url_61zpoe$; | |
var trimStart = Kotlin.kotlin.text.trimStart_wqw3xr$; | |
var endsWith = Kotlin.kotlin.text.endsWith_sgbm27$; | |
var toString = Kotlin.toString; | |
var hostIsIp = $module$ktor_http.io.ktor.http.hostIsIp_61zpoe$; | |
var endsWith_0 = Kotlin.kotlin.text.endsWith_7epoxm$; | |
var startsWith = Kotlin.kotlin.text.startsWith_7epoxm$; | |
var isSecure = $module$ktor_http.io.ktor.http.isSecure_v5fpbg$; | |
var clone = $module$ktor_http.io.ktor.http.clone_3q1sfd$; | |
var setCookie = $module$ktor_http.io.ktor.http.setCookie_v1wgmc$; | |
var encodeURLParameter = $module$ktor_http.io.ktor.http.encodeURLParameter_f4dhtg$; | |
var emptyList = Kotlin.kotlin.collections.emptyList_287e2$; | |
var CompletableDeferred_0 = $module$kotlinx_coroutines_core.kotlinx.coroutines.CompletableDeferred_xptg6w$; | |
var split = $module$ktor_utils.io.ktor.util.split_eiug82$; | |
var launch = $module$kotlinx_coroutines_core.kotlinx.coroutines.launch_s496o7$; | |
var copyAndClose = $module$kotlinx_coroutines_io.kotlinx.coroutines.io.copyAndClose_lhug7f$; | |
var OutgoingContent$NoContent = $module$ktor_http.io.ktor.http.content.OutgoingContent.NoContent; | |
var ByteChannel = $module$kotlinx_coroutines_io.kotlinx.coroutines.io.ByteChannel_6taknv$; | |
var lazy = Kotlin.kotlin.lazy_klfg04$; | |
var HttpMessage = $module$ktor_http.io.ktor.http.HttpMessage; | |
var takeFrom_1 = $module$ktor_http.io.ktor.http.takeFrom_rs9g2p$; | |
var appendAll = $module$ktor_utils.io.ktor.util.appendAll_k10e8h$; | |
var HttpMethod = $module$ktor_http.io.ktor.http.HttpMethod; | |
var HeadersBuilder = $module$ktor_http.io.ktor.http.HeadersBuilder; | |
var HttpMessageBuilder = $module$ktor_http.io.ktor.http.HttpMessageBuilder; | |
var URLProtocol = $module$ktor_http.io.ktor.http.URLProtocol; | |
var PipelinePhase = $module$ktor_utils.io.ktor.util.pipeline.PipelinePhase; | |
var Pipeline = $module$ktor_utils.io.ktor.util.pipeline.Pipeline; | |
var formUrlEncode = $module$ktor_http.io.ktor.http.formUrlEncode_invt95$; | |
var writeStringUtf8 = $module$kotlinx_coroutines_io.kotlinx.coroutines.io.writeStringUtf8_n9qdmv$; | |
var readBytes_0 = $module$kotlinx_io.kotlinx.io.core.readBytes_wb5b4t$; | |
var writeFully = $module$kotlinx_coroutines_io.kotlinx.coroutines.io.writeFully_p8yv3v$; | |
var PartData$FileItem = $module$ktor_http.io.ktor.http.content.PartData.FileItem; | |
var PartData$FormItem = $module$ktor_http.io.ktor.http.content.PartData.FormItem; | |
var PartData$BinaryItem = $module$ktor_http.io.ktor.http.content.PartData.BinaryItem; | |
var close = $module$kotlinx_coroutines_io.kotlinx.coroutines.io.close_sypobt$; | |
var OutgoingContent$WriteChannelContent = $module$ktor_http.io.ktor.http.content.OutgoingContent.WriteChannelContent; | |
var Random = Kotlin.kotlin.random.Random; | |
var toString_0 = Kotlin.kotlin.text.toString_dqglrj$; | |
var take = Kotlin.kotlin.text.take_6ic1pp$; | |
var Headers = $module$ktor_http.io.ktor.http.Headers; | |
var writeFully_0 = $module$kotlinx_io.kotlinx.io.core.writeFully_u129dg$; | |
var Input = $module$kotlinx_io.kotlinx.io.core.Input; | |
var charset = $module$ktor_http.io.ktor.http.charset_v1wgmc$; | |
var readText = $module$kotlinx_io.kotlinx.io.core.readText_q10u79$; | |
var Charset = $module$kotlinx_io.kotlinx.io.charsets.Charset; | |
var readFully = $module$kotlinx_coroutines_io.kotlinx.coroutines.io.readFully_5l0546$; | |
var discard = $module$kotlinx_coroutines_io.kotlinx.coroutines.io.discard_ep79e2$; | |
var OutgoingContent$ReadChannelContent = $module$ktor_http.io.ktor.http.content.OutgoingContent.ReadChannelContent; | |
var OutgoingContent$ProtocolUpgrade = $module$ktor_http.io.ktor.http.content.OutgoingContent.ProtocolUpgrade; | |
var CoroutineScope_0 = $module$kotlinx_coroutines_core.kotlinx.coroutines.CoroutineScope_1fupul$; | |
var withContext = $module$kotlinx_coroutines_core.kotlinx.coroutines.withContext_i5cbzn$; | |
var coroutines = $module$kotlinx_coroutines_core.kotlinx.coroutines; | |
var SupervisorJob = $module$kotlinx_coroutines_core.kotlinx.coroutines.SupervisorJob_5dx9e$; | |
var HttpProtocolVersion = $module$ktor_http.io.ktor.http.HttpProtocolVersion; | |
var readRemaining_0 = $module$kotlinx_coroutines_io.kotlinx.coroutines.io.readRemaining_ep79e2$; | |
var writer = $module$kotlinx_coroutines_io.kotlinx.coroutines.io.writer_r5ogg1$; | |
var toTypedArray = Kotlin.kotlin.collections.toTypedArray_964n91$; | |
var Any = Object; | |
var Error_init = Kotlin.kotlin.Error_init_pdl1vj$; | |
DoubleReceiveException.prototype = Object.create(IllegalStateException.prototype); | |
DoubleReceiveException.prototype.constructor = DoubleReceiveException; | |
ReceivePipelineException.prototype = Object.create(IllegalStateException.prototype); | |
ReceivePipelineException.prototype.constructor = ReceivePipelineException; | |
NoTransformationFoundException.prototype = Object.create(UnsupportedOperationException.prototype); | |
NoTransformationFoundException.prototype.constructor = NoTransformationFoundException; | |
UnsupportedContentTypeException.prototype = Object.create(IllegalStateException.prototype); | |
UnsupportedContentTypeException.prototype.constructor = UnsupportedContentTypeException; | |
UnsupportedUpgradeProtocolException.prototype = Object.create(IllegalArgumentException.prototype); | |
UnsupportedUpgradeProtocolException.prototype.constructor = UnsupportedUpgradeProtocolException; | |
defaultTransformers$lambda$ObjectLiteral.prototype = Object.create(OutgoingContent$ByteArrayContent.prototype); | |
defaultTransformers$lambda$ObjectLiteral.prototype.constructor = defaultTransformers$lambda$ObjectLiteral; | |
BadResponseStatusException.prototype = Object.create(IllegalStateException.prototype); | |
BadResponseStatusException.prototype.constructor = BadResponseStatusException; | |
RedirectException.prototype = Object.create(IllegalStateException.prototype); | |
RedirectException.prototype.constructor = RedirectException; | |
SendCountExceedException.prototype = Object.create(IllegalStateException.prototype); | |
SendCountExceedException.prototype.constructor = SendCountExceedException; | |
ClientUpgradeContent.prototype = Object.create(OutgoingContent$NoContent.prototype); | |
ClientUpgradeContent.prototype.constructor = ClientUpgradeContent; | |
HttpRequestPipeline.prototype = Object.create(Pipeline.prototype); | |
HttpRequestPipeline.prototype.constructor = HttpRequestPipeline; | |
HttpSendPipeline.prototype = Object.create(Pipeline.prototype); | |
HttpSendPipeline.prototype.constructor = HttpSendPipeline; | |
FormDataContent.prototype = Object.create(OutgoingContent$ByteArrayContent.prototype); | |
FormDataContent.prototype.constructor = FormDataContent; | |
MultiPartFormDataContent.prototype = Object.create(OutgoingContent$WriteChannelContent.prototype); | |
MultiPartFormDataContent.prototype.constructor = MultiPartFormDataContent; | |
HttpResponsePipeline.prototype = Object.create(Pipeline.prototype); | |
HttpResponsePipeline.prototype.constructor = HttpResponsePipeline; | |
HttpReceivePipeline.prototype = Object.create(Pipeline.prototype); | |
HttpReceivePipeline.prototype.constructor = HttpReceivePipeline; | |
EmptyContent.prototype = Object.create(OutgoingContent$NoContent.prototype); | |
EmptyContent.prototype.constructor = EmptyContent; | |
wrapHeaders$ObjectLiteral.prototype = Object.create(OutgoingContent$NoContent.prototype); | |
wrapHeaders$ObjectLiteral.prototype.constructor = wrapHeaders$ObjectLiteral; | |
wrapHeaders$ObjectLiteral_0.prototype = Object.create(OutgoingContent$ReadChannelContent.prototype); | |
wrapHeaders$ObjectLiteral_0.prototype.constructor = wrapHeaders$ObjectLiteral_0; | |
wrapHeaders$ObjectLiteral_1.prototype = Object.create(OutgoingContent$WriteChannelContent.prototype); | |
wrapHeaders$ObjectLiteral_1.prototype.constructor = wrapHeaders$ObjectLiteral_1; | |
wrapHeaders$ObjectLiteral_2.prototype = Object.create(OutgoingContent$ByteArrayContent.prototype); | |
wrapHeaders$ObjectLiteral_2.prototype.constructor = wrapHeaders$ObjectLiteral_2; | |
wrapHeaders$ObjectLiteral_3.prototype = Object.create(OutgoingContent$ProtocolUpgrade.prototype); | |
wrapHeaders$ObjectLiteral_3.prototype.constructor = wrapHeaders$ObjectLiteral_3; | |
JsError.prototype = Object.create(Throwable.prototype); | |
JsError.prototype.constructor = JsError; | |
BrowserUtils.prototype = Object.create(Utils.prototype); | |
BrowserUtils.prototype.constructor = BrowserUtils; | |
NodeUtils.prototype = Object.create(Utils.prototype); | |
NodeUtils.prototype.constructor = NodeUtils; | |
function HttpClient$lambda($receiver) { | |
return Unit; | |
} | |
function HttpClient(engineFactory, block) { | |
if (block === void 0) | |
block = HttpClient$lambda; | |
var $receiver = new HttpClientConfig(); | |
block($receiver); | |
var config = $receiver; | |
var engine = engineFactory.create_dxyxif$(config.engineConfig_8be2vx$); | |
return new HttpClient_1(engine, config); | |
} | |
function HttpClient_0(engine, block) { | |
var $receiver = new HttpClientConfig(); | |
block($receiver); | |
return new HttpClient_1(engine, $receiver); | |
} | |
function HttpClient_1(engine, userConfig) { | |
if (userConfig === void 0) | |
userConfig = new HttpClientConfig(); | |
this.engine = engine; | |
this.userConfig_0 = userConfig; | |
this.closed_0 = false; | |
this.requestPipeline = new HttpRequestPipeline(); | |
this.responsePipeline = new HttpResponsePipeline(); | |
var $receiver = new HttpSendPipeline(); | |
$receiver.intercept_h71y74$(HttpSendPipeline$Phases_getInstance().Engine, HttpClient$sendPipeline$lambda$lambda(this)); | |
this.sendPipeline = $receiver; | |
this.receivePipeline = new HttpReceivePipeline(); | |
this.attributes = Attributes(); | |
this.engineConfig = this.engine.config; | |
this.config_0 = new HttpClientConfig(); | |
var $receiver_0 = this.userConfig_0; | |
if ($receiver_0.useDefaultTransformers) { | |
this.config_0.install_xlxg29$(HttpPlainText$Feature_getInstance()); | |
this.config_0.install_q2ual$('DefaultTransformers', HttpClient_init$lambda$lambda); | |
} | |
if ($receiver_0.expectSuccess) | |
this.config_0.install_xlxg29$(ExpectSuccess$Companion_getInstance()); | |
this.config_0.install_xlxg29$(HttpSend$Feature_getInstance()); | |
if ($receiver_0.followRedirects) | |
this.config_0.install_xlxg29$(HttpRedirect$Feature_getInstance()); | |
this.config_0.plusAssign_bi476h$($receiver_0); | |
this.config_0.install_k5i6f8$(this); | |
} | |
Object.defineProperty(HttpClient_1.prototype, 'coroutineContext', { | |
get: function() { | |
return this.engine.coroutineContext; | |
}}); | |
Object.defineProperty(HttpClient_1.prototype, 'dispatcher', { | |
get: function() { | |
return this.engine.dispatcher; | |
}}); | |
function Coroutine$execute_s9rlw$($this, builder_0, continuation_0) { | |
CoroutineImpl.call(this, continuation_0); | |
this.exceptionState_0 = 1; | |
this.$this = $this; | |
this.local$builder = builder_0; | |
} | |
Coroutine$execute_s9rlw$.$metadata$ = { | |
kind: Kotlin.Kind.CLASS, | |
simpleName: null, | |
interfaces: [CoroutineImpl]}; | |
Coroutine$execute_s9rlw$.prototype = Object.create(CoroutineImpl.prototype); | |
Coroutine$execute_s9rlw$.prototype.constructor = Coroutine$execute_s9rlw$; | |
Coroutine$execute_s9rlw$.prototype.doResume = function() { | |
do try { | |
switch (this.state_0) { | |
case 0: | |
var tmp$; | |
this.state_0 = 2; | |
this.result_0 = this.$this.requestPipeline.execute_8pmvt0$(this.local$builder, this.local$builder.body, this); | |
if (this.result_0 === COROUTINE_SUSPENDED) | |
return COROUTINE_SUSPENDED; | |
continue; | |
case 1: | |
throw this.exception_0; | |
case 2: | |
return Kotlin.isType(tmp$ = this.result_0, HttpClientCall) ? tmp$ : throwCCE(); | |
default: | |
this.state_0 = 1; | |
throw new Error('State Machine Unreachable execution'); | |
} | |
} catch (e) { | |
if (this.state_0 === 1) { | |
this.exceptionState_0 = this.state_0; | |
throw e; | |
} else { | |
this.state_0 = this.exceptionState_0; | |
this.exception_0 = e; | |
} | |
} while (true); | |
}; | |
HttpClient_1.prototype.execute_s9rlw$ = function(builder_0, continuation_0, suspended) { | |
var instance = new Coroutine$execute_s9rlw$(this, builder_0, continuation_0); | |
if (suspended) | |
return instance; | |
else | |
return instance.doResume(null); | |
}; | |
HttpClient_1.prototype.config_f0veat$ = function(block) { | |
var tmp$ = this.engine; | |
var $receiver = new HttpClientConfig(); | |
$receiver.plusAssign_bi476h$(this.userConfig_0); | |
block($receiver); | |
return new HttpClient_1(tmp$, $receiver); | |
}; | |
HttpClient_1.prototype.close = function() { | |
var success = (function(scope) {return scope.closed_0 === false ? function() {scope.closed_0 = true;return true;}() : false})(this); | |
if (!success) | |
return; | |
var tmp$; | |
tmp$ = this.attributes.allKeys.iterator(); | |
while (tmp$.hasNext()) { | |
var element = tmp$.next(); | |
var tmp$_0; | |
var feature = this.attributes.get_yzaw86$(Kotlin.isType(tmp$_0 = element, AttributeKey) ? tmp$_0 : throwCCE()); | |
if (Kotlin.isType(feature, Closeable)) { | |
feature.close(); | |
} | |
} | |
this.engine.close(); | |
}; | |
function HttpClient$sendPipeline$lambda$lambda$lambda(closure$requestData) { | |
return function(cause) { | |
var tmp$; | |
var childContext = Kotlin.isType(tmp$ = closure$requestData.executionContext, CompletableDeferred) ? tmp$ : throwCCE(); | |
if (cause == null) | |
childContext.complete_11rb$(Unit); | |
else | |
childContext.completeExceptionally_tcv7n7$(cause); | |
return Unit; | |
}; | |
} | |
function Coroutine$HttpClient$sendPipeline$lambda$lambda(this$HttpClient_0, $receiver_0, content_0, controller, continuation_0) { | |
CoroutineImpl.call(this, continuation_0); | |
this.$controller = controller; | |
this.exceptionState_0 = 1; | |
this.local$this$HttpClient = this$HttpClient_0; | |
this.local$call = void 0; | |
this.local$requestData = void 0; | |
this.local$$receiver = $receiver_0; | |
this.local$content = content_0; | |
} | |
Coroutine$HttpClient$sendPipeline$lambda$lambda.$metadata$ = { | |
kind: Kotlin.Kind.CLASS, | |
simpleName: null, | |
interfaces: [CoroutineImpl]}; | |
Coroutine$HttpClient$sendPipeline$lambda$lambda.prototype = Object.create(CoroutineImpl.prototype); | |
Coroutine$HttpClient$sendPipeline$lambda$lambda.prototype.constructor = Coroutine$HttpClient$sendPipeline$lambda$lambda; | |
Coroutine$HttpClient$sendPipeline$lambda$lambda.prototype.doResume = function() { | |
do try { | |
switch (this.state_0) { | |
case 0: | |
this.local$call = new HttpClientCall(this.local$this$HttpClient); | |
var $receiver = new HttpRequestBuilder(); | |
$receiver.takeFrom_s9rlw$(this.local$$receiver.context); | |
$receiver.body = this.local$content; | |
this.local$requestData = $receiver.build(); | |
validateHeaders(this.local$requestData); | |
this.state_0 = 2; | |
this.result_0 = this.local$this$HttpClient.engine.execute_jw3znh$(this.local$call, this.local$requestData, this); | |
if (this.result_0 === COROUTINE_SUSPENDED) | |
return COROUTINE_SUSPENDED; | |
continue; | |
case 1: | |
throw this.exception_0; | |
case 2: | |
var tmp$ = this.result_0; | |
var request = tmp$.component1(), response = tmp$.component2(); | |
this.local$call.request = request; | |
this.local$call.response = response; | |
ensureNotNull(response.coroutineContext.get_j3r2sn$(Job.Key)).invokeOnCompletion_f05bi3$(HttpClient$sendPipeline$lambda$lambda$lambda(this.local$requestData)); | |
this.state_0 = 3; | |
this.result_0 = this.local$this$HttpClient.receivePipeline.execute_8pmvt0$(this.local$call, this.local$call.response, this); | |
if (this.result_0 === COROUTINE_SUSPENDED) | |
return COROUTINE_SUSPENDED; | |
continue; | |
case 3: | |
var receivedCall = this.result_0.call; | |
this.state_0 = 4; | |
this.result_0 = this.local$$receiver.proceedWith_trkh7z$(receivedCall, this); | |
if (this.result_0 === COROUTINE_SUSPENDED) | |
return COROUTINE_SUSPENDED; | |
continue; | |
case 4: | |
return this.result_0; | |
default: | |
this.state_0 = 1; | |
throw new Error('State Machine Unreachable execution'); | |
} | |
} catch (e) { | |
if (this.state_0 === 1) { | |
this.exceptionState_0 = this.state_0; | |
throw e; | |
} else { | |
this.state_0 = this.exceptionState_0; | |
this.exception_0 = e; | |
} | |
} while (true); | |
}; | |
function HttpClient$sendPipeline$lambda$lambda(this$HttpClient_0) { | |
return function($receiver_0, content_0, continuation_0, suspended) { | |
var instance = new Coroutine$HttpClient$sendPipeline$lambda$lambda(this$HttpClient_0, $receiver_0, content_0, this, continuation_0); | |
if (suspended) | |
return instance; | |
else | |
return instance.doResume(null); | |
}; | |
} | |
function HttpClient_init$lambda$lambda($receiver) { | |
defaultTransformers($receiver); | |
return Unit; | |
} | |
HttpClient_1.$metadata$ = { | |
kind: Kind_CLASS, | |
simpleName: 'HttpClient', | |
interfaces: [Closeable, CoroutineScope]}; | |
function validateHeaders(request) { | |
var tmp$, tmp$_0; | |
var requestHeaders = request.headers; | |
tmp$ = http.HttpHeaders.UnsafeHeaders; | |
for (tmp$_0 = 0; tmp$_0 !== tmp$.length; ++tmp$_0) { | |
var header = tmp$[tmp$_0]; | |
if (requestHeaders.contains_61zpoe$(header)) { | |
throw new UnsafeHeaderException(header); | |
} | |
} | |
} | |
var LinkedHashMap_init = Kotlin.kotlin.collections.LinkedHashMap_init_q3lmfv$; | |
function HttpClientConfig() { | |
this.features_0 = LinkedHashMap_init(); | |
this.customInterceptors_0 = LinkedHashMap_init(); | |
this.engineConfig_8be2vx$ = HttpClientConfig$engineConfig$lambda; | |
this.followRedirects = true; | |
this.useDefaultTransformers = true; | |
this.expectSuccess = true; | |
} | |
function HttpClientConfig$engine$lambda(closure$oldConfig, closure$block) { | |
return function($receiver) { | |
closure$oldConfig($receiver); | |
closure$block($receiver); | |
return Unit; | |
}; | |
} | |
HttpClientConfig.prototype.engine_dxyxif$ = function(block) { | |
var oldConfig = this.engineConfig_8be2vx$; | |
this.engineConfig_8be2vx$ = HttpClientConfig$engine$lambda(oldConfig, block); | |
}; | |
function HttpClientConfig$install$lambda($receiver) { | |
return Unit; | |
} | |
function HttpClientConfig$install$lambda$lambda() { | |
return Attributes(); | |
} | |
function HttpClientConfig$install$lambda_0(closure$feature, closure$featureData) { | |
return function(scope) { | |
var attributes = scope.attributes.computeIfAbsent_u4q9l2$(FEATURE_INSTALLED_LIST, HttpClientConfig$install$lambda$lambda); | |
closure$feature.install_wojrb5$(closure$featureData, scope); | |
attributes.put_uuntuo$(closure$feature.key, closure$featureData); | |
return Unit; | |
}; | |
} | |
HttpClientConfig.prototype.install_xlxg29$ = function(feature, configure) { | |
if (configure === void 0) | |
configure = HttpClientConfig$install$lambda; | |
var featureData = feature.prepare_oh3mgy$(configure); | |
var $receiver = this.features_0; | |
var key = feature.key; | |
$receiver.put_xwzc9p$(key, HttpClientConfig$install$lambda_0(feature, featureData)); | |
}; | |
HttpClientConfig.prototype.install_q2ual$ = function(key, block) { | |
this.customInterceptors_0.put_xwzc9p$(key, block); | |
}; | |
HttpClientConfig.prototype.install_k5i6f8$ = function(client) { | |
var tmp$; | |
tmp$ = this.features_0.values.iterator(); | |
while (tmp$.hasNext()) { | |
var element = tmp$.next(); | |
element(client); | |
} | |
var tmp$_0; | |
tmp$_0 = this.customInterceptors_0.values.iterator(); | |
while (tmp$_0.hasNext()) { | |
var element_0 = tmp$_0.next(); | |
element_0(client); | |
} | |
}; | |
HttpClientConfig.prototype.clone = function() { | |
var result = new HttpClientConfig(); | |
result.features_0.putAll_a2k3zr$(this.features_0); | |
result.customInterceptors_0.putAll_a2k3zr$(this.customInterceptors_0); | |
result.engineConfig_8be2vx$ = this.engineConfig_8be2vx$; | |
return result; | |
}; | |
HttpClientConfig.prototype.plusAssign_bi476h$ = function(other) { | |
this.followRedirects = other.followRedirects; | |
this.useDefaultTransformers = other.useDefaultTransformers; | |
this.expectSuccess = other.expectSuccess; | |
var $receiver = this.features_0; | |
var map = other.features_0; | |
$receiver.putAll_a2k3zr$(map); | |
var $receiver_0 = this.customInterceptors_0; | |
var map_0 = other.customInterceptors_0; | |
$receiver_0.putAll_a2k3zr$(map_0); | |
}; | |
function HttpClientConfig$engineConfig$lambda($receiver) { | |
return Unit; | |
} | |
HttpClientConfig.$metadata$ = { | |
kind: Kind_CLASS, | |
simpleName: 'HttpClientConfig', | |
interfaces: []}; | |
function HttpClientDsl() { | |
} | |
HttpClientDsl.$metadata$ = { | |
kind: Kind_CLASS, | |
simpleName: 'HttpClientDsl', | |
interfaces: [Annotation]}; | |
function HttpClientCall(client) { | |
this.client = client; | |
this.received_8b75r7$_0 = false; | |
this.request_vta333$_0 = this.request_vta333$_0; | |
this.response_zcvbsz$_0 = this.response_zcvbsz$_0; | |
this.responseConfig = this.client.engineConfig.response; | |
} | |
Object.defineProperty(HttpClientCall.prototype, 'coroutineContext', { | |
get: function() { | |
return this.response.coroutineContext; | |
}}); | |
Object.defineProperty(HttpClientCall.prototype, 'attributes', { | |
get: function() { | |
return this.request.attributes; | |
}}); | |
Object.defineProperty(HttpClientCall.prototype, 'request', { | |
get: function() { | |
if (this.request_vta333$_0 == null) | |
return throwUPAE('request'); | |
return this.request_vta333$_0; | |
}, | |
set: function(request) { | |
this.request_vta333$_0 = request; | |
}}); | |
Object.defineProperty(HttpClientCall.prototype, 'response', { | |
get: function() { | |
if (this.response_zcvbsz$_0 == null) | |
return throwUPAE('response'); | |
return this.response_zcvbsz$_0; | |
}, | |
set: function(response) { | |
this.response_zcvbsz$_0 = response; | |
}}); | |
function Coroutine$receive_jo9acv$($this, info_0, continuation_0) { | |
CoroutineImpl.call(this, continuation_0); | |
this.exceptionState_0 = 5; | |
this.$this = $this; | |
this.local$info = info_0; | |
} | |
Coroutine$receive_jo9acv$.$metadata$ = { | |
kind: Kotlin.Kind.CLASS, | |
simpleName: null, | |
interfaces: [CoroutineImpl]}; | |
Coroutine$receive_jo9acv$.prototype = Object.create(CoroutineImpl.prototype); | |
Coroutine$receive_jo9acv$.prototype.constructor = Coroutine$receive_jo9acv$; | |
Coroutine$receive_jo9acv$.prototype.doResume = function() { | |
do try { | |
switch (this.state_0) { | |
case 0: | |
if (this.local$info.type.isInstance_s8jyv4$(this.$this.response)) { | |
return this.$this.response; | |
} else { | |
this.state_0 = 1; | |
continue; | |
} | |
case 1: | |
if (!(function(scope) {return scope.$this.received_8b75r7$_0 === false ? function() {scope.$this.received_8b75r7$_0 = true;return true;}() : false})(this)) | |
throw new DoubleReceiveException(this.$this); | |
var subject = new HttpResponseContainer(this.local$info, this.$this.response); | |
this.exceptionState_0 = 3; | |
this.state_0 = 2; | |
this.result_0 = this.$this.client.responsePipeline.execute_8pmvt0$(this.$this, subject, this); | |
if (this.result_0 === COROUTINE_SUSPENDED) | |
return COROUTINE_SUSPENDED; | |
continue; | |
case 2: | |
var result = this.result_0.response; | |
if (!this.local$info.type.isInstance_s8jyv4$(result)) | |
throw new NoTransformationFoundException(Kotlin.getKClassFromExpression(result), this.local$info.type); | |
return result; | |
case 3: | |
this.exceptionState_0 = 5; | |
var cause = this.exception_0; | |
if (Kotlin.isType(cause, BadResponseStatusException)) { | |
throw cause; | |
} else if (Kotlin.isType(cause, Throwable)) { | |
throw new ReceivePipelineException(this.$this.response.call, this.local$info, cause); | |
} else | |
throw cause; | |
case 4: | |
return; | |
case 5: | |
throw this.exception_0; | |
default: | |
this.state_0 = 5; | |
throw new Error('State Machine Unreachable execution'); | |
} | |
} catch (e) { | |
if (this.state_0 === 5) { | |
this.exceptionState_0 = this.state_0; | |
throw e; | |
} else { | |
this.state_0 = this.exceptionState_0; | |
this.exception_0 = e; | |
} | |
} while (true); | |
}; | |
HttpClientCall.prototype.receive_jo9acv$ = function(info_0, continuation_0, suspended) { | |
var instance = new Coroutine$receive_jo9acv$(this, info_0, continuation_0); | |
if (suspended) | |
return instance; | |
else | |
return instance.doResume(null); | |
}; | |
HttpClientCall.prototype.close = function() { | |
this.response.close(); | |
}; | |
HttpClientCall.$metadata$ = { | |
kind: Kind_CLASS, | |
simpleName: 'HttpClientCall', | |
interfaces: [Closeable, CoroutineScope]}; | |
function HttpEngineCall(request, response) { | |
this.request = request; | |
this.response = response; | |
} | |
HttpEngineCall.$metadata$ = { | |
kind: Kind_CLASS, | |
simpleName: 'HttpEngineCall', | |
interfaces: []}; | |
HttpEngineCall.prototype.component1 = function() { | |
return this.request; | |
}; | |
HttpEngineCall.prototype.component2 = function() { | |
return this.response; | |
}; | |
HttpEngineCall.prototype.copy_edjo92$ = function(request, response) { | |
return new HttpEngineCall(request === void 0 ? this.request : request, response === void 0 ? this.response : response); | |
}; | |
HttpEngineCall.prototype.toString = function() { | |
return 'HttpEngineCall(request=' + Kotlin.toString(this.request) + (', response=' + Kotlin.toString(this.response)) + ')'; | |
}; | |
HttpEngineCall.prototype.hashCode = function() { | |
var result = 0; | |
result = result * 31 + Kotlin.hashCode(this.request) | 0; | |
result = result * 31 + Kotlin.hashCode(this.response) | 0; | |
return result; | |
}; | |
HttpEngineCall.prototype.equals = function(other) { | |
return this === other || (other !== null && (typeof other === 'object' && (Object.getPrototypeOf(this) === Object.getPrototypeOf(other) && (Kotlin.equals(this.request, other.request) && Kotlin.equals(this.response, other.response))))); | |
}; | |
function Coroutine$call$lambda($receiver_0, controller, continuation_0) { | |
CoroutineImpl.call(this, continuation_0); | |
this.$controller = controller; | |
this.exceptionState_0 = 1; | |
} | |
Coroutine$call$lambda.$metadata$ = { | |
kind: Kotlin.Kind.CLASS, | |
simpleName: null, | |
interfaces: [CoroutineImpl]}; | |
Coroutine$call$lambda.prototype = Object.create(CoroutineImpl.prototype); | |
Coroutine$call$lambda.prototype.constructor = Coroutine$call$lambda; | |
Coroutine$call$lambda.prototype.doResume = function() { | |
do try { | |
switch (this.state_0) { | |
case 0: | |
return Unit; | |
case 1: | |
throw this.exception_0; | |
default: | |
this.state_0 = 1; | |
throw new Error('State Machine Unreachable execution'); | |
} | |
} catch (e) { | |
if (this.state_0 === 1) { | |
this.exceptionState_0 = this.state_0; | |
throw e; | |
} else { | |
this.state_0 = this.exceptionState_0; | |
this.exception_0 = e; | |
} | |
} while (true); | |
}; | |
function call$lambda($receiver_0, continuation_0, suspended) { | |
var instance = new Coroutine$call$lambda($receiver_0, this, continuation_0); | |
if (suspended) | |
return instance; | |
else | |
return instance.doResume(null); | |
} | |
function Coroutine$call($receiver_0, block_0, continuation_0) { | |
CoroutineImpl.call(this, continuation_0); | |
this.exceptionState_0 = 1; | |
this.local$$receiver = void 0; | |
this.local$$receiver_0 = $receiver_0; | |
this.local$block = block_0; | |
} | |
Coroutine$call.$metadata$ = { | |
kind: Kotlin.Kind.CLASS, | |
simpleName: null, | |
interfaces: [CoroutineImpl]}; | |
Coroutine$call.prototype = Object.create(CoroutineImpl.prototype); | |
Coroutine$call.prototype.constructor = Coroutine$call; | |
Coroutine$call.prototype.doResume = function() { | |
do try { | |
switch (this.state_0) { | |
case 0: | |
if (this.local$block === void 0) | |
this.local$block = call$lambda; | |
this.local$$receiver = new HttpRequestBuilder(); | |
this.state_0 = 2; | |
this.result_0 = this.local$block(this.local$$receiver, this); | |
if (this.result_0 === COROUTINE_SUSPENDED) | |
return COROUTINE_SUSPENDED; | |
continue; | |
case 1: | |
throw this.exception_0; | |
case 2: | |
this.state_0 = 3; | |
this.result_0 = this.local$$receiver_0.execute_s9rlw$(this.local$$receiver, this); | |
if (this.result_0 === COROUTINE_SUSPENDED) | |
return COROUTINE_SUSPENDED; | |
continue; | |
case 3: | |
return this.result_0; | |
default: | |
this.state_0 = 1; | |
throw new Error('State Machine Unreachable execution'); | |
} | |
} catch (e) { | |
if (this.state_0 === 1) { | |
this.exceptionState_0 = this.state_0; | |
throw e; | |
} else { | |
this.state_0 = this.exceptionState_0; | |
this.exception_0 = e; | |
} | |
} while (true); | |
}; | |
function call($receiver_0, block_0, continuation_0, suspended) { | |
var instance = new Coroutine$call($receiver_0, block_0, continuation_0); | |
if (suspended) | |
return instance; | |
else | |
return instance.doResume(null); | |
} | |
function Coroutine$receive(T_0, isT, $receiver, continuation) { | |
CoroutineImpl.call(this, continuation); | |
this.exceptionState_0 = 1; | |
this.local$T_0 = T_0; | |
this.local$isT = isT; | |
this.local$$receiver = $receiver; | |
} | |
Coroutine$receive.$metadata$ = { | |
kind: Kotlin.Kind.CLASS, | |
simpleName: null, | |
interfaces: [CoroutineImpl]}; | |
Coroutine$receive.prototype = Object.create(CoroutineImpl.prototype); | |
Coroutine$receive.prototype.constructor = Coroutine$receive; | |
Coroutine$receive.prototype.doResume = function() { | |
do try { | |
switch (this.state_0) { | |
case 0: | |
var tmp$_0; | |
this.state_0 = 2; | |
this.result_0 = this.local$$receiver.receive_jo9acv$(new TypeInfo(getKClass(this.local$T_0), package$call.JsType), this); | |
if (this.result_0 === COROUTINE_SUSPENDED) | |
return COROUTINE_SUSPENDED; | |
continue; | |
case 1: | |
throw this.exception_0; | |
case 2: | |
return this.local$isT(tmp$_0 = this.result_0) ? tmp$_0 : throwCCE(); | |
default: | |
this.state_0 = 1; | |
throw new Error('State Machine Unreachable execution'); | |
} | |
} catch (e) { | |
if (this.state_0 === 1) { | |
this.exceptionState_0 = this.state_0; | |
throw e; | |
} else { | |
this.state_0 = this.exceptionState_0; | |
this.exception_0 = e; | |
} | |
} while (true); | |
}; | |
function receive(T_0, isT, $receiver, continuation, suspended) { | |
var instance = new Coroutine$receive(T_0, isT, $receiver, continuation); | |
if (suspended) | |
return instance; | |
else | |
return instance.doResume(null); | |
} | |
defineInlineFunction('ktor-client-core.io.ktor.client.call.receive_8ov3cv$', wrapFunction(function() { | |
var throwCCE = Kotlin.throwCCE; | |
var getKClass = Kotlin.getKClass; | |
var call = _.io.ktor.client.call; | |
var TypeInfo_init = _.io.ktor.client.call.TypeInfo; | |
return function(T_0, isT, $receiver, continuation) { | |
var tmp$_0; | |
Kotlin.suspendCall($receiver.receive_jo9acv$(new TypeInfo_init(getKClass(T_0), call.JsType), Kotlin.coroutineReceiver())); | |
return isT(tmp$_0 = Kotlin.coroutineResult(Kotlin.coroutineReceiver())) ? tmp$_0 : throwCCE(); | |
}; | |
})); | |
function Coroutine$receive_0(T_0, isT, $receiver, continuation) { | |
CoroutineImpl.call(this, continuation); | |
this.exceptionState_0 = 1; | |
this.local$T_0 = T_0; | |
this.local$isT = isT; | |
this.local$$receiver = $receiver; | |
} | |
Coroutine$receive_0.$metadata$ = { | |
kind: Kotlin.Kind.CLASS, | |
simpleName: null, | |
interfaces: [CoroutineImpl]}; | |
Coroutine$receive_0.prototype = Object.create(CoroutineImpl.prototype); | |
Coroutine$receive_0.prototype.constructor = Coroutine$receive_0; | |
Coroutine$receive_0.prototype.doResume = function() { | |
do try { | |
switch (this.state_0) { | |
case 0: | |
var tmp$_0; | |
this.state_0 = 2; | |
this.result_0 = this.local$$receiver.call.receive_jo9acv$(new TypeInfo(getKClass(this.local$T_0), package$call.JsType), this); | |
if (this.result_0 === COROUTINE_SUSPENDED) | |
return COROUTINE_SUSPENDED; | |
continue; | |
case 1: | |
throw this.exception_0; | |
case 2: | |
return this.local$isT(tmp$_0 = this.result_0) ? tmp$_0 : throwCCE(); | |
default: | |
this.state_0 = 1; | |
throw new Error('State Machine Unreachable execution'); | |
} | |
} catch (e) { | |
if (this.state_0 === 1) { | |
this.exceptionState_0 = this.state_0; | |
throw e; | |
} else { | |
this.state_0 = this.exceptionState_0; | |
this.exception_0 = e; | |
} | |
} while (true); | |
}; | |
function receive_0(T_0, isT, $receiver, continuation, suspended) { | |
var instance = new Coroutine$receive_0(T_0, isT, $receiver, continuation); | |
if (suspended) | |
return instance; | |
else | |
return instance.doResume(null); | |
} | |
defineInlineFunction('ktor-client-core.io.ktor.client.call.receive_q6wtkc$', wrapFunction(function() { | |
var throwCCE = Kotlin.throwCCE; | |
var getKClass = Kotlin.getKClass; | |
var call = _.io.ktor.client.call; | |
var TypeInfo_init = _.io.ktor.client.call.TypeInfo; | |
return function(T_0, isT, $receiver, continuation) { | |
var tmp$_0; | |
Kotlin.suspendCall($receiver.call.receive_jo9acv$(new TypeInfo_init(getKClass(T_0), call.JsType), Kotlin.coroutineReceiver())); | |
return isT(tmp$_0 = Kotlin.coroutineResult(Kotlin.coroutineReceiver())) ? tmp$_0 : throwCCE(); | |
}; | |
})); | |
function DoubleReceiveException(call) { | |
IllegalStateException_init(this); | |
this.name = 'DoubleReceiveException'; | |
this.message_eo7lbx$_0 = 'Response already received: ' + call; | |
} | |
Object.defineProperty(DoubleReceiveException.prototype, 'message', { | |
get: function() { | |
return this.message_eo7lbx$_0; | |
}}); | |
DoubleReceiveException.$metadata$ = { | |
kind: Kind_CLASS, | |
simpleName: 'DoubleReceiveException', | |
interfaces: [IllegalStateException]}; | |
function ReceivePipelineException(request, info, cause) { | |
IllegalStateException_init_0('Fail to run receive pipeline', this); | |
this.request = request; | |
this.info = info; | |
this.cause_xlcv2q$_0 = cause; | |
this.name = 'ReceivePipelineException'; | |
} | |
Object.defineProperty(ReceivePipelineException.prototype, 'cause', { | |
get: function() { | |
return this.cause_xlcv2q$_0; | |
}}); | |
ReceivePipelineException.$metadata$ = { | |
kind: Kind_CLASS, | |
simpleName: 'ReceivePipelineException', | |
interfaces: [IllegalStateException]}; | |
function NoTransformationFoundException(from, to) { | |
UnsupportedOperationException_init(this); | |
this.name = 'NoTransformationFoundException'; | |
this.message_gd84kd$_0 = 'No transformation found: ' + from + ' -> ' + to; | |
} | |
Object.defineProperty(NoTransformationFoundException.prototype, 'message', { | |
get: function() { | |
return this.message_gd84kd$_0; | |
}}); | |
NoTransformationFoundException.$metadata$ = { | |
kind: Kind_CLASS, | |
simpleName: 'NoTransformationFoundException', | |
interfaces: [UnsupportedOperationException]}; | |
function TypeInfo(type, reifiedType) { | |
this.type = type; | |
this.reifiedType = reifiedType; | |
} | |
TypeInfo.$metadata$ = { | |
kind: Kind_CLASS, | |
simpleName: 'TypeInfo', | |
interfaces: []}; | |
TypeInfo.prototype.component1 = function() { | |
return this.type; | |
}; | |
TypeInfo.prototype.component2 = function() { | |
return this.reifiedType; | |
}; | |
TypeInfo.prototype.copy_netrco$ = function(type, reifiedType) { | |
return new TypeInfo(type === void 0 ? this.type : type, reifiedType === void 0 ? this.reifiedType : reifiedType); | |
}; | |
TypeInfo.prototype.toString = function() { | |
return 'TypeInfo(type=' + Kotlin.toString(this.type) + (', reifiedType=' + Kotlin.toString(this.reifiedType)) + ')'; | |
}; | |
TypeInfo.prototype.hashCode = function() { | |
var result = 0; | |
result = result * 31 + Kotlin.hashCode(this.type) | 0; | |
result = result * 31 + Kotlin.hashCode(this.reifiedType) | 0; | |
return result; | |
}; | |
TypeInfo.prototype.equals = function(other) { | |
return this === other || (other !== null && (typeof other === 'object' && (Object.getPrototypeOf(this) === Object.getPrototypeOf(other) && (Kotlin.equals(this.type, other.type) && Kotlin.equals(this.reifiedType, other.reifiedType))))); | |
}; | |
function UnsupportedContentTypeException(content) { | |
IllegalStateException_init_0('Failed to write body: ' + Kotlin.getKClassFromExpression(content), this); | |
this.name = 'UnsupportedContentTypeException'; | |
} | |
UnsupportedContentTypeException.$metadata$ = { | |
kind: Kind_CLASS, | |
simpleName: 'UnsupportedContentTypeException', | |
interfaces: [IllegalStateException]}; | |
function UnsupportedUpgradeProtocolException(url) { | |
IllegalArgumentException_init('Unsupported upgrade protocol exception: ' + url, this); | |
this.name = 'UnsupportedUpgradeProtocolException'; | |
} | |
UnsupportedUpgradeProtocolException.$metadata$ = { | |
kind: Kind_CLASS, | |
simpleName: 'UnsupportedUpgradeProtocolException', | |
interfaces: [IllegalArgumentException]}; | |
function Coroutine$call$lambda_0(closure$builder_0, $receiver_0, controller, continuation_0) { | |
CoroutineImpl.call(this, continuation_0); | |
this.$controller = controller; | |
this.exceptionState_0 = 1; | |
this.local$closure$builder = closure$builder_0; | |
this.local$$receiver = $receiver_0; | |
} | |
Coroutine$call$lambda_0.$metadata$ = { | |
kind: Kotlin.Kind.CLASS, | |
simpleName: null, | |
interfaces: [CoroutineImpl]}; | |
Coroutine$call$lambda_0.prototype = Object.create(CoroutineImpl.prototype); | |
Coroutine$call$lambda_0.prototype.constructor = Coroutine$call$lambda_0; | |
Coroutine$call$lambda_0.prototype.doResume = function() { | |
do try { | |
switch (this.state_0) { | |
case 0: | |
return this.local$$receiver.takeFrom_s9rlw$(this.local$closure$builder); | |
case 1: | |
throw this.exception_0; | |
default: | |
this.state_0 = 1; | |
throw new Error('State Machine Unreachable execution'); | |
} | |
} catch (e) { | |
if (this.state_0 === 1) { | |
this.exceptionState_0 = this.state_0; | |
throw e; | |
} else { | |
this.state_0 = this.exceptionState_0; | |
this.exception_0 = e; | |
} | |
} while (true); | |
}; | |
function call$lambda_0(closure$builder_0) { | |
return function($receiver_0, continuation_0, suspended) { | |
var instance = new Coroutine$call$lambda_0(closure$builder_0, $receiver_0, this, continuation_0); | |
if (suspended) | |
return instance; | |
else | |
return instance.doResume(null); | |
}; | |
} | |
function call_0($receiver, builder, continuation) { | |
return call($receiver, call$lambda_0(builder), continuation); | |
} | |
function Coroutine$call$lambda_1($receiver_0, controller, continuation_0) { | |
CoroutineImpl.call(this, continuation_0); | |
this.$controller = controller; | |
this.exceptionState_0 = 1; | |
} | |
Coroutine$call$lambda_1.$metadata$ = { | |
kind: Kotlin.Kind.CLASS, | |
simpleName: null, | |
interfaces: [CoroutineImpl]}; | |
Coroutine$call$lambda_1.prototype = Object.create(CoroutineImpl.prototype); | |
Coroutine$call$lambda_1.prototype.constructor = Coroutine$call$lambda_1; | |
Coroutine$call$lambda_1.prototype.doResume = function() { | |
do try { | |
switch (this.state_0) { | |
case 0: | |
return Unit; | |
case 1: | |
throw this.exception_0; | |
default: | |
this.state_0 = 1; | |
throw new Error('State Machine Unreachable execution'); | |
} | |
} catch (e) { | |
if (this.state_0 === 1) { | |
this.exceptionState_0 = this.state_0; | |
throw e; | |
} else { | |
this.state_0 = this.exceptionState_0; | |
this.exception_0 = e; | |
} | |
} while (true); | |
}; | |
function call$lambda_1($receiver_0, continuation_0, suspended) { | |
var instance = new Coroutine$call$lambda_1($receiver_0, this, continuation_0); | |
if (suspended) | |
return instance; | |
else | |
return instance.doResume(null); | |
} | |
function Coroutine$call$lambda_2(closure$urlString_0, closure$block_0, $receiver_0, controller, continuation_0) { | |
CoroutineImpl.call(this, continuation_0); | |
this.$controller = controller; | |
this.exceptionState_0 = 1; | |
this.local$closure$urlString = closure$urlString_0; | |
this.local$closure$block = closure$block_0; | |
this.local$$receiver = $receiver_0; | |
} | |
Coroutine$call$lambda_2.$metadata$ = { | |
kind: Kotlin.Kind.CLASS, | |
simpleName: null, | |
interfaces: [CoroutineImpl]}; | |
Coroutine$call$lambda_2.prototype = Object.create(CoroutineImpl.prototype); | |
Coroutine$call$lambda_2.prototype.constructor = Coroutine$call$lambda_2; | |
Coroutine$call$lambda_2.prototype.doResume = function() { | |
do try { | |
switch (this.state_0) { | |
case 0: | |
takeFrom(this.local$$receiver.url, this.local$closure$urlString); | |
this.state_0 = 2; | |
this.result_0 = this.local$closure$block(this.local$$receiver, this); | |
if (this.result_0 === COROUTINE_SUSPENDED) | |
return COROUTINE_SUSPENDED; | |
continue; | |
case 1: | |
throw this.exception_0; | |
case 2: | |
return this.result_0; | |
default: | |
this.state_0 = 1; | |
throw new Error('State Machine Unreachable execution'); | |
} | |
} catch (e) { | |
if (this.state_0 === 1) { | |
this.exceptionState_0 = this.state_0; | |
throw e; | |
} else { | |
this.state_0 = this.exceptionState_0; | |
this.exception_0 = e; | |
} | |
} while (true); | |
}; | |
function call$lambda_2(closure$urlString_0, closure$block_0) { | |
return function($receiver_0, continuation_0, suspended) { | |
var instance = new Coroutine$call$lambda_2(closure$urlString_0, closure$block_0, $receiver_0, this, continuation_0); | |
if (suspended) | |
return instance; | |
else | |
return instance.doResume(null); | |
}; | |
} | |
function call_1($receiver, urlString, block, continuation) { | |
if (block === void 0) | |
block = call$lambda_1; | |
return call($receiver, call$lambda_2(urlString, block), continuation); | |
} | |
function Coroutine$call$lambda_3($receiver_0, controller, continuation_0) { | |
CoroutineImpl.call(this, continuation_0); | |
this.$controller = controller; | |
this.exceptionState_0 = 1; | |
} | |
Coroutine$call$lambda_3.$metadata$ = { | |
kind: Kotlin.Kind.CLASS, | |
simpleName: null, | |
interfaces: [CoroutineImpl]}; | |
Coroutine$call$lambda_3.prototype = Object.create(CoroutineImpl.prototype); | |
Coroutine$call$lambda_3.prototype.constructor = Coroutine$call$lambda_3; | |
Coroutine$call$lambda_3.prototype.doResume = function() { | |
do try { | |
switch (this.state_0) { | |
case 0: | |
return Unit; | |
case 1: | |
throw this.exception_0; | |
default: | |
this.state_0 = 1; | |
throw new Error('State Machine Unreachable execution'); | |
} | |
} catch (e) { | |
if (this.state_0 === 1) { | |
this.exceptionState_0 = this.state_0; | |
throw e; | |
} else { | |
this.state_0 = this.exceptionState_0; | |
this.exception_0 = e; | |
} | |
} while (true); | |
}; | |
function call$lambda_3($receiver_0, continuation_0, suspended) { | |
var instance = new Coroutine$call$lambda_3($receiver_0, this, continuation_0); | |
if (suspended) | |
return instance; | |
else | |
return instance.doResume(null); | |
} | |
function Coroutine$call$lambda_4(closure$url_0, closure$block_0, $receiver_0, controller, continuation_0) { | |
CoroutineImpl.call(this, continuation_0); | |
this.$controller = controller; | |
this.exceptionState_0 = 1; | |
this.local$closure$url = closure$url_0; | |
this.local$closure$block = closure$block_0; | |
this.local$$receiver = $receiver_0; | |
} | |
Coroutine$call$lambda_4.$metadata$ = { | |
kind: Kotlin.Kind.CLASS, | |
simpleName: null, | |
interfaces: [CoroutineImpl]}; | |
Coroutine$call$lambda_4.prototype = Object.create(CoroutineImpl.prototype); | |
Coroutine$call$lambda_4.prototype.constructor = Coroutine$call$lambda_4; | |
Coroutine$call$lambda_4.prototype.doResume = function() { | |
do try { | |
switch (this.state_0) { | |
case 0: | |
takeFrom_0(this.local$$receiver.url, this.local$closure$url); | |
this.state_0 = 2; | |
this.result_0 = this.local$closure$block(this.local$$receiver, this); | |
if (this.result_0 === COROUTINE_SUSPENDED) | |
return COROUTINE_SUSPENDED; | |
continue; | |
case 1: | |
throw this.exception_0; | |
case 2: | |
return this.result_0; | |
default: | |
this.state_0 = 1; | |
throw new Error('State Machine Unreachable execution'); | |
} | |
} catch (e) { | |
if (this.state_0 === 1) { | |
this.exceptionState_0 = this.state_0; | |
throw e; | |
} else { | |
this.state_0 = this.exceptionState_0; | |
this.exception_0 = e; | |
} | |
} while (true); | |
}; | |
function call$lambda_4(closure$url_0, closure$block_0) { | |
return function($receiver_0, continuation_0, suspended) { | |
var instance = new Coroutine$call$lambda_4(closure$url_0, closure$block_0, $receiver_0, this, continuation_0); | |
if (suspended) | |
return instance; | |
else | |
return instance.doResume(null); | |
}; | |
} | |
function call_2($receiver, url, block, continuation) { | |
if (block === void 0) | |
block = call$lambda_3; | |
return call($receiver, call$lambda_4(url, block), continuation); | |
} | |
function HttpClientEngine() { | |
} | |
HttpClientEngine.$metadata$ = { | |
kind: Kind_INTERFACE, | |
simpleName: 'HttpClientEngine', | |
interfaces: [Closeable, CoroutineScope]}; | |
function HttpClientEngineFactory() { | |
} | |
function HttpClientEngineFactory$create$lambda($receiver) { | |
return Unit; | |
} | |
HttpClientEngineFactory.prototype.create_dxyxif$ = function(block, callback$default) { | |
if (block === void 0) | |
block = HttpClientEngineFactory$create$lambda; | |
return callback$default ? callback$default(block) : this.create_dxyxif$$default(block); | |
}; | |
HttpClientEngineFactory.$metadata$ = { | |
kind: Kind_INTERFACE, | |
simpleName: 'HttpClientEngineFactory', | |
interfaces: []}; | |
function config$ObjectLiteral(closure$parent, closure$nested) { | |
this.closure$parent = closure$parent; | |
this.closure$nested = closure$nested; | |
} | |
function config$ObjectLiteral$create$lambda(closure$nested, closure$block) { | |
return function($receiver) { | |
closure$nested($receiver); | |
closure$block($receiver); | |
return Unit; | |
}; | |
} | |
config$ObjectLiteral.prototype.create_dxyxif$$default = function(block) { | |
return this.closure$parent.create_dxyxif$(config$ObjectLiteral$create$lambda(this.closure$nested, block)); | |
}; | |
config$ObjectLiteral.$metadata$ = { | |
kind: Kind_CLASS, | |
interfaces: [HttpClientEngineFactory]}; | |
function config($receiver, nested) { | |
var parent = $receiver; | |
return new config$ObjectLiteral(parent, nested); | |
} | |
function HttpClientEngineConfig() { | |
this.dispatcher = null; | |
this.threadsCount = 4; | |
this.pipelining = false; | |
this.response = new HttpResponseConfig(); | |
} | |
HttpClientEngineConfig.$metadata$ = { | |
kind: Kind_CLASS, | |
simpleName: 'HttpClientEngineConfig', | |
interfaces: []}; | |
function mergeHeaders$lambda(closure$requestHeaders, closure$content) { | |
return function($receiver) { | |
$receiver.appendAll_hb0ubp$(closure$requestHeaders); | |
$receiver.appendAll_hb0ubp$(closure$content.headers); | |
return Unit; | |
}; | |
} | |
function mergeHeaders$lambda_0(closure$block) { | |
return function(key, values) { | |
if (equals(http.HttpHeaders.ContentLength, key)) | |
return; | |
if (equals(http.HttpHeaders.ContentType, key)) | |
return; | |
closure$block(key, joinToString(values, ';')); | |
return Unit; | |
}; | |
} | |
function mergeHeaders(requestHeaders, content, block) { | |
var tmp$, tmp$_0, tmp$_1, tmp$_2; | |
buildHeaders(mergeHeaders$lambda(requestHeaders, content)).forEach_ubvtmq$(mergeHeaders$lambda_0(block)); | |
if (requestHeaders.get_61zpoe$(http.HttpHeaders.UserAgent) == null && content.headers.get_61zpoe$(http.HttpHeaders.UserAgent) == null) { | |
block(http.HttpHeaders.UserAgent, 'Ktor client'); | |
} | |
var type = (tmp$_0 = (tmp$ = content.contentType) != null ? tmp$.toString() : null) != null ? tmp$_0 : content.headers.get_61zpoe$(http.HttpHeaders.ContentType); | |
var length = (tmp$_2 = (tmp$_1 = content.contentLength) != null ? tmp$_1.toString() : null) != null ? tmp$_2 : content.headers.get_61zpoe$(http.HttpHeaders.ContentLength); | |
if (type != null) { | |
block(http.HttpHeaders.ContentType, type); | |
} | |
if (length != null) { | |
block(http.HttpHeaders.ContentLength, length); | |
} | |
} | |
function DefaultRequest(builder) { | |
DefaultRequest$Feature_getInstance(); | |
this.builder_0 = builder; | |
} | |
function DefaultRequest$Feature() { | |
DefaultRequest$Feature_instance = this; | |
this.key_2n0sxh$_0 = new AttributeKey('DefaultRequest'); | |
} | |
Object.defineProperty(DefaultRequest$Feature.prototype, 'key', { | |
get: function() { | |
return this.key_2n0sxh$_0; | |
}}); | |
DefaultRequest$Feature.prototype.prepare_oh3mgy$$default = function(block) { | |
return new DefaultRequest(block); | |
}; | |
function Coroutine$DefaultRequest$Feature$install$lambda(closure$feature_0, $receiver_0, it_0, controller, continuation_0) { | |
CoroutineImpl.call(this, continuation_0); | |
this.$controller = controller; | |
this.exceptionState_0 = 1; | |
this.local$closure$feature = closure$feature_0; | |
this.local$$receiver = $receiver_0; | |
} | |
Coroutine$DefaultRequest$Feature$install$lambda.$metadata$ = { | |
kind: Kotlin.Kind.CLASS, | |
simpleName: null, | |
interfaces: [CoroutineImpl]}; | |
Coroutine$DefaultRequest$Feature$install$lambda.prototype = Object.create(CoroutineImpl.prototype); | |
Coroutine$DefaultRequest$Feature$install$lambda.prototype.constructor = Coroutine$DefaultRequest$Feature$install$lambda; | |
Coroutine$DefaultRequest$Feature$install$lambda.prototype.doResume = function() { | |
do try { | |
switch (this.state_0) { | |
case 0: | |
var $receiver = this.local$$receiver.context; | |
this.local$closure$feature.builder_0($receiver); | |
return $receiver; | |
case 1: | |
throw this.exception_0; | |
default: | |
this.state_0 = 1; | |
throw new Error('State Machine Unreachable execution'); | |
} | |
} catch (e) { | |
if (this.state_0 === 1) { | |
this.exceptionState_0 = this.state_0; | |
throw e; | |
} else { | |
this.state_0 = this.exceptionState_0; | |
this.exception_0 = e; | |
} | |
} while (true); | |
}; | |
function DefaultRequest$Feature$install$lambda(closure$feature_0) { | |
return function($receiver_0, it_0, continuation_0, suspended) { | |
var instance = new Coroutine$DefaultRequest$Feature$install$lambda(closure$feature_0, $receiver_0, it_0, this, continuation_0); | |
if (suspended) | |
return instance; | |
else | |
return instance.doResume(null); | |
}; | |
} | |
DefaultRequest$Feature.prototype.install_wojrb5$ = function(feature, scope) { | |
scope.requestPipeline.intercept_h71y74$(HttpRequestPipeline$Phases_getInstance().Before, DefaultRequest$Feature$install$lambda(feature)); | |
}; | |
DefaultRequest$Feature.$metadata$ = { | |
kind: Kind_OBJECT, | |
simpleName: 'Feature', | |
interfaces: [HttpClientFeature]}; | |
var DefaultRequest$Feature_instance = null; | |
function DefaultRequest$Feature_getInstance() { | |
if (DefaultRequest$Feature_instance === null) { | |
new DefaultRequest$Feature(); | |
} | |
return DefaultRequest$Feature_instance; | |
} | |
DefaultRequest.$metadata$ = { | |
kind: Kind_CLASS, | |
simpleName: 'DefaultRequest', | |
interfaces: []}; | |
function defaultRequest$lambda(closure$block) { | |
return function($receiver) { | |
closure$block($receiver); | |
return Unit; | |
}; | |
} | |
function defaultRequest($receiver, block) { | |
$receiver.install_xlxg29$(DefaultRequest$Feature_getInstance(), defaultRequest$lambda(block)); | |
} | |
function defaultTransformers$lambda$ObjectLiteral(closure$body) { | |
this.closure$body = closure$body; | |
OutgoingContent$ByteArrayContent.call(this); | |
this.contentLength_ca0n1g$_0 = Kotlin.Long.fromInt(closure$body.length); | |
} | |
Object.defineProperty(defaultTransformers$lambda$ObjectLiteral.prototype, 'contentLength', { | |
get: function() { | |
return this.contentLength_ca0n1g$_0; | |
}}); | |
defaultTransformers$lambda$ObjectLiteral.prototype.bytes = function() { | |
return this.closure$body; | |
}; | |
defaultTransformers$lambda$ObjectLiteral.$metadata$ = { | |
kind: Kind_CLASS, | |
interfaces: [OutgoingContent$ByteArrayContent]}; | |
function Coroutine$defaultTransformers$lambda($receiver_0, body_0, controller, continuation_0) { | |
CoroutineImpl.call(this, continuation_0); | |
this.$controller = controller; | |
this.exceptionState_0 = 1; | |
this.local$$receiver = $receiver_0; | |
this.local$body = body_0; | |
} | |
Coroutine$defaultTransformers$lambda.$metadata$ = { | |
kind: Kotlin.Kind.CLASS, | |
simpleName: null, | |
interfaces: [CoroutineImpl]}; | |
Coroutine$defaultTransformers$lambda.prototype = Object.create(CoroutineImpl.prototype); | |
Coroutine$defaultTransformers$lambda.prototype.constructor = Coroutine$defaultTransformers$lambda; | |
Coroutine$defaultTransformers$lambda.prototype.doResume = function() { | |
do try { | |
switch (this.state_0) { | |
case 0: | |
if (this.local$$receiver.context.headers.get_61zpoe$(http.HttpHeaders.Accept) == null) { | |
this.local$$receiver.context.headers.append_puj7f4$(http.HttpHeaders.Accept, '*/*'); | |
} | |
if (Kotlin.isByteArray(this.local$body)) { | |
this.state_0 = 2; | |
this.result_0 = this.local$$receiver.proceedWith_trkh7z$(new defaultTransformers$lambda$ObjectLiteral(this.local$body), this); | |
if (this.result_0 === COROUTINE_SUSPENDED) | |
return COROUTINE_SUSPENDED; | |
continue; | |
} else { | |
this.state_0 = 3; | |
continue; | |
} | |
case 1: | |
throw this.exception_0; | |
case 2: | |
return this.result_0; | |
case 3: | |
return Unit; | |
default: | |
this.state_0 = 1; | |
throw new Error('State Machine Unreachable execution'); | |
} | |
} catch (e) { | |
if (this.state_0 === 1) { | |
this.exceptionState_0 = this.state_0; | |
throw e; | |
} else { | |
this.state_0 = this.exceptionState_0; | |
this.exception_0 = e; | |
} | |
} while (true); | |
}; | |
function defaultTransformers$lambda($receiver_0, body_0, continuation_0, suspended) { | |
var instance = new Coroutine$defaultTransformers$lambda($receiver_0, body_0, this, continuation_0); | |
if (suspended) | |
return instance; | |
else | |
return instance.doResume(null); | |
} | |
function Coroutine$defaultTransformers$lambda_0($receiver_0, f_0, controller, continuation_0) { | |
CoroutineImpl.call(this, continuation_0); | |
this.$controller = controller; | |
this.exceptionState_0 = 1; | |
this.local$info = void 0; | |
this.local$response = void 0; | |
this.local$$receiver = $receiver_0; | |
this.local$f = f_0; | |
} | |
Coroutine$defaultTransformers$lambda_0.$metadata$ = { | |
kind: Kotlin.Kind.CLASS, | |
simpleName: null, | |
interfaces: [CoroutineImpl]}; | |
Coroutine$defaultTransformers$lambda_0.prototype = Object.create(CoroutineImpl.prototype); | |
Coroutine$defaultTransformers$lambda_0.prototype.constructor = Coroutine$defaultTransformers$lambda_0; | |
Coroutine$defaultTransformers$lambda_0.prototype.doResume = function() { | |
do try { | |
switch (this.state_0) { | |
case 0: | |
this.local$info = this.local$f.component1() , this.local$response = this.local$f.component2(); | |
var tmp$, tmp$_0, tmp$_1; | |
if (!Kotlin.isType(this.local$response, HttpResponse)) { | |
return; | |
} else { | |
this.state_0 = 2; | |
continue; | |
} | |
case 1: | |
throw this.exception_0; | |
case 2: | |
var contentLength = (tmp$_0 = (tmp$ = this.local$response.headers.get_61zpoe$(http.HttpHeaders.ContentLength)) != null ? toLong(tmp$) : null) != null ? tmp$_0 : Long$Companion$MAX_VALUE; | |
tmp$_1 = this.local$info.type; | |
if (equals(tmp$_1, getKClass(Object.getPrototypeOf(kotlin.Unit).constructor))) { | |
cancel(this.local$response.content); | |
this.local$response.close(); | |
this.state_0 = 8; | |
this.result_0 = this.local$$receiver.proceedWith_trkh7z$(new HttpResponseContainer(this.local$info, Unit), this); | |
if (this.result_0 === COROUTINE_SUSPENDED) | |
return COROUTINE_SUSPENDED; | |
continue; | |
} else { | |
if (equals(tmp$_1, getKClass(ByteReadChannel))) { | |
this.state_0 = 6; | |
this.result_0 = this.local$$receiver.proceedWith_trkh7z$(new HttpResponseContainer(this.local$info, this.local$response.content), this); | |
if (this.result_0 === COROUTINE_SUSPENDED) | |
return COROUTINE_SUSPENDED; | |
continue; | |
} else { | |
if (equals(tmp$_1, PrimitiveClasses$byteArrayClass)) { | |
this.state_0 = 3; | |
this.result_0 = readRemaining(this.local$response.content, contentLength, this); | |
if (this.result_0 === COROUTINE_SUSPENDED) | |
return COROUTINE_SUSPENDED; | |
continue; | |
} else { | |
this.state_0 = 5; | |
continue; | |
} | |
} | |
} | |
case 3: | |
var readRemaining_0 = this.result_0; | |
this.state_0 = 4; | |
this.result_0 = this.local$$receiver.proceedWith_trkh7z$(new HttpResponseContainer(this.local$info, readBytes(readRemaining_0)), this); | |
if (this.result_0 === COROUTINE_SUSPENDED) | |
return COROUTINE_SUSPENDED; | |
continue; | |
case 4: | |
return this.result_0; | |
case 5: | |
this.state_0 = 7; | |
continue; | |
case 6: | |
return this.result_0; | |
case 7: | |
this.state_0 = 9; | |
continue; | |
case 8: | |
return this.result_0; | |
case 9: | |
return Unit; | |
default: | |
this.state_0 = 1; | |
throw new Error('State Machine Unreachable execution'); | |
} | |
} catch (e) { | |
if (this.state_0 === 1) { | |
this.exceptionState_0 = this.state_0; | |
throw e; | |
} else { | |
this.state_0 = this.exceptionState_0; | |
this.exception_0 = e; | |
} | |
} while (true); | |
}; | |
function defaultTransformers$lambda_0($receiver_0, f_0, continuation_0, suspended) { | |
var instance = new Coroutine$defaultTransformers$lambda_0($receiver_0, f_0, this, continuation_0); | |
if (suspended) | |
return instance; | |
else | |
return instance.doResume(null); | |
} | |
function defaultTransformers($receiver) { | |
$receiver.requestPipeline.intercept_h71y74$(HttpRequestPipeline$Phases_getInstance().Render, defaultTransformers$lambda); | |
$receiver.responsePipeline.intercept_h71y74$(HttpResponsePipeline$Phases_getInstance().Parse, defaultTransformers$lambda_0); | |
platformDefaultTransformers($receiver); | |
} | |
function ExpectSuccess() { | |
ExpectSuccess$Companion_getInstance(); | |
} | |
function ExpectSuccess$Companion() { | |
ExpectSuccess$Companion_instance = this; | |
this.key_do7dj$_0 = new AttributeKey('ExpectSuccess'); | |
} | |
Object.defineProperty(ExpectSuccess$Companion.prototype, 'key', { | |
get: function() { | |
return this.key_do7dj$_0; | |
}}); | |
ExpectSuccess$Companion.prototype.prepare_oh3mgy$$default = function(block) { | |
return new ExpectSuccess(); | |
}; | |
function Coroutine$ExpectSuccess$Companion$install$lambda($receiver_0, it_0, controller, continuation_0) { | |
CoroutineImpl.call(this, continuation_0); | |
this.$controller = controller; | |
this.exceptionState_0 = 1; | |
this.local$$receiver = $receiver_0; | |
} | |
Coroutine$ExpectSuccess$Companion$install$lambda.$metadata$ = { | |
kind: Kotlin.Kind.CLASS, | |
simpleName: null, | |
interfaces: [CoroutineImpl]}; | |
Coroutine$ExpectSuccess$Companion$install$lambda.prototype = Object.create(CoroutineImpl.prototype); | |
Coroutine$ExpectSuccess$Companion$install$lambda.prototype.constructor = Coroutine$ExpectSuccess$Companion$install$lambda; | |
Coroutine$ExpectSuccess$Companion$install$lambda.prototype.doResume = function() { | |
do try { | |
switch (this.state_0) { | |
case 0: | |
var response = this.local$$receiver.context.response; | |
if (response.status.value >= 300) | |
throw new BadResponseStatusException(response.status, response); | |
return Unit; | |
case 1: | |
throw this.exception_0; | |
default: | |
this.state_0 = 1; | |
throw new Error('State Machine Unreachable execution'); | |
} | |
} catch (e) { | |
if (this.state_0 === 1) { | |
this.exceptionState_0 = this.state_0; | |
throw e; | |
} else { | |
this.state_0 = this.exceptionState_0; | |
this.exception_0 = e; | |
} | |
} while (true); | |
}; | |
function ExpectSuccess$Companion$install$lambda($receiver_0, it_0, continuation_0, suspended) { | |
var instance = new Coroutine$ExpectSuccess$Companion$install$lambda($receiver_0, it_0, this, continuation_0); | |
if (suspended) | |
return instance; | |
else | |
return instance.doResume(null); | |
} | |
ExpectSuccess$Companion.prototype.install_wojrb5$ = function(feature, scope) { | |
scope.responsePipeline.intercept_h71y74$(HttpResponsePipeline$Phases_getInstance().Receive, ExpectSuccess$Companion$install$lambda); | |
}; | |
ExpectSuccess$Companion.$metadata$ = { | |
kind: Kind_OBJECT, | |
simpleName: 'Companion', | |
interfaces: [HttpClientFeature]}; | |
var ExpectSuccess$Companion_instance = null; | |
function ExpectSuccess$Companion_getInstance() { | |
if (ExpectSuccess$Companion_instance === null) { | |
new ExpectSuccess$Companion(); | |
} | |
return ExpectSuccess$Companion_instance; | |
} | |
ExpectSuccess.$metadata$ = { | |
kind: Kind_CLASS, | |
simpleName: 'ExpectSuccess', | |
interfaces: []}; | |
function BadResponseStatusException(statusCode, response) { | |
IllegalStateException_init_0('Received bad status code: ' + statusCode + '. Expected status code < 300.', this); | |
this.statusCode = statusCode; | |
this.response = response; | |
this.name = 'BadResponseStatusException'; | |
} | |
BadResponseStatusException.$metadata$ = { | |
kind: Kind_CLASS, | |
simpleName: 'BadResponseStatusException', | |
interfaces: [IllegalStateException]}; | |
var FEATURE_INSTALLED_LIST; | |
function HttpClientFeature() { | |
} | |
function HttpClientFeature$prepare$lambda($receiver) { | |
return Unit; | |
} | |
HttpClientFeature.prototype.prepare_oh3mgy$ = function(block, callback$default) { | |
if (block === void 0) | |
block = HttpClientFeature$prepare$lambda; | |
return callback$default ? callback$default(block) : this.prepare_oh3mgy$$default(block); | |
}; | |
HttpClientFeature.$metadata$ = { | |
kind: Kind_INTERFACE, | |
simpleName: 'HttpClientFeature', | |
interfaces: []}; | |
function feature($receiver, feature) { | |
var tmp$; | |
return (tmp$ = $receiver.attributes.getOrNull_yzaw86$(FEATURE_INSTALLED_LIST)) != null ? tmp$.getOrNull_yzaw86$(feature.key) : null; | |
} | |
function HttpPlainText(defaultCharset) { | |
HttpPlainText$Feature_getInstance(); | |
this.defaultCharset = defaultCharset; | |
} | |
var addSuppressedInternal = $module$kotlinx_io.kotlinx.io.core.addSuppressedInternal_oh0dqn$; | |
function Coroutine$read_71tmp6$($this, response_0, continuation_0) { | |
CoroutineImpl.call(this, continuation_0); | |
this.exceptionState_0 = 5; | |
this.$this = $this; | |
this.local$tmp$ = void 0; | |
this.local$closed = void 0; | |
this.local$response = response_0; | |
} | |
Coroutine$read_71tmp6$.$metadata$ = { | |
kind: Kotlin.Kind.CLASS, | |
simpleName: null, | |
interfaces: [CoroutineImpl]}; | |
Coroutine$read_71tmp6$.prototype = Object.create(CoroutineImpl.prototype); | |
Coroutine$read_71tmp6$.prototype.constructor = Coroutine$read_71tmp6$; | |
Coroutine$read_71tmp6$.prototype.doResume = function() { | |
do try { | |
switch (this.state_0) { | |
case 0: | |
this.local$closed = false; | |
this.exceptionState_0 = 2; | |
this.state_0 = 1; | |
this.result_0 = readText_0(this.local$response, this.$this.defaultCharset, this); | |
if (this.result_0 === COROUTINE_SUSPENDED) | |
return COROUTINE_SUSPENDED; | |
continue; | |
case 1: | |
this.local$tmp$ = this.result_0; | |
this.exceptionState_0 = 5; | |
this.finallyPath_0 = [4]; | |
this.state_0 = 3; | |
continue; | |
case 2: | |
this.finallyPath_0 = [5]; | |
this.exceptionState_0 = 3; | |
var first = this.exception_0; | |
if (Kotlin.isType(first, Throwable)) { | |
try { | |
this.local$closed = true; | |
this.local$response.close(); | |
} catch (second) { | |
if (Kotlin.isType(second, Throwable)) { | |
addSuppressedInternal(first, second); | |
} else | |
throw second; | |
} | |
throw first; | |
} else | |
throw first; | |
case 3: | |
this.exceptionState_0 = 5; | |
if (!this.local$closed) { | |
this.local$response.close(); | |
} | |
this.state_0 = this.finallyPath_0.shift(); | |
continue; | |
case 4: | |
return this.local$tmp$; | |
case 5: | |
throw this.exception_0; | |
default: | |
this.state_0 = 5; | |
throw new Error('State Machine Unreachable execution'); | |
} | |
} catch (e) { | |
if (this.state_0 === 5) { | |
this.exceptionState_0 = this.state_0; | |
throw e; | |
} else { | |
this.state_0 = this.exceptionState_0; | |
this.exception_0 = e; | |
} | |
} while (true); | |
}; | |
HttpPlainText.prototype.read_71tmp6$ = function(response_0, continuation_0, suspended) { | |
var instance = new Coroutine$read_71tmp6$(this, response_0, continuation_0); | |
if (suspended) | |
return instance; | |
else | |
return instance.doResume(null); | |
}; | |
function HttpPlainText$Config() { | |
this.defaultCharset = charsets.Charsets.UTF_8; | |
} | |
HttpPlainText$Config.prototype.build_8be2vx$ = function() { | |
return new HttpPlainText(this.defaultCharset); | |
}; | |
HttpPlainText$Config.$metadata$ = { | |
kind: Kind_CLASS, | |
simpleName: 'Config', | |
interfaces: []}; | |
function HttpPlainText$Feature() { | |
HttpPlainText$Feature_instance = this; | |
this.key_wkh146$_0 = new AttributeKey('HttpPlainText'); | |
} | |
Object.defineProperty(HttpPlainText$Feature.prototype, 'key', { | |
get: function() { | |
return this.key_wkh146$_0; | |
}}); | |
HttpPlainText$Feature.prototype.prepare_oh3mgy$$default = function(block) { | |
var $receiver = new HttpPlainText$Config(); | |
block($receiver); | |
return $receiver.build_8be2vx$(); | |
}; | |
function Coroutine$HttpPlainText$Feature$install$lambda(closure$feature_0, $receiver_0, content_0, controller, continuation_0) { | |
CoroutineImpl.call(this, continuation_0); | |
this.$controller = controller; | |
this.exceptionState_0 = 1; | |
this.local$closure$feature = closure$feature_0; | |
this.local$$receiver = $receiver_0; | |
this.local$content = content_0; | |
} | |
Coroutine$HttpPlainText$Feature$install$lambda.$metadata$ = { | |
kind: Kotlin.Kind.CLASS, | |
simpleName: null, | |
interfaces: [CoroutineImpl]}; | |
Coroutine$HttpPlainText$Feature$install$lambda.prototype = Object.create(CoroutineImpl.prototype); | |
Coroutine$HttpPlainText$Feature$install$lambda.prototype.constructor = Coroutine$HttpPlainText$Feature$install$lambda; | |
Coroutine$HttpPlainText$Feature$install$lambda.prototype.doResume = function() { | |
do try { | |
switch (this.state_0) { | |
case 0: | |
if (!(typeof this.local$content === 'string')) { | |
return; | |
} else { | |
this.state_0 = 2; | |
continue; | |
} | |
case 1: | |
throw this.exception_0; | |
case 2: | |
var contentType = withCharset(ContentType.Text.Plain, this.local$closure$feature.defaultCharset); | |
this.state_0 = 3; | |
this.result_0 = this.local$$receiver.proceedWith_trkh7z$(new TextContent(this.local$content, contentType), this); | |
if (this.result_0 === COROUTINE_SUSPENDED) | |
return COROUTINE_SUSPENDED; | |
continue; | |
case 3: | |
return this.result_0; | |
default: | |
this.state_0 = 1; | |
throw new Error('State Machine Unreachable execution'); | |
} | |
} catch (e) { | |
if (this.state_0 === 1) { | |
this.exceptionState_0 = this.state_0; | |
throw e; | |
} else { | |
this.state_0 = this.exceptionState_0; | |
this.exception_0 = e; | |
} | |
} while (true); | |
}; | |
function HttpPlainText$Feature$install$lambda(closure$feature_0) { | |
return function($receiver_0, content_0, continuation_0, suspended) { | |
var instance = new Coroutine$HttpPlainText$Feature$install$lambda(closure$feature_0, $receiver_0, content_0, this, continuation_0); | |
if (suspended) | |
return instance; | |
else | |
return instance.doResume(null); | |
}; | |
} | |
function Coroutine$HttpPlainText$Feature$install$lambda_0(closure$feature_0, $receiver_0, f_0, controller, continuation_0) { | |
CoroutineImpl.call(this, continuation_0); | |
this.$controller = controller; | |
this.exceptionState_0 = 1; | |
this.local$closure$feature = closure$feature_0; | |
this.local$info = void 0; | |
this.local$response = void 0; | |
this.local$$receiver = $receiver_0; | |
this.local$f = f_0; | |
} | |
Coroutine$HttpPlainText$Feature$install$lambda_0.$metadata$ = { | |
kind: Kotlin.Kind.CLASS, | |
simpleName: null, | |
interfaces: [CoroutineImpl]}; | |
Coroutine$HttpPlainText$Feature$install$lambda_0.prototype = Object.create(CoroutineImpl.prototype); | |
Coroutine$HttpPlainText$Feature$install$lambda_0.prototype.constructor = Coroutine$HttpPlainText$Feature$install$lambda_0; | |
Coroutine$HttpPlainText$Feature$install$lambda_0.prototype.doResume = function() { | |
do try { | |
switch (this.state_0) { | |
case 0: | |
this.local$info = this.local$f.component1() , this.local$response = this.local$f.component2(); | |
var tmp$; | |
if (!((tmp$ = this.local$info.type) != null ? tmp$.equals(PrimitiveClasses$stringClass) : null) || !Kotlin.isType(this.local$response, HttpResponse)) { | |
return; | |
} else { | |
this.state_0 = 2; | |
continue; | |
} | |
case 1: | |
throw this.exception_0; | |
case 2: | |
this.state_0 = 3; | |
this.result_0 = this.local$closure$feature.read_71tmp6$(this.local$response, this); | |
if (this.result_0 === COROUTINE_SUSPENDED) | |
return COROUTINE_SUSPENDED; | |
continue; | |
case 3: | |
var content = this.result_0; | |
this.state_0 = 4; | |
this.result_0 = this.local$$receiver.proceedWith_trkh7z$(new HttpResponseContainer(this.local$info, content), this); | |
if (this.result_0 === COROUTINE_SUSPENDED) | |
return COROUTINE_SUSPENDED; | |
continue; | |
case 4: | |
return this.result_0; | |
default: | |
this.state_0 = 1; | |
throw new Error('State Machine Unreachable execution'); | |
} | |
} catch (e) { | |
if (this.state_0 === 1) { | |
this.exceptionState_0 = this.state_0; | |
throw e; | |
} else { | |
this.state_0 = this.exceptionState_0; | |
this.exception_0 = e; | |
} | |
} while (true); | |
}; | |
function HttpPlainText$Feature$install$lambda_0(closure$feature_0) { | |
return function($receiver_0, f_0, continuation_0, suspended) { | |
var instance = new Coroutine$HttpPlainText$Feature$install$lambda_0(closure$feature_0, $receiver_0, f_0, this, continuation_0); | |
if (suspended) | |
return instance; | |
else | |
return instance.doResume(null); | |
}; | |
} | |
HttpPlainText$Feature.prototype.install_wojrb5$ = function(feature, scope) { | |
scope.requestPipeline.intercept_h71y74$(HttpRequestPipeline$Phases_getInstance().Render, HttpPlainText$Feature$install$lambda(feature)); | |
scope.responsePipeline.intercept_h71y74$(HttpResponsePipeline$Phases_getInstance().Parse, HttpPlainText$Feature$install$lambda_0(feature)); | |
}; | |
HttpPlainText$Feature.$metadata$ = { | |
kind: Kind_OBJECT, | |
simpleName: 'Feature', | |
interfaces: [HttpClientFeature]}; | |
var HttpPlainText$Feature_instance = null; | |
function HttpPlainText$Feature_getInstance() { | |
if (HttpPlainText$Feature_instance === null) { | |
new HttpPlainText$Feature(); | |
} | |
return HttpPlainText$Feature_instance; | |
} | |
HttpPlainText.$metadata$ = { | |
kind: Kind_CLASS, | |
simpleName: 'HttpPlainText', | |
interfaces: []}; | |
function HttpRedirect() { | |
HttpRedirect$Feature_getInstance(); | |
} | |
function HttpRedirect$Feature() { | |
HttpRedirect$Feature_instance = this; | |
this.key_oxn36d$_0 = new AttributeKey('HttpRedirect'); | |
} | |
Object.defineProperty(HttpRedirect$Feature.prototype, 'key', { | |
get: function() { | |
return this.key_oxn36d$_0; | |
}}); | |
HttpRedirect$Feature.prototype.prepare_oh3mgy$$default = function(block) { | |
return new HttpRedirect(); | |
}; | |
function Coroutine$HttpRedirect$Feature$install$lambda(this$HttpRedirect$_0, $receiver_0, origin_0, controller, continuation_0) { | |
CoroutineImpl.call(this, continuation_0); | |
this.$controller = controller; | |
this.exceptionState_0 = 1; | |
this.local$this$HttpRedirect$ = this$HttpRedirect$_0; | |
this.local$$receiver = $receiver_0; | |
this.local$origin = origin_0; | |
} | |
Coroutine$HttpRedirect$Feature$install$lambda.$metadata$ = { | |
kind: Kotlin.Kind.CLASS, | |
simpleName: null, | |
interfaces: [CoroutineImpl]}; | |
Coroutine$HttpRedirect$Feature$install$lambda.prototype = Object.create(CoroutineImpl.prototype); | |
Coroutine$HttpRedirect$Feature$install$lambda.prototype.constructor = Coroutine$HttpRedirect$Feature$install$lambda; | |
Coroutine$HttpRedirect$Feature$install$lambda.prototype.doResume = function() { | |
do try { | |
switch (this.state_0) { | |
case 0: | |
this.state_0 = 2; | |
this.result_0 = this.local$this$HttpRedirect$.handleCall_0(this.local$$receiver, this.local$origin, this); | |
if (this.result_0 === COROUTINE_SUSPENDED) | |
return COROUTINE_SUSPENDED; | |
continue; | |
case 1: | |
throw this.exception_0; | |
case 2: | |
return this.result_0; | |
default: | |
this.state_0 = 1; | |
throw new Error('State Machine Unreachable execution'); | |
} | |
} catch (e) { | |
if (this.state_0 === 1) { | |
this.exceptionState_0 = this.state_0; | |
throw e; | |
} else { | |
this.state_0 = this.exceptionState_0; | |
this.exception_0 = e; | |
} | |
} while (true); | |
}; | |
function HttpRedirect$Feature$install$lambda(this$HttpRedirect$_0) { | |
return function($receiver_0, origin_0, continuation_0, suspended) { | |
var instance = new Coroutine$HttpRedirect$Feature$install$lambda(this$HttpRedirect$_0, $receiver_0, origin_0, this, continuation_0); | |
if (suspended) | |
return instance; | |
else | |
return instance.doResume(null); | |
}; | |
} | |
HttpRedirect$Feature.prototype.install_wojrb5$ = function(feature_0, scope) { | |
ensureNotNull(feature(scope, HttpSend$Feature_getInstance())).intercept_efqc3v$(HttpRedirect$Feature$install$lambda(this)); | |
}; | |
function Coroutine$handleCall_0($this, $receiver_0, origin_0, continuation_0) { | |
CoroutineImpl.call(this, continuation_0); | |
this.exceptionState_0 = 1; | |
this.$this = $this; | |
this.local$call = void 0; | |
this.local$$receiver = $receiver_0; | |
this.local$origin = origin_0; | |
} | |
Coroutine$handleCall_0.$metadata$ = { | |
kind: Kotlin.Kind.CLASS, | |
simpleName: null, | |
interfaces: [CoroutineImpl]}; | |
Coroutine$handleCall_0.prototype = Object.create(CoroutineImpl.prototype); | |
Coroutine$handleCall_0.prototype.constructor = Coroutine$handleCall_0; | |
Coroutine$handleCall_0.prototype.doResume = function() { | |
do try { | |
switch (this.state_0) { | |
case 0: | |
if (!isRedirect(this.local$origin.response.status)) { | |
return this.local$origin; | |
} else { | |
this.state_0 = 2; | |
continue; | |
} | |
case 1: | |
throw this.exception_0; | |
case 2: | |
this.local$call = this.local$origin; | |
this.state_0 = 3; | |
continue; | |
case 3: | |
var location = this.local$call.response.headers.get_61zpoe$(http.HttpHeaders.Location); | |
var $receiver = new HttpRequestBuilder(); | |
takeFrom_2($receiver, this.local$origin.request); | |
$receiver.url.parameters.clear(); | |
if (location != null) { | |
takeFrom($receiver.url, location); | |
} | |
this.state_0 = 4; | |
this.result_0 = this.local$$receiver.execute_s9rlw$($receiver, this); | |
if (this.result_0 === COROUTINE_SUSPENDED) | |
return COROUTINE_SUSPENDED; | |
continue; | |
case 4: | |
this.local$call = this.result_0; | |
if (!isRedirect(this.local$call.response.status)) { | |
return this.local$call; | |
} else { | |
this.state_0 = 5; | |
continue; | |
} | |
case 5: | |
this.state_0 = 3; | |
continue; | |
default: | |
this.state_0 = 1; | |
throw new Error('State Machine Unreachable execution'); | |
} | |
} catch (e) { | |
if (this.state_0 === 1) { | |
this.exceptionState_0 = this.state_0; | |
throw e; | |
} else { | |
this.state_0 = this.exceptionState_0; | |
this.exception_0 = e; | |
} | |
} while (true); | |
}; | |
HttpRedirect$Feature.prototype.handleCall_0 = function($receiver_0, origin_0, continuation_0, suspended) { | |
var instance = new Coroutine$handleCall_0(this, $receiver_0, origin_0, continuation_0); | |
if (suspended) | |
return instance; | |
else | |
return instance.doResume(null); | |
}; | |
HttpRedirect$Feature.$metadata$ = { | |
kind: Kind_OBJECT, | |
simpleName: 'Feature', | |
interfaces: [HttpClientFeature]}; | |
var HttpRedirect$Feature_instance = null; | |
function HttpRedirect$Feature_getInstance() { | |
if (HttpRedirect$Feature_instance === null) { | |
new HttpRedirect$Feature(); | |
} | |
return HttpRedirect$Feature_instance; | |
} | |
HttpRedirect.$metadata$ = { | |
kind: Kind_CLASS, | |
simpleName: 'HttpRedirect', | |
interfaces: []}; | |
function isRedirect($receiver) { | |
var tmp$; | |
tmp$ = $receiver.value; | |
if (tmp$ === HttpStatusCode.Companion.MovedPermanently.value || tmp$ === HttpStatusCode.Companion.Found.value || tmp$ === HttpStatusCode.Companion.TemporaryRedirect.value || tmp$ === HttpStatusCode.Companion.PermanentRedirect.value) | |
return true; | |
else | |
return false; | |
} | |
function RedirectException(request, cause) { | |
IllegalStateException_init_0(cause, this); | |
this.request = request; | |
this.name = 'RedirectException'; | |
} | |
RedirectException.$metadata$ = { | |
kind: Kind_CLASS, | |
simpleName: 'RedirectException', | |
interfaces: [IllegalStateException]}; | |
function Sender() { | |
} | |
Sender.$metadata$ = { | |
kind: Kind_INTERFACE, | |
simpleName: 'Sender', | |
interfaces: []}; | |
var ArrayList_init = Kotlin.kotlin.collections.ArrayList_init_287e2$; | |
function HttpSend(maxSendCount) { | |
HttpSend$Feature_getInstance(); | |
if (maxSendCount === void 0) | |
maxSendCount = 20; | |
this.maxSendCount = maxSendCount; | |
this.interceptors_0 = ArrayList_init(); | |
} | |
HttpSend.prototype.intercept_efqc3v$ = function(block) { | |
this.interceptors_0.add_11rb$(block); | |
}; | |
function HttpSend$Feature() { | |
HttpSend$Feature_instance = this; | |
this.key_x494tl$_0 = new AttributeKey('HttpSend'); | |
} | |
Object.defineProperty(HttpSend$Feature.prototype, 'key', { | |
get: function() { | |
return this.key_x494tl$_0; | |
}}); | |
HttpSend$Feature.prototype.prepare_oh3mgy$$default = function(block) { | |
var $receiver = new HttpSend(); | |
block($receiver); | |
return $receiver; | |
}; | |
function Coroutine$HttpSend$Feature$install$lambda(closure$feature_0, closure$scope_0, $receiver_0, content_0, controller, continuation_0) { | |
CoroutineImpl.call(this, continuation_0); | |
this.$controller = controller; | |
this.exceptionState_0 = 1; | |
this.local$closure$feature = closure$feature_0; | |
this.local$closure$scope = closure$scope_0; | |
this.local$tmp$ = void 0; | |
this.local$sender = void 0; | |
this.local$currentCall = void 0; | |
this.local$callChanged = void 0; | |
this.local$transformed = void 0; | |
this.local$$receiver = $receiver_0; | |
this.local$content = content_0; | |
} | |
Coroutine$HttpSend$Feature$install$lambda.$metadata$ = { | |
kind: Kotlin.Kind.CLASS, | |
simpleName: null, | |
interfaces: [CoroutineImpl]}; | |
Coroutine$HttpSend$Feature$install$lambda.prototype = Object.create(CoroutineImpl.prototype); | |
Coroutine$HttpSend$Feature$install$lambda.prototype.constructor = Coroutine$HttpSend$Feature$install$lambda; | |
Coroutine$HttpSend$Feature$install$lambda.prototype.doResume = function() { | |
do try { | |
switch (this.state_0) { | |
case 0: | |
if (!Kotlin.isType(this.local$content, OutgoingContent)) { | |
return; | |
} else { | |
this.state_0 = 2; | |
continue; | |
} | |
case 1: | |
throw this.exception_0; | |
case 2: | |
this.local$$receiver.context.body = this.local$content; | |
this.local$sender = new HttpSend$DefaultSender(this.local$closure$feature.maxSendCount, this.local$closure$scope); | |
this.state_0 = 3; | |
this.result_0 = this.local$sender.execute_s9rlw$(this.local$$receiver.context, this); | |
if (this.result_0 === COROUTINE_SUSPENDED) | |
return COROUTINE_SUSPENDED; | |
continue; | |
case 3: | |
this.local$currentCall = this.result_0; | |
this.state_0 = 4; | |
continue; | |
case 4: | |
this.local$callChanged = false; | |
this.local$tmp$ = this.local$closure$feature.interceptors_0.iterator(); | |
this.state_0 = 5; | |
continue; | |
case 5: | |
if (!this.local$tmp$.hasNext()) { | |
this.state_0 = 8; | |
continue; | |
} | |
var interceptor = this.local$tmp$.next(); | |
this.state_0 = 6; | |
this.result_0 = interceptor(this.local$sender, this.local$currentCall, this); | |
if (this.result_0 === COROUTINE_SUSPENDED) | |
return COROUTINE_SUSPENDED; | |
continue; | |
case 6: | |
this.local$transformed = this.result_0; | |
if (this.local$transformed === this.local$currentCall) { | |
this.state_0 = 5; | |
continue; | |
} else { | |
this.state_0 = 7; | |
continue; | |
} | |
case 7: | |
this.local$currentCall = this.local$transformed; | |
this.local$callChanged = true; | |
this.state_0 = 8; | |
continue; | |
case 8: | |
if (!this.local$callChanged) { | |
this.state_0 = 9; | |
continue; | |
} | |
this.state_0 = 4; | |
continue; | |
case 9: | |
this.state_0 = 10; | |
this.result_0 = this.local$$receiver.proceedWith_trkh7z$(this.local$currentCall, this); | |
if (this.result_0 === COROUTINE_SUSPENDED) | |
return COROUTINE_SUSPENDED; | |
continue; | |
case 10: | |
return this.result_0; | |
default: | |
this.state_0 = 1; | |
throw new Error('State Machine Unreachable execution'); | |
} | |
} catch (e) { | |
if (this.state_0 === 1) { | |
this.exceptionState_0 = this.state_0; | |
throw e; | |
} else { | |
this.state_0 = this.exceptionState_0; | |
this.exception_0 = e; | |
} | |
} while (true); | |
}; | |
function HttpSend$Feature$install$lambda(closure$feature_0, closure$scope_0) { | |
return function($receiver_0, content_0, continuation_0, suspended) { | |
var instance = new Coroutine$HttpSend$Feature$install$lambda(closure$feature_0, closure$scope_0, $receiver_0, content_0, this, continuation_0); | |
if (suspended) | |
return instance; | |
else | |
return instance.doResume(null); | |
}; | |
} | |
HttpSend$Feature.prototype.install_wojrb5$ = function(feature, scope) { | |
scope.requestPipeline.intercept_h71y74$(HttpRequestPipeline$Phases_getInstance().Send, HttpSend$Feature$install$lambda(feature, scope)); | |
}; | |
HttpSend$Feature.$metadata$ = { | |
kind: Kind_OBJECT, | |
simpleName: 'Feature', | |
interfaces: [HttpClientFeature]}; | |
var HttpSend$Feature_instance = null; | |
function HttpSend$Feature_getInstance() { | |
if (HttpSend$Feature_instance === null) { | |
new HttpSend$Feature(); | |
} | |
return HttpSend$Feature_instance; | |
} | |
function HttpSend$DefaultSender(maxSendCount, client) { | |
this.maxSendCount_0 = maxSendCount; | |
this.client_0 = client; | |
this.sentCount_0 = 0; | |
} | |
function Coroutine$execute_s9rlw$_0($this, requestBuilder_0, continuation_0) { | |
CoroutineImpl.call(this, continuation_0); | |
this.exceptionState_0 = 1; | |
this.$this = $this; | |
this.local$requestBuilder = requestBuilder_0; | |
} | |
Coroutine$execute_s9rlw$_0.$metadata$ = { | |
kind: Kotlin.Kind.CLASS, | |
simpleName: null, | |
interfaces: [CoroutineImpl]}; | |
Coroutine$execute_s9rlw$_0.prototype = Object.create(CoroutineImpl.prototype); | |
Coroutine$execute_s9rlw$_0.prototype.constructor = Coroutine$execute_s9rlw$_0; | |
Coroutine$execute_s9rlw$_0.prototype.doResume = function() { | |
do try { | |
switch (this.state_0) { | |
case 0: | |
var tmp$; | |
if (this.$this.sentCount_0 >= this.$this.maxSendCount_0) | |
throw new SendCountExceedException('Max send count ' + this.$this.maxSendCount_0 + ' exceeded'); | |
this.$this.sentCount_0 = this.$this.sentCount_0 + 1 | 0; | |
this.state_0 = 2; | |
this.result_0 = this.$this.client_0.sendPipeline.execute_8pmvt0$(this.local$requestBuilder, this.local$requestBuilder.body, this); | |
if (this.result_0 === COROUTINE_SUSPENDED) | |
return COROUTINE_SUSPENDED; | |
continue; | |
case 1: | |
throw this.exception_0; | |
case 2: | |
return Kotlin.isType(tmp$ = this.result_0, HttpClientCall) ? tmp$ : throwCCE(); | |
default: | |
this.state_0 = 1; | |
throw new Error('State Machine Unreachable execution'); | |
} | |
} catch (e) { | |
if (this.state_0 === 1) { | |
this.exceptionState_0 = this.state_0; | |
throw e; | |
} else { | |
this.state_0 = this.exceptionState_0; | |
this.exception_0 = e; | |
} | |
} while (true); | |
}; | |
HttpSend$DefaultSender.prototype.execute_s9rlw$ = function(requestBuilder_0, continuation_0, suspended) { | |
var instance = new Coroutine$execute_s9rlw$_0(this, requestBuilder_0, continuation_0); | |
if (suspended) | |
return instance; | |
else | |
return instance.doResume(null); | |
}; | |
HttpSend$DefaultSender.$metadata$ = { | |
kind: Kind_CLASS, | |
simpleName: 'DefaultSender', | |
interfaces: [Sender]}; | |
HttpSend.$metadata$ = { | |
kind: Kind_CLASS, | |
simpleName: 'HttpSend', | |
interfaces: []}; | |
function SendCountExceedException(message) { | |
IllegalStateException_init_0(message, this); | |
this.name = 'SendCountExceedException'; | |
} | |
SendCountExceedException.$metadata$ = { | |
kind: Kind_CLASS, | |
simpleName: 'SendCountExceedException', | |
interfaces: [IllegalStateException]}; | |
function UserAgent(agent) { | |
UserAgent$Feature_getInstance(); | |
this.agent = agent; | |
} | |
function UserAgent$Config(agent) { | |
if (agent === void 0) | |
agent = 'Ktor http-client'; | |
this.agent = agent; | |
} | |
UserAgent$Config.$metadata$ = { | |
kind: Kind_CLASS, | |
simpleName: 'Config', | |
interfaces: []}; | |
function UserAgent$Feature() { | |
UserAgent$Feature_instance = this; | |
this.key_2jmgf$_0 = new AttributeKey('UserAgent'); | |
} | |
Object.defineProperty(UserAgent$Feature.prototype, 'key', { | |
get: function() { | |
return this.key_2jmgf$_0; | |
}}); | |
UserAgent$Feature.prototype.prepare_oh3mgy$$default = function(block) { | |
var $receiver = new UserAgent$Config(); | |
block($receiver); | |
return new UserAgent($receiver.agent); | |
}; | |
function Coroutine$UserAgent$Feature$install$lambda(closure$feature_0, $receiver_0, it_0, controller, continuation_0) { | |
CoroutineImpl.call(this, continuation_0); | |
this.$controller = controller; | |
this.exceptionState_0 = 1; | |
this.local$closure$feature = closure$feature_0; | |
this.local$$receiver = $receiver_0; | |
} | |
Coroutine$UserAgent$Feature$install$lambda.$metadata$ = { | |
kind: Kotlin.Kind.CLASS, | |
simpleName: null, | |
interfaces: [CoroutineImpl]}; | |
Coroutine$UserAgent$Feature$install$lambda.prototype = Object.create(CoroutineImpl.prototype); | |
Coroutine$UserAgent$Feature$install$lambda.prototype.constructor = Coroutine$UserAgent$Feature$install$lambda; | |
Coroutine$UserAgent$Feature$install$lambda.prototype.doResume = function() { | |
do try { | |
switch (this.state_0) { | |
case 0: | |
return header(this.local$$receiver.context, http.HttpHeaders.UserAgent, this.local$closure$feature.agent) , Unit; | |
case 1: | |
throw this.exception_0; | |
default: | |
this.state_0 = 1; | |
throw new Error('State Machine Unreachable execution'); | |
} | |
} catch (e) { | |
if (this.state_0 === 1) { | |
this.exceptionState_0 = this.state_0; | |
throw e; | |
} else { | |
this.state_0 = this.exceptionState_0; | |
this.exception_0 = e; | |
} | |
} while (true); | |
}; | |
function UserAgent$Feature$install$lambda(closure$feature_0) { | |
return function($receiver_0, it_0, continuation_0, suspended) { | |
var instance = new Coroutine$UserAgent$Feature$install$lambda(closure$feature_0, $receiver_0, it_0, this, continuation_0); | |
if (suspended) | |
return instance; | |
else | |
return instance.doResume(null); | |
}; | |
} | |
UserAgent$Feature.prototype.install_wojrb5$ = function(feature, scope) { | |
scope.requestPipeline.intercept_h71y74$(HttpRequestPipeline$Phases_getInstance().State, UserAgent$Feature$install$lambda(feature)); | |
}; | |
UserAgent$Feature.$metadata$ = { | |
kind: Kind_OBJECT, | |
simpleName: 'Feature', | |
interfaces: [HttpClientFeature]}; | |
var UserAgent$Feature_instance = null; | |
function UserAgent$Feature_getInstance() { | |
if (UserAgent$Feature_instance === null) { | |
new UserAgent$Feature(); | |
} | |
return UserAgent$Feature_instance; | |
} | |
UserAgent.$metadata$ = { | |
kind: Kind_CLASS, | |
simpleName: 'UserAgent', | |
interfaces: []}; | |
function BrowserUserAgent$lambda($receiver) { | |
$receiver.agent = 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/70.0.3538.77 Chrome/70.0.3538.77 Safari/537.36'; | |
return Unit; | |
} | |
function BrowserUserAgent($receiver) { | |
$receiver.install_xlxg29$(UserAgent$Feature_getInstance(), BrowserUserAgent$lambda); | |
} | |
function CurlUserAgent$lambda($receiver) { | |
$receiver.agent = 'curl/7.61.0'; | |
return Unit; | |
} | |
function CurlUserAgent($receiver) { | |
$receiver.install_xlxg29$(UserAgent$Feature_getInstance(), CurlUserAgent$lambda); | |
} | |
function AcceptAllCookiesStorage() { | |
this.container_0 = ArrayList_init(); | |
this.oldestCookie_0 = L0; | |
this.mutex_0 = new Lock(); | |
} | |
AcceptAllCookiesStorage.prototype.get_dxu3lv$ = function(requestUrl, continuation) { | |
var $receiver = this.mutex_0; | |
try { | |
$receiver.lock(); | |
var date = GMTDate(); | |
if (date.timestamp.compareTo_11rb$(this.oldestCookie_0) < 0) | |
this.cleanup_0(date.timestamp); | |
var $receiver_0 = this.container_0; | |
var destination = ArrayList_init(); | |
var tmp$; | |
tmp$ = $receiver_0.iterator(); | |
while (tmp$.hasNext()) { | |
var element = tmp$.next(); | |
if (matches(element, requestUrl)) | |
destination.add_11rb$(element); | |
} | |
return destination; | |
} finally { | |
$receiver.unlock(); | |
} | |
}; | |
function AcceptAllCookiesStorage$addCookie$lambda$lambda(closure$cookie, closure$requestUrl) { | |
return function(it) { | |
return equals(it.name, closure$cookie.name) && matches(it, closure$requestUrl); | |
}; | |
} | |
AcceptAllCookiesStorage.prototype.addCookie_c6y2p3$ = function(requestUrl, cookie, continuation) { | |
var $receiver = this.mutex_0; | |
try { | |
$receiver.lock(); | |
do { | |
removeAll(this.container_0, AcceptAllCookiesStorage$addCookie$lambda$lambda(cookie, requestUrl)); | |
this.container_0.add_11rb$(fillDefaults(cookie, requestUrl)); | |
} while (false && !isBlank(cookie.name)); | |
} finally { | |
$receiver.unlock(); | |
} | |
return Unit; | |
}; | |
function AcceptAllCookiesStorage$cleanup$lambda(closure$timestamp) { | |
return function(cookie) { | |
var tmp$, tmp$_0; | |
tmp$_0 = (tmp$ = cookie.expires) != null ? tmp$.timestamp : null; | |
if (tmp$_0 == null) { | |
return false; | |
} | |
var expires = tmp$_0; | |
return expires.compareTo_11rb$(closure$timestamp) < 0; | |
}; | |
} | |
AcceptAllCookiesStorage.prototype.cleanup_0 = function(timestamp) { | |
removeAll(this.container_0, AcceptAllCookiesStorage$cleanup$lambda(timestamp)); | |
var $receiver = this.container_0; | |
var tmp$; | |
var accumulator = Long$Companion$MAX_VALUE; | |
tmp$ = $receiver.iterator(); | |
while (tmp$.hasNext()) { | |
var element = tmp$.next(); | |
var acc = accumulator; | |
var tmp$_0, tmp$_1, tmp$_2; | |
accumulator = (tmp$_2 = (tmp$_1 = (tmp$_0 = element.expires) != null ? tmp$_0.timestamp : null) != null ? acc.compareTo_11rb$(tmp$_1) <= 0 ? acc : tmp$_1 : null) != null ? tmp$_2 : acc; | |
} | |
var newOldest = accumulator; | |
this.oldestCookie_0 = newOldest; | |
}; | |
AcceptAllCookiesStorage.$metadata$ = { | |
kind: Kind_CLASS, | |
simpleName: 'AcceptAllCookiesStorage', | |
interfaces: [CookiesStorage]}; | |
var ArrayList_init_0 = Kotlin.kotlin.collections.ArrayList_init_ww73n8$; | |
function ConstantCookiesStorage(cookies) { | |
var destination = ArrayList_init_0(cookies.length); | |
var tmp$; | |
for (tmp$ = 0; tmp$ !== cookies.length; ++tmp$) { | |
var item = cookies[tmp$]; | |
destination.add_11rb$(fillDefaults(item, (new URLBuilder()).build())); | |
} | |
this.storage_0 = toList(destination); | |
} | |
ConstantCookiesStorage.prototype.get_dxu3lv$ = function(requestUrl, continuation) { | |
var $receiver = this.storage_0; | |
var destination = ArrayList_init(); | |
var tmp$; | |
tmp$ = $receiver.iterator(); | |
while (tmp$.hasNext()) { | |
var element = tmp$.next(); | |
if (matches(element, requestUrl)) | |
destination.add_11rb$(element); | |
} | |
return destination; | |
}; | |
ConstantCookiesStorage.prototype.addCookie_c6y2p3$ = function(requestUrl, cookie, continuation) { | |
}; | |
ConstantCookiesStorage.$metadata$ = { | |
kind: Kind_CLASS, | |
simpleName: 'ConstantCookiesStorage', | |
interfaces: [CookiesStorage]}; | |
function CookiesStorage() { | |
} | |
CookiesStorage.$metadata$ = { | |
kind: Kind_INTERFACE, | |
simpleName: 'CookiesStorage', | |
interfaces: []}; | |
function Coroutine$addCookie($receiver_0, urlString_0, cookie_0, continuation_0) { | |
CoroutineImpl.call(this, continuation_0); | |
this.exceptionState_0 = 1; | |
this.local$$receiver = $receiver_0; | |
this.local$urlString = urlString_0; | |
this.local$cookie = cookie_0; | |
} | |
Coroutine$addCookie.$metadata$ = { | |
kind: Kotlin.Kind.CLASS, | |
simpleName: null, | |
interfaces: [CoroutineImpl]}; | |
Coroutine$addCookie.prototype = Object.create(CoroutineImpl.prototype); | |
Coroutine$addCookie.prototype.constructor = Coroutine$addCookie; | |
Coroutine$addCookie.prototype.doResume = function() { | |
do try { | |
switch (this.state_0) { | |
case 0: | |
this.state_0 = 2; | |
this.result_0 = this.local$$receiver.addCookie_c6y2p3$(Url(this.local$urlString), this.local$cookie, this); | |
if (this.result_0 === COROUTINE_SUSPENDED) | |
return COROUTINE_SUSPENDED; | |
continue; | |
case 1: | |
throw this.exception_0; | |
case 2: | |
return; | |
default: | |
this.state_0 = 1; | |
throw new Error('State Machine Unreachable execution'); | |
} | |
} catch (e) { | |
if (this.state_0 === 1) { | |
this.exceptionState_0 = this.state_0; | |
throw e; | |
} else { | |
this.state_0 = this.exceptionState_0; | |
this.exception_0 = e; | |
} | |
} while (true); | |
}; | |
function addCookie($receiver_0, urlString_0, cookie_0, continuation_0, suspended) { | |
var instance = new Coroutine$addCookie($receiver_0, urlString_0, cookie_0, continuation_0); | |
if (suspended) | |
return instance; | |
else | |
return instance.doResume(null); | |
} | |
function matches($receiver, requestUrl) { | |
var tmp$, tmp$_0, tmp$_1; | |
var tmp$_2; | |
if ((tmp$_1 = (tmp$_0 = (tmp$ = $receiver.domain) != null ? tmp$.toLowerCase() : null) != null ? trimStart(tmp$_0, Kotlin.charArrayOf(46)) : null) != null) | |
tmp$_2 = tmp$_1; | |
else { | |
throw IllegalStateException_init_0('Domain field should have the default value'.toString()); | |
} | |
var domain = tmp$_2; | |
var tmp$_3; | |
var tmp$_4; | |
if ((tmp$_3 = $receiver.path) != null) | |
tmp$_4 = tmp$_3; | |
else { | |
throw IllegalStateException_init_0('Path field should have the default value'.toString()); | |
} | |
var current = tmp$_4; | |
var path = endsWith(current, 47) ? current : toString($receiver.path) + '/'; | |
var host = requestUrl.host.toLowerCase(); | |
var pathInRequest = requestUrl.encodedPath; | |
var requestPath = endsWith(pathInRequest, 47) ? pathInRequest : pathInRequest + '/'; | |
if (!equals(host, domain) && (hostIsIp(host) || !endsWith_0(host, '.' + domain))) | |
return false; | |
if (!equals(path, '/') && !equals(requestPath, path) && !startsWith(requestPath, path)) | |
return false; | |
if ($receiver.secure && !isSecure(requestUrl.protocol)) | |
return false; | |
return true; | |
} | |
function fillDefaults($receiver, requestUrl) { | |
var tmp$; | |
var result = $receiver; | |
if (((tmp$ = result.path) != null ? startsWith(tmp$, '/') : null) !== true) { | |
result = result.copy_hcwwmo$(void 0, void 0, void 0, void 0, void 0, void 0, requestUrl.encodedPath); | |
} | |
var $receiver_0 = result.domain; | |
if ($receiver_0 == null || isBlank($receiver_0)) { | |
result = result.copy_hcwwmo$(void 0, void 0, void 0, void 0, void 0, requestUrl.host); | |
} | |
return result; | |
} | |
function HttpCookies(storage) { | |
HttpCookies$Companion_getInstance(); | |
this.storage_0 = storage; | |
} | |
HttpCookies.prototype.get_dxu3lv$ = function(requestUrl, continuation) { | |
return this.storage_0.get_dxu3lv$(requestUrl, continuation); | |
}; | |
function HttpCookies$Config() { | |
this.defaults_0 = ArrayList_init(); | |
this.storage = new AcceptAllCookiesStorage(); | |
} | |
HttpCookies$Config.prototype.default_sjua2s$ = function(block) { | |
this.defaults_0.add_11rb$(block); | |
}; | |
HttpCookies$Config.prototype.build_8be2vx$ = function() { | |
var tmp$; | |
tmp$ = this.defaults_0.iterator(); | |
while (tmp$.hasNext()) { | |
var element = tmp$.next(); | |
element(this.storage); | |
} | |
return new HttpCookies(this.storage); | |
}; | |
HttpCookies$Config.$metadata$ = { | |
kind: Kind_CLASS, | |
simpleName: 'Config', | |
interfaces: []}; | |
function HttpCookies$Companion() { | |
HttpCookies$Companion_instance = this; | |
this.key_sy00j9$_0 = new AttributeKey('HttpCookies'); | |
} | |
HttpCookies$Companion.prototype.prepare_oh3mgy$$default = function(block) { | |
var $receiver = new HttpCookies$Config(); | |
block($receiver); | |
return $receiver.build_8be2vx$(); | |
}; | |
Object.defineProperty(HttpCookies$Companion.prototype, 'key', { | |
get: function() { | |
return this.key_sy00j9$_0; | |
}}); | |
function Coroutine$HttpCookies$Companion$install$lambda(closure$feature_0, $receiver_0, it_0, controller, continuation_0) { | |
CoroutineImpl.call(this, continuation_0); | |
this.$controller = controller; | |
this.exceptionState_0 = 1; | |
this.local$closure$feature = closure$feature_0; | |
this.local$$receiver = $receiver_0; | |
} | |
Coroutine$HttpCookies$Companion$install$lambda.$metadata$ = { | |
kind: Kotlin.Kind.CLASS, | |
simpleName: null, | |
interfaces: [CoroutineImpl]}; | |
Coroutine$HttpCookies$Companion$install$lambda.prototype = Object.create(CoroutineImpl.prototype); | |
Coroutine$HttpCookies$Companion$install$lambda.prototype.constructor = Coroutine$HttpCookies$Companion$install$lambda; | |
Coroutine$HttpCookies$Companion$install$lambda.prototype.doResume = function() { | |
do try { | |
switch (this.state_0) { | |
case 0: | |
this.state_0 = 2; | |
this.result_0 = this.local$closure$feature.get_dxu3lv$(clone(this.local$$receiver.context.url).build(), this); | |
if (this.result_0 === COROUTINE_SUSPENDED) | |
return COROUTINE_SUSPENDED; | |
continue; | |
case 1: | |
throw this.exception_0; | |
case 2: | |
var cookies = this.result_0; | |
this.local$$receiver.context.headers.set_puj7f4$(http.HttpHeaders.Cookie, renderClientCookies(cookies)); | |
return Unit; | |
default: | |
this.state_0 = 1; | |
throw new Error('State Machine Unreachable execution'); | |
} | |
} catch (e) { | |
if (this.state_0 === 1) { | |
this.exceptionState_0 = this.state_0; | |
throw e; | |
} else { | |
this.state_0 = this.exceptionState_0; | |
this.exception_0 = e; | |
} | |
} while (true); | |
}; | |
function HttpCookies$Companion$install$lambda(closure$feature_0) { | |
return function($receiver_0, it_0, continuation_0, suspended) { | |
var instance = new Coroutine$HttpCookies$Companion$install$lambda(closure$feature_0, $receiver_0, it_0, this, continuation_0); | |
if (suspended) | |
return instance; | |
else | |
return instance.doResume(null); | |
}; | |
} | |
function Coroutine$HttpCookies$Companion$install$lambda_0(closure$feature_0, $receiver_0, response_0, controller, continuation_0) { | |
CoroutineImpl.call(this, continuation_0); | |
this.$controller = controller; | |
this.exceptionState_0 = 1; | |
this.local$closure$feature = closure$feature_0; | |
this.local$url = void 0; | |
this.local$tmp$ = void 0; | |
this.local$$receiver = $receiver_0; | |
this.local$response = response_0; | |
} | |
Coroutine$HttpCookies$Companion$install$lambda_0.$metadata$ = { | |
kind: Kotlin.Kind.CLASS, | |
simpleName: null, | |
interfaces: [CoroutineImpl]}; | |
Coroutine$HttpCookies$Companion$install$lambda_0.prototype = Object.create(CoroutineImpl.prototype); | |
Coroutine$HttpCookies$Companion$install$lambda_0.prototype.constructor = Coroutine$HttpCookies$Companion$install$lambda_0; | |
Coroutine$HttpCookies$Companion$install$lambda_0.prototype.doResume = function() { | |
do try { | |
switch (this.state_0) { | |
case 0: | |
this.local$url = this.local$$receiver.context.request.url; | |
this.local$tmp$ = setCookie(this.local$response).iterator(); | |
this.state_0 = 2; | |
continue; | |
case 1: | |
throw this.exception_0; | |
case 2: | |
if (!this.local$tmp$.hasNext()) { | |
this.state_0 = 4; | |
continue; | |
} | |
var element = this.local$tmp$.next(); | |
this.state_0 = 3; | |
this.result_0 = this.local$closure$feature.storage_0.addCookie_c6y2p3$(this.local$url, element, this); | |
if (this.result_0 === COROUTINE_SUSPENDED) | |
return COROUTINE_SUSPENDED; | |
continue; | |
case 3: | |
this.state_0 = 2; | |
continue; | |
case 4: | |
return Unit; | |
default: | |
this.state_0 = 1; | |
throw new Error('State Machine Unreachable execution'); | |
} | |
} catch (e) { | |
if (this.state_0 === 1) { | |
this.exceptionState_0 = this.state_0; | |
throw e; | |
} else { | |
this.state_0 = this.exceptionState_0; | |
this.exception_0 = e; | |
} | |
} while (true); | |
}; | |
function HttpCookies$Companion$install$lambda_0(closure$feature_0) { | |
return function($receiver_0, response_0, continuation_0, suspended) { | |
var instance = new Coroutine$HttpCookies$Companion$install$lambda_0(closure$feature_0, $receiver_0, response_0, this, continuation_0); | |
if (suspended) | |
return instance; | |
else | |
return instance.doResume(null); | |
}; | |
} | |
HttpCookies$Companion.prototype.install_wojrb5$ = function(feature, scope) { | |
scope.sendPipeline.intercept_h71y74$(HttpSendPipeline$Phases_getInstance().State, HttpCookies$Companion$install$lambda(feature)); | |
scope.receivePipeline.intercept_h71y74$(HttpReceivePipeline$Phases_getInstance().State, HttpCookies$Companion$install$lambda_0(feature)); | |
}; | |
HttpCookies$Companion.$metadata$ = { | |
kind: Kind_OBJECT, | |
simpleName: 'Companion', | |
interfaces: [HttpClientFeature]}; | |
var HttpCookies$Companion_instance = null; | |
function HttpCookies$Companion_getInstance() { | |
if (HttpCookies$Companion_instance === null) { | |
new HttpCookies$Companion(); | |
} | |
return HttpCookies$Companion_instance; | |
} | |
HttpCookies.$metadata$ = { | |
kind: Kind_CLASS, | |
simpleName: 'HttpCookies', | |
interfaces: []}; | |
var StringBuilder_init = Kotlin.kotlin.text.StringBuilder_init; | |
function renderClientCookies(cookies) { | |
var $receiver = StringBuilder_init(); | |
var tmp$; | |
tmp$ = cookies.iterator(); | |
while (tmp$.hasNext()) { | |
var element = tmp$.next(); | |
$receiver.append_gw00v9$(element.name); | |
$receiver.append_s8itvh$(61); | |
$receiver.append_gw00v9$(encodeURLParameter(element.value)); | |
$receiver.append_s8itvh$(59); | |
} | |
return $receiver.toString(); | |
} | |
function Coroutine$cookies($receiver_0, url_0, continuation_0) { | |
CoroutineImpl.call(this, continuation_0); | |
this.exceptionState_0 = 1; | |
this.local$$receiver = $receiver_0; | |
this.local$url = url_0; | |
} | |
Coroutine$cookies.$metadata$ = { | |
kind: Kotlin.Kind.CLASS, | |
simpleName: null, | |
interfaces: [CoroutineImpl]}; | |
Coroutine$cookies.prototype = Object.create(CoroutineImpl.prototype); | |
Coroutine$cookies.prototype.constructor = Coroutine$cookies; | |
Coroutine$cookies.prototype.doResume = function() { | |
do try { | |
switch (this.state_0) { | |
case 0: | |
var tmp$, tmp$_0; | |
if ((tmp$ = feature(this.local$$receiver, HttpCookies$Companion_getInstance())) != null) { | |
this.state_0 = 2; | |
this.result_0 = tmp$.get_dxu3lv$(this.local$url, this); | |
if (this.result_0 === COROUTINE_SUSPENDED) | |
return COROUTINE_SUSPENDED; | |
continue; | |
} else { | |
this.result_0 = null; | |
this.state_0 = 3; | |
continue; | |
} | |
case 1: | |
throw this.exception_0; | |
case 2: | |
this.state_0 = 3; | |
continue; | |
case 3: | |
return (tmp$_0 = this.result_0) != null ? tmp$_0 : emptyList(); | |
default: | |
this.state_0 = 1; | |
throw new Error('State Machine Unreachable execution'); | |
} | |
} catch (e) { | |
if (this.state_0 === 1) { | |
this.exceptionState_0 = this.state_0; | |
throw e; | |
} else { | |
this.state_0 = this.exceptionState_0; | |
this.exception_0 = e; | |
} | |
} while (true); | |
}; | |
function cookies($receiver_0, url_0, continuation_0, suspended) { | |
var instance = new Coroutine$cookies($receiver_0, url_0, continuation_0); | |
if (suspended) | |
return instance; | |
else | |
return instance.doResume(null); | |
} | |
function Coroutine$cookies_0($receiver_0, urlString_0, continuation_0) { | |
CoroutineImpl.call(this, continuation_0); | |
this.exceptionState_0 = 1; | |
this.local$$receiver = $receiver_0; | |
this.local$urlString = urlString_0; | |
} | |
Coroutine$cookies_0.$metadata$ = { | |
kind: Kotlin.Kind.CLASS, | |
simpleName: null, | |
interfaces: [CoroutineImpl]}; | |
Coroutine$cookies_0.prototype = Object.create(CoroutineImpl.prototype); | |
Coroutine$cookies_0.prototype.constructor = Coroutine$cookies_0; | |
Coroutine$cookies_0.prototype.doResume = function() { | |
do try { | |
switch (this.state_0) { | |
case 0: | |
var tmp$, tmp$_0; | |
if ((tmp$ = feature(this.local$$receiver, HttpCookies$Companion_getInstance())) != null) { | |
this.state_0 = 2; | |
this.result_0 = tmp$.get_dxu3lv$(Url(this.local$urlString), this); | |
if (this.result_0 === COROUTINE_SUSPENDED) | |
return COROUTINE_SUSPENDED; | |
continue; | |
} else { | |
this.result_0 = null; | |
this.state_0 = 3; | |
continue; | |
} | |
case 1: | |
throw this.exception_0; | |
case 2: | |
this.state_0 = 3; | |
continue; | |
case 3: | |
return (tmp$_0 = this.result_0) != null ? tmp$_0 : emptyList(); | |
default: | |
this.state_0 = 1; | |
throw new Error('State Machine Unreachable execution'); | |
} | |
} catch (e) { | |
if (this.state_0 === 1) { | |
this.exceptionState_0 = this.state_0; | |
throw e; | |
} else { | |
this.state_0 = this.exceptionState_0; | |
this.exception_0 = e; | |
} | |
} while (true); | |
}; | |
function cookies_0($receiver_0, urlString_0, continuation_0, suspended) { | |
var instance = new Coroutine$cookies_0($receiver_0, urlString_0, continuation_0); | |
if (suspended) | |
return instance; | |
else | |
return instance.doResume(null); | |
} | |
function get_0($receiver, name) { | |
var firstOrNull$result; | |
firstOrNull$break: | |
do { | |
var tmp$; | |
tmp$ = $receiver.iterator(); | |
while (tmp$.hasNext()) { | |
var element = tmp$.next(); | |
if (equals(element.name, name)) { | |
firstOrNull$result = element; | |
break firstOrNull$break; | |
} | |
} | |
firstOrNull$result = null; | |
} while (false); | |
return firstOrNull$result; | |
} | |
function wrapWithContent($receiver, content, shouldCloseOrigin) { | |
return wrapWithContent_0($receiver, content); | |
} | |
function wrapWithContent_0($receiver, content) { | |
var $receiver_0 = new HttpClientCall($receiver.client); | |
$receiver_0.request = new DelegatedRequest($receiver_0, $receiver.request); | |
$receiver_0.response = new DelegatedResponse(content, $receiver_0, $receiver.response); | |
return $receiver_0; | |
} | |
function DelegatedRequest(call, origin) { | |
this.call_lxy36a$_0 = call; | |
this.$delegate_pysw8w$_0 = origin; | |
} | |
Object.defineProperty(DelegatedRequest.prototype, 'call', { | |
get: function() { | |
return this.call_lxy36a$_0; | |
}}); | |
Object.defineProperty(DelegatedRequest.prototype, 'attributes', { | |
get: function() { | |
return this.$delegate_pysw8w$_0.attributes; | |
}}); | |
Object.defineProperty(DelegatedRequest.prototype, 'content', { | |
get: function() { | |
return this.$delegate_pysw8w$_0.content; | |
}}); | |
Object.defineProperty(DelegatedRequest.prototype, 'coroutineContext', { | |
get: function() { | |
return this.$delegate_pysw8w$_0.coroutineContext; | |
}}); | |
Object.defineProperty(DelegatedRequest.prototype, 'executionContext', { | |
get: function() { | |
return this.$delegate_pysw8w$_0.executionContext; | |
}}); | |
Object.defineProperty(DelegatedRequest.prototype, 'headers', { | |
get: function() { | |
return this.$delegate_pysw8w$_0.headers; | |
}}); | |
Object.defineProperty(DelegatedRequest.prototype, 'method', { | |
get: function() { | |
return this.$delegate_pysw8w$_0.method; | |
}}); | |
Object.defineProperty(DelegatedRequest.prototype, 'url', { | |
get: function() { | |
return this.$delegate_pysw8w$_0.url; | |
}}); | |
DelegatedRequest.$metadata$ = { | |
kind: Kind_CLASS, | |
simpleName: 'DelegatedRequest', | |
interfaces: [HttpRequest]}; | |
function DelegatedResponse(content, call, origin) { | |
this.content_luf9up$_0 = content; | |
this.call_c6mvxe$_0 = call; | |
this.origin_0 = origin; | |
this.completionState_0 = CompletableDeferred_0(this.origin_0.coroutineContext.get_j3r2sn$(Job.Key)); | |
this.coroutineContext_62th7f$_0 = this.origin_0.coroutineContext.plus_1fupul$(this.completionState_0); | |
} | |
Object.defineProperty(DelegatedResponse.prototype, 'content', { | |
get: function() { | |
return this.content_luf9up$_0; | |
}}); | |
Object.defineProperty(DelegatedResponse.prototype, 'call', { | |
get: function() { | |
return this.call_c6mvxe$_0; | |
}}); | |
Object.defineProperty(DelegatedResponse.prototype, 'coroutineContext', { | |
get: function() { | |
return this.coroutineContext_62th7f$_0; | |
}}); | |
Object.defineProperty(DelegatedResponse.prototype, 'status', { | |
get: function() { | |
return this.origin_0.status; | |
}}); | |
Object.defineProperty(DelegatedResponse.prototype, 'version', { | |
get: function() { | |
return this.origin_0.version; | |
}}); | |
Object.defineProperty(DelegatedResponse.prototype, 'requestTime', { | |
get: function() { | |
return this.origin_0.requestTime; | |
}}); | |
Object.defineProperty(DelegatedResponse.prototype, 'responseTime', { | |
get: function() { | |
return this.origin_0.responseTime; | |
}}); | |
Object.defineProperty(DelegatedResponse.prototype, 'headers', { | |
get: function() { | |
return this.origin_0.headers; | |
}}); | |
DelegatedResponse.prototype.close = function() { | |
this.completionState_0.complete_11rb$(Unit); | |
}; | |
DelegatedResponse.$metadata$ = { | |
kind: Kind_CLASS, | |
simpleName: 'DelegatedResponse', | |
interfaces: [HttpResponse]}; | |
function ResponseObserver(responseHandler) { | |
ResponseObserver$Feature_getInstance(); | |
this.responseHandler_0 = responseHandler; | |
} | |
function ResponseObserver$Config() { | |
this.responseHandler_8be2vx$ = ResponseObserver$Config$responseHandler$lambda; | |
} | |
ResponseObserver$Config.prototype.onResponse_d84kwk$ = function(block) { | |
this.responseHandler_8be2vx$ = block; | |
}; | |
function Coroutine$ResponseObserver$Config$responseHandler$lambda(it_0, continuation_0) { | |
CoroutineImpl.call(this, continuation_0); | |
this.exceptionState_0 = 1; | |
} | |
Coroutine$ResponseObserver$Config$responseHandler$lambda.$metadata$ = { | |
kind: Kotlin.Kind.CLASS, | |
simpleName: null, | |
interfaces: [CoroutineImpl]}; | |
Coroutine$ResponseObserver$Config$responseHandler$lambda.prototype = Object.create(CoroutineImpl.prototype); | |
Coroutine$ResponseObserver$Config$responseHandler$lambda.prototype.constructor = Coroutine$ResponseObserver$Config$responseHandler$lambda; | |
Coroutine$ResponseObserver$Config$responseHandler$lambda.prototype.doResume = function() { | |
do try { | |
switch (this.state_0) { | |
case 0: | |
return Unit; | |
case 1: | |
throw this.exception_0; | |
default: | |
this.state_0 = 1; | |
throw new Error('State Machine Unreachable execution'); | |
} | |
} catch (e) { | |
if (this.state_0 === 1) { | |
this.exceptionState_0 = this.state_0; | |
throw e; | |
} else { | |
this.state_0 = this.exceptionState_0; | |
this.exception_0 = e; | |
} | |
} while (true); | |
}; | |
function ResponseObserver$Config$responseHandler$lambda(it_0, continuation_0, suspended) { | |
var instance = new Coroutine$ResponseObserver$Config$responseHandler$lambda(it_0, continuation_0); | |
if (suspended) | |
return instance; | |
else | |
return instance.doResume(null); | |
} | |
ResponseObserver$Config.$metadata$ = { | |
kind: Kind_CLASS, | |
simpleName: 'Config', | |
interfaces: []}; | |
function ResponseObserver$Feature() { | |
ResponseObserver$Feature_instance = this; | |
this.key_1kjwna$_0 = new AttributeKey('BodyInterceptor'); | |
} | |
Object.defineProperty(ResponseObserver$Feature.prototype, 'key', { | |
get: function() { | |
return this.key_1kjwna$_0; | |
}}); | |
ResponseObserver$Feature.prototype.prepare_oh3mgy$$default = function(block) { | |
var $receiver = new ResponseObserver$Config(); | |
block($receiver); | |
return new ResponseObserver($receiver.responseHandler_8be2vx$); | |
}; | |
function Coroutine$ResponseObserver$Feature$install$lambda$lambda(closure$feature_0, closure$sideCall_0, $receiver_0, controller, continuation_0) { | |
CoroutineImpl.call(this, continuation_0); | |
this.$controller = controller; | |
this.exceptionState_0 = 1; | |
this.local$closure$feature = closure$feature_0; | |
this.local$closure$sideCall = closure$sideCall_0; | |
} | |
Coroutine$ResponseObserver$Feature$install$lambda$lambda.$metadata$ = { | |
kind: Kotlin.Kind.CLASS, | |
simpleName: null, | |
interfaces: [CoroutineImpl]}; | |
Coroutine$ResponseObserver$Feature$install$lambda$lambda.prototype = Object.create(CoroutineImpl.prototype); | |
Coroutine$ResponseObserver$Feature$install$lambda$lambda.prototype.constructor = Coroutine$ResponseObserver$Feature$install$lambda$lambda; | |
Coroutine$ResponseObserver$Feature$install$lambda$lambda.prototype.doResume = function() { | |
do try { | |
switch (this.state_0) { | |
case 0: | |
this.state_0 = 2; | |
this.result_0 = this.local$closure$feature.responseHandler_0(this.local$closure$sideCall.response, this); | |
if (this.result_0 === COROUTINE_SUSPENDED) | |
return COROUTINE_SUSPENDED; | |
continue; | |
case 1: | |
throw this.exception_0; | |
case 2: | |
return this.result_0; | |
default: | |
this.state_0 = 1; | |
throw new Error('State Machine Unreachable execution'); | |
} | |
} catch (e) { | |
if (this.state_0 === 1) { | |
this.exceptionState_0 = this.state_0; | |
throw e; | |
} else { | |
this.state_0 = this.exceptionState_0; | |
this.exception_0 = e; | |
} | |
} while (true); | |
}; | |
function ResponseObserver$Feature$install$lambda$lambda(closure$feature_0, closure$sideCall_0) { | |
return function($receiver_0, continuation_0, suspended) { | |
var instance = new Coroutine$ResponseObserver$Feature$install$lambda$lambda(closure$feature_0, closure$sideCall_0, $receiver_0, this, continuation_0); | |
if (suspended) | |
return instance; | |
else | |
return instance.doResume(null); | |
}; | |
} | |
function Coroutine$ResponseObserver$Feature$install$lambda(closure$scope_0, closure$feature_0, $receiver_0, response_0, controller, continuation_0) { | |
CoroutineImpl.call(this, continuation_0); | |
this.$controller = controller; | |
this.exceptionState_0 = 1; | |
this.local$closure$scope = closure$scope_0; | |
this.local$closure$feature = closure$feature_0; | |
this.local$$receiver = $receiver_0; | |
this.local$response = response_0; | |
} | |
Coroutine$ResponseObserver$Feature$install$lambda.$metadata$ = { | |
kind: Kotlin.Kind.CLASS, | |
simpleName: null, | |
interfaces: [CoroutineImpl]}; | |
Coroutine$ResponseObserver$Feature$install$lambda.prototype = Object.create(CoroutineImpl.prototype); | |
Coroutine$ResponseObserver$Feature$install$lambda.prototype.constructor = Coroutine$ResponseObserver$Feature$install$lambda; | |
Coroutine$ResponseObserver$Feature$install$lambda.prototype.doResume = function() { | |
do try { | |
switch (this.state_0) { | |
case 0: | |
var tmp$ = split(this.local$response.content, this.local$closure$scope); | |
var loggingContent = tmp$.component1(), responseContent = tmp$.component2(); | |
var newClientCall = wrapWithContent_0(this.local$$receiver.context, responseContent); | |
var sideCall = wrapWithContent_0(newClientCall, loggingContent); | |
launch(this.local$$receiver, void 0, void 0, ResponseObserver$Feature$install$lambda$lambda(this.local$closure$feature, sideCall)); | |
this.local$$receiver.context.response = newClientCall.response; | |
this.local$$receiver.context.request = newClientCall.request; | |
this.local$response.close(); | |
this.state_0 = 2; | |
this.result_0 = this.local$$receiver.proceedWith_trkh7z$(this.local$$receiver.context.response, this); | |
if (this.result_0 === COROUTINE_SUSPENDED) | |
return COROUTINE_SUSPENDED; | |
continue; | |
case 1: | |
throw this.exception_0; | |
case 2: | |
return this.result_0; | |
default: | |
this.state_0 = 1; | |
throw new Error('State Machine Unreachable execution'); | |
} | |
} catch (e) { | |
if (this.state_0 === 1) { | |
this.exceptionState_0 = this.state_0; | |
throw e; | |
} else { | |
this.state_0 = this.exceptionState_0; | |
this.exception_0 = e; | |
} | |
} while (true); | |
}; | |
function ResponseObserver$Feature$install$lambda(closure$scope_0, closure$feature_0) { | |
return function($receiver_0, response_0, continuation_0, suspended) { | |
var instance = new Coroutine$ResponseObserver$Feature$install$lambda(closure$scope_0, closure$feature_0, $receiver_0, response_0, this, continuation_0); | |
if (suspended) | |
return instance; | |
else | |
return instance.doResume(null); | |
}; | |
} | |
ResponseObserver$Feature.prototype.install_wojrb5$ = function(feature, scope) { | |
scope.receivePipeline.intercept_h71y74$(HttpReceivePipeline$Phases_getInstance().Before, ResponseObserver$Feature$install$lambda(scope, feature)); | |
}; | |
ResponseObserver$Feature.$metadata$ = { | |
kind: Kind_OBJECT, | |
simpleName: 'Feature', | |
interfaces: [HttpClientFeature]}; | |
var ResponseObserver$Feature_instance = null; | |
function ResponseObserver$Feature_getInstance() { | |
if (ResponseObserver$Feature_instance === null) { | |
new ResponseObserver$Feature(); | |
} | |
return ResponseObserver$Feature_instance; | |
} | |
ResponseObserver.$metadata$ = { | |
kind: Kind_CLASS, | |
simpleName: 'ResponseObserver', | |
interfaces: []}; | |
function ResponseObserver$lambda(closure$block) { | |
return function($receiver) { | |
$receiver.responseHandler_8be2vx$ = closure$block; | |
return Unit; | |
}; | |
} | |
function ResponseObserver_0($receiver, block) { | |
$receiver.install_xlxg29$(ResponseObserver$Feature_getInstance(), ResponseObserver$lambda(block)); | |
} | |
function ClientUpgradeContent() { | |
OutgoingContent$NoContent.call(this); | |
this.content_1mwwgv$_xt2h6t$_0 = lazy(ClientUpgradeContent$content$lambda); | |
} | |
Object.defineProperty(ClientUpgradeContent.prototype, 'content_1mwwgv$_0', { | |
get: function() { | |
return this.content_1mwwgv$_xt2h6t$_0.value; | |
}}); | |
Object.defineProperty(ClientUpgradeContent.prototype, 'output', { | |
get: function() { | |
return this.content_1mwwgv$_0; | |
}}); | |
function Coroutine$pipeTo_sfhht4$($this, output_0, continuation_0) { | |
CoroutineImpl.call(this, continuation_0); | |
this.exceptionState_0 = 1; | |
this.$this = $this; | |
this.local$output = output_0; | |
} | |
Coroutine$pipeTo_sfhht4$.$metadata$ = { | |
kind: Kotlin.Kind.CLASS, | |
simpleName: null, | |
interfaces: [CoroutineImpl]}; | |
Coroutine$pipeTo_sfhht4$.prototype = Object.create(CoroutineImpl.prototype); | |
Coroutine$pipeTo_sfhht4$.prototype.constructor = Coroutine$pipeTo_sfhht4$; | |
Coroutine$pipeTo_sfhht4$.prototype.doResume = function() { | |
do try { | |
switch (this.state_0) { | |
case 0: | |
this.state_0 = 2; | |
this.result_0 = copyAndClose(this.$this.content_1mwwgv$_0, this.local$output, void 0, this); | |
if (this.result_0 === COROUTINE_SUSPENDED) | |
return COROUTINE_SUSPENDED; | |
continue; | |
case 1: | |
throw this.exception_0; | |
case 2: | |
return; | |
default: | |
this.state_0 = 1; | |
throw new Error('State Machine Unreachable execution'); | |
} | |
} catch (e) { | |
if (this.state_0 === 1) { | |
this.exceptionState_0 = this.state_0; | |
throw e; | |
} else { | |
this.state_0 = this.exceptionState_0; | |
this.exception_0 = e; | |
} | |
} while (true); | |
}; | |
ClientUpgradeContent.prototype.pipeTo_sfhht4$ = function(output_0, continuation_0, suspended) { | |
var instance = new Coroutine$pipeTo_sfhht4$(this, output_0, continuation_0); | |
if (suspended) | |
return instance; | |
else | |
return instance.doResume(null); | |
}; | |
function ClientUpgradeContent$content$lambda() { | |
return ByteChannel(); | |
} | |
ClientUpgradeContent.$metadata$ = { | |
kind: Kind_CLASS, | |
simpleName: 'ClientUpgradeContent', | |
interfaces: [OutgoingContent$NoContent]}; | |
function HttpRequest() { | |
} | |
Object.defineProperty(HttpRequest.prototype, 'coroutineContext', { | |
get: function() { | |
return this.call.coroutineContext; | |
}}); | |
Object.defineProperty(HttpRequest.prototype, 'executionContext', { | |
get: function() { | |
throw IllegalStateException_init_0('[executionContext] is deprecated. Use coroutineContext instead'.toString()); | |
}}); | |
HttpRequest.$metadata$ = { | |
kind: Kind_INTERFACE, | |
simpleName: 'HttpRequest', | |
interfaces: [CoroutineScope, HttpMessage]}; | |
function DefaultHttpRequest(call, data) { | |
this.call_bo7spw$_0 = call; | |
this.method_c5x7eh$_0 = data.method; | |
this.url_9j6cnp$_0 = data.url; | |
var tmp$; | |
this.content_jw4yw1$_0 = Kotlin.isType(tmp$ = data.body, OutgoingContent) ? tmp$ : throwCCE(); | |
this.headers_atwsac$_0 = data.headers; | |
this.attributes_el41s3$_0 = data.attributes; | |
} | |
Object.defineProperty(DefaultHttpRequest.prototype, 'call', { | |
get: function() { | |
return this.call_bo7spw$_0; | |
}}); | |
Object.defineProperty(DefaultHttpRequest.prototype, 'coroutineContext', { | |
get: function() { | |
return this.call.coroutineContext; | |
}}); | |
Object.defineProperty(DefaultHttpRequest.prototype, 'method', { | |
get: function() { | |
return this.method_c5x7eh$_0; | |
}}); | |
Object.defineProperty(DefaultHttpRequest.prototype, 'url', { | |
get: function() { | |
return this.url_9j6cnp$_0; | |
}}); | |
Object.defineProperty(DefaultHttpRequest.prototype, 'content', { | |
get: function() { | |
return this.content_jw4yw1$_0; | |
}}); | |
Object.defineProperty(DefaultHttpRequest.prototype, 'headers', { | |
get: function() { | |
return this.headers_atwsac$_0; | |
}}); | |
Object.defineProperty(DefaultHttpRequest.prototype, 'attributes', { | |
get: function() { | |
return this.attributes_el41s3$_0; | |
}}); | |
DefaultHttpRequest.$metadata$ = { | |
kind: Kind_CLASS, | |
simpleName: 'DefaultHttpRequest', | |
interfaces: [HttpRequest]}; | |
function HttpRequestBuilder() { | |
HttpRequestBuilder$Companion_getInstance(); | |
this.url = new URLBuilder(); | |
this.method = HttpMethod.Companion.Get; | |
this.headers_nor9ye$_0 = new HeadersBuilder(); | |
this.body = EmptyContent_getInstance(); | |
this.executionContext = CompletableDeferred_0(); | |
this.attributesBuilder_0 = HttpRequestBuilder$attributesBuilder$lambda; | |
} | |
Object.defineProperty(HttpRequestBuilder.prototype, 'headers', { | |
get: function() { | |
return this.headers_nor9ye$_0; | |
}}); | |
HttpRequestBuilder.prototype.url_6yzzjr$ = function(block) { | |
block(this.url, this.url); | |
}; | |
HttpRequestBuilder.prototype.build = function() { | |
var tmp$ = this.url.build(); | |
var tmp$_0 = this.method; | |
var tmp$_1 = this.headers.build(); | |
var tmp$_2 = this.body; | |
var tmp$_3 = this.executionContext; | |
var $receiver = Attributes(); | |
this.attributesBuilder_0($receiver); | |
return new HttpRequestData(tmp$, tmp$_0, tmp$_1, tmp$_2, tmp$_3, $receiver); | |
}; | |
function HttpRequestBuilder$setAttributes$lambda(closure$old, closure$block) { | |
return function($receiver) { | |
closure$old($receiver); | |
closure$block($receiver); | |
return Unit; | |
}; | |
} | |
HttpRequestBuilder.prototype.setAttributes_yhh5ns$ = function(block) { | |
var old = this.attributesBuilder_0; | |
this.attributesBuilder_0 = HttpRequestBuilder$setAttributes$lambda(old, block); | |
}; | |
HttpRequestBuilder.prototype.takeFrom_s9rlw$ = function(builder) { | |
this.method = builder.method; | |
this.body = builder.body; | |
takeFrom_1(this.url, builder.url); | |
appendAll(this.headers, builder.headers); | |
this.attributesBuilder_0 = builder.attributesBuilder_0; | |
return this; | |
}; | |
function HttpRequestBuilder$Companion() { | |
HttpRequestBuilder$Companion_instance = this; | |
} | |
HttpRequestBuilder$Companion.$metadata$ = { | |
kind: Kind_OBJECT, | |
simpleName: 'Companion', | |
interfaces: []}; | |
var HttpRequestBuilder$Companion_instance = null; | |
function HttpRequestBuilder$Companion_getInstance() { | |
if (HttpRequestBuilder$Companion_instance === null) { | |
new HttpRequestBuilder$Companion(); | |
} | |
return HttpRequestBuilder$Companion_instance; | |
} | |
function HttpRequestBuilder$attributesBuilder$lambda($receiver) { | |
return Unit; | |
} | |
HttpRequestBuilder.$metadata$ = { | |
kind: Kind_CLASS, | |
simpleName: 'HttpRequestBuilder', | |
interfaces: [HttpMessageBuilder]}; | |
function HttpRequestData(url, method, headers, body, executionContext, attributes) { | |
this.url = url; | |
this.method = method; | |
this.headers = headers; | |
this.body = body; | |
this.executionContext = executionContext; | |
this.attributes = attributes; | |
} | |
HttpRequestData.$metadata$ = { | |
kind: Kind_CLASS, | |
simpleName: 'HttpRequestData', | |
interfaces: []}; | |
function headers($receiver, block) { | |
var $receiver_0 = $receiver.headers; | |
block($receiver_0); | |
return $receiver_0; | |
} | |
function takeFrom_2($receiver, request) { | |
$receiver.method = request.method; | |
$receiver.body = request.content; | |
takeFrom_0($receiver.url, request.url); | |
$receiver.headers.appendAll_hb0ubp$(request.headers); | |
return $receiver; | |
} | |
function url($receiver, block) { | |
block($receiver.url); | |
} | |
function takeFrom_3($receiver, request) { | |
$receiver.method = request.method; | |
$receiver.body = request.body; | |
takeFrom_0($receiver.url, request.url); | |
$receiver.headers.appendAll_hb0ubp$(request.headers); | |
return $receiver; | |
} | |
function invoke($receiver, block) { | |
var $receiver_0 = new HttpRequestBuilder(); | |
url($receiver_0, block); | |
return $receiver_0; | |
} | |
function url$lambda($receiver) { | |
return Unit; | |
} | |
function url_0($receiver, scheme, host, port, path, block) { | |
if (scheme === void 0) | |
scheme = 'http'; | |
if (host === void 0) | |
host = 'localhost'; | |
if (port === void 0) | |
port = 0; | |
if (path === void 0) | |
path = '/'; | |
if (block === void 0) | |
block = url$lambda; | |
var $receiver_0 = $receiver.url; | |
$receiver_0.protocol = URLProtocol.Companion.createOrDefault_61zpoe$(scheme); | |
$receiver_0.host = host; | |
$receiver_0.port = port; | |
$receiver_0.encodedPath = path; | |
block($receiver.url); | |
} | |
function invoke$lambda($receiver) { | |
return Unit; | |
} | |
function invoke_0($receiver, scheme, host, port, path, block) { | |
if (scheme === void 0) | |
scheme = 'http'; | |
if (host === void 0) | |
host = 'localhost'; | |
if (port === void 0) | |
port = 0; | |
if (path === void 0) | |
path = '/'; | |
if (block === void 0) | |
block = invoke$lambda; | |
var $receiver_0 = new HttpRequestBuilder(); | |
url_0($receiver_0, scheme, host, port, path, block); | |
return $receiver_0; | |
} | |
function url_1($receiver, urlString) { | |
takeFrom($receiver.url, urlString); | |
} | |
function HttpRequestPipeline() { | |
HttpRequestPipeline$Phases_getInstance(); | |
Pipeline.call(this, [HttpRequestPipeline$Phases_getInstance().Before, HttpRequestPipeline$Phases_getInstance().State, HttpRequestPipeline$Phases_getInstance().Transform, HttpRequestPipeline$Phases_getInstance().Render, HttpRequestPipeline$Phases_getInstance().Send]); | |
} | |
function HttpRequestPipeline$Phases() { | |
HttpRequestPipeline$Phases_instance = this; | |
this.Before = new PipelinePhase('Before'); | |
this.State = new PipelinePhase('State'); | |
this.Transform = new PipelinePhase('Transform'); | |
this.Render = new PipelinePhase('Render'); | |
this.Send = new PipelinePhase('Send'); | |
} | |
HttpRequestPipeline$Phases.$metadata$ = { | |
kind: Kind_OBJECT, | |
simpleName: 'Phases', | |
interfaces: []}; | |
var HttpRequestPipeline$Phases_instance = null; | |
function HttpRequestPipeline$Phases_getInstance() { | |
if (HttpRequestPipeline$Phases_instance === null) { | |
new HttpRequestPipeline$Phases(); | |
} | |
return HttpRequestPipeline$Phases_instance; | |
} | |
HttpRequestPipeline.$metadata$ = { | |
kind: Kind_CLASS, | |
simpleName: 'HttpRequestPipeline', | |
interfaces: [Pipeline]}; | |
function HttpSendPipeline() { | |
HttpSendPipeline$Phases_getInstance(); | |
Pipeline.call(this, [HttpSendPipeline$Phases_getInstance().Before, HttpSendPipeline$Phases_getInstance().State, HttpSendPipeline$Phases_getInstance().Engine]); | |
} | |
function HttpSendPipeline$Phases() { | |
HttpSendPipeline$Phases_instance = this; | |
this.Before = new PipelinePhase('Before'); | |
this.State = new PipelinePhase('State'); | |
this.Engine = new PipelinePhase('Engine'); | |
} | |
HttpSendPipeline$Phases.$metadata$ = { | |
kind: Kind_OBJECT, | |
simpleName: 'Phases', | |
interfaces: []}; | |
var HttpSendPipeline$Phases_instance = null; | |
function HttpSendPipeline$Phases_getInstance() { | |
if (HttpSendPipeline$Phases_instance === null) { | |
new HttpSendPipeline$Phases(); | |
} | |
return HttpSendPipeline$Phases_instance; | |
} | |
HttpSendPipeline.$metadata$ = { | |
kind: Kind_CLASS, | |
simpleName: 'HttpSendPipeline', | |
interfaces: [Pipeline]}; | |
function Coroutine$request(T_0, isT, $receiver, builder, continuation) { | |
CoroutineImpl.call(this, continuation); | |
this.exceptionState_0 = 1; | |
this.local$T_0 = T_0; | |
this.local$isT = isT; | |
this.local$$receiver = $receiver; | |
this.local$builder = builder; | |
} | |
Coroutine$request.$metadata$ = { | |
kind: Kotlin.Kind.CLASS, | |
simpleName: null, | |
interfaces: [CoroutineImpl]}; | |
Coroutine$request.prototype = Object.create(CoroutineImpl.prototype); | |
Coroutine$request.prototype.constructor = Coroutine$request; | |
Coroutine$request.prototype.doResume = function() { | |
do try { | |
switch (this.state_0) { | |
case 0: | |
if (this.local$builder === void 0) | |
this.local$builder = new HttpRequestBuilder(); | |
this.state_0 = 2; | |
this.result_0 = call_0(this.local$$receiver, this.local$builder, this); | |
if (this.result_0 === COROUTINE_SUSPENDED) | |
return COROUTINE_SUSPENDED; | |
continue; | |
case 1: | |
throw this.exception_0; | |
case 2: | |
var tmp$_0; | |
this.state_0 = 3; | |
this.result_0 = this.result_0.receive_jo9acv$(new TypeInfo(getKClass(this.local$T_0), package$call.JsType), this); | |
if (this.result_0 === COROUTINE_SUSPENDED) | |
return COROUTINE_SUSPENDED; | |
continue; | |
case 3: | |
this.result_0 = this.local$isT(tmp$_0 = this.result_0) ? tmp$_0 : throwCCE(); | |
return this.result_0; | |
default: | |
this.state_0 = 1; | |
throw new Error('State Machine Unreachable execution'); | |
} | |
} catch (e) { | |
if (this.state_0 === 1) { | |
this.exceptionState_0 = this.state_0; | |
throw e; | |
} else { | |
this.state_0 = this.exceptionState_0; | |
this.exception_0 = e; | |
} | |
} while (true); | |
}; | |
function request(T_0, isT, $receiver, builder, continuation, suspended) { | |
var instance = new Coroutine$request(T_0, isT, $receiver, builder, continuation); | |
if (suspended) | |
return instance; | |
else | |
return instance.doResume(null); | |
} | |
defineInlineFunction('ktor-client-core.io.ktor.client.request.request_ixrg4t$', wrapFunction(function() { | |
var HttpRequestBuilder_init = _.io.ktor.client.request.HttpRequestBuilder; | |
var call = _.io.ktor.client.call.call_30bfl5$; | |
var throwCCE = Kotlin.throwCCE; | |
var getKClass = Kotlin.getKClass; | |
var call_0 = _.io.ktor.client.call; | |
var TypeInfo_init = _.io.ktor.client.call.TypeInfo; | |
return function(T_0, isT, $receiver, builder, continuation) { | |
if (builder === void 0) | |
builder = new HttpRequestBuilder_init(); | |
Kotlin.suspendCall(call($receiver, builder, Kotlin.coroutineReceiver())); | |
var tmp$_0; | |
Kotlin.suspendCall(Kotlin.coroutineResult(Kotlin.coroutineReceiver()).receive_jo9acv$(new TypeInfo_init(getKClass(T_0), call_0.JsType), Kotlin.coroutineReceiver())); | |
Kotlin.setCoroutineResult(isT(tmp$_0 = Kotlin.coroutineResult(Kotlin.coroutineReceiver())) ? tmp$_0 : throwCCE(), Kotlin.coroutineReceiver()); | |
return Kotlin.coroutineResult(Kotlin.coroutineReceiver()); | |
}; | |
})); | |
function Coroutine$request_0(T_0, isT, $receiver_1, block, continuation) { | |
CoroutineImpl.call(this, continuation); | |
this.exceptionState_0 = 1; | |
this.local$T_0 = T_0; | |
this.local$isT = isT; | |
this.local$$receiver = $receiver_1; | |
this.local$block = block; | |
} | |
Coroutine$request_0.$metadata$ = { | |
kind: Kotlin.Kind.CLASS, | |
simpleName: null, | |
interfaces: [CoroutineImpl]}; | |
Coroutine$request_0.prototype = Object.create(CoroutineImpl.prototype); | |
Coroutine$request_0.prototype.constructor = Coroutine$request_0; | |
Coroutine$request_0.prototype.doResume = function() { | |
do try { | |
switch (this.state_0) { | |
case 0: | |
var $receiver_2 = new HttpRequestBuilder(); | |
this.local$block($receiver_2); | |
this.state_0 = 2; | |
this.result_0 = call_0(this.local$$receiver, $receiver_2, this); | |
if (this.result_0 === COROUTINE_SUSPENDED) | |
return COROUTINE_SUSPENDED; | |
continue; | |
case 1: | |
throw this.exception_0; | |
case 2: | |
var tmp$_0; | |
this.state_0 = 3; | |
this.result_0 = this.result_0.receive_jo9acv$(new TypeInfo(getKClass(this.local$T_0), package$call.JsType), this); | |
if (this.result_0 === COROUTINE_SUSPENDED) | |
return COROUTINE_SUSPENDED; | |
continue; | |
case 3: | |
this.result_0 = this.local$isT(tmp$_0 = this.result_0) ? tmp$_0 : throwCCE(); | |
return this.result_0; | |
default: | |
this.state_0 = 1; | |
throw new Error('State Machine Unreachable execution'); | |
} | |
} catch (e) { | |
if (this.state_0 === 1) { | |
this.exceptionState_0 = this.state_0; | |
throw e; | |
} else { | |
this.state_0 = this.exceptionState_0; | |
this.exception_0 = e; | |
} | |
} while (true); | |
}; | |
function request_0(T_0, isT, $receiver_1, block, continuation, suspended) { | |
var instance = new Coroutine$request_0(T_0, isT, $receiver_1, block, continuation); | |
if (suspended) | |
return instance; | |
else | |
return instance.doResume(null); | |
} | |
defineInlineFunction('ktor-client-core.io.ktor.client.request.request_g0tv8i$', wrapFunction(function() { | |
var HttpRequestBuilder_init = _.io.ktor.client.request.HttpRequestBuilder; | |
var call = _.io.ktor.client.call.call_30bfl5$; | |
var throwCCE = Kotlin.throwCCE; | |
var getKClass = Kotlin.getKClass; | |
var call_0 = _.io.ktor.client.call; | |
var TypeInfo_init = _.io.ktor.client.call.TypeInfo; | |
return function(T_0, isT, $receiver_1, block, continuation) { | |
var $receiver_2 = new HttpRequestBuilder_init(); | |
block($receiver_2); | |
Kotlin.suspendCall(call($receiver_1, $receiver_2, Kotlin.coroutineReceiver())); | |
var tmp$_0; | |
Kotlin.suspendCall(Kotlin.coroutineResult(Kotlin.coroutineReceiver()).receive_jo9acv$(new TypeInfo_init(getKClass(T_0), call_0.JsType), Kotlin.coroutineReceiver())); | |
Kotlin.setCoroutineResult(isT(tmp$_0 = Kotlin.coroutineResult(Kotlin.coroutineReceiver())) ? tmp$_0 : throwCCE(), Kotlin.coroutineReceiver()); | |
return Kotlin.coroutineResult(Kotlin.coroutineReceiver()); | |
}; | |
})); | |
function Coroutine$request_1(T_0, isT, $receiver_1, urlString, block, continuation) { | |
CoroutineImpl.call(this, continuation); | |
this.exceptionState_0 = 1; | |
this.local$T_0 = T_0; | |
this.local$isT = isT; | |
this.local$$receiver = $receiver_1; | |
this.local$urlString = urlString; | |
this.local$block = block; | |
} | |
Coroutine$request_1.$metadata$ = { | |
kind: Kotlin.Kind.CLASS, | |
simpleName: null, | |
interfaces: [CoroutineImpl]}; | |
Coroutine$request_1.prototype = Object.create(CoroutineImpl.prototype); | |
Coroutine$request_1.prototype.constructor = Coroutine$request_1; | |
Coroutine$request_1.prototype.doResume = function() { | |
do try { | |
switch (this.state_0) { | |
case 0: | |
var $receiver_2 = new HttpRequestBuilder(); | |
url_1($receiver_2, this.local$urlString); | |
this.local$block($receiver_2); | |
this.state_0 = 2; | |
this.result_0 = call_0(this.local$$receiver, $receiver_2, this); | |
if (this.result_0 === COROUTINE_SUSPENDED) | |
return COROUTINE_SUSPENDED; | |
continue; | |
case 1: | |
throw this.exception_0; | |
case 2: | |
var tmp$_0; | |
this.state_0 = 3; | |
this.result_0 = this.result_0.receive_jo9acv$(new TypeInfo(getKClass(this.local$T_0), package$call.JsType), this); | |
if (this.result_0 === COROUTINE_SUSPENDED) | |
return COROUTINE_SUSPENDED; | |
continue; | |
case 3: | |
this.result_0 = this.local$isT(tmp$_0 = this.result_0) ? tmp$_0 : throwCCE(); | |
return this.result_0; | |
default: | |
this.state_0 = 1; | |
throw new Error('State Machine Unreachable execution'); | |
} | |
} catch (e) { | |
if (this.state_0 === 1) { | |
this.exceptionState_0 = this.state_0; | |
throw e; | |
} else { | |
this.state_0 = this.exceptionState_0; | |
this.exception_0 = e; | |
} | |
} while (true); | |
}; | |
function request_1(T_0, isT, $receiver_1, urlString, block, continuation, suspended) { | |
var instance = new Coroutine$request_1(T_0, isT, $receiver_1, urlString, block, continuation); | |
if (suspended) | |
return instance; | |
else | |
return instance.doResume(null); | |
} | |
defineInlineFunction('ktor-client-core.io.ktor.client.request.request_hf8dw$', wrapFunction(function() { | |
var HttpRequestBuilder_init = _.io.ktor.client.request.HttpRequestBuilder; | |
var url = _.io.ktor.client.request.url_g8iu3v$; | |
var call = _.io.ktor.client.call.call_30bfl5$; | |
var throwCCE = Kotlin.throwCCE; | |
var getKClass = Kotlin.getKClass; | |
var call_0 = _.io.ktor.client.call; | |
var TypeInfo_init = _.io.ktor.client.call.TypeInfo; | |
return function(T_0, isT, $receiver_1, urlString, block, continuation) { | |
var $receiver_2 = new HttpRequestBuilder_init(); | |
url($receiver_2, urlString); | |
block($receiver_2); | |
Kotlin.suspendCall(call($receiver_1, $receiver_2, Kotlin.coroutineReceiver())); | |
var tmp$_0; | |
Kotlin.suspendCall(Kotlin.coroutineResult(Kotlin.coroutineReceiver()).receive_jo9acv$(new TypeInfo_init(getKClass(T_0), call_0.JsType), Kotlin.coroutineReceiver())); | |
Kotlin.setCoroutineResult(isT(tmp$_0 = Kotlin.coroutineResult(Kotlin.coroutineReceiver())) ? tmp$_0 : throwCCE(), Kotlin.coroutineReceiver()); | |
return Kotlin.coroutineResult(Kotlin.coroutineReceiver()); | |
}; | |
})); | |
function Coroutine$request_2(T_0, isT, $receiver_1, url_1, block, continuation) { | |
CoroutineImpl.call(this, continuation); | |
this.exceptionState_0 = 1; | |
this.local$T_0 = T_0; | |
this.local$isT = isT; | |
this.local$$receiver = $receiver_1; | |
this.local$url = url_1; | |
this.local$block = block; | |
} | |
Coroutine$request_2.$metadata$ = { | |
kind: Kotlin.Kind.CLASS, | |
simpleName: null, | |
interfaces: [CoroutineImpl]}; | |
Coroutine$request_2.prototype = Object.create(CoroutineImpl.prototype); | |
Coroutine$request_2.prototype.constructor = Coroutine$request_2; | |
Coroutine$request_2.prototype.doResume = function() { | |
do try { | |
switch (this.state_0) { | |
case 0: | |
var $receiver_2 = new HttpRequestBuilder(); | |
url_2($receiver_2, this.local$url); | |
this.local$block($receiver_2); | |
this.state_0 = 2; | |
this.result_0 = call_0(this.local$$receiver, $receiver_2, this); | |
if (this.result_0 === COROUTINE_SUSPENDED) | |
return COROUTINE_SUSPENDED; | |
continue; | |
case 1: | |
throw this.exception_0; | |
case 2: | |
var tmp$_0; | |
this.state_0 = 3; | |
this.result_0 = this.result_0.receive_jo9acv$(new TypeInfo(getKClass(this.local$T_0), package$call.JsType), this); | |
if (this.result_0 === COROUTINE_SUSPENDED) | |
return COROUTINE_SUSPENDED; | |
continue; | |
case 3: | |
this.result_0 = this.local$isT(tmp$_0 = this.result_0) ? tmp$_0 : throwCCE(); | |
return this.result_0; | |
default: | |
this.state_0 = 1; | |
throw new Error('State Machine Unreachable execution'); | |
} | |
} catch (e) { | |
if (this.state_0 === 1) { | |
this.exceptionState_0 = this.state_0; | |
throw e; | |
} else { | |
this.state_0 = this.exceptionState_0; | |
this.exception_0 = e; | |
} | |
} while (true); | |
}; | |
function request_2(T_0, isT, $receiver_1, url_1, block, continuation, suspended) { | |
var instance = new Coroutine$request_2(T_0, isT, $receiver_1, url_1, block, continuation); | |
if (suspended) | |
return instance; | |
else | |
return instance.doResume(null); | |
} | |
defineInlineFunction('ktor-client-core.io.ktor.client.request.request_2swosf$', wrapFunction(function() { | |
var HttpRequestBuilder_init = _.io.ktor.client.request.HttpRequestBuilder; | |
var url = _.io.ktor.client.request.url_qpqkqe$; | |
var call = _.io.ktor.client.call.call_30bfl5$; | |
var throwCCE = Kotlin.throwCCE; | |
var getKClass = Kotlin.getKClass; | |
var call_0 = _.io.ktor.client.call; | |
var TypeInfo_init = _.io.ktor.client.call.TypeInfo; | |
return function(T_0, isT, $receiver_1, url_1, block, continuation) { | |
var $receiver_2 = new HttpRequestBuilder_init(); | |
url($receiver_2, url_1); | |
block($receiver_2); | |
Kotlin.suspendCall(call($receiver_1, $receiver_2, Kotlin.coroutineReceiver())); | |
var tmp$_0; | |
Kotlin.suspendCall(Kotlin.coroutineResult(Kotlin.coroutineReceiver()).receive_jo9acv$(new TypeInfo_init(getKClass(T_0), call_0.JsType), Kotlin.coroutineReceiver())); | |
Kotlin.setCoroutineResult(isT(tmp$_0 = Kotlin.coroutineResult(Kotlin.coroutineReceiver())) ? tmp$_0 : throwCCE(), Kotlin.coroutineReceiver()); | |
return Kotlin.coroutineResult(Kotlin.coroutineReceiver()); | |
}; | |
})); | |
function Coroutine$get(T_0, isT, $receiver, builder, continuation) { | |
CoroutineImpl.call(this, continuation); | |
this.exceptionState_0 = 1; | |
this.local$T_0 = T_0; | |
this.local$isT = isT; | |
this.local$$receiver = $receiver; | |
this.local$builder = builder; | |
} | |
Coroutine$get.$metadata$ = { | |
kind: Kotlin.Kind.CLASS, | |
simpleName: null, | |
interfaces: [CoroutineImpl]}; | |
Coroutine$get.prototype = Object.create(CoroutineImpl.prototype); | |
Coroutine$get.prototype.constructor = Coroutine$get; | |
Coroutine$get.prototype.doResume = function() { | |
do try { | |
switch (this.state_0) { | |
case 0: | |
this.local$builder.method = HttpMethod.Companion.Get; | |
this.state_0 = 2; | |
this.result_0 = call_0(this.local$$receiver, this.local$builder, this); | |
if (this.result_0 === COROUTINE_SUSPENDED) | |
return COROUTINE_SUSPENDED; | |
continue; | |
case 1: | |
throw this.exception_0; | |
case 2: | |
var tmp$_0; | |
this.state_0 = 3; | |
this.result_0 = this.result_0.receive_jo9acv$(new TypeInfo(getKClass(this.local$T_0), package$call.JsType), this); | |
if (this.result_0 === COROUTINE_SUSPENDED) | |
return COROUTINE_SUSPENDED; | |
continue; | |
case 3: | |
this.result_0 = this.local$isT(tmp$_0 = this.result_0) ? tmp$_0 : throwCCE(); | |
return this.result_0; | |
default: | |
this.state_0 = 1; | |
throw new Error('State Machine Unreachable execution'); | |
} | |
} catch (e) { | |
if (this.state_0 === 1) { | |
this.exceptionState_0 = this.state_0; | |
throw e; | |
} else { | |
this.state_0 = this.exceptionState_0; | |
this.exception_0 = e; | |
} | |
} while (true); | |
}; | |
function get_1(T_0, isT, $receiver, builder, continuation, suspended) { | |
var instance = new Coroutine$get(T_0, isT, $receiver, builder, continuation); | |
if (suspended) | |
return instance; | |
else | |
return instance.doResume(null); | |
} | |
defineInlineFunction('ktor-client-core.io.ktor.client.request.get_ixrg4t$', wrapFunction(function() { | |
var HttpMethod = _.$$importsForInline$$['ktor-http'].io.ktor.http.HttpMethod; | |
var call = _.io.ktor.client.call.call_30bfl5$; | |
var throwCCE = Kotlin.throwCCE; | |
var getKClass = Kotlin.getKClass; | |
var call_0 = _.io.ktor.client.call; | |
var TypeInfo_init = _.io.ktor.client.call.TypeInfo; | |
return function(T_0, isT, $receiver, builder, continuation) { | |
builder.method = HttpMethod.Companion.Get; | |
Kotlin.suspendCall(call($receiver, builder, Kotlin.coroutineReceiver())); | |
var tmp$_0; | |
Kotlin.suspendCall(Kotlin.coroutineResult(Kotlin.coroutineReceiver()).receive_jo9acv$(new TypeInfo_init(getKClass(T_0), call_0.JsType), Kotlin.coroutineReceiver())); | |
Kotlin.setCoroutineResult(isT(tmp$_0 = Kotlin.coroutineResult(Kotlin.coroutineReceiver())) ? tmp$_0 : throwCCE(), Kotlin.coroutineReceiver()); | |
return Kotlin.coroutineResult(Kotlin.coroutineReceiver()); | |
}; | |
})); | |
function Coroutine$post(T_0, isT, $receiver, builder, continuation) { | |
CoroutineImpl.call(this, continuation); | |
this.exceptionState_0 = 1; | |
this.local$T_0 = T_0; | |
this.local$isT = isT; | |
this.local$$receiver = $receiver; | |
this.local$builder = builder; | |
} | |
Coroutine$post.$metadata$ = { | |
kind: Kotlin.Kind.CLASS, | |
simpleName: null, | |
interfaces: [CoroutineImpl]}; | |
Coroutine$post.prototype = Object.create(CoroutineImpl.prototype); | |
Coroutine$post.prototype.constructor = Coroutine$post; | |
Coroutine$post.prototype.doResume = function() { | |
do try { | |
switch (this.state_0) { | |
case 0: | |
this.local$builder.method = HttpMethod.Companion.Post; | |
this.state_0 = 2; | |
this.result_0 = call_0(this.local$$receiver, this.local$builder, this); | |
if (this.result_0 === COROUTINE_SUSPENDED) | |
return COROUTINE_SUSPENDED; | |
continue; | |
case 1: | |
throw this.exception_0; | |
case 2: | |
var tmp$_0; | |
this.state_0 = 3; | |
this.result_0 = this.result_0.receive_jo9acv$(new TypeInfo(getKClass(this.local$T_0), package$call.JsType), this); | |
if (this.result_0 === COROUTINE_SUSPENDED) | |
return COROUTINE_SUSPENDED; | |
continue; | |
case 3: | |
this.result_0 = this.local$isT(tmp$_0 = this.result_0) ? tmp$_0 : throwCCE(); | |
return this.result_0; | |
default: | |
this.state_0 = 1; | |
throw new Error('State Machine Unreachable execution'); | |
} | |
} catch (e) { | |
if (this.state_0 === 1) { | |
this.exceptionState_0 = this.state_0; | |
throw e; | |
} else { | |
this.state_0 = this.exceptionState_0; | |
this.exception_0 = e; | |
} | |
} while (true); | |
}; | |
function post(T_0, isT, $receiver, builder, continuation, suspended) { | |
var instance = new Coroutine$post(T_0, isT, $receiver, builder, continuation); | |
if (suspended) | |
return instance; | |
else | |
return instance.doResume(null); | |
} | |
defineInlineFunction('ktor-client-core.io.ktor.client.request.post_ixrg4t$', wrapFunction(function() { | |
var HttpMethod = _.$$importsForInline$$['ktor-http'].io.ktor.http.HttpMethod; | |
var call = _.io.ktor.client.call.call_30bfl5$; | |
var throwCCE = Kotlin.throwCCE; | |
var getKClass = Kotlin.getKClass; | |
var call_0 = _.io.ktor.client.call; | |
var TypeInfo_init = _.io.ktor.client.call.TypeInfo; | |
return function(T_0, isT, $receiver, builder, continuation) { | |
builder.method = HttpMethod.Companion.Post; | |
Kotlin.suspendCall(call($receiver, builder, Kotlin.coroutineReceiver())); | |
var tmp$_0; | |
Kotlin.suspendCall(Kotlin.coroutineResult(Kotlin.coroutineReceiver()).receive_jo9acv$(new TypeInfo_init(getKClass(T_0), call_0.JsType), Kotlin.coroutineReceiver())); | |
Kotlin.setCoroutineResult(isT(tmp$_0 = Kotlin.coroutineResult(Kotlin.coroutineReceiver())) ? tmp$_0 : throwCCE(), Kotlin.coroutineReceiver()); | |
return Kotlin.coroutineResult(Kotlin.coroutineReceiver()); | |
}; | |
})); | |
function Coroutine$put(T_0, isT, $receiver, builder, continuation) { | |
CoroutineImpl.call(this, continuation); | |
this.exceptionState_0 = 1; | |
this.local$T_0 = T_0; | |
this.local$isT = isT; | |
this.local$$receiver = $receiver; | |
this.local$builder = builder; | |
} | |
Coroutine$put.$metadata$ = { | |
kind: Kotlin.Kind.CLASS, | |
simpleName: null, | |
interfaces: [CoroutineImpl]}; | |
Coroutine$put.prototype = Object.create(CoroutineImpl.prototype); | |
Coroutine$put.prototype.constructor = Coroutine$put; | |
Coroutine$put.prototype.doResume = function() { | |
do try { | |
switch (this.state_0) { | |
case 0: | |
this.local$builder.method = HttpMethod.Companion.Put; | |
this.state_0 = 2; | |
this.result_0 = call_0(this.local$$receiver, this.local$builder, this); | |
if (this.result_0 === COROUTINE_SUSPENDED) | |
return COROUTINE_SUSPENDED; | |
continue; | |
case 1: | |
throw this.exception_0; | |
case 2: | |
var tmp$_0; | |
this.state_0 = 3; | |
this.result_0 = this.result_0.receive_jo9acv$(new TypeInfo(getKClass(this.local$T_0), package$call.JsType), this); | |
if (this.result_0 === COROUTINE_SUSPENDED) | |
return COROUTINE_SUSPENDED; | |
continue; | |
case 3: | |
this.result_0 = this.local$isT(tmp$_0 = this.result_0) ? tmp$_0 : throwCCE(); | |
return this.result_0; | |
default: | |
this.state_0 = 1; | |
throw new Error('State Machine Unreachable execution'); | |
} | |
} catch (e) { | |
if (this.state_0 === 1) { | |
this.exceptionState_0 = this.state_0; | |
throw e; | |
} else { | |
this.state_0 = this.exceptionState_0; | |
this.exception_0 = e; | |
} | |
} while (true); | |
}; | |
function put(T_0, isT, $receiver, builder, continuation, suspended) { | |
var instance = new Coroutine$put(T_0, isT, $receiver, builder, continuation); | |
if (suspended) | |
return instance; | |
else | |
return instance.doResume(null); | |
} | |
defineInlineFunction('ktor-client-core.io.ktor.client.request.put_ixrg4t$', wrapFunction(function() { | |
var HttpMethod = _.$$importsForInline$$['ktor-http'].io.ktor.http.HttpMethod; | |
var call = _.io.ktor.client.call.call_30bfl5$; | |
var throwCCE = Kotlin.throwCCE; | |
var getKClass = Kotlin.getKClass; | |
var call_0 = _.io.ktor.client.call; | |
var TypeInfo_init = _.io.ktor.client.call.TypeInfo; | |
return function(T_0, isT, $receiver, builder, continuation) { | |
builder.method = HttpMethod.Companion.Put; | |
Kotlin.suspendCall(call($receiver, builder, Kotlin.coroutineReceiver())); | |
var tmp$_0; | |
Kotlin.suspendCall(Kotlin.coroutineResult(Kotlin.coroutineReceiver()).receive_jo9acv$(new TypeInfo_init(getKClass(T_0), call_0.JsType), Kotlin.coroutineReceiver())); | |
Kotlin.setCoroutineResult(isT(tmp$_0 = Kotlin.coroutineResult(Kotlin.coroutineReceiver())) ? tmp$_0 : throwCCE(), Kotlin.coroutineReceiver()); | |
return Kotlin.coroutineResult(Kotlin.coroutineReceiver()); | |
}; | |
})); | |
function Coroutine$delete(T_0, isT, $receiver, builder, continuation) { | |
CoroutineImpl.call(this, continuation); | |
this.exceptionState_0 = 1; | |
this.local$T_0 = T_0; | |
this.local$isT = isT; | |
this.local$$receiver = $receiver; | |
this.local$builder = builder; | |
} | |
Coroutine$delete.$metadata$ = { | |
kind: Kotlin.Kind.CLASS, | |
simpleName: null, | |
interfaces: [CoroutineImpl]}; | |
Coroutine$delete.prototype = Object.create(CoroutineImpl.prototype); | |
Coroutine$delete.prototype.constructor = Coroutine$delete; | |
Coroutine$delete.prototype.doResume = function() { | |
do try { | |
switch (this.state_0) { | |
case 0: | |
this.local$builder.method = HttpMethod.Companion.Delete; | |
this.state_0 = 2; | |
this.result_0 = call_0(this.local$$receiver, this.local$builder, this); | |
if (this.result_0 === COROUTINE_SUSPENDED) | |
return COROUTINE_SUSPENDED; | |
continue; | |
case 1: | |
throw this.exception_0; | |
case 2: | |
var tmp$_0; | |
this.state_0 = 3; | |
this.result_0 = this.result_0.receive_jo9acv$(new TypeInfo(getKClass(this.local$T_0), package$call.JsType), this); | |
if (this.result_0 === COROUTINE_SUSPENDED) | |
return COROUTINE_SUSPENDED; | |
continue; | |
case 3: | |
this.result_0 = this.local$isT(tmp$_0 = this.result_0) ? tmp$_0 : throwCCE(); | |
return this.result_0; | |
default: | |
this.state_0 = 1; | |
throw new Error('State Machine Unreachable execution'); | |
} | |
} catch (e) { | |
if (this.state_0 === 1) { | |
this.exceptionState_0 = this.state_0; | |
throw e; | |
} else { | |
this.state_0 = this.exceptionState_0; | |
this.exception_0 = e; | |
} | |
} while (true); | |
}; | |
function delete_0(T_0, isT, $receiver, builder, continuation, suspended) { | |
var instance = new Coroutine$delete(T_0, isT, $receiver, builder, continuation); | |
if (suspended) | |
return instance; | |
else | |
return instance.doResume(null); | |
} | |
defineInlineFunction('ktor-client-core.io.ktor.client.request.delete_ixrg4t$', wrapFunction(function() { | |
var HttpMethod = _.$$importsForInline$$['ktor-http'].io.ktor.http.HttpMethod; | |
var call = _.io.ktor.client.call.call_30bfl5$; | |
var throwCCE = Kotlin.throwCCE; | |
var getKClass = Kotlin.getKClass; | |
var call_0 = _.io.ktor.client.call; | |
var TypeInfo_init = _.io.ktor.client.call.TypeInfo; | |
return function(T_0, isT, $receiver, builder, continuation) { | |
builder.method = HttpMethod.Companion.Delete; | |
Kotlin.suspendCall(call($receiver, builder, Kotlin.coroutineReceiver())); | |
var tmp$_0; | |
Kotlin.suspendCall(Kotlin.coroutineResult(Kotlin.coroutineReceiver()).receive_jo9acv$(new TypeInfo_init(getKClass(T_0), call_0.JsType), Kotlin.coroutineReceiver())); | |
Kotlin.setCoroutineResult(isT(tmp$_0 = Kotlin.coroutineResult(Kotlin.coroutineReceiver())) ? tmp$_0 : throwCCE(), Kotlin.coroutineReceiver()); | |
return Kotlin.coroutineResult(Kotlin.coroutineReceiver()); | |
}; | |
})); | |
function Coroutine$options(T_0, isT, $receiver, builder, continuation) { | |
CoroutineImpl.call(this, continuation); | |
this.exceptionState_0 = 1; | |
this.local$T_0 = T_0; | |
this.local$isT = isT; | |
this.local$$receiver = $receiver; | |
this.local$builder = builder; | |
} | |
Coroutine$options.$metadata$ = { | |
kind: Kotlin.Kind.CLASS, | |
simpleName: null, | |
interfaces: [CoroutineImpl]}; | |
Coroutine$options.prototype = Object.create(CoroutineImpl.prototype); | |
Coroutine$options.prototype.constructor = Coroutine$options; | |
Coroutine$options.prototype.doResume = function() { | |
do try { | |
switch (this.state_0) { | |
case 0: | |
this.local$builder.method = HttpMethod.Companion.Options; | |
this.state_0 = 2; | |
this.result_0 = call_0(this.local$$receiver, this.local$builder, this); | |
if (this.result_0 === COROUTINE_SUSPENDED) | |
return COROUTINE_SUSPENDED; | |
continue; | |
case 1: | |
throw this.exception_0; | |
case 2: | |
var tmp$_0; | |
this.state_0 = 3; | |
this.result_0 = this.result_0.receive_jo9acv$(new TypeInfo(getKClass(this.local$T_0), package$call.JsType), this); | |
if (this.result_0 === COROUTINE_SUSPENDED) | |
return COROUTINE_SUSPENDED; | |
continue; | |
case 3: | |
this.result_0 = this.local$isT(tmp$_0 = this.result_0) ? tmp$_0 : throwCCE(); | |
return this.result_0; | |
default: | |
this.state_0 = 1; | |
throw new Error('State Machine Unreachable execution'); | |
} | |
} catch (e) { | |
if (this.state_0 === 1) { | |
this.exceptionState_0 = this.state_0; | |
throw e; | |
} else { | |
this.state_0 = this.exceptionState_0; | |
this.exception_0 = e; | |
} | |
} while (true); | |
}; | |
function options(T_0, isT, $receiver, builder, continuation, suspended) { | |
var instance = new Coroutine$options(T_0, isT, $receiver, builder, continuation); | |
if (suspended) | |
return instance; | |
else | |
return instance.doResume(null); | |
} | |
defineInlineFunction('ktor-client-core.io.ktor.client.request.options_ixrg4t$', wrapFunction(function() { | |
var HttpMethod = _.$$importsForInline$$['ktor-http'].io.ktor.http.HttpMethod; | |
var call = _.io.ktor.client.call.call_30bfl5$; | |
var throwCCE = Kotlin.throwCCE; | |
var getKClass = Kotlin.getKClass; | |
var call_0 = _.io.ktor.client.call; | |
var TypeInfo_init = _.io.ktor.client.call.TypeInfo; | |
return function(T_0, isT, $receiver, builder, continuation) { | |
builder.method = HttpMethod.Companion.Options; | |
Kotlin.suspendCall(call($receiver, builder, Kotlin.coroutineReceiver())); | |
var tmp$_0; | |
Kotlin.suspendCall(Kotlin.coroutineResult(Kotlin.coroutineReceiver()).receive_jo9acv$(new TypeInfo_init(getKClass(T_0), call_0.JsType), Kotlin.coroutineReceiver())); | |
Kotlin.setCoroutineResult(isT(tmp$_0 = Kotlin.coroutineResult(Kotlin.coroutineReceiver())) ? tmp$_0 : throwCCE(), Kotlin.coroutineReceiver()); | |
return Kotlin.coroutineResult(Kotlin.coroutineReceiver()); | |
}; | |
})); | |
function Coroutine$patch(T_0, isT, $receiver, builder, continuation) { | |
CoroutineImpl.call(this, continuation); | |
this.exceptionState_0 = 1; | |
this.local$T_0 = T_0; | |
this.local$isT = isT; | |
this.local$$receiver = $receiver; | |
this.local$builder = builder; | |
} | |
Coroutine$patch.$metadata$ = { | |
kind: Kotlin.Kind.CLASS, | |
simpleName: null, | |
interfaces: [CoroutineImpl]}; | |
Coroutine$patch.prototype = Object.create(CoroutineImpl.prototype); | |
Coroutine$patch.prototype.constructor = Coroutine$patch; | |
Coroutine$patch.prototype.doResume = function() { | |
do try { | |
switch (this.state_0) { | |
case 0: | |
this.local$builder.method = HttpMethod.Companion.Patch; | |
this.state_0 = 2; | |
this.result_0 = call_0(this.local$$receiver, this.local$builder, this); | |
if (this.result_0 === COROUTINE_SUSPENDED) | |
return COROUTINE_SUSPENDED; | |
continue; | |
case 1: | |
throw this.exception_0; | |
case 2: | |
var tmp$_0; | |
this.state_0 = 3; | |
this.result_0 = this.result_0.receive_jo9acv$(new TypeInfo(getKClass(this.local$T_0), package$call.JsType), this); | |
if (this.result_0 === COROUTINE_SUSPENDED) | |
return COROUTINE_SUSPENDED; | |
continue; | |
case 3: | |
this.result_0 = this.local$isT(tmp$_0 = this.result_0) ? tmp$_0 : throwCCE(); | |
return this.result_0; | |
default: | |
this.state_0 = 1; | |
throw new Error('State Machine Unreachable execution'); | |
} | |
} catch (e) { | |
if (this.state_0 === 1) { | |
this.exceptionState_0 = this.state_0; | |
throw e; | |
} else { | |
this.state_0 = this.exceptionState_0; | |
this.exception_0 = e; | |
} | |
} while (true); | |
}; | |
function patch(T_0, isT, $receiver, builder, continuation, suspended) { | |
var instance = new Coroutine$patch(T_0, isT, $receiver, builder, continuation); | |
if (suspended) | |
return instance; | |
else | |
return instance.doResume(null); | |
} | |
defineInlineFunction('ktor-client-core.io.ktor.client.request.patch_ixrg4t$', wrapFunction(function() { | |
var HttpMethod = _.$$importsForInline$$['ktor-http'].io.ktor.http.HttpMethod; | |
var call = _.io.ktor.client.call.call_30bfl5$; | |
var throwCCE = Kotlin.throwCCE; | |
var getKClass = Kotlin.getKClass; | |
var call_0 = _.io.ktor.client.call; | |
var TypeInfo_init = _.io.ktor.client.call.TypeInfo; | |
return function(T_0, isT, $receiver, builder, continuation) { | |
builder.method = HttpMethod.Companion.Patch; | |
Kotlin.suspendCall(call($receiver, builder, Kotlin.coroutineReceiver())); | |
var tmp$_0; | |
Kotlin.suspendCall(Kotlin.coroutineResult(Kotlin.coroutineReceiver()).receive_jo9acv$(new TypeInfo_init(getKClass(T_0), call_0.JsType), Kotlin.coroutineReceiver())); | |
Kotlin.setCoroutineResult(isT(tmp$_0 = Kotlin.coroutineResult(Kotlin.coroutineReceiver())) ? tmp$_0 : throwCCE(), Kotlin.coroutineReceiver()); | |
return Kotlin.coroutineResult(Kotlin.coroutineReceiver()); | |
}; | |
})); | |
function Coroutine$head(T_0, isT, $receiver, builder, continuation) { | |
CoroutineImpl.call(this, continuation); | |
this.exceptionState_0 = 1; | |
this.local$T_0 = T_0; | |
this.local$isT = isT; | |
this.local$$receiver = $receiver; | |
this.local$builder = builder; | |
} | |
Coroutine$head.$metadata$ = { | |
kind: Kotlin.Kind.CLASS, | |
simpleName: null, | |
interfaces: [CoroutineImpl]}; | |
Coroutine$head.prototype = Object.create(CoroutineImpl.prototype); | |
Coroutine$head.prototype.constructor = Coroutine$head; | |
Coroutine$head.prototype.doResume = function() { | |
do try { | |
switch (this.state_0) { | |
case 0: | |
this.local$builder.method = HttpMethod.Companion.Head; | |
this.state_0 = 2; | |
this.result_0 = call_0(this.local$$receiver, this.local$builder, this); | |
if (this.result_0 === COROUTINE_SUSPENDED) | |
return COROUTINE_SUSPENDED; | |
continue; | |
case 1: | |
throw this.exception_0; | |
case 2: | |
var tmp$_0; | |
this.state_0 = 3; | |
this.result_0 = this.result_0.receive_jo9acv$(new TypeInfo(getKClass(this.local$T_0), package$call.JsType), this); | |
if (this.result_0 === COROUTINE_SUSPENDED) | |
return COROUTINE_SUSPENDED; | |
continue; | |
case 3: | |
this.result_0 = this.local$isT(tmp$_0 = this.result_0) ? tmp$_0 : throwCCE(); | |
return this.result_0; | |
default: | |
this.state_0 = 1; | |
throw new Error('State Machine Unreachable execution'); | |
} | |
} catch (e) { | |
if (this.state_0 === 1) { | |
this.exceptionState_0 = this.state_0; | |
throw e; | |
} else { | |
this.state_0 = this.exceptionState_0; | |
this.exception_0 = e; | |
} | |
} while (true); | |
}; | |
function head(T_0, isT, $receiver, builder, continuation, suspended) { | |
var instance = new Coroutine$head(T_0, isT, $receiver, builder, continuation); | |
if (suspended) | |
return instance; | |
else | |
return instance.doResume(null); | |
} | |
defineInlineFunction('ktor-client-core.io.ktor.client.request.head_ixrg4t$', wrapFunction(function() { | |
var HttpMethod = _.$$importsForInline$$['ktor-http'].io.ktor.http.HttpMethod; | |
var call = _.io.ktor.client.call.call_30bfl5$; | |
var throwCCE = Kotlin.throwCCE; | |
var getKClass = Kotlin.getKClass; | |
var call_0 = _.io.ktor.client.call; | |
var TypeInfo_init = _.io.ktor.client.call.TypeInfo; | |
return function(T_0, isT, $receiver, builder, continuation) { | |
builder.method = HttpMethod.Companion.Head; | |
Kotlin.suspendCall(call($receiver, builder, Kotlin.coroutineReceiver())); | |
var tmp$_0; | |
Kotlin.suspendCall(Kotlin.coroutineResult(Kotlin.coroutineReceiver()).receive_jo9acv$(new TypeInfo_init(getKClass(T_0), call_0.JsType), Kotlin.coroutineReceiver())); | |
Kotlin.setCoroutineResult(isT(tmp$_0 = Kotlin.coroutineResult(Kotlin.coroutineReceiver())) ? tmp$_0 : throwCCE(), Kotlin.coroutineReceiver()); | |
return Kotlin.coroutineResult(Kotlin.coroutineReceiver()); | |
}; | |
})); | |
function get$lambda($receiver) { | |
return Unit; | |
} | |
function Coroutine$get_0(T_0, isT, $receiver_1, scheme, host, port, path, body, block, continuation) { | |
CoroutineImpl.call(this, continuation); | |
this.exceptionState_0 = 1; | |
this.local$T_0 = T_0; | |
this.local$isT = isT; | |
this.local$$receiver = $receiver_1; | |
this.local$scheme = scheme; | |
this.local$host = host; | |
this.local$port = port; | |
this.local$path = path; | |
this.local$body = body; | |
this.local$block = block; | |
} | |
Coroutine$get_0.$metadata$ = { | |
kind: Kotlin.Kind.CLASS, | |
simpleName: null, | |
interfaces: [CoroutineImpl]}; | |
Coroutine$get_0.prototype = Object.create(CoroutineImpl.prototype); | |
Coroutine$get_0.prototype.constructor = Coroutine$get_0; | |
Coroutine$get_0.prototype.doResume = function() { | |
do try { | |
switch (this.state_0) { | |
case 0: | |
if (this.local$scheme === void 0) | |
this.local$scheme = 'http'; | |
if (this.local$host === void 0) | |
this.local$host = 'localhost'; | |
if (this.local$port === void 0) | |
this.local$port = 0; | |
if (this.local$path === void 0) | |
this.local$path = '/'; | |
if (this.local$body === void 0) | |
this.local$body = package$utils.EmptyContent; | |
if (this.local$block === void 0) | |
this.local$block = get$lambda; | |
var $receiver_2 = new HttpRequestBuilder(); | |
url_0($receiver_2, this.local$scheme, this.local$host, this.local$port, this.local$path); | |
$receiver_2.method = HttpMethod.Companion.Get; | |
$receiver_2.body = this.local$body; | |
this.local$block($receiver_2); | |
this.state_0 = 2; | |
this.result_0 = call_0(this.local$$receiver, $receiver_2, this); | |
if (this.result_0 === COROUTINE_SUSPENDED) | |
return COROUTINE_SUSPENDED; | |
continue; | |
case 1: | |
throw this.exception_0; | |
case 2: | |
var tmp$_0; | |
this.state_0 = 3; | |
this.result_0 = this.result_0.receive_jo9acv$(new TypeInfo(getKClass(this.local$T_0), package$call.JsType), this); | |
if (this.result_0 === COROUTINE_SUSPENDED) | |
return COROUTINE_SUSPENDED; | |
continue; | |
case 3: | |
this.result_0 = this.local$isT(tmp$_0 = this.result_0) ? tmp$_0 : throwCCE(); | |
return this.result_0; | |
default: | |
this.state_0 = 1; | |
throw new Error('State Machine Unreachable execution'); | |
} | |
} catch (e) { | |
if (this.state_0 === 1) { | |
this.exceptionState_0 = this.state_0; | |
throw e; | |
} else { | |
this.state_0 = this.exceptionState_0; | |
this.exception_0 = e; | |
} | |
} while (true); | |
}; | |
function get_2(T_0, isT, $receiver_1, scheme, host, port, path, body, block, continuation, suspended) { | |
var instance = new Coroutine$get_0(T_0, isT, $receiver_1, scheme, host, port, path, body, block, continuation); | |
if (suspended) | |
return instance; | |
else | |
return instance.doResume(null); | |
} | |
defineInlineFunction('ktor-client-core.io.ktor.client.request.get_xwttm9$', wrapFunction(function() { | |
var utils = _.io.ktor.client.utils; | |
var Unit = Kotlin.kotlin.Unit; | |
var url = _.io.ktor.client.request.url_3rzbk2$; | |
var HttpMethod = _.$$importsForInline$$['ktor-http'].io.ktor.http.HttpMethod; | |
function get$lambda($receiver) { | |
return Unit; | |
} | |
var HttpRequestBuilder_init = _.io.ktor.client.request.HttpRequestBuilder; | |
var call = _.io.ktor.client.call.call_30bfl5$; | |
var throwCCE = Kotlin.throwCCE; | |
var getKClass = Kotlin.getKClass; | |
var call_0 = _.io.ktor.client.call; | |
var TypeInfo_init = _.io.ktor.client.call.TypeInfo; | |
return function(T_0, isT, $receiver_1, scheme, host, port, path, body, block, continuation) { | |
if (scheme === void 0) | |
scheme = 'http'; | |
if (host === void 0) | |
host = 'localhost'; | |
if (port === void 0) | |
port = 0; | |
if (path === void 0) | |
path = '/'; | |
if (body === void 0) | |
body = utils.EmptyContent; | |
if (block === void 0) | |
block = get$lambda; | |
var $receiver_2 = new HttpRequestBuilder_init(); | |
url($receiver_2, scheme, host, port, path); | |
$receiver_2.method = HttpMethod.Companion.Get; | |
$receiver_2.body = body; | |
block($receiver_2); | |
Kotlin.suspendCall(call($receiver_1, $receiver_2, Kotlin.coroutineReceiver())); | |
var tmp$_0; | |
Kotlin.suspendCall(Kotlin.coroutineResult(Kotlin.coroutineReceiver()).receive_jo9acv$(new TypeInfo_init(getKClass(T_0), call_0.JsType), Kotlin.coroutineReceiver())); | |
Kotlin.setCoroutineResult(isT(tmp$_0 = Kotlin.coroutineResult(Kotlin.coroutineReceiver())) ? tmp$_0 : throwCCE(), Kotlin.coroutineReceiver()); | |
return Kotlin.coroutineResult(Kotlin.coroutineReceiver()); | |
}; | |
})); | |
function post$lambda($receiver) { | |
return Unit; | |
} | |
function Coroutine$post_0(T_0, isT, $receiver_1, scheme, host, port, path, body, block, continuation) { | |
CoroutineImpl.call(this, continuation); | |
this.exceptionState_0 = 1; | |
this.local$T_0 = T_0; | |
this.local$isT = isT; | |
this.local$$receiver = $receiver_1; | |
this.local$scheme = scheme; | |
this.local$host = host; | |
this.local$port = port; | |
this.local$path = path; | |
this.local$body = body; | |
this.local$block = block; | |
} | |
Coroutine$post_0.$metadata$ = { | |
kind: Kotlin.Kind.CLASS, | |
simpleName: null, | |
interfaces: [CoroutineImpl]}; | |
Coroutine$post_0.prototype = Object.create(CoroutineImpl.prototype); | |
Coroutine$post_0.prototype.constructor = Coroutine$post_0; | |
Coroutine$post_0.prototype.doResume = function() { | |
do try { | |
switch (this.state_0) { | |
case 0: | |
if (this.local$scheme === void 0) | |
this.local$scheme = 'http'; | |
if (this.local$host === void 0) | |
this.local$host = 'localhost'; | |
if (this.local$port === void 0) | |
this.local$port = 0; | |
if (this.local$path === void 0) | |
this.local$path = '/'; | |
if (this.local$body === void 0) | |
this.local$body = package$utils.EmptyContent; | |
if (this.local$block === void 0) | |
this.local$block = post$lambda; | |
var $receiver_2 = new HttpRequestBuilder(); | |
url_0($receiver_2, this.local$scheme, this.local$host, this.local$port, this.local$path); | |
$receiver_2.method = HttpMethod.Companion.Post; | |
$receiver_2.body = this.local$body; | |
this.local$block($receiver_2); | |
this.state_0 = 2; | |
this.result_0 = call_0(this.local$$receiver, $receiver_2, this); | |
if (this.result_0 === COROUTINE_SUSPENDED) | |
return COROUTINE_SUSPENDED; | |
continue; | |
case 1: | |
throw this.exception_0; | |
case 2: | |
var tmp$_0; | |
this.state_0 = 3; | |
this.result_0 = this.result_0.receive_jo9acv$(new TypeInfo(getKClass(this.local$T_0), package$call.JsType), this); | |
if (this.result_0 === COROUTINE_SUSPENDED) | |
return COROUTINE_SUSPENDED; | |
continue; | |
case 3: | |
this.result_0 = this.local$isT(tmp$_0 = this.result_0) ? tmp$_0 : throwCCE(); | |
return this.result_0; | |
default: | |
this.state_0 = 1; | |
throw new Error('State Machine Unreachable execution'); | |
} | |
} catch (e) { | |
if (this.state_0 === 1) { | |
this.exceptionState_0 = this.state_0; | |
throw e; | |
} else { | |
this.state_0 = this.exceptionState_0; | |
this.exception_0 = e; | |
} | |
} while (true); | |
}; | |
function post_0(T_0, isT, $receiver_1, scheme, host, port, path, body, block, continuation, suspended) { | |
var instance = new Coroutine$post_0(T_0, isT, $receiver_1, scheme, host, port, path, body, block, continuation); | |
if (suspended) | |
return instance; | |
else | |
return instance.doResume(null); | |
} | |
defineInlineFunction('ktor-client-core.io.ktor.client.request.post_xwttm9$', wrapFunction(function() { | |
var utils = _.io.ktor.client.utils; | |
var Unit = Kotlin.kotlin.Unit; | |
var url = _.io.ktor.client.request.url_3rzbk2$; | |
var HttpMethod = _.$$importsForInline$$['ktor-http'].io.ktor.http.HttpMethod; | |
function post$lambda($receiver) { | |
return Unit; | |
} | |
var HttpRequestBuilder_init = _.io.ktor.client.request.HttpRequestBuilder; | |
var call = _.io.ktor.client.call.call_30bfl5$; | |
var throwCCE = Kotlin.throwCCE; | |
var getKClass = Kotlin.getKClass; | |
var call_0 = _.io.ktor.client.call; | |
var TypeInfo_init = _.io.ktor.client.call.TypeInfo; | |
return function(T_0, isT, $receiver_1, scheme, host, port, path, body, block, continuation) { | |
if (scheme === void 0) | |
scheme = 'http'; | |
if (host === void 0) | |
host = 'localhost'; | |
if (port === void 0) | |
port = 0; | |
if (path === void 0) | |
path = '/'; | |
if (body === void 0) | |
body = utils.EmptyContent; | |
if (block === void 0) | |
block = post$lambda; | |
var $receiver_2 = new HttpRequestBuilder_init(); | |
url($receiver_2, scheme, host, port, path); | |
$receiver_2.method = HttpMethod.Companion.Post; | |
$receiver_2.body = body; | |
block($receiver_2); | |
Kotlin.suspendCall(call($receiver_1, $receiver_2, Kotlin.coroutineReceiver())); | |
var tmp$_0; | |
Kotlin.suspendCall(Kotlin.coroutineResult(Kotlin.coroutineReceiver()).receive_jo9acv$(new TypeInfo_init(getKClass(T_0), call_0.JsType), Kotlin.coroutineReceiver())); | |
Kotlin.setCoroutineResult(isT(tmp$_0 = Kotlin.coroutineResult(Kotlin.coroutineReceiver())) ? tmp$_0 : throwCCE(), Kotlin.coroutineReceiver()); | |
return Kotlin.coroutineResult(Kotlin.coroutineReceiver()); | |
}; | |
})); | |
function put$lambda($receiver) { | |
return Unit; | |
} | |
function Coroutine$put_0(T_0, isT, $receiver_1, scheme, host, port, path, body, block, continuation) { | |
CoroutineImpl.call(this, continuation); | |
this.exceptionState_0 = 1; | |
this.local$T_0 = T_0; | |
this.local$isT = isT; | |
this.local$$receiver = $receiver_1; | |
this.local$scheme = scheme; | |
this.local$host = host; | |
this.local$port = port; | |
this.local$path = path; | |
this.local$body = body; | |
this.local$block = block; | |
} | |
Coroutine$put_0.$metadata$ = { | |
kind: Kotlin.Kind.CLASS, | |
simpleName: null, | |
interfaces: [CoroutineImpl]}; | |
Coroutine$put_0.prototype = Object.create(CoroutineImpl.prototype); | |
Coroutine$put_0.prototype.constructor = Coroutine$put_0; | |
Coroutine$put_0.prototype.doResume = function() { | |
do try { | |
switch (this.state_0) { | |
case 0: | |
if (this.local$scheme === void 0) | |
this.local$scheme = 'http'; | |
if (this.local$host === void 0) | |
this.local$host = 'localhost'; | |
if (this.local$port === void 0) | |
this.local$port = 0; | |
if (this.local$path === void 0) | |
this.local$path = '/'; | |
if (this.local$body === void 0) | |
this.local$body = package$utils.EmptyContent; | |
if (this.local$block === void 0) | |
this.local$block = put$lambda; | |
var $receiver_2 = new HttpRequestBuilder(); | |
url_0($receiver_2, this.local$scheme, this.local$host, this.local$port, this.local$path); | |
$receiver_2.method = HttpMethod.Companion.Put; | |
$receiver_2.body = this.local$body; | |
this.local$block($receiver_2); | |
this.state_0 = 2; | |
this.result_0 = call_0(this.local$$receiver, $receiver_2, this); | |
if (this.result_0 === COROUTINE_SUSPENDED) | |
return COROUTINE_SUSPENDED; | |
continue; | |
case 1: | |
throw this.exception_0; | |
case 2: | |
var tmp$_0; | |
this.state_0 = 3; | |
this.result_0 = this.result_0.receive_jo9acv$(new TypeInfo(getKClass(this.local$T_0), package$call.JsType), this); | |
if (this.result_0 === COROUTINE_SUSPENDED) | |
return COROUTINE_SUSPENDED; | |
continue; | |
case 3: | |
this.result_0 = this.local$isT(tmp$_0 = this.result_0) ? tmp$_0 : throwCCE(); | |
return this.result_0; | |
default: | |
this.state_0 = 1; | |
throw new Error('State Machine Unreachable execution'); | |
} | |
} catch (e) { | |
if (this.state_0 === 1) { | |
this.exceptionState_0 = this.state_0; | |
throw e; | |
} else { | |
this.state_0 = this.exceptionState_0; | |
this.exception_0 = e; | |
} | |
} while (true); | |
}; | |
function put_0(T_0, isT, $receiver_1, scheme, host, port, path, body, block, continuation, suspended) { | |
var instance = new Coroutine$put_0(T_0, isT, $receiver_1, scheme, host, port, path, body, block, continuation); | |
if (suspended) | |
return instance; | |
else | |
return instance.doResume(null); | |
} | |
defineInlineFunction('ktor-client-core.io.ktor.client.request.put_xwttm9$', wrapFunction(function() { | |
var utils = _.io.ktor.client.utils; | |
var Unit = Kotlin.kotlin.Unit; | |
var url = _.io.ktor.client.request.url_3rzbk2$; | |
var HttpMethod = _.$$importsForInline$$['ktor-http'].io.ktor.http.HttpMethod; | |
function put$lambda($receiver) { | |
return Unit; | |
} | |
var HttpRequestBuilder_init = _.io.ktor.client.request.HttpRequestBuilder; | |
var call = _.io.ktor.client.call.call_30bfl5$; | |
var throwCCE = Kotlin.throwCCE; | |
var getKClass = Kotlin.getKClass; | |
var call_0 = _.io.ktor.client.call; | |
var TypeInfo_init = _.io.ktor.client.call.TypeInfo; | |
return function(T_0, isT, $receiver_1, scheme, host, port, path, body, block, continuation) { | |
if (scheme === void 0) | |
scheme = 'http'; | |
if (host === void 0) | |
host = 'localhost'; | |
if (port === void 0) | |
port = 0; | |
if (path === void 0) | |
path = '/'; | |
if (body === void 0) | |
body = utils.EmptyContent; | |
if (block === void 0) | |
block = put$lambda; | |
var $receiver_2 = new HttpRequestBuilder_init(); | |
url($receiver_2, scheme, host, port, path); | |
$receiver_2.method = HttpMethod.Companion.Put; | |
$receiver_2.body = body; | |
block($receiver_2); | |
Kotlin.suspendCall(call($receiver_1, $receiver_2, Kotlin.coroutineReceiver())); | |
var tmp$_0; | |
Kotlin.suspendCall(Kotlin.coroutineResult(Kotlin.coroutineReceiver()).receive_jo9acv$(new TypeInfo_init(getKClass(T_0), call_0.JsType), Kotlin.coroutineReceiver())); | |
Kotlin.setCoroutineResult(isT(tmp$_0 = Kotlin.coroutineResult(Kotlin.coroutineReceiver())) ? tmp$_0 : throwCCE(), Kotlin.coroutineReceiver()); | |
return Kotlin.coroutineResult(Kotlin.coroutineReceiver()); | |
}; | |
})); | |
function delete$lambda($receiver) { | |
return Unit; | |
} | |
function Coroutine$delete_0(T_0, isT, $receiver_1, scheme, host, port, path, body, block, continuation) { | |
CoroutineImpl.call(this, continuation); | |
this.exceptionState_0 = 1; | |
this.local$T_0 = T_0; | |
this.local$isT = isT; | |
this.local$$receiver = $receiver_1; | |
this.local$scheme = scheme; | |
this.local$host = host; | |
this.local$port = port; | |
this.local$path = path; | |
this.local$body = body; | |
this.local$block = block; | |
} | |
Coroutine$delete_0.$metadata$ = { | |
kind: Kotlin.Kind.CLASS, | |
simpleName: null, | |
interfaces: [CoroutineImpl]}; | |
Coroutine$delete_0.prototype = Object.create(CoroutineImpl.prototype); | |
Coroutine$delete_0.prototype.constructor = Coroutine$delete_0; | |
Coroutine$delete_0.prototype.doResume = function() { | |
do try { | |
switch (this.state_0) { | |
case 0: | |
if (this.local$scheme === void 0) | |
this.local$scheme = 'http'; | |
if (this.local$host === void 0) | |
this.local$host = 'localhost'; | |
if (this.local$port === void 0) | |
this.local$port = 0; | |
if (this.local$path === void 0) | |
this.local$path = '/'; | |
if (this.local$body === void 0) | |
this.local$body = package$utils.EmptyContent; | |
if (this.local$block === void 0) | |
this.local$block = delete$lambda; | |
var $receiver_2 = new HttpRequestBuilder(); | |
url_0($receiver_2, this.local$scheme, this.local$host, this.local$port, this.local$path); | |
$receiver_2.method = HttpMethod.Companion.Delete; | |
$receiver_2.body = this.local$body; | |
this.local$block($receiver_2); | |
this.state_0 = 2; | |
this.result_0 = call_0(this.local$$receiver, $receiver_2, this); | |
if (this.result_0 === COROUTINE_SUSPENDED) | |
return COROUTINE_SUSPENDED; | |
continue; | |
case 1: | |
throw this.exception_0; | |
case 2: | |
var tmp$_0; | |
this.state_0 = 3; | |
this.result_0 = this.result_0.receive_jo9acv$(new TypeInfo(getKClass(this.local$T_0), package$call.JsType), this); | |
if (this.result_0 === COROUTINE_SUSPENDED) | |
return COROUTINE_SUSPENDED; | |
continue; | |
case 3: | |
this.result_0 = this.local$isT(tmp$_0 = this.result_0) ? tmp$_0 : throwCCE(); | |
return this.result_0; | |
default: | |
this.state_0 = 1; | |
throw new Error('State Machine Unreachable execution'); | |
} | |
} catch (e) { | |
if (this.state_0 === 1) { | |
this.exceptionState_0 = this.state_0; | |
throw e; | |
} else { | |
this.state_0 = this.exceptionState_0; | |
this.exception_0 = e; | |
} | |
} while (true); | |
}; | |
function delete_1(T_0, isT, $receiver_1, scheme, host, port, path, body, block, continuation, suspended) { | |
var instance = new Coroutine$delete_0(T_0, isT, $receiver_1, scheme, host, port, path, body, block, continuation); | |
if (suspended) | |
return instance; | |
else | |
return instance.doResume(null); | |
} | |
defineInlineFunction('ktor-client-core.io.ktor.client.request.delete_xwttm9$', wrapFunction(function() { | |
var utils = _.io.ktor.client.utils; | |
var Unit = Kotlin.kotlin.Unit; | |
var url = _.io.ktor.client.request.url_3rzbk2$; | |
var HttpMethod = _.$$importsForInline$$['ktor-http'].io.ktor.http.HttpMethod; | |
function delete$lambda($receiver) { | |
return Unit; | |
} | |
var HttpRequestBuilder_init = _.io.ktor.client.request.HttpRequestBuilder; | |
var call = _.io.ktor.client.call.call_30bfl5$; | |
var throwCCE = Kotlin.throwCCE; | |
var getKClass = Kotlin.getKClass; | |
var call_0 = _.io.ktor.client.call; | |
var TypeInfo_init = _.io.ktor.client.call.TypeInfo; | |
return function(T_0, isT, $receiver_1, scheme, host, port, path, body, block, continuation) { | |
if (scheme === void 0) | |
scheme = 'http'; | |
if (host === void 0) | |
host = 'localhost'; | |
if (port === void 0) | |
port = 0; | |
if (path === void 0) | |
path = '/'; | |
if (body === void 0) | |
body = utils.EmptyContent; | |
if (block === void 0) | |
block = delete$lambda; | |
var $receiver_2 = new HttpRequestBuilder_init(); | |
url($receiver_2, scheme, host, port, path); | |
$receiver_2.method = HttpMethod.Companion.Delete; | |
$receiver_2.body = body; | |
block($receiver_2); | |
Kotlin.suspendCall(call($receiver_1, $receiver_2, Kotlin.coroutineReceiver())); | |
var tmp$_0; | |
Kotlin.suspendCall(Kotlin.coroutineResult(Kotlin.coroutineReceiver()).receive_jo9acv$(new TypeInfo_init(getKClass(T_0), call_0.JsType), Kotlin.coroutineReceiver())); | |
Kotlin.setCoroutineResult(isT(tmp$_0 = Kotlin.coroutineResult(Kotlin.coroutineReceiver())) ? tmp$_0 : throwCCE(), Kotlin.coroutineReceiver()); | |
return Kotlin.coroutineResult(Kotlin.coroutineReceiver()); | |
}; | |
})); | |
function patch$lambda($receiver) { | |
return Unit; | |
} | |
function Coroutine$patch_0(T_0, isT, $receiver_1, scheme, host, port, path, body, block, continuation) { | |
CoroutineImpl.call(this, continuation); | |
this.exceptionState_0 = 1; | |
this.local$T_0 = T_0; | |
this.local$isT = isT; | |
this.local$$receiver = $receiver_1; | |
this.local$scheme = scheme; | |
this.local$host = host; | |
this.local$port = port; | |
this.local$path = path; | |
this.local$body = body; | |
this.local$block = block; | |
} | |
Coroutine$patch_0.$metadata$ = { | |
kind: Kotlin.Kind.CLASS, | |
simpleName: null, | |
interfaces: [CoroutineImpl]}; | |
Coroutine$patch_0.prototype = Object.create(CoroutineImpl.prototype); | |
Coroutine$patch_0.prototype.constructor = Coroutine$patch_0; | |
Coroutine$patch_0.prototype.doResume = function() { | |
do try { | |
switch (this.state_0) { | |
case 0: | |
if (this.local$scheme === void 0) | |
this.local$scheme = 'http'; | |
if (this.local$host === void 0) | |
this.local$host = 'localhost'; | |
if (this.local$port === void 0) | |
this.local$port = 0; | |
if (this.local$path === void 0) | |
this.local$path = '/'; | |
if (this.local$body === void 0) | |
this.local$body = package$utils.EmptyContent; | |
if (this.local$block === void 0) | |
this.local$block = patch$lambda; | |
var $receiver_2 = new HttpRequestBuilder(); | |
url_0($receiver_2, this.local$scheme, this.local$host, this.local$port, this.local$path); | |
$receiver_2.method = HttpMethod.Companion.Patch; | |
$receiver_2.body = this.local$body; | |
this.local$block($receiver_2); | |
this.state_0 = 2; | |
this.result_0 = call_0(this.local$$receiver, $receiver_2, this); | |
if (this.result_0 === COROUTINE_SUSPENDED) | |
return COROUTINE_SUSPENDED; | |
continue; | |
case 1: | |
throw this.exception_0; | |
case 2: | |
var tmp$_0; | |
this.state_0 = 3; | |
this.result_0 = this.result_0.receive_jo9acv$(new TypeInfo(getKClass(this.local$T_0), package$call.JsType), this); | |
if (this.result_0 === COROUTINE_SUSPENDED) | |
return COROUTINE_SUSPENDED; | |
continue; | |
case 3: | |
this.result_0 = this.local$isT(tmp$_0 = this.result_0) ? tmp$_0 : throwCCE(); | |
return this.result_0; | |
default: | |
this.state_0 = 1; | |
throw new Error('State Machine Unreachable execution'); | |
} | |
} catch (e) { | |
if (this.state_0 === 1) { | |
this.exceptionState_0 = this.state_0; | |
throw e; | |
} else { | |
this.state_0 = this.exceptionState_0; | |
this.exception_0 = e; | |
} | |
} while (true); | |
}; | |
function patch_0(T_0, isT, $receiver_1, scheme, host, port, path, body, block, continuation, suspended) { | |
var instance = new Coroutine$patch_0(T_0, isT, $receiver_1, scheme, host, port, path, body, block, continuation); | |
if (suspended) | |
return instance; | |
else | |
return instance.doResume(null); | |
} | |
defineInlineFunction('ktor-client-core.io.ktor.client.request.patch_xwttm9$', wrapFunction(function() { | |
var utils = _.io.ktor.client.utils; | |
var Unit = Kotlin.kotlin.Unit; | |
var url = _.io.ktor.client.request.url_3rzbk2$; | |
var HttpMethod = _.$$importsForInline$$['ktor-http'].io.ktor.http.HttpMethod; | |
function patch$lambda($receiver) { | |
return Unit; | |
} | |
var HttpRequestBuilder_init = _.io.ktor.client.request.HttpRequestBuilder; | |
var call = _.io.ktor.client.call.call_30bfl5$; | |
var throwCCE = Kotlin.throwCCE; | |
var getKClass = Kotlin.getKClass; | |
var call_0 = _.io.ktor.client.call; | |
var TypeInfo_init = _.io.ktor.client.call.TypeInfo; | |
return function(T_0, isT, $receiver_1, scheme, host, port, path, body, block, continuation) { | |
if (scheme === void 0) | |
scheme = 'http'; | |
if (host === void 0) | |
host = 'localhost'; | |
if (port === void 0) | |
port = 0; | |
if (path === void 0) | |
path = '/'; | |
if (body === void 0) | |
body = utils.EmptyContent; | |
if (block === void 0) | |
block = patch$lambda; | |
var $receiver_2 = new HttpRequestBuilder_init(); | |
url($receiver_2, scheme, host, port, path); | |
$receiver_2.method = HttpMethod.Companion.Patch; | |
$receiver_2.body = body; | |
block($receiver_2); | |
Kotlin.suspendCall(call($receiver_1, $receiver_2, Kotlin.coroutineReceiver())); | |
var tmp$_0; | |
Kotlin.suspendCall(Kotlin.coroutineResult(Kotlin.coroutineReceiver()).receive_jo9acv$(new TypeInfo_init(getKClass(T_0), call_0.JsType), Kotlin.coroutineReceiver())); | |
Kotlin.setCoroutineResult(isT(tmp$_0 = Kotlin.coroutineResult(Kotlin.coroutineReceiver())) ? tmp$_0 : throwCCE(), Kotlin.coroutineReceiver()); | |
return Kotlin.coroutineResult(Kotlin.coroutineReceiver()); | |
}; | |
})); | |
function head$lambda($receiver) { | |
return Unit; | |
} | |
function Coroutine$head_0(T_0, isT, $receiver_1, scheme, host, port, path, body, block, continuation) { | |
CoroutineImpl.call(this, continuation); | |
this.exceptionState_0 = 1; | |
this.local$T_0 = T_0; | |
this.local$isT = isT; | |
this.local$$receiver = $receiver_1; | |
this.local$scheme = scheme; | |
this.local$host = host; | |
this.local$port = port; | |
this.local$path = path; | |
this.local$body = body; | |
this.local$block = block; | |
} | |
Coroutine$head_0.$metadata$ = { | |
kind: Kotlin.Kind.CLASS, | |
simpleName: null, | |
interfaces: [CoroutineImpl]}; | |
Coroutine$head_0.prototype = Object.create(CoroutineImpl.prototype); | |
Coroutine$head_0.prototype.constructor = Coroutine$head_0; | |
Coroutine$head_0.prototype.doResume = function() { | |
do try { | |
switch (this.state_0) { | |
case 0: | |
if (this.local$scheme === void 0) | |
this.local$scheme = 'http'; | |
if (this.local$host === void 0) | |
this.local$host = 'localhost'; | |
if (this.local$port === void 0) | |
this.local$port = 0; | |
if (this.local$path === void 0) | |
this.local$path = '/'; | |
if (this.local$body === void 0) | |
this.local$body = package$utils.EmptyContent; | |
if (this.local$block === void 0) | |
this.local$block = head$lambda; | |
var $receiver_2 = new HttpRequestBuilder(); | |
url_0($receiver_2, this.local$scheme, this.local$host, this.local$port, this.local$path); | |
$receiver_2.method = HttpMethod.Companion.Head; | |
$receiver_2.body = this.local$body; | |
this.local$block($receiver_2); | |
this.state_0 = 2; | |
this.result_0 = call_0(this.local$$receiver, $receiver_2, this); | |
if (this.result_0 === COROUTINE_SUSPENDED) | |
return COROUTINE_SUSPENDED; | |
continue; | |
case 1: | |
throw this.exception_0; | |
case 2: | |
var tmp$_0; | |
this.state_0 = 3; | |
this.result_0 = this.result_0.receive_jo9acv$(new TypeInfo(getKClass(this.local$T_0), package$call.JsType), this); | |
if (this.result_0 === COROUTINE_SUSPENDED) | |
return COROUTINE_SUSPENDED; | |
continue; | |
case 3: | |
this.result_0 = this.local$isT(tmp$_0 = this.result_0) ? tmp$_0 : throwCCE(); | |
return this.result_0; | |
default: | |
this.state_0 = 1; | |
throw new Error('State Machine Unreachable execution'); | |
} | |
} catch (e) { | |
if (this.state_0 === 1) { | |
this.exceptionState_0 = this.state_0; | |
throw e; | |
} else { | |
this.state_0 = this.exceptionState_0; | |
this.exception_0 = e; | |
} | |
} while (true); | |
}; | |
function head_0(T_0, isT, $receiver_1, scheme, host, port, path, body, block, continuation, suspended) { | |
var instance = new Coroutine$head_0(T_0, isT, $receiver_1, scheme, host, port, path, body, block, continuation); | |
if (suspended) | |
return instance; | |
else | |
return instance.doResume(null); | |
} | |
defineInlineFunction('ktor-client-core.io.ktor.client.request.head_xwttm9$', wrapFunction(function() { | |
var utils = _.io.ktor.client.utils; | |
var Unit = Kotlin.kotlin.Unit; | |
var url = _.io.ktor.client.request.url_3rzbk2$; | |
var HttpMethod = _.$$importsForInline$$['ktor-http'].io.ktor.http.HttpMethod; | |
function head$lambda($receiver) { | |
return Unit; | |
} | |
var HttpRequestBuilder_init = _.io.ktor.client.request.HttpRequestBuilder; | |
var call = _.io.ktor.client.call.call_30bfl5$; | |
var throwCCE = Kotlin.throwCCE; | |
var getKClass = Kotlin.getKClass; | |
var call_0 = _.io.ktor.client.call; | |
var TypeInfo_init = _.io.ktor.client.call.TypeInfo; | |
return function(T_0, isT, $receiver_1, scheme, host, port, path, body, block, continuation) { | |
if (scheme === void 0) | |
scheme = 'http'; | |
if (host === void 0) | |
host = 'localhost'; | |
if (port === void 0) | |
port = 0; | |
if (path === void 0) | |
path = '/'; | |
if (body === void 0) | |
body = utils.EmptyContent; | |
if (block === void 0) | |
block = head$lambda; | |
var $receiver_2 = new HttpRequestBuilder_init(); | |
url($receiver_2, scheme, host, port, path); | |
$receiver_2.method = HttpMethod.Companion.Head; | |
$receiver_2.body = body; | |
block($receiver_2); | |
Kotlin.suspendCall(call($receiver_1, $receiver_2, Kotlin.coroutineReceiver())); | |
var tmp$_0; | |
Kotlin.suspendCall(Kotlin.coroutineResult(Kotlin.coroutineReceiver()).receive_jo9acv$(new TypeInfo_init(getKClass(T_0), call_0.JsType), Kotlin.coroutineReceiver())); | |
Kotlin.setCoroutineResult(isT(tmp$_0 = Kotlin.coroutineResult(Kotlin.coroutineReceiver())) ? tmp$_0 : throwCCE(), Kotlin.coroutineReceiver()); | |
return Kotlin.coroutineResult(Kotlin.coroutineReceiver()); | |
}; | |
})); | |
function options$lambda($receiver) { | |
return Unit; | |
} | |
function Coroutine$options_0(T_0, isT, $receiver_1, scheme, host, port, path, body, block, continuation) { | |
CoroutineImpl.call(this, continuation); | |
this.exceptionState_0 = 1; | |
this.local$T_0 = T_0; | |
this.local$isT = isT; | |
this.local$$receiver = $receiver_1; | |
this.local$scheme = scheme; | |
this.local$host = host; | |
this.local$port = port; | |
this.local$path = path; | |
this.local$body = body; | |
this.local$block = block; | |
} | |
Coroutine$options_0.$metadata$ = { | |
kind: Kotlin.Kind.CLASS, | |
simpleName: null, | |
interfaces: [CoroutineImpl]}; | |
Coroutine$options_0.prototype = Object.create(CoroutineImpl.prototype); | |
Coroutine$options_0.prototype.constructor = Coroutine$options_0; | |
Coroutine$options_0.prototype.doResume = function() { | |
do try { | |
switch (this.state_0) { | |
case 0: | |
if (this.local$scheme === void 0) | |
this.local$scheme = 'http'; | |
if (this.local$host === void 0) | |
this.local$host = 'localhost'; | |
if (this.local$port === void 0) | |
this.local$port = 0; | |
if (this.local$path === void 0) | |
this.local$path = '/'; | |
if (this.local$body === void 0) | |
this.local$body = package$utils.EmptyContent; | |
if (this.local$block === void 0) | |
this.local$block = options$lambda; | |
var $receiver_2 = new HttpRequestBuilder(); | |
url_0($receiver_2, this.local$scheme, this.local$host, this.local$port, this.local$path); | |
$receiver_2.method = HttpMethod.Companion.Options; | |
$receiver_2.body = this.local$body; | |
this.local$block($receiver_2); | |
this.state_0 = 2; | |
this.result_0 = call_0(this.local$$receiver, $receiver_2, this); | |
if (this.result_0 === COROUTINE_SUSPENDED) | |
return COROUTINE_SUSPENDED; | |
continue; | |
case 1: | |
throw this.exception_0; | |
case 2: | |
var tmp$_0; | |
this.state_0 = 3; | |
this.result_0 = this.result_0.receive_jo9acv$(new TypeInfo(getKClass(this.local$T_0), package$call.JsType), this); | |
if (this.result_0 === COROUTINE_SUSPENDED) | |
return COROUTINE_SUSPENDED; | |
continue; | |
case 3: | |
this.result_0 = this.local$isT(tmp$_0 = this.result_0) ? tmp$_0 : throwCCE(); | |
return this.result_0; | |
default: | |
this.state_0 = 1; | |
throw new Error('State Machine Unreachable execution'); | |
} | |
} catch (e) { | |
if (this.state_0 === 1) { | |
this.exceptionState_0 = this.state_0; | |
throw e; | |
} else { | |
this.state_0 = this.exceptionState_0; | |
this.exception_0 = e; | |
} | |
} while (true); | |
}; | |
function options_0(T_0, isT, $receiver_1, scheme, host, port, path, body, block, continuation, suspended) { | |
var instance = new Coroutine$options_0(T_0, isT, $receiver_1, scheme, host, port, path, body, block, continuation); | |
if (suspended) | |
return instance; | |
else | |
return instance.doResume(null); | |
} | |
defineInlineFunction('ktor-client-core.io.ktor.client.request.options_xwttm9$', wrapFunction(function() { | |
var utils = _.io.ktor.client.utils; | |
var Unit = Kotlin.kotlin.Unit; | |
var url = _.io.ktor.client.request.url_3rzbk2$; | |
var HttpMethod = _.$$importsForInline$$['ktor-http'].io.ktor.http.HttpMethod; | |
function options$lambda($receiver) { | |
return Unit; | |
} | |
var HttpRequestBuilder_init = _.io.ktor.client.request.HttpRequestBuilder; | |
var call = _.io.ktor.client.call.call_30bfl5$; | |
var throwCCE = Kotlin.throwCCE; | |
var getKClass = Kotlin.getKClass; | |
var call_0 = _.io.ktor.client.call; | |
var TypeInfo_init = _.io.ktor.client.call.TypeInfo; | |
return function(T_0, isT, $receiver_1, scheme, host, port, path, body, block, continuation) { | |
if (scheme === void 0) | |
scheme = 'http'; | |
if (host === void 0) | |
host = 'localhost'; | |
if (port === void 0) | |
port = 0; | |
if (path === void 0) | |
path = '/'; | |
if (body === void 0) | |
body = utils.EmptyContent; | |
if (block === void 0) | |
block = options$lambda; | |
var $receiver_2 = new HttpRequestBuilder_init(); | |
url($receiver_2, scheme, host, port, path); | |
$receiver_2.method = HttpMethod.Companion.Options; | |
$receiver_2.body = body; | |
block($receiver_2); | |
Kotlin.suspendCall(call($receiver_1, $receiver_2, Kotlin.coroutineReceiver())); | |
var tmp$_0; | |
Kotlin.suspendCall(Kotlin.coroutineResult(Kotlin.coroutineReceiver()).receive_jo9acv$(new TypeInfo_init(getKClass(T_0), call_0.JsType), Kotlin.coroutineReceiver())); | |
Kotlin.setCoroutineResult(isT(tmp$_0 = Kotlin.coroutineResult(Kotlin.coroutineReceiver())) ? tmp$_0 : throwCCE(), Kotlin.coroutineReceiver()); | |
return Kotlin.coroutineResult(Kotlin.coroutineReceiver()); | |
}; | |
})); | |
function request_3(block) { | |
var $receiver = new HttpRequestBuilder(); | |
block($receiver); | |
return $receiver; | |
} | |
function get$lambda_0($receiver) { | |
return Unit; | |
} | |
function Coroutine$get_1(T_0, isT, $receiver_1, urlString, block, continuation) { | |
CoroutineImpl.call(this, continuation); | |
this.exceptionState_0 = 1; | |
this.local$T_0 = T_0; | |
this.local$isT = isT; | |
this.local$$receiver = $receiver_1; | |
this.local$urlString = urlString; | |
this.local$block = block; | |
} | |
Coroutine$get_1.$metadata$ = { | |
kind: Kotlin.Kind.CLASS, | |
simpleName: null, | |
interfaces: [CoroutineImpl]}; | |
Coroutine$get_1.prototype = Object.create(CoroutineImpl.prototype); | |
Coroutine$get_1.prototype.constructor = Coroutine$get_1; | |
Coroutine$get_1.prototype.doResume = function() { | |
do try { | |
switch (this.state_0) { | |
case 0: | |
if (this.local$block === void 0) | |
this.local$block = get$lambda_0; | |
var host_0; | |
var body_0; | |
host_0 = 'localhost'; | |
body_0 = package$utils.EmptyContent; | |
var $receiver_2 = new HttpRequestBuilder(); | |
url_0($receiver_2, 'http', host_0, 0, '/'); | |
$receiver_2.method = HttpMethod.Companion.Get; | |
$receiver_2.body = body_0; | |
takeFrom($receiver_2.url, this.local$urlString); | |
this.local$block($receiver_2); | |
this.state_0 = 2; | |
this.result_0 = call_0(this.local$$receiver, $receiver_2, this); | |
if (this.result_0 === COROUTINE_SUSPENDED) | |
return COROUTINE_SUSPENDED; | |
continue; | |
case 1: | |
throw this.exception_0; | |
case 2: | |
var tmp$_0; | |
this.state_0 = 3; | |
this.result_0 = this.result_0.receive_jo9acv$(new TypeInfo(getKClass(this.local$T_0), package$call.JsType), this); | |
if (this.result_0 === COROUTINE_SUSPENDED) | |
return COROUTINE_SUSPENDED; | |
continue; | |
case 3: | |
this.result_0 = this.local$isT(tmp$_0 = this.result_0) ? tmp$_0 : throwCCE(); | |
return this.result_0; | |
default: | |
this.state_0 = 1; | |
throw new Error('State Machine Unreachable execution'); | |
} | |
} catch (e) { | |
if (this.state_0 === 1) { | |
this.exceptionState_0 = this.state_0; | |
throw e; | |
} else { | |
this.state_0 = this.exceptionState_0; | |
this.exception_0 = e; | |
} | |
} while (true); | |
}; | |
function get_3(T_0, isT, $receiver_1, urlString, block, continuation, suspended) { | |
var instance = new Coroutine$get_1(T_0, isT, $receiver_1, urlString, block, continuation); | |
if (suspended) | |
return instance; | |
else | |
return instance.doResume(null); | |
} | |
defineInlineFunction('ktor-client-core.io.ktor.client.request.get_hf8dw$', wrapFunction(function() { | |
var Unit = Kotlin.kotlin.Unit; | |
var takeFrom = _.$$importsForInline$$['ktor-http'].io.ktor.http.takeFrom_jl1sg7$; | |
function get$lambda($receiver) { | |
return Unit; | |
} | |
var utils = _.io.ktor.client.utils; | |
var url = _.io.ktor.client.request.url_3rzbk2$; | |
var HttpMethod = _.$$importsForInline$$['ktor-http'].io.ktor.http.HttpMethod; | |
var HttpRequestBuilder_init = _.io.ktor.client.request.HttpRequestBuilder; | |
var call = _.io.ktor.client.call.call_30bfl5$; | |
var throwCCE = Kotlin.throwCCE; | |
var getKClass = Kotlin.getKClass; | |
var call_0 = _.io.ktor.client.call; | |
var TypeInfo_init = _.io.ktor.client.call.TypeInfo; | |
return function(T_0, isT, $receiver_1, urlString, block, continuation) { | |
if (block === void 0) | |
block = get$lambda; | |
var host_0; | |
var body_0; | |
host_0 = 'localhost'; | |
body_0 = utils.EmptyContent; | |
var $receiver_2 = new HttpRequestBuilder_init(); | |
url($receiver_2, 'http', host_0, 0, '/'); | |
$receiver_2.method = HttpMethod.Companion.Get; | |
$receiver_2.body = body_0; | |
takeFrom($receiver_2.url, urlString); | |
block($receiver_2); | |
Kotlin.suspendCall(call($receiver_1, $receiver_2, Kotlin.coroutineReceiver())); | |
var tmp$_0; | |
Kotlin.suspendCall(Kotlin.coroutineResult(Kotlin.coroutineReceiver()).receive_jo9acv$(new TypeInfo_init(getKClass(T_0), call_0.JsType), Kotlin.coroutineReceiver())); | |
Kotlin.setCoroutineResult(isT(tmp$_0 = Kotlin.coroutineResult(Kotlin.coroutineReceiver())) ? tmp$_0 : throwCCE(), Kotlin.coroutineReceiver()); | |
return Kotlin.coroutineResult(Kotlin.coroutineReceiver()); | |
}; | |
})); | |
function post$lambda_0($receiver) { | |
return Unit; | |
} | |
function Coroutine$post_1(T_0, isT, $receiver_1, urlString, block, continuation) { | |
CoroutineImpl.call(this, continuation); | |
this.exceptionState_0 = 1; | |
this.local$T_0 = T_0; | |
this.local$isT = isT; | |
this.local$$receiver = $receiver_1; | |
this.local$urlString = urlString; | |
this.local$block = block; | |
} | |
Coroutine$post_1.$metadata$ = { | |
kind: Kotlin.Kind.CLASS, | |
simpleName: null, | |
interfaces: [CoroutineImpl]}; | |
Coroutine$post_1.prototype = Object.create(CoroutineImpl.prototype); | |
Coroutine$post_1.prototype.constructor = Coroutine$post_1; | |
Coroutine$post_1.prototype.doResume = function() { | |
do try { | |
switch (this.state_0) { | |
case 0: | |
if (this.local$block === void 0) | |
this.local$block = post$lambda_0; | |
var host_0; | |
var body_0; | |
host_0 = 'localhost'; | |
body_0 = package$utils.EmptyContent; | |
var $receiver_2 = new HttpRequestBuilder(); | |
url_0($receiver_2, 'http', host_0, 0, '/'); | |
$receiver_2.method = HttpMethod.Companion.Post; | |
$receiver_2.body = body_0; | |
takeFrom($receiver_2.url, this.local$urlString); | |
this.local$block($receiver_2); | |
this.state_0 = 2; | |
this.result_0 = call_0(this.local$$receiver, $receiver_2, this); | |
if (this.result_0 === COROUTINE_SUSPENDED) | |
return COROUTINE_SUSPENDED; | |
continue; | |
case 1: | |
throw this.exception_0; | |
case 2: | |
var tmp$_0; | |
this.state_0 = 3; | |
this.result_0 = this.result_0.receive_jo9acv$(new TypeInfo(getKClass(this.local$T_0), package$call.JsType), this); | |
if (this.result_0 === COROUTINE_SUSPENDED) | |
return COROUTINE_SUSPENDED; | |
continue; | |
case 3: | |
this.result_0 = this.local$isT(tmp$_0 = this.result_0) ? tmp$_0 : throwCCE(); | |
return this.result_0; | |
default: | |
this.state_0 = 1; | |
throw new Error('State Machine Unreachable execution'); | |
} | |
} catch (e) { | |
if (this.state_0 === 1) { | |
this.exceptionState_0 = this.state_0; | |
throw e; | |
} else { | |
this.state_0 = this.exceptionState_0; | |
this.exception_0 = e; | |
} | |
} while (true); | |
}; | |
function post_1(T_0, isT, $receiver_1, urlString, block, continuation, suspended) { | |
var instance = new Coroutine$post_1(T_0, isT, $receiver_1, urlString, block, continuation); | |
if (suspended) | |
return instance; | |
else | |
return instance.doResume(null); | |
} | |
defineInlineFunction('ktor-client-core.io.ktor.client.request.post_hf8dw$', wrapFunction(function() { | |
var Unit = Kotlin.kotlin.Unit; | |
var takeFrom = _.$$importsForInline$$['ktor-http'].io.ktor.http.takeFrom_jl1sg7$; | |
function post$lambda($receiver) { | |
return Unit; | |
} | |
var utils = _.io.ktor.client.utils; | |
var url = _.io.ktor.client.request.url_3rzbk2$; | |
var HttpMethod = _.$$importsForInline$$['ktor-http'].io.ktor.http.HttpMethod; | |
var HttpRequestBuilder_init = _.io.ktor.client.request.HttpRequestBuilder; | |
var call = _.io.ktor.client.call.call_30bfl5$; | |
var throwCCE = Kotlin.throwCCE; | |
var getKClass = Kotlin.getKClass; | |
var call_0 = _.io.ktor.client.call; | |
var TypeInfo_init = _.io.ktor.client.call.TypeInfo; | |
return function(T_0, isT, $receiver_1, urlString, block, continuation) { | |
if (block === void 0) | |
block = post$lambda; | |
var host_0; | |
var body_0; | |
host_0 = 'localhost'; | |
body_0 = utils.EmptyContent; | |
var $receiver_2 = new HttpRequestBuilder_init(); | |
url($receiver_2, 'http', host_0, 0, '/'); | |
$receiver_2.method = HttpMethod.Companion.Post; | |
$receiver_2.body = body_0; | |
takeFrom($receiver_2.url, urlString); | |
block($receiver_2); | |
Kotlin.suspendCall(call($receiver_1, $receiver_2, Kotlin.coroutineReceiver())); | |
var tmp$_0; | |
Kotlin.suspendCall(Kotlin.coroutineResult(Kotlin.coroutineReceiver()).receive_jo9acv$(new TypeInfo_init(getKClass(T_0), call_0.JsType), Kotlin.coroutineReceiver())); | |
Kotlin.setCoroutineResult(isT(tmp$_0 = Kotlin.coroutineResult(Kotlin.coroutineReceiver())) ? tmp$_0 : throwCCE(), Kotlin.coroutineReceiver()); | |
return Kotlin.coroutineResult(Kotlin.coroutineReceiver()); | |
}; | |
})); | |
function put$lambda_0($receiver) { | |
return Unit; | |
} | |
function Coroutine$put_1(T_0, isT, $receiver_1, urlString, block, continuation) { | |
CoroutineImpl.call(this, continuation); | |
this.exceptionState_0 = 1; | |
this.local$T_0 = T_0; | |
this.local$isT = isT; | |
this.local$$receiver = $receiver_1; | |
this.local$urlString = urlString; | |
this.local$block = block; | |
} | |
Coroutine$put_1.$metadata$ = { | |
kind: Kotlin.Kind.CLASS, | |
simpleName: null, | |
interfaces: [CoroutineImpl]}; | |
Coroutine$put_1.prototype = Object.create(CoroutineImpl.prototype); | |
Coroutine$put_1.prototype.constructor = Coroutine$put_1; | |
Coroutine$put_1.prototype.doResume = function() { | |
do try { | |
switch (this.state_0) { | |
case 0: | |
if (this.local$block === void 0) | |
this.local$block = put$lambda_0; | |
var host_0; | |
var body_0; | |
host_0 = 'localhost'; | |
body_0 = package$utils.EmptyContent; | |
var $receiver_2 = new HttpRequestBuilder(); | |
url_0($receiver_2, 'http', host_0, 0, '/'); | |
$receiver_2.method = HttpMethod.Companion.Put; | |
$receiver_2.body = body_0; | |
takeFrom($receiver_2.url, this.local$urlString); | |
this.local$block($receiver_2); | |
this.state_0 = 2; | |
this.result_0 = call_0(this.local$$receiver, $receiver_2, this); | |
if (this.result_0 === COROUTINE_SUSPENDED) | |
return COROUTINE_SUSPENDED; | |
continue; | |
case 1: | |
throw this.exception_0; | |
case 2: | |
var tmp$_0; | |
this.state_0 = 3; | |
this.result_0 = this.result_0.receive_jo9acv$(new TypeInfo(getKClass(this.local$T_0), package$call.JsType), this); | |
if (this.result_0 === COROUTINE_SUSPENDED) | |
return COROUTINE_SUSPENDED; | |
continue; | |
case 3: | |
this.result_0 = this.local$isT(tmp$_0 = this.result_0) ? tmp$_0 : throwCCE(); | |
return this.result_0; | |
default: | |
this.state_0 = 1; | |
throw new Error('State Machine Unreachable execution'); | |
} | |
} catch (e) { | |
if (this.state_0 === 1) { | |
this.exceptionState_0 = this.state_0; | |
throw e; | |
} else { | |
this.state_0 = this.exceptionState_0; | |
this.exception_0 = e; | |
} | |
} while (true); | |
}; | |
function put_1(T_0, isT, $receiver_1, urlString, block, continuation, suspended) { | |
var instance = new Coroutine$put_1(T_0, isT, $receiver_1, urlString, block, continuation); | |
if (suspended) | |
return instance; | |
else | |
return instance.doResume(null); | |
} | |
defineInlineFunction('ktor-client-core.io.ktor.client.request.put_hf8dw$', wrapFunction(function() { | |
var Unit = Kotlin.kotlin.Unit; | |
var takeFrom = _.$$importsForInline$$['ktor-http'].io.ktor.http.takeFrom_jl1sg7$; | |
function put$lambda($receiver) { | |
return Unit; | |
} | |
var utils = _.io.ktor.client.utils; | |
var url = _.io.ktor.client.request.url_3rzbk2$; | |
var HttpMethod = _.$$importsForInline$$['ktor-http'].io.ktor.http.HttpMethod; | |
var HttpRequestBuilder_init = _.io.ktor.client.request.HttpRequestBuilder; | |
var call = _.io.ktor.client.call.call_30bfl5$; | |
var throwCCE = Kotlin.throwCCE; | |
var getKClass = Kotlin.getKClass; | |
var call_0 = _.io.ktor.client.call; | |
var TypeInfo_init = _.io.ktor.client.call.TypeInfo; | |
return function(T_0, isT, $receiver_1, urlString, block, continuation) { | |
if (block === void 0) | |
block = put$lambda; | |
var host_0; | |
var body_0; | |
host_0 = 'localhost'; | |
body_0 = utils.EmptyContent; | |
var $receiver_2 = new HttpRequestBuilder_init(); | |
url($receiver_2, 'http', host_0, 0, '/'); | |
$receiver_2.method = HttpMethod.Companion.Put; | |
$receiver_2.body = body_0; | |
takeFrom($receiver_2.url, urlString); | |
block($receiver_2); | |
Kotlin.suspendCall(call($receiver_1, $receiver_2, Kotlin.coroutineReceiver())); | |
var tmp$_0; | |
Kotlin.suspendCall(Kotlin.coroutineResult(Kotlin.coroutineReceiver()).receive_jo9acv$(new TypeInfo_init(getKClass(T_0), call_0.JsType), Kotlin.coroutineReceiver())); | |
Kotlin.setCoroutineResult(isT(tmp$_0 = Kotlin.coroutineResult(Kotlin.coroutineReceiver())) ? tmp$_0 : throwCCE(), Kotlin.coroutineReceiver()); | |
return Kotlin.coroutineResult(Kotlin.coroutineReceiver()); | |
}; | |
})); | |
function delete$lambda_0($receiver) { | |
return Unit; | |
} | |
function Coroutine$delete_1(T_0, isT, $receiver_1, urlString, block, continuation) { | |
CoroutineImpl.call(this, continuation); | |
this.exceptionState_0 = 1; | |
this.local$T_0 = T_0; | |
this.local$isT = isT; | |
this.local$$receiver = $receiver_1; | |
this.local$urlString = urlString; | |
this.local$block = block; | |
} | |
Coroutine$delete_1.$metadata$ = { | |
kind: Kotlin.Kind.CLASS, | |
simpleName: null, | |
interfaces: [CoroutineImpl]}; | |
Coroutine$delete_1.prototype = Object.create(CoroutineImpl.prototype); | |
Coroutine$delete_1.prototype.constructor = Coroutine$delete_1; | |
Coroutine$delete_1.prototype.doResume = function() { | |
do try { | |
switch (this.state_0) { | |
case 0: | |
if (this.local$block === void 0) | |
this.local$block = delete$lambda_0; | |
var host_0; | |
var body_0; | |
host_0 = 'localhost'; | |
body_0 = package$utils.EmptyContent; | |
var $receiver_2 = new HttpRequestBuilder(); | |
url_0($receiver_2, 'http', host_0, 0, '/'); | |
$receiver_2.method = HttpMethod.Companion.Delete; | |
$receiver_2.body = body_0; | |
takeFrom($receiver_2.url, this.local$urlString); | |
this.local$block($receiver_2); | |
this.state_0 = 2; | |
this.result_0 = call_0(this.local$$receiver, $receiver_2, this); | |
if (this.result_0 === COROUTINE_SUSPENDED) | |
return COROUTINE_SUSPENDED; | |
continue; | |
case 1: | |
throw this.exception_0; | |
case 2: | |
var tmp$_0; | |
this.state_0 = 3; | |
this.result_0 = this.result_0.receive_jo9acv$(new TypeInfo(getKClass(this.local$T_0), package$call.JsType), this); | |
if (this.result_0 === COROUTINE_SUSPENDED) | |
return COROUTINE_SUSPENDED; | |
continue; | |
case 3: | |
this.result_0 = this.local$isT(tmp$_0 = this.result_0) ? tmp$_0 : throwCCE(); | |
return this.result_0; | |
default: | |
this.state_0 = 1; | |
throw new Error('State Machine Unreachable execution'); | |
} | |
} catch (e) { | |
if (this.state_0 === 1) { | |
this.exceptionState_0 = this.state_0; | |
throw e; | |
} else { | |
this.state_0 = this.exceptionState_0; | |
this.exception_0 = e; | |
} | |
} while (true); | |
}; | |
function delete_2(T_0, isT, $receiver_1, urlString, block, continuation, suspended) { | |
var instance = new Coroutine$delete_1(T_0, isT, $receiver_1, urlString, block, continuation); | |
if (suspended) | |
return instance; | |
else | |
return instance.doResume(null); | |
} | |
defineInlineFunction('ktor-client-core.io.ktor.client.request.delete_hf8dw$', wrapFunction(function() { | |
var Unit = Kotlin.kotlin.Unit; | |
var takeFrom = _.$$importsForInline$$['ktor-http'].io.ktor.http.takeFrom_jl1sg7$; | |
function delete$lambda($receiver) { | |
return Unit; | |
} | |
var utils = _.io.ktor.client.utils; | |
var url = _.io.ktor.client.request.url_3rzbk2$; | |
var HttpMethod = _.$$importsForInline$$['ktor-http'].io.ktor.http.HttpMethod; | |
var HttpRequestBuilder_init = _.io.ktor.client.request.HttpRequestBuilder; | |
var call = _.io.ktor.client.call.call_30bfl5$; | |
var throwCCE = Kotlin.throwCCE; | |
var getKClass = Kotlin.getKClass; | |
var call_0 = _.io.ktor.client.call; | |
var TypeInfo_init = _.io.ktor.client.call.TypeInfo; | |
return function(T_0, isT, $receiver_1, urlString, block, continuation) { | |
if (block === void 0) | |
block = delete$lambda; | |
var host_0; | |
var body_0; | |
host_0 = 'localhost'; | |
body_0 = utils.EmptyContent; | |
var $receiver_2 = new HttpRequestBuilder_init(); | |
url($receiver_2, 'http', host_0, 0, '/'); | |
$receiver_2.method = HttpMethod.Companion.Delete; | |
$receiver_2.body = body_0; | |
takeFrom($receiver_2.url, urlString); | |
block($receiver_2); | |
Kotlin.suspendCall(call($receiver_1, $receiver_2, Kotlin.coroutineReceiver())); | |
var tmp$_0; | |
Kotlin.suspendCall(Kotlin.coroutineResult(Kotlin.coroutineReceiver()).receive_jo9acv$(new TypeInfo_init(getKClass(T_0), call_0.JsType), Kotlin.coroutineReceiver())); | |
Kotlin.setCoroutineResult(isT(tmp$_0 = Kotlin.coroutineResult(Kotlin.coroutineReceiver())) ? tmp$_0 : throwCCE(), Kotlin.coroutineReceiver()); | |
return Kotlin.coroutineResult(Kotlin.coroutineReceiver()); | |
}; | |
})); | |
function options$lambda_0($receiver) { | |
return Unit; | |
} | |
function Coroutine$options_1(T_0, isT, $receiver_1, urlString, block, continuation) { | |
CoroutineImpl.call(this, continuation); | |
this.exceptionState_0 = 1; | |
this.local$T_0 = T_0; | |
this.local$isT = isT; | |
this.local$$receiver = $receiver_1; | |
this.local$urlString = urlString; | |
this.local$block = block; | |
} | |
Coroutine$options_1.$metadata$ = { | |
kind: Kotlin.Kind.CLASS, | |
simpleName: null, | |
interfaces: [CoroutineImpl]}; | |
Coroutine$options_1.prototype = Object.create(CoroutineImpl.prototype); | |
Coroutine$options_1.prototype.constructor = Coroutine$options_1; | |
Coroutine$options_1.prototype.doResume = function() { | |
do try { | |
switch (this.state_0) { | |
case 0: | |
if (this.local$block === void 0) | |
this.local$block = options$lambda_0; | |
var host_0; | |
var body_0; | |
host_0 = 'localhost'; | |
body_0 = package$utils.EmptyContent; | |
var $receiver_2 = new HttpRequestBuilder(); | |
url_0($receiver_2, 'http', host_0, 0, '/'); | |
$receiver_2.method = HttpMethod.Companion.Options; | |
$receiver_2.body = body_0; | |
takeFrom($receiver_2.url, this.local$urlString); | |
this.local$block($receiver_2); | |
this.state_0 = 2; | |
this.result_0 = call_0(this.local$$receiver, $receiver_2, this); | |
if (this.result_0 === COROUTINE_SUSPENDED) | |
return COROUTINE_SUSPENDED; | |
continue; | |
case 1: | |
throw this.exception_0; | |
case 2: | |
var tmp$_0; | |
this.state_0 = 3; | |
this.result_0 = this.result_0.receive_jo9acv$(new TypeInfo(getKClass(this.local$T_0), package$call.JsType), this); | |
if (this.result_0 === COROUTINE_SUSPENDED) | |
return COROUTINE_SUSPENDED; | |
continue; | |
case 3: | |
this.result_0 = this.local$isT(tmp$_0 = this.result_0) ? tmp$_0 : throwCCE(); | |
return this.result_0; | |
default: | |
this.state_0 = 1; | |
throw new Error('State Machine Unreachable execution'); | |
} | |
} catch (e) { | |
if (this.state_0 === 1) { | |
this.exceptionState_0 = this.state_0; | |
throw e; | |
} else { | |
this.state_0 = this.exceptionState_0; | |
this.exception_0 = e; | |
} | |
} while (true); | |
}; | |
function options_1(T_0, isT, $receiver_1, urlString, block, continuation, suspended) { | |
var instance = new Coroutine$options_1(T_0, isT, $receiver_1, urlString, block, continuation); | |
if (suspended) | |
return instance; | |
else | |
return instance.doResume(null); | |
} | |
defineInlineFunction('ktor-client-core.io.ktor.client.request.options_hf8dw$', wrapFunction(function() { | |
var Unit = Kotlin.kotlin.Unit; | |
var takeFrom = _.$$importsForInline$$['ktor-http'].io.ktor.http.takeFrom_jl1sg7$; | |
function options$lambda($receiver) { | |
return Unit; | |
} | |
var utils = _.io.ktor.client.utils; | |
var url = _.io.ktor.client.request.url_3rzbk2$; | |
var HttpMethod = _.$$importsForInline$$['ktor-http'].io.ktor.http.HttpMethod; | |
var HttpRequestBuilder_init = _.io.ktor.client.request.HttpRequestBuilder; | |
var call = _.io.ktor.client.call.call_30bfl5$; | |
var throwCCE = Kotlin.throwCCE; | |
var getKClass = Kotlin.getKClass; | |
var call_0 = _.io.ktor.client.call; | |
var TypeInfo_init = _.io.ktor.client.call.TypeInfo; | |
return function(T_0, isT, $receiver_1, urlString, block, continuation) { | |
if (block === void 0) | |
block = options$lambda; | |
var host_0; | |
var body_0; | |
host_0 = 'localhost'; | |
body_0 = utils.EmptyContent; | |
var $receiver_2 = new HttpRequestBuilder_init(); | |
url($receiver_2, 'http', host_0, 0, '/'); | |
$receiver_2.method = HttpMethod.Companion.Options; | |
$receiver_2.body = body_0; | |
takeFrom($receiver_2.url, urlString); | |
block($receiver_2); | |
Kotlin.suspendCall(call($receiver_1, $receiver_2, Kotlin.coroutineReceiver())); | |
var tmp$_0; | |
Kotlin.suspendCall(Kotlin.coroutineResult(Kotlin.coroutineReceiver()).receive_jo9acv$(new TypeInfo_init(getKClass(T_0), call_0.JsType), Kotlin.coroutineReceiver())); | |
Kotlin.setCoroutineResult(isT(tmp$_0 = Kotlin.coroutineResult(Kotlin.coroutineReceiver())) ? tmp$_0 : throwCCE(), Kotlin.coroutineReceiver()); | |
return Kotlin.coroutineResult(Kotlin.coroutineReceiver()); | |
}; | |
})); | |
function patch$lambda_0($receiver) { | |
return Unit; | |
} | |
function Coroutine$patch_1(T_0, isT, $receiver_1, urlString, block, continuation) { | |
CoroutineImpl.call(this, continuation); | |
this.exceptionState_0 = 1; | |
this.local$T_0 = T_0; | |
this.local$isT = isT; | |
this.local$$receiver = $receiver_1; | |
this.local$urlString = urlString; | |
this.local$block = block; | |
} | |
Coroutine$patch_1.$metadata$ = { | |
kind: Kotlin.Kind.CLASS, | |
simpleName: null, | |
interfaces: [CoroutineImpl]}; | |
Coroutine$patch_1.prototype = Object.create(CoroutineImpl.prototype); | |
Coroutine$patch_1.prototype.constructor = Coroutine$patch_1; | |
Coroutine$patch_1.prototype.doResume = function() { | |
do try { | |
switch (this.state_0) { | |
case 0: | |
if (this.local$block === void 0) | |
this.local$block = patch$lambda_0; | |
var host_0; | |
var body_0; | |
host_0 = 'localhost'; | |
body_0 = package$utils.EmptyContent; | |
var $receiver_2 = new HttpRequestBuilder(); | |
url_0($receiver_2, 'http', host_0, 0, '/'); | |
$receiver_2.method = HttpMethod.Companion.Patch; | |
$receiver_2.body = body_0; | |
takeFrom($receiver_2.url, this.local$urlString); | |
this.local$block($receiver_2); | |
this.state_0 = 2; | |
this.result_0 = call_0(this.local$$receiver, $receiver_2, this); | |
if (this.result_0 === COROUTINE_SUSPENDED) | |
return COROUTINE_SUSPENDED; | |
continue; | |
case 1: | |
throw this.exception_0; | |
case 2: | |
var tmp$_0; | |
this.state_0 = 3; | |
this.result_0 = this.result_0.receive_jo9acv$(new TypeInfo(getKClass(this.local$T_0), package$call.JsType), this); | |
if (this.result_0 === COROUTINE_SUSPENDED) | |
return COROUTINE_SUSPENDED; | |
continue; | |
case 3: | |
this.result_0 = this.local$isT(tmp$_0 = this.result_0) ? tmp$_0 : throwCCE(); | |
return this.result_0; | |
default: | |
this.state_0 = 1; | |
throw new Error('State Machine Unreachable execution'); | |
} | |
} catch (e) { | |
if (this.state_0 === 1) { | |
this.exceptionState_0 = this.state_0; | |
throw e; | |
} else { | |
this.state_0 = this.exceptionState_0; | |
this.exception_0 = e; | |
} | |
} while (true); | |
}; | |
function patch_1(T_0, isT, $receiver_1, urlString, block, continuation, suspended) { | |
var instance = new Coroutine$patch_1(T_0, isT, $receiver_1, urlString, block, continuation); | |
if (suspended) | |
return instance; | |
else | |
return instance.doResume(null); | |
} | |
defineInlineFunction('ktor-client-core.io.ktor.client.request.patch_hf8dw$', wrapFunction(function() { | |
var Unit = Kotlin.kotlin.Unit; | |
var takeFrom = _.$$importsForInline$$['ktor-http'].io.ktor.http.takeFrom_jl1sg7$; | |
function patch$lambda($receiver) { | |
return Unit; | |
} | |
var utils = _.io.ktor.client.utils; | |
var url = _.io.ktor.client.request.url_3rzbk2$; | |
var HttpMethod = _.$$importsForInline$$['ktor-http'].io.ktor.http.HttpMethod; | |
var HttpRequestBuilder_init = _.io.ktor.client.request.HttpRequestBuilder; | |
var call = _.io.ktor.client.call.call_30bfl5$; | |
var throwCCE = Kotlin.throwCCE; | |
var getKClass = Kotlin.getKClass; | |
var call_0 = _.io.ktor.client.call; | |
var TypeInfo_init = _.io.ktor.client.call.TypeInfo; | |
return function(T_0, isT, $receiver_1, urlString, block, continuation) { | |
if (block === void 0) | |
block = patch$lambda; | |
var host_0; | |
var body_0; | |
host_0 = 'localhost'; | |
body_0 = utils.EmptyContent; | |
var $receiver_2 = new HttpRequestBuilder_init(); | |
url($receiver_2, 'http', host_0, 0, '/'); | |
$receiver_2.method = HttpMethod.Companion.Patch; | |
$receiver_2.body = body_0; | |
takeFrom($receiver_2.url, urlString); | |
block($receiver_2); | |
Kotlin.suspendCall(call($receiver_1, $receiver_2, Kotlin.coroutineReceiver())); | |
var tmp$_0; | |
Kotlin.suspendCall(Kotlin.coroutineResult(Kotlin.coroutineReceiver()).receive_jo9acv$(new TypeInfo_init(getKClass(T_0), call_0.JsType), Kotlin.coroutineReceiver())); | |
Kotlin.setCoroutineResult(isT(tmp$_0 = Kotlin.coroutineResult(Kotlin.coroutineReceiver())) ? tmp$_0 : throwCCE(), Kotlin.coroutineReceiver()); | |
return Kotlin.coroutineResult(Kotlin.coroutineReceiver()); | |
}; | |
})); | |
function head$lambda_0($receiver) { | |
return Unit; | |
} | |
function Coroutine$head_1(T_0, isT, $receiver_1, urlString, block, continuation) { | |
CoroutineImpl.call(this, continuation); | |
this.exceptionState_0 = 1; | |
this.local$T_0 = T_0; | |
this.local$isT = isT; | |
this.local$$receiver = $receiver_1; | |
this.local$urlString = urlString; | |
this.local$block = block; | |
} | |
Coroutine$head_1.$metadata$ = { | |
kind: Kotlin.Kind.CLASS, | |
simpleName: null, | |
interfaces: [CoroutineImpl]}; | |
Coroutine$head_1.prototype = Object.create(CoroutineImpl.prototype); | |
Coroutine$head_1.prototype.constructor = Coroutine$head_1; | |
Coroutine$head_1.prototype.doResume = function() { | |
do try { | |
switch (this.state_0) { | |
case 0: | |
if (this.local$block === void 0) | |
this.local$block = head$lambda_0; | |
var host_0; | |
var body_0; | |
host_0 = 'localhost'; | |
body_0 = package$utils.EmptyContent; | |
var $receiver_2 = new HttpRequestBuilder(); | |
url_0($receiver_2, 'http', host_0, 0, '/'); | |
$receiver_2.method = HttpMethod.Companion.Head; | |
$receiver_2.body = body_0; | |
takeFrom($receiver_2.url, this.local$urlString); | |
this.local$block($receiver_2); | |
this.state_0 = 2; | |
this.result_0 = call_0(this.local$$receiver, $receiver_2, this); | |
if (this.result_0 === COROUTINE_SUSPENDED) | |
return COROUTINE_SUSPENDED; | |
continue; | |
case 1: | |
throw this.exception_0; | |
case 2: | |
var tmp$_0; | |
this.state_0 = 3; | |
this.result_0 = this.result_0.receive_jo9acv$(new TypeInfo(getKClass(this.local$T_0), package$call.JsType), this); | |
if (this.result_0 === COROUTINE_SUSPENDED) | |
return COROUTINE_SUSPENDED; | |
continue; | |
case 3: | |
this.result_0 = this.local$isT(tmp$_0 = this.result_0) ? tmp$_0 : throwCCE(); | |
return this.result_0; | |
default: | |
this.state_0 = 1; | |
throw new Error('State Machine Unreachable execution'); | |
} | |
} catch (e) { | |
if (this.state_0 === 1) { | |
this.exceptionState_0 = this.state_0; | |
throw e; | |
} else { | |
this.state_0 = this.exceptionState_0; | |
this.exception_0 = e; | |
} | |
} while (true); | |
}; | |
function head_1(T_0, isT, $receiver_1, urlString, block, continuation, suspended) { | |
var instance = new Coroutine$head_1(T_0, isT, $receiver_1, urlString, block, continuation); | |
if (suspended) | |
return instance; | |
else | |
return instance.doResume(null); | |
} | |
defineInlineFunction('ktor-client-core.io.ktor.client.request.head_hf8dw$', wrapFunction(function() { | |
var Unit = Kotlin.kotlin.Unit; | |
var takeFrom = _.$$importsForInline$$['ktor-http'].io.ktor.http.takeFrom_jl1sg7$; | |
function head$lambda($receiver) { | |
return Unit; | |
} | |
var utils = _.io.ktor.client.utils; | |
var url = _.io.ktor.client.request.url_3rzbk2$; | |
var HttpMethod = _.$$importsForInline$$['ktor-http'].io.ktor.http.HttpMethod; | |
var HttpRequestBuilder_init = _.io.ktor.client.request.HttpRequestBuilder; | |
var call = _.io.ktor.client.call.call_30bfl5$; | |
var throwCCE = Kotlin.throwCCE; | |
var getKClass = Kotlin.getKClass; | |
var call_0 = _.io.ktor.client.call; | |
var TypeInfo_init = _.io.ktor.client.call.TypeInfo; | |
return function(T_0, isT, $receiver_1, urlString, block, continuation) { | |
if (block === void 0) | |
block = head$lambda; | |
var host_0; | |
var body_0; | |
host_0 = 'localhost'; | |
body_0 = utils.EmptyContent; | |
var $receiver_2 = new HttpRequestBuilder_init(); | |
url($receiver_2, 'http', host_0, 0, '/'); | |
$receiver_2.method = HttpMethod.Companion.Head; | |
$receiver_2.body = body_0; | |
takeFrom($receiver_2.url, urlString); | |
block($receiver_2); | |
Kotlin.suspendCall(call($receiver_1, $receiver_2, Kotlin.coroutineReceiver())); | |
var tmp$_0; | |
Kotlin.suspendCall(Kotlin.coroutineResult(Kotlin.coroutineReceiver()).receive_jo9acv$(new TypeInfo_init(getKClass(T_0), call_0.JsType), Kotlin.coroutineReceiver())); | |
Kotlin.setCoroutineResult(isT(tmp$_0 = Kotlin.coroutineResult(Kotlin.coroutineReceiver())) ? tmp$_0 : throwCCE(), Kotlin.coroutineReceiver()); | |
return Kotlin.coroutineResult(Kotlin.coroutineReceiver()); | |
}; | |
})); | |
function get$lambda_1($receiver) { | |
return Unit; | |
} | |
function Coroutine$get_2(T_0, isT, $receiver_1, url_1, block, continuation) { | |
CoroutineImpl.call(this, continuation); | |
this.exceptionState_0 = 1; | |
this.local$T_0 = T_0; | |
this.local$isT = isT; | |
this.local$$receiver = $receiver_1; | |
this.local$url = url_1; | |
this.local$block = block; | |
} | |
Coroutine$get_2.$metadata$ = { | |
kind: Kotlin.Kind.CLASS, | |
simpleName: null, | |
interfaces: [CoroutineImpl]}; | |
Coroutine$get_2.prototype = Object.create(CoroutineImpl.prototype); | |
Coroutine$get_2.prototype.constructor = Coroutine$get_2; | |
Coroutine$get_2.prototype.doResume = function() { | |
do try { | |
switch (this.state_0) { | |
case 0: | |
if (this.local$block === void 0) | |
this.local$block = get$lambda_1; | |
var host_0; | |
var body_0; | |
host_0 = 'localhost'; | |
body_0 = package$utils.EmptyContent; | |
var $receiver_2 = new HttpRequestBuilder(); | |
url_0($receiver_2, 'http', host_0, 0, '/'); | |
$receiver_2.method = HttpMethod.Companion.Get; | |
$receiver_2.body = body_0; | |
takeFrom_0($receiver_2.url, this.local$url); | |
this.local$block($receiver_2); | |
this.state_0 = 2; | |
this.result_0 = call_0(this.local$$receiver, $receiver_2, this); | |
if (this.result_0 === COROUTINE_SUSPENDED) | |
return COROUTINE_SUSPENDED; | |
continue; | |
case 1: | |
throw this.exception_0; | |
case 2: | |
var tmp$_0; | |
this.state_0 = 3; | |
this.result_0 = this.result_0.receive_jo9acv$(new TypeInfo(getKClass(this.local$T_0), package$call.JsType), this); | |
if (this.result_0 === COROUTINE_SUSPENDED) | |
return COROUTINE_SUSPENDED; | |
continue; | |
case 3: | |
this.result_0 = this.local$isT(tmp$_0 = this.result_0) ? tmp$_0 : throwCCE(); | |
return this.result_0; | |
default: | |
this.state_0 = 1; | |
throw new Error('State Machine Unreachable execution'); | |
} | |
} catch (e) { | |
if (this.state_0 === 1) { | |
this.exceptionState_0 = this.state_0; | |
throw e; | |
} else { | |
this.state_0 = this.exceptionState_0; | |
this.exception_0 = e; | |
} | |
} while (true); | |
}; | |
function get_4(T_0, isT, $receiver_1, url_1, block, continuation, suspended) { | |
var instance = new Coroutine$get_2(T_0, isT, $receiver_1, url_1, block, continuation); | |
if (suspended) | |
return instance; | |
else | |
return instance.doResume(null); | |
} | |
defineInlineFunction('ktor-client-core.io.ktor.client.request.get_2swosf$', wrapFunction(function() { | |
var Unit = Kotlin.kotlin.Unit; | |
var takeFrom = _.$$importsForInline$$['ktor-http'].io.ktor.http.takeFrom_wol2ee$; | |
function get$lambda($receiver) { | |
return Unit; | |
} | |
var utils = _.io.ktor.client.utils; | |
var url = _.io.ktor.client.request.url_3rzbk2$; | |
var HttpMethod = _.$$importsForInline$$['ktor-http'].io.ktor.http.HttpMethod; | |
var HttpRequestBuilder_init = _.io.ktor.client.request.HttpRequestBuilder; | |
var call = _.io.ktor.client.call.call_30bfl5$; | |
var throwCCE = Kotlin.throwCCE; | |
var getKClass = Kotlin.getKClass; | |
var call_0 = _.io.ktor.client.call; | |
var TypeInfo_init = _.io.ktor.client.call.TypeInfo; | |
return function(T_0, isT, $receiver_1, url_1, block, continuation) { | |
if (block === void 0) | |
block = get$lambda; | |
var host_0; | |
var body_0; | |
host_0 = 'localhost'; | |
body_0 = utils.EmptyContent; | |
var $receiver_2 = new HttpRequestBuilder_init(); | |
url($receiver_2, 'http', host_0, 0, '/'); | |
$receiver_2.method = HttpMethod.Companion.Get; | |
$receiver_2.body = body_0; | |
takeFrom($receiver_2.url, url_1); | |
block($receiver_2); | |
Kotlin.suspendCall(call($receiver_1, $receiver_2, Kotlin.coroutineReceiver())); | |
var tmp$_0; | |
Kotlin.suspendCall(Kotlin.coroutineResult(Kotlin.coroutineReceiver()).receive_jo9acv$(new TypeInfo_init(getKClass(T_0), call_0.JsType), Kotlin.coroutineReceiver())); | |
Kotlin.setCoroutineResult(isT(tmp$_0 = Kotlin.coroutineResult(Kotlin.coroutineReceiver())) ? tmp$_0 : throwCCE(), Kotlin.coroutineReceiver()); | |
return Kotlin.coroutineResult(Kotlin.coroutineReceiver()); | |
}; | |
})); | |
function post$lambda_1($receiver) { | |
return Unit; | |
} | |
function Coroutine$post_2(T_0, isT, $receiver_1, url_1, block, continuation) { | |
CoroutineImpl.call(this, continuation); | |
this.exceptionState_0 = 1; | |
this.local$T_0 = T_0; | |
this.local$isT = isT; | |
this.local$$receiver = $receiver_1; | |
this.local$url = url_1; | |
this.local$block = block; | |
} | |
Coroutine$post_2.$metadata$ = { | |
kind: Kotlin.Kind.CLASS, | |
simpleName: null, | |
interfaces: [CoroutineImpl]}; | |
Coroutine$post_2.prototype = Object.create(CoroutineImpl.prototype); | |
Coroutine$post_2.prototype.constructor = Coroutine$post_2; | |
Coroutine$post_2.prototype.doResume = function() { | |
do try { | |
switch (this.state_0) { | |
case 0: | |
if (this.local$block === void 0) | |
this.local$block = post$lambda_1; | |
var host_0; | |
var body_0; | |
host_0 = 'localhost'; | |
body_0 = package$utils.EmptyContent; | |
var $receiver_2 = new HttpRequestBuilder(); | |
url_0($receiver_2, 'http', host_0, 0, '/'); | |
$receiver_2.method = HttpMethod.Companion.Post; | |
$receiver_2.body = body_0; | |
takeFrom_0($receiver_2.url, this.local$url); | |
this.local$block($receiver_2); | |
this.state_0 = 2; | |
this.result_0 = call_0(this.local$$receiver, $receiver_2, this); | |
if (this.result_0 === COROUTINE_SUSPENDED) | |
return COROUTINE_SUSPENDED; | |
continue; | |
case 1: | |
throw this.exception_0; | |
case 2: | |
var tmp$_0; | |
this.state_0 = 3; | |
this.result_0 = this.result_0.receive_jo9acv$(new TypeInfo(getKClass(this.local$T_0), package$call.JsType), this); | |
if (this.result_0 === COROUTINE_SUSPENDED) | |
return COROUTINE_SUSPENDED; | |
continue; | |
case 3: | |
this.result_0 = this.local$isT(tmp$_0 = this.result_0) ? tmp$_0 : throwCCE(); | |
return this.result_0; | |
default: | |
this.state_0 = 1; | |
throw new Error('State Machine Unreachable execution'); | |
} | |
} catch (e) { | |
if (this.state_0 === 1) { | |
this.exceptionState_0 = this.state_0; | |
throw e; | |
} else { | |
this.state_0 = this.exceptionState_0; | |
this.exception_0 = e; | |
} | |
} while (true); | |
}; | |
function post_2(T_0, isT, $receiver_1, url_1, block, continuation, suspended) { | |
var instance = new Coroutine$post_2(T_0, isT, $receiver_1, url_1, block, continuation); | |
if (suspended) | |
return instance; | |
else | |
return instance.doResume(null); | |
} | |
defineInlineFunction('ktor-client-core.io.ktor.client.request.post_2swosf$', wrapFunction(function() { | |
var Unit = Kotlin.kotlin.Unit; | |
var takeFrom = _.$$importsForInline$$['ktor-http'].io.ktor.http.takeFrom_wol2ee$; | |
function post$lambda($receiver) { | |
return Unit; | |
} | |
var utils = _.io.ktor.client.utils; | |
var url = _.io.ktor.client.request.url_3rzbk2$; | |
var HttpMethod = _.$$importsForInline$$['ktor-http'].io.ktor.http.HttpMethod; | |
var HttpRequestBuilder_init = _.io.ktor.client.request.HttpRequestBuilder; | |
var call = _.io.ktor.client.call.call_30bfl5$; | |
var throwCCE = Kotlin.throwCCE; | |
var getKClass = Kotlin.getKClass; | |
var call_0 = _.io.ktor.client.call; | |
var TypeInfo_init = _.io.ktor.client.call.TypeInfo; | |
return function(T_0, isT, $receiver_1, url_1, block, continuation) { | |
if (block === void 0) | |
block = post$lambda; | |
var host_0; | |
var body_0; | |
host_0 = 'localhost'; | |
body_0 = utils.EmptyContent; | |
var $receiver_2 = new HttpRequestBuilder_init(); | |
url($receiver_2, 'http', host_0, 0, '/'); | |
$receiver_2.method = HttpMethod.Companion.Post; | |
$receiver_2.body = body_0; | |
takeFrom($receiver_2.url, url_1); | |
block($receiver_2); | |
Kotlin.suspendCall(call($receiver_1, $receiver_2, Kotlin.coroutineReceiver())); | |
var tmp$_0; | |
Kotlin.suspendCall(Kotlin.coroutineResult(Kotlin.coroutineReceiver()).receive_jo9acv$(new TypeInfo_init(getKClass(T_0), call_0.JsType), Kotlin.coroutineReceiver())); | |
Kotlin.setCoroutineResult(isT(tmp$_0 = Kotlin.coroutineResult(Kotlin.coroutineReceiver())) ? tmp$_0 : throwCCE(), Kotlin.coroutineReceiver()); | |
return Kotlin.coroutineResult(Kotlin.coroutineReceiver()); | |
}; | |
})); | |
function put$lambda_1($receiver) { | |
return Unit; | |
} | |
function Coroutine$put_2(T_0, isT, $receiver_1, url_1, block, continuation) { | |
CoroutineImpl.call(this, continuation); | |
this.exceptionState_0 = 1; | |
this.local$T_0 = T_0; | |
this.local$isT = isT; | |
this.local$$receiver = $receiver_1; | |
this.local$url = url_1; | |
this.local$block = block; | |
} | |
Coroutine$put_2.$metadata$ = { | |
kind: Kotlin.Kind.CLASS, | |
simpleName: null, | |
interfaces: [CoroutineImpl]}; | |
Coroutine$put_2.prototype = Object.create(CoroutineImpl.prototype); | |
Coroutine$put_2.prototype.constructor = Coroutine$put_2; | |
Coroutine$put_2.prototype.doResume = function() { | |
do try { | |
switch (this.state_0) { | |
case 0: | |
if (this.local$block === void 0) | |
this.local$block = put$lambda_1; | |
var host_0; | |
var body_0; | |
host_0 = 'localhost'; | |
body_0 = package$utils.EmptyContent; | |
var $receiver_2 = new HttpRequestBuilder(); | |
url_0($receiver_2, 'http', host_0, 0, '/'); | |
$receiver_2.method = HttpMethod.Companion.Put; | |
$receiver_2.body = body_0; | |
takeFrom_0($receiver_2.url, this.local$url); | |
this.local$block($receiver_2); | |
this.state_0 = 2; | |
this.result_0 = call_0(this.local$$receiver, $receiver_2, this); | |
if (this.result_0 === COROUTINE_SUSPENDED) | |
return COROUTINE_SUSPENDED; | |
continue; | |
case 1: | |
throw this.exception_0; | |
case 2: | |
var tmp$_0; | |
this.state_0 = 3; | |
this.result_0 = this.result_0.receive_jo9acv$(new TypeInfo(getKClass(this.local$T_0), package$call.JsType), this); | |
if (this.result_0 === COROUTINE_SUSPENDED) | |
return COROUTINE_SUSPENDED; | |
continue; | |
case 3: | |
this.result_0 = this.local$isT(tmp$_0 = this.result_0) ? tmp$_0 : throwCCE(); | |
return this.result_0; | |
default: | |
this.state_0 = 1; | |
throw new Error('State Machine Unreachable execution'); | |
} | |
} catch (e) { | |
if (this.state_0 === 1) { | |
this.exceptionState_0 = this.state_0; | |
throw e; | |
} else { | |
this.state_0 = this.exceptionState_0; | |
this.exception_0 = e; | |
} | |
} while (true); | |
}; | |
function put_2(T_0, isT, $receiver_1, url_1, block, continuation, suspended) { | |
var instance = new Coroutine$put_2(T_0, isT, $receiver_1, url_1, block, continuation); | |
if (suspended) | |
return instance; | |
else | |
return instance.doResume(null); | |
} | |
defineInlineFunction('ktor-client-core.io.ktor.client.request.put_2swosf$', wrapFunction(function() { | |
var Unit = Kotlin.kotlin.Unit; | |
var takeFrom = _.$$importsForInline$$['ktor-http'].io.ktor.http.takeFrom_wol2ee$; | |
function put$lambda($receiver) { | |
return Unit; | |
} | |
var utils = _.io.ktor.client.utils; | |
var url = _.io.ktor.client.request.url_3rzbk2$; | |
var HttpMethod = _.$$importsForInline$$['ktor-http'].io.ktor.http.HttpMethod; | |
var HttpRequestBuilder_init = _.io.ktor.client.request.HttpRequestBuilder; | |
var call = _.io.ktor.client.call.call_30bfl5$; | |
var throwCCE = Kotlin.throwCCE; | |
var getKClass = Kotlin.getKClass; | |
var call_0 = _.io.ktor.client.call; | |
var TypeInfo_init = _.io.ktor.client.call.TypeInfo; | |
return function(T_0, isT, $receiver_1, url_1, block, continuation) { | |
if (block === void 0) | |
block = put$lambda; | |
var host_0; | |
var body_0; | |
host_0 = 'localhost'; | |
body_0 = utils.EmptyContent; | |
var $receiver_2 = new HttpRequestBuilder_init(); | |
url($receiver_2, 'http', host_0, 0, '/'); | |
$receiver_2.method = HttpMethod.Companion.Put; | |
$receiver_2.body = body_0; | |
takeFrom($receiver_2.url, url_1); | |
block($receiver_2); | |
Kotlin.suspendCall(call($receiver_1, $receiver_2, Kotlin.coroutineReceiver())); | |
var tmp$_0; | |
Kotlin.suspendCall(Kotlin.coroutineResult(Kotlin.coroutineReceiver()).receive_jo9acv$(new TypeInfo_init(getKClass(T_0), call_0.JsType), Kotlin.coroutineReceiver())); | |
Kotlin.setCoroutineResult(isT(tmp$_0 = Kotlin.coroutineResult(Kotlin.coroutineReceiver())) ? tmp$_0 : throwCCE(), Kotlin.coroutineReceiver()); | |
return Kotlin.coroutineResult(Kotlin.coroutineReceiver()); | |
}; | |
})); | |
function patch$lambda_1($receiver) { | |
return Unit; | |
} | |
function Coroutine$patch_2(T_0, isT, $receiver_1, url_1, block, continuation) { | |
CoroutineImpl.call(this, continuation); | |
this.exceptionState_0 = 1; | |
this.local$T_0 = T_0; | |
this.local$isT = isT; | |
this.local$$receiver = $receiver_1; | |
this.local$url = url_1; | |
this.local$block = block; | |
} | |
Coroutine$patch_2.$metadata$ = { | |
kind: Kotlin.Kind.CLASS, | |
simpleName: null, | |
interfaces: [CoroutineImpl]}; | |
Coroutine$patch_2.prototype = Object.create(CoroutineImpl.prototype); | |
Coroutine$patch_2.prototype.constructor = Coroutine$patch_2; | |
Coroutine$patch_2.prototype.doResume = function() { | |
do try { | |
switch (this.state_0) { | |
case 0: | |
if (this.local$block === void 0) | |
this.local$block = patch$lambda_1; | |
var host_0; | |
var body_0; | |
host_0 = 'localhost'; | |
body_0 = package$utils.EmptyContent; | |
var $receiver_2 = new HttpRequestBuilder(); | |
url_0($receiver_2, 'http', host_0, 0, '/'); | |
$receiver_2.method = HttpMethod.Companion.Patch; | |
$receiver_2.body = body_0; | |
takeFrom_0($receiver_2.url, this.local$url); | |
this.local$block($receiver_2); | |
this.state_0 = 2; | |
this.result_0 = call_0(this.local$$receiver, $receiver_2, this); | |
if (this.result_0 === COROUTINE_SUSPENDED) | |
return COROUTINE_SUSPENDED; | |
continue; | |
case 1: | |
throw this.exception_0; | |
case 2: | |
var tmp$_0; | |
this.state_0 = 3; | |
this.result_0 = this.result_0.receive_jo9acv$(new TypeInfo(getKClass(this.local$T_0), package$call.JsType), this); | |
if (this.result_0 === COROUTINE_SUSPENDED) | |
return COROUTINE_SUSPENDED; | |
continue; | |
case 3: | |
this.result_0 = this.local$isT(tmp$_0 = this.result_0) ? tmp$_0 : throwCCE(); | |
return this.result_0; | |
default: | |
this.state_0 = 1; | |
throw new Error('State Machine Unreachable execution'); | |
} | |
} catch (e) { | |
if (this.state_0 === 1) { | |
this.exceptionState_0 = this.state_0; | |
throw e; | |
} else { | |
this.state_0 = this.exceptionState_0; | |
this.exception_0 = e; | |
} | |
} while (true); | |
}; | |
function patch_2(T_0, isT, $receiver_1, url_1, block, continuation, suspended) { | |
var instance = new Coroutine$patch_2(T_0, isT, $receiver_1, url_1, block, continuation); | |
if (suspended) | |
return instance; | |
else | |
return instance.doResume(null); | |
} | |
defineInlineFunction('ktor-client-core.io.ktor.client.request.patch_2swosf$', wrapFunction(function() { | |
var Unit = Kotlin.kotlin.Unit; | |
var takeFrom = _.$$importsForInline$$['ktor-http'].io.ktor.http.takeFrom_wol2ee$; | |
function patch$lambda($receiver) { | |
return Unit; | |
} | |
var utils = _.io.ktor.client.utils; | |
var url = _.io.ktor.client.request.url_3rzbk2$; | |
var HttpMethod = _.$$importsForInline$$['ktor-http'].io.ktor.http.HttpMethod; | |
var HttpRequestBuilder_init = _.io.ktor.client.request.HttpRequestBuilder; | |
var call = _.io.ktor.client.call.call_30bfl5$; | |
var throwCCE = Kotlin.throwCCE; | |
var getKClass = Kotlin.getKClass; | |
var call_0 = _.io.ktor.client.call; | |
var TypeInfo_init = _.io.ktor.client.call.TypeInfo; | |
return function(T_0, isT, $receiver_1, url_1, block, continuation) { | |
if (block === void 0) | |
block = patch$lambda; | |
var host_0; | |
var body_0; | |
host_0 = 'localhost'; | |
body_0 = utils.EmptyContent; | |
var $receiver_2 = new HttpRequestBuilder_init(); | |
url($receiver_2, 'http', host_0, 0, '/'); | |
$receiver_2.method = HttpMethod.Companion.Patch; | |
$receiver_2.body = body_0; | |
takeFrom($receiver_2.url, url_1); | |
block($receiver_2); | |
Kotlin.suspendCall(call($receiver_1, $receiver_2, Kotlin.coroutineReceiver())); | |
var tmp$_0; | |
Kotlin.suspendCall(Kotlin.coroutineResult(Kotlin.coroutineReceiver()).receive_jo9acv$(new TypeInfo_init(getKClass(T_0), call_0.JsType), Kotlin.coroutineReceiver())); | |
Kotlin.setCoroutineResult(isT(tmp$_0 = Kotlin.coroutineResult(Kotlin.coroutineReceiver())) ? tmp$_0 : throwCCE(), Kotlin.coroutineReceiver()); | |
return Kotlin.coroutineResult(Kotlin.coroutineReceiver()); | |
}; | |
})); | |
function options$lambda_1($receiver) { | |
return Unit; | |
} | |
function Coroutine$options_2(T_0, isT, $receiver_1, url_1, block, continuation) { | |
CoroutineImpl.call(this, continuation); | |
this.exceptionState_0 = 1; | |
this.local$T_0 = T_0; | |
this.local$isT = isT; | |
this.local$$receiver = $receiver_1; | |
this.local$url = url_1; | |
this.local$block = block; | |
} | |
Coroutine$options_2.$metadata$ = { | |
kind: Kotlin.Kind.CLASS, | |
simpleName: null, | |
interfaces: [CoroutineImpl]}; | |
Coroutine$options_2.prototype = Object.create(CoroutineImpl.prototype); | |
Coroutine$options_2.prototype.constructor = Coroutine$options_2; | |
Coroutine$options_2.prototype.doResume = function() { | |
do try { | |
switch (this.state_0) { | |
case 0: | |
if (this.local$block === void 0) | |
this.local$block = options$lambda_1; | |
var host_0; | |
var body_0; | |
host_0 = 'localhost'; | |
body_0 = package$utils.EmptyContent; | |
var $receiver_2 = new HttpRequestBuilder(); | |
url_0($receiver_2, 'http', host_0, 0, '/'); | |
$receiver_2.method = HttpMethod.Companion.Options; | |
$receiver_2.body = body_0; | |
takeFrom_0($receiver_2.url, this.local$url); | |
this.local$block($receiver_2); | |
this.state_0 = 2; | |
this.result_0 = call_0(this.local$$receiver, $receiver_2, this); | |
if (this.result_0 === COROUTINE_SUSPENDED) | |
return COROUTINE_SUSPENDED; | |
continue; | |
case 1: | |
throw this.exception_0; | |
case 2: | |
var tmp$_0; | |
this.state_0 = 3; | |
this.result_0 = this.result_0.receive_jo9acv$(new TypeInfo(getKClass(this.local$T_0), package$call.JsType), this); | |
if (this.result_0 === COROUTINE_SUSPENDED) | |
return COROUTINE_SUSPENDED; | |
continue; | |
case 3: | |
this.result_0 = this.local$isT(tmp$_0 = this.result_0) ? tmp$_0 : throwCCE(); | |
return this.result_0; | |
default: | |
this.state_0 = 1; | |
throw new Error('State Machine Unreachable execution'); | |
} | |
} catch (e) { | |
if (this.state_0 === 1) { | |
this.exceptionState_0 = this.state_0; | |
throw e; | |
} else { | |
this.state_0 = this.exceptionState_0; | |
this.exception_0 = e; | |
} | |
} while (true); | |
}; | |
function options_2(T_0, isT, $receiver_1, url_1, block, continuation, suspended) { | |
var instance = new Coroutine$options_2(T_0, isT, $receiver_1, url_1, block, continuation); | |
if (suspended) | |
return instance; | |
else | |
return instance.doResume(null); | |
} | |
defineInlineFunction('ktor-client-core.io.ktor.client.request.options_2swosf$', wrapFunction(function() { | |
var Unit = Kotlin.kotlin.Unit; | |
var takeFrom = _.$$importsForInline$$['ktor-http'].io.ktor.http.takeFrom_wol2ee$; | |
function options$lambda($receiver) { | |
return Unit; | |
} | |
var utils = _.io.ktor.client.utils; | |
var url = _.io.ktor.client.request.url_3rzbk2$; | |
var HttpMethod = _.$$importsForInline$$['ktor-http'].io.ktor.http.HttpMethod; | |
var HttpRequestBuilder_init = _.io.ktor.client.request.HttpRequestBuilder; | |
var call = _.io.ktor.client.call.call_30bfl5$; | |
var throwCCE = Kotlin.throwCCE; | |
var getKClass = Kotlin.getKClass; | |
var call_0 = _.io.ktor.client.call; | |
var TypeInfo_init = _.io.ktor.client.call.TypeInfo; | |
return function(T_0, isT, $receiver_1, url_1, block, continuation) { | |
if (block === void 0) | |
block = options$lambda; | |
var host_0; | |
var body_0; | |
host_0 = 'localhost'; | |
body_0 = utils.EmptyContent; | |
var $receiver_2 = new HttpRequestBuilder_init(); | |
url($receiver_2, 'http', host_0, 0, '/'); | |
$receiver_2.method = HttpMethod.Companion.Options; | |
$receiver_2.body = body_0; | |
takeFrom($receiver_2.url, url_1); | |
block($receiver_2); | |
Kotlin.suspendCall(call($receiver_1, $receiver_2, Kotlin.coroutineReceiver())); | |
var tmp$_0; | |
Kotlin.suspendCall(Kotlin.coroutineResult(Kotlin.coroutineReceiver()).receive_jo9acv$(new TypeInfo_init(getKClass(T_0), call_0.JsType), Kotlin.coroutineReceiver())); | |
Kotlin.setCoroutineResult(isT(tmp$_0 = Kotlin.coroutineResult(Kotlin.coroutineReceiver())) ? tmp$_0 : throwCCE(), Kotlin.coroutineReceiver()); | |
return Kotlin.coroutineResult(Kotlin.coroutineReceiver()); | |
}; | |
})); | |
function head$lambda_1($receiver) { | |
return Unit; | |
} | |
function Coroutine$head_2(T_0, isT, $receiver_1, url_1, block, continuation) { | |
CoroutineImpl.call(this, continuation); | |
this.exceptionState_0 = 1; | |
this.local$T_0 = T_0; | |
this.local$isT = isT; | |
this.local$$receiver = $receiver_1; | |
this.local$url = url_1; | |
this.local$block = block; | |
} | |
Coroutine$head_2.$metadata$ = { | |
kind: Kotlin.Kind.CLASS, | |
simpleName: null, | |
interfaces: [CoroutineImpl]}; | |
Coroutine$head_2.prototype = Object.create(CoroutineImpl.prototype); | |
Coroutine$head_2.prototype.constructor = Coroutine$head_2; | |
Coroutine$head_2.prototype.doResume = function() { | |
do try { | |
switch (this.state_0) { | |
case 0: | |
if (this.local$block === void 0) | |
this.local$block = head$lambda_1; | |
var host_0; | |
var body_0; | |
host_0 = 'localhost'; | |
body_0 = package$utils.EmptyContent; | |
var $receiver_2 = new HttpRequestBuilder(); | |
url_0($receiver_2, 'http', host_0, 0, '/'); | |
$receiver_2.method = HttpMethod.Companion.Head; | |
$receiver_2.body = body_0; | |
takeFrom_0($receiver_2.url, this.local$url); | |
this.local$block($receiver_2); | |
this.state_0 = 2; | |
this.result_0 = call_0(this.local$$receiver, $receiver_2, this); | |
if (this.result_0 === COROUTINE_SUSPENDED) | |
return COROUTINE_SUSPENDED; | |
continue; | |
case 1: | |
throw this.exception_0; | |
case 2: | |
var tmp$_0; | |
this.state_0 = 3; | |
this.result_0 = this.result_0.receive_jo9acv$(new TypeInfo(getKClass(this.local$T_0), package$call.JsType), this); | |
if (this.result_0 === COROUTINE_SUSPENDED) | |
return COROUTINE_SUSPENDED; | |
continue; | |
case 3: | |
this.result_0 = this.local$isT(tmp$_0 = this.result_0) ? tmp$_0 : throwCCE(); | |
return this.result_0; | |
default: | |
this.state_0 = 1; | |
throw new Error('State Machine Unreachable execution'); | |
} | |
} catch (e) { | |
if (this.state_0 === 1) { | |
this.exceptionState_0 = this.state_0; | |
throw e; | |
} else { | |
this.state_0 = this.exceptionState_0; | |
this.exception_0 = e; | |
} | |
} while (true); | |
}; | |
function head_2(T_0, isT, $receiver_1, url_1, block, continuation, suspended) { | |
var instance = new Coroutine$head_2(T_0, isT, $receiver_1, url_1, block, continuation); | |
if (suspended) | |
return instance; | |
else | |
return instance.doResume(null); | |
} | |
defineInlineFunction('ktor-client-core.io.ktor.client.request.head_2swosf$', wrapFunction(function() { | |
var Unit = Kotlin.kotlin.Unit; | |
var takeFrom = _.$$importsForInline$$['ktor-http'].io.ktor.http.takeFrom_wol2ee$; | |
function head$lambda($receiver) { | |
return Unit; | |
} | |
var utils = _.io.ktor.client.utils; | |
var url = _.io.ktor.client.request.url_3rzbk2$; | |
var HttpMethod = _.$$importsForInline$$['ktor-http'].io.ktor.http.HttpMethod; | |
var HttpRequestBuilder_init = _.io.ktor.client.request.HttpRequestBuilder; | |
var call = _.io.ktor.client.call.call_30bfl5$; | |
var throwCCE = Kotlin.throwCCE; | |
var getKClass = Kotlin.getKClass; | |
var call_0 = _.io.ktor.client.call; | |
var TypeInfo_init = _.io.ktor.client.call.TypeInfo; | |
return function(T_0, isT, $receiver_1, url_1, block, continuation) { | |
if (block === void 0) | |
block = head$lambda; | |
var host_0; | |
var body_0; | |
host_0 = 'localhost'; | |
body_0 = utils.EmptyContent; | |
var $receiver_2 = new HttpRequestBuilder_init(); | |
url($receiver_2, 'http', host_0, 0, '/'); | |
$receiver_2.method = HttpMethod.Companion.Head; | |
$receiver_2.body = body_0; | |
takeFrom($receiver_2.url, url_1); | |
block($receiver_2); | |
Kotlin.suspendCall(call($receiver_1, $receiver_2, Kotlin.coroutineReceiver())); | |
var tmp$_0; | |
Kotlin.suspendCall(Kotlin.coroutineResult(Kotlin.coroutineReceiver()).receive_jo9acv$(new TypeInfo_init(getKClass(T_0), call_0.JsType), Kotlin.coroutineReceiver())); | |
Kotlin.setCoroutineResult(isT(tmp$_0 = Kotlin.coroutineResult(Kotlin.coroutineReceiver())) ? tmp$_0 : throwCCE(), Kotlin.coroutineReceiver()); | |
return Kotlin.coroutineResult(Kotlin.coroutineReceiver()); | |
}; | |
})); | |
function delete$lambda_1($receiver) { | |
return Unit; | |
} | |
function Coroutine$delete_2(T_0, isT, $receiver_1, url_1, block, continuation) { | |
CoroutineImpl.call(this, continuation); | |
this.exceptionState_0 = 1; | |
this.local$T_0 = T_0; | |
this.local$isT = isT; | |
this.local$$receiver = $receiver_1; | |
this.local$url = url_1; | |
this.local$block = block; | |
} | |
Coroutine$delete_2.$metadata$ = { | |
kind: Kotlin.Kind.CLASS, | |
simpleName: null, | |
interfaces: [CoroutineImpl]}; | |
Coroutine$delete_2.prototype = Object.create(CoroutineImpl.prototype); | |
Coroutine$delete_2.prototype.constructor = Coroutine$delete_2; | |
Coroutine$delete_2.prototype.doResume = function() { | |
do try { | |
switch (this.state_0) { | |
case 0: | |
if (this.local$block === void 0) | |
this.local$block = delete$lambda_1; | |
var host_0; | |
var body_0; | |
host_0 = 'localhost'; | |
body_0 = package$utils.EmptyContent; | |
var $receiver_2 = new HttpRequestBuilder(); | |
url_0($receiver_2, 'http', host_0, 0, '/'); | |
$receiver_2.method = HttpMethod.Companion.Delete; | |
$receiver_2.body = body_0; | |
takeFrom_0($receiver_2.url, this.local$url); | |
this.local$block($receiver_2); | |
this.state_0 = 2; | |
this.result_0 = call_0(this.local$$receiver, $receiver_2, this); | |
if (this.result_0 === COROUTINE_SUSPENDED) | |
return COROUTINE_SUSPENDED; | |
continue; | |
case 1: | |
throw this.exception_0; | |
case 2: | |
var tmp$_0; | |
this.state_0 = 3; | |
this.result_0 = this.result_0.receive_jo9acv$(new TypeInfo(getKClass(this.local$T_0), package$call.JsType), this); | |
if (this.result_0 === COROUTINE_SUSPENDED) | |
return COROUTINE_SUSPENDED; | |
continue; | |
case 3: | |
this.result_0 = this.local$isT(tmp$_0 = this.result_0) ? tmp$_0 : throwCCE(); | |
return this.result_0; | |
default: | |
this.state_0 = 1; | |
throw new Error('State Machine Unreachable execution'); | |
} | |
} catch (e) { | |
if (this.state_0 === 1) { | |
this.exceptionState_0 = this.state_0; | |
throw e; | |
} else { | |
this.state_0 = this.exceptionState_0; | |
this.exception_0 = e; | |
} | |
} while (true); | |
}; | |
function delete_3(T_0, isT, $receiver_1, url_1, block, continuation, suspended) { | |
var instance = new Coroutine$delete_2(T_0, isT, $receiver_1, url_1, block, continuation); | |
if (suspended) | |
return instance; | |
else | |
return instance.doResume(null); | |
} | |
defineInlineFunction('ktor-client-core.io.ktor.client.request.delete_2swosf$', wrapFunction(function() { | |
var Unit = Kotlin.kotlin.Unit; | |
var takeFrom = _.$$importsForInline$$['ktor-http'].io.ktor.http.takeFrom_wol2ee$; | |
function delete$lambda($receiver) { | |
return Unit; | |
} | |
var utils = _.io.ktor.client.utils; | |
var url = _.io.ktor.client.request.url_3rzbk2$; | |
var HttpMethod = _.$$importsForInline$$['ktor-http'].io.ktor.http.HttpMethod; | |
var HttpRequestBuilder_init = _.io.ktor.client.request.HttpRequestBuilder; | |
var call = _.io.ktor.client.call.call_30bfl5$; | |
var throwCCE = Kotlin.throwCCE; | |
var getKClass = Kotlin.getKClass; | |
var call_0 = _.io.ktor.client.call; | |
var TypeInfo_init = _.io.ktor.client.call.TypeInfo; | |
return function(T_0, isT, $receiver_1, url_1, block, continuation) { | |
if (block === void 0) | |
block = delete$lambda; | |
var host_0; | |
var body_0; | |
host_0 = 'localhost'; | |
body_0 = utils.EmptyContent; | |
var $receiver_2 = new HttpRequestBuilder_init(); | |
url($receiver_2, 'http', host_0, 0, '/'); | |
$receiver_2.method = HttpMethod.Companion.Delete; | |
$receiver_2.body = body_0; | |
takeFrom($receiver_2.url, url_1); | |
block($receiver_2); | |
Kotlin.suspendCall(call($receiver_1, $receiver_2, Kotlin.coroutineReceiver())); | |
var tmp$_0; | |
Kotlin.suspendCall(Kotlin.coroutineResult(Kotlin.coroutineReceiver()).receive_jo9acv$(new TypeInfo_init(getKClass(T_0), call_0.JsType), Kotlin.coroutineReceiver())); | |
Kotlin.setCoroutineResult(isT(tmp$_0 = Kotlin.coroutineResult(Kotlin.coroutineReceiver())) ? tmp$_0 : throwCCE(), Kotlin.coroutineReceiver()); | |
return Kotlin.coroutineResult(Kotlin.coroutineReceiver()); | |
}; | |
})); | |
function url_2($receiver, url) { | |
takeFrom_0($receiver.url, url); | |
} | |
var encodeToByteArray = $module$kotlinx_io.kotlinx.io.charsets.encodeToByteArray_478lbv$; | |
function FormDataContent(formData) { | |
OutgoingContent$ByteArrayContent.call(this); | |
this.formData = formData; | |
var $receiver = formUrlEncode(this.formData); | |
this.content_0 = encodeToByteArray(charsets.Charsets.UTF_8.newEncoder(), $receiver, 0, $receiver.length); | |
this.contentLength_f2tvnf$_0 = Kotlin.Long.fromInt(this.content_0.length); | |
this.contentType_gyve29$_0 = withCharset(ContentType.Application.FormUrlEncoded, charsets.Charsets.UTF_8); | |
} | |
Object.defineProperty(FormDataContent.prototype, 'contentLength', { | |
get: function() { | |
return this.contentLength_f2tvnf$_0; | |
}}); | |
Object.defineProperty(FormDataContent.prototype, 'contentType', { | |
get: function() { | |
return this.contentType_gyve29$_0; | |
}}); | |
FormDataContent.prototype.bytes = function() { | |
return this.content_0; | |
}; | |
FormDataContent.$metadata$ = { | |
kind: Kind_CLASS, | |
simpleName: 'FormDataContent', | |
interfaces: [OutgoingContent$ByteArrayContent]}; | |
function MultiPartFormDataContent(parts) { | |
OutgoingContent$WriteChannelContent.call(this); | |
this.parts_0 = parts; | |
this.boundary_0 = generateBoundary(); | |
this.contentType_azd2en$_0 = ContentType.MultiPart.FormData.withParameter_puj7f4$('boundary', this.boundary_0); | |
} | |
Object.defineProperty(MultiPartFormDataContent.prototype, 'contentType', { | |
get: function() { | |
return this.contentType_azd2en$_0; | |
}}); | |
function Coroutine$writeTo_sfhht4$($this, channel_0, continuation_0) { | |
CoroutineImpl.call(this, continuation_0); | |
this.exceptionState_0 = 21; | |
this.$this = $this; | |
this.local$tmp$ = void 0; | |
this.local$element = void 0; | |
this.local$tmp$_0 = void 0; | |
this.local$channel = channel_0; | |
} | |
Coroutine$writeTo_sfhht4$.$metadata$ = { | |
kind: Kotlin.Kind.CLASS, | |
simpleName: null, | |
interfaces: [CoroutineImpl]}; | |
Coroutine$writeTo_sfhht4$.prototype = Object.create(CoroutineImpl.prototype); | |
Coroutine$writeTo_sfhht4$.prototype.constructor = Coroutine$writeTo_sfhht4$; | |
Coroutine$writeTo_sfhht4$.prototype.doResume = function() { | |
do try { | |
switch (this.state_0) { | |
case 0: | |
this.exceptionState_0 = 1; | |
if (this.$this.parts_0.isEmpty()) { | |
this.exceptionState_0 = 21; | |
this.finallyPath_0 = [2]; | |
this.state_0 = 20; | |
continue; | |
} else { | |
this.state_0 = 3; | |
continue; | |
} | |
case 1: | |
this.finallyPath_0 = [21]; | |
this.exceptionState_0 = 20; | |
var cause = this.exception_0; | |
if (Kotlin.isType(cause, Throwable)) { | |
this.local$channel.close_dbl4no$(cause); | |
} else | |
throw cause; | |
this.finallyPath_0 = [22]; | |
this.state_0 = 20; | |
continue; | |
case 2: | |
return; | |
case 3: | |
this.state_0 = 4; | |
this.result_0 = writeStringUtf8(this.local$channel, '\r\n\r\n', this); | |
if (this.result_0 === COROUTINE_SUSPENDED) | |
return COROUTINE_SUSPENDED; | |
continue; | |
case 4: | |
this.local$tmp$ = this.$this.parts_0.iterator(); | |
this.state_0 = 5; | |
continue; | |
case 5: | |
if (!this.local$tmp$.hasNext()) { | |
this.state_0 = 18; | |
continue; | |
} | |
this.local$element = this.local$tmp$.next(); | |
this.state_0 = 6; | |
this.result_0 = writeStringUtf8(this.local$channel, '--' + this.$this.boundary_0 + '\r' + '\n', this); | |
if (this.result_0 === COROUTINE_SUSPENDED) | |
return COROUTINE_SUSPENDED; | |
continue; | |
case 6: | |
this.local$tmp$_0 = this.local$element.headers.entries().iterator(); | |
this.state_0 = 7; | |
continue; | |
case 7: | |
if (!this.local$tmp$_0.hasNext()) { | |
this.state_0 = 9; | |
continue; | |
} | |
var tmp$ = this.local$tmp$_0.next(); | |
var key = tmp$.key; | |
var values = tmp$.value; | |
this.state_0 = 8; | |
this.result_0 = writeStringUtf8(this.local$channel, key + ': ' + joinToString(values, ';') + '\r' + '\n', this); | |
if (this.result_0 === COROUTINE_SUSPENDED) | |
return COROUTINE_SUSPENDED; | |
continue; | |
case 8: | |
this.state_0 = 7; | |
continue; | |
case 9: | |
this.state_0 = 10; | |
this.result_0 = writeStringUtf8(this.local$channel, '\r\n', this); | |
if (this.result_0 === COROUTINE_SUSPENDED) | |
return COROUTINE_SUSPENDED; | |
continue; | |
case 10: | |
if (Kotlin.isType(this.local$element, PartData$FileItem)) { | |
this.state_0 = 15; | |
this.result_0 = writeFully(this.local$channel, readBytes_0(this.local$element.provider()), this); | |
if (this.result_0 === COROUTINE_SUSPENDED) | |
return COROUTINE_SUSPENDED; | |
continue; | |
} else { | |
if (Kotlin.isType(this.local$element, PartData$FormItem)) { | |
this.state_0 = 13; | |
this.result_0 = writeStringUtf8(this.local$channel, this.local$element.value, this); | |
if (this.result_0 === COROUTINE_SUSPENDED) | |
return COROUTINE_SUSPENDED; | |
continue; | |
} else { | |
if (Kotlin.isType(this.local$element, PartData$BinaryItem)) { | |
this.state_0 = 11; | |
this.result_0 = writeFully(this.local$channel, readBytes_0(this.local$element.provider()), this); | |
if (this.result_0 === COROUTINE_SUSPENDED) | |
return COROUTINE_SUSPENDED; | |
continue; | |
} else { | |
this.state_0 = 12; | |
continue; | |
} | |
} | |
} | |
case 11: | |
this.state_0 = 12; | |
continue; | |
case 12: | |
this.state_0 = 14; | |
continue; | |
case 13: | |
this.state_0 = 14; | |
continue; | |
case 14: | |
this.state_0 = 16; | |
continue; | |
case 15: | |
this.state_0 = 16; | |
continue; | |
case 16: | |
this.state_0 = 17; | |
this.result_0 = writeStringUtf8(this.local$channel, '\r\n', this); | |
if (this.result_0 === COROUTINE_SUSPENDED) | |
return COROUTINE_SUSPENDED; | |
continue; | |
case 17: | |
this.state_0 = 5; | |
continue; | |
case 18: | |
this.state_0 = 19; | |
this.result_0 = writeStringUtf8(this.local$channel, '--' + this.$this.boundary_0 + '--' + '\r' + '\n' + '\r' + '\n', this); | |
if (this.result_0 === COROUTINE_SUSPENDED) | |
return COROUTINE_SUSPENDED; | |
continue; | |
case 19: | |
this.exceptionState_0 = 21; | |
this.finallyPath_0 = [22]; | |
this.state_0 = 20; | |
continue; | |
case 20: | |
this.exceptionState_0 = 21; | |
var tmp$_0; | |
tmp$_0 = this.$this.parts_0.iterator(); | |
while (tmp$_0.hasNext()) { | |
var element = tmp$_0.next(); | |
element.dispose(); | |
} | |
close(this.local$channel); | |
this.state_0 = this.finallyPath_0.shift(); | |
continue; | |
case 21: | |
throw this.exception_0; | |
case 22: | |
return; | |
default: | |
this.state_0 = 21; | |
throw new Error('State Machine Unreachable execution'); | |
} | |
} catch (e) { | |
if (this.state_0 === 21) { | |
this.exceptionState_0 = this.state_0; | |
throw e; | |
} else { | |
this.state_0 = this.exceptionState_0; | |
this.exception_0 = e; | |
} | |
} while (true); | |
}; | |
MultiPartFormDataContent.prototype.writeTo_sfhht4$ = function(channel_0, continuation_0, suspended) { | |
var instance = new Coroutine$writeTo_sfhht4$(this, channel_0, continuation_0); | |
if (suspended) | |
return instance; | |
else | |
return instance.doResume(null); | |
}; | |
MultiPartFormDataContent.$metadata$ = { | |
kind: Kind_CLASS, | |
simpleName: 'MultiPartFormDataContent', | |
interfaces: [OutgoingContent$WriteChannelContent]}; | |
function generateBoundary() { | |
var $receiver = StringBuilder_init(); | |
for (var index = 0; index < 32; index++) { | |
$receiver.append_gw00v9$(toString_0(Random.Default.nextInt(), 16)); | |
} | |
return take($receiver.toString(), 70); | |
} | |
var Parameters = $module$ktor_http.io.ktor.http.Parameters; | |
function submitForm$lambda($receiver) { | |
return Unit; | |
} | |
function Coroutine$submitForm(T_0, isT, $receiver_1, formData, encodeInQuery, block, continuation) { | |
CoroutineImpl.call(this, continuation); | |
this.exceptionState_0 = 1; | |
this.local$T_0 = T_0; | |
this.local$isT = isT; | |
this.local$$receiver = $receiver_1; | |
this.local$formData = formData; | |
this.local$encodeInQuery = encodeInQuery; | |
this.local$block = block; | |
} | |
Coroutine$submitForm.$metadata$ = { | |
kind: Kotlin.Kind.CLASS, | |
simpleName: null, | |
interfaces: [CoroutineImpl]}; | |
Coroutine$submitForm.prototype = Object.create(CoroutineImpl.prototype); | |
Coroutine$submitForm.prototype.constructor = Coroutine$submitForm; | |
Coroutine$submitForm.prototype.doResume = function() { | |
do try { | |
switch (this.state_0) { | |
case 0: | |
if (this.local$formData === void 0) | |
this.local$formData = Parameters.Companion.Empty; | |
if (this.local$encodeInQuery === void 0) | |
this.local$encodeInQuery = false; | |
if (this.local$block === void 0) | |
this.local$block = submitForm$lambda; | |
var $receiver_2 = new HttpRequestBuilder(); | |
if (this.local$encodeInQuery) { | |
$receiver_2.method = HttpMethod.Companion.Get; | |
$receiver_2.url.parameters.appendAll_hb0ubp$(this.local$formData); | |
} else { | |
$receiver_2.method = HttpMethod.Companion.Post; | |
$receiver_2.body = new FormDataContent(this.local$formData); | |
} | |
this.local$block($receiver_2); | |
this.state_0 = 2; | |
this.result_0 = call_0(this.local$$receiver, $receiver_2, this); | |
if (this.result_0 === COROUTINE_SUSPENDED) | |
return COROUTINE_SUSPENDED; | |
continue; | |
case 1: | |
throw this.exception_0; | |
case 2: | |
var tmp$_0; | |
this.state_0 = 3; | |
this.result_0 = this.result_0.receive_jo9acv$(new TypeInfo(getKClass(this.local$T_0), package$call.JsType), this); | |
if (this.result_0 === COROUTINE_SUSPENDED) | |
return COROUTINE_SUSPENDED; | |
continue; | |
case 3: | |
this.result_0 = this.local$isT(tmp$_0 = this.result_0) ? tmp$_0 : throwCCE(); | |
return this.result_0; | |
default: | |
this.state_0 = 1; | |
throw new Error('State Machine Unreachable execution'); | |
} | |
} catch (e) { | |
if (this.state_0 === 1) { | |
this.exceptionState_0 = this.state_0; | |
throw e; | |
} else { | |
this.state_0 = this.exceptionState_0; | |
this.exception_0 = e; | |
} | |
} while (true); | |
}; | |
function submitForm(T_0, isT, $receiver_1, formData, encodeInQuery, block, continuation, suspended) { | |
var instance = new Coroutine$submitForm(T_0, isT, $receiver_1, formData, encodeInQuery, block, continuation); | |
if (suspended) | |
return instance; | |
else | |
return instance.doResume(null); | |
} | |
defineInlineFunction('ktor-client-core.io.ktor.client.request.forms.submitForm_k24olv$', wrapFunction(function() { | |
var Parameters = _.$$importsForInline$$['ktor-http'].io.ktor.http.Parameters; | |
var Unit = Kotlin.kotlin.Unit; | |
var HttpMethod = _.$$importsForInline$$['ktor-http'].io.ktor.http.HttpMethod; | |
var FormDataContent_init = _.io.ktor.client.request.forms.FormDataContent; | |
function submitForm$lambda($receiver) { | |
return Unit; | |
} | |
var HttpRequestBuilder_init = _.io.ktor.client.request.HttpRequestBuilder; | |
var call = _.io.ktor.client.call.call_30bfl5$; | |
var throwCCE = Kotlin.throwCCE; | |
var getKClass = Kotlin.getKClass; | |
var call_0 = _.io.ktor.client.call; | |
var TypeInfo_init = _.io.ktor.client.call.TypeInfo; | |
return function(T_0, isT, $receiver_1, formData, encodeInQuery, block, continuation) { | |
if (formData === void 0) | |
formData = Parameters.Companion.Empty; | |
if (encodeInQuery === void 0) | |
encodeInQuery = false; | |
if (block === void 0) | |
block = submitForm$lambda; | |
var $receiver_2 = new HttpRequestBuilder_init(); | |
if (encodeInQuery) { | |
$receiver_2.method = HttpMethod.Companion.Get; | |
$receiver_2.url.parameters.appendAll_hb0ubp$(formData); | |
} else { | |
$receiver_2.method = HttpMethod.Companion.Post; | |
$receiver_2.body = new FormDataContent_init(formData); | |
} | |
block($receiver_2); | |
Kotlin.suspendCall(call($receiver_1, $receiver_2, Kotlin.coroutineReceiver())); | |
var tmp$_0; | |
Kotlin.suspendCall(Kotlin.coroutineResult(Kotlin.coroutineReceiver()).receive_jo9acv$(new TypeInfo_init(getKClass(T_0), call_0.JsType), Kotlin.coroutineReceiver())); | |
Kotlin.setCoroutineResult(isT(tmp$_0 = Kotlin.coroutineResult(Kotlin.coroutineReceiver())) ? tmp$_0 : throwCCE(), Kotlin.coroutineReceiver()); | |
return Kotlin.coroutineResult(Kotlin.coroutineReceiver()); | |
}; | |
})); | |
function submitForm$lambda_0($receiver) { | |
return Unit; | |
} | |
function Coroutine$submitForm_0(T_0, isT, $receiver_1, url_1, formData, encodeInQuery, block, continuation) { | |
CoroutineImpl.call(this, continuation); | |
this.exceptionState_0 = 1; | |
this.local$T_0 = T_0; | |
this.local$isT = isT; | |
this.local$$receiver = $receiver_1; | |
this.local$url = url_1; | |
this.local$formData = formData; | |
this.local$encodeInQuery = encodeInQuery; | |
this.local$block = block; | |
} | |
Coroutine$submitForm_0.$metadata$ = { | |
kind: Kotlin.Kind.CLASS, | |
simpleName: null, | |
interfaces: [CoroutineImpl]}; | |
Coroutine$submitForm_0.prototype = Object.create(CoroutineImpl.prototype); | |
Coroutine$submitForm_0.prototype.constructor = Coroutine$submitForm_0; | |
Coroutine$submitForm_0.prototype.doResume = function() { | |
do try { | |
switch (this.state_0) { | |
case 0: | |
if (this.local$formData === void 0) | |
this.local$formData = Parameters.Companion.Empty; | |
if (this.local$encodeInQuery === void 0) | |
this.local$encodeInQuery = false; | |
if (this.local$block === void 0) | |
this.local$block = submitForm$lambda_0; | |
var $receiver_2 = new HttpRequestBuilder(); | |
if (this.local$encodeInQuery) { | |
$receiver_2.method = HttpMethod.Companion.Get; | |
$receiver_2.url.parameters.appendAll_hb0ubp$(this.local$formData); | |
} else { | |
$receiver_2.method = HttpMethod.Companion.Post; | |
$receiver_2.body = new FormDataContent(this.local$formData); | |
} | |
url_1($receiver_2, this.local$url); | |
this.local$block($receiver_2); | |
this.state_0 = 2; | |
this.result_0 = call_0(this.local$$receiver, $receiver_2, this); | |
if (this.result_0 === COROUTINE_SUSPENDED) | |
return COROUTINE_SUSPENDED; | |
continue; | |
case 1: | |
throw this.exception_0; | |
case 2: | |
var tmp$_0; | |
this.state_0 = 3; | |
this.result_0 = this.result_0.receive_jo9acv$(new TypeInfo(getKClass(this.local$T_0), package$call.JsType), this); | |
if (this.result_0 === COROUTINE_SUSPENDED) | |
return COROUTINE_SUSPENDED; | |
continue; | |
case 3: | |
this.result_0 = this.local$isT(tmp$_0 = this.result_0) ? tmp$_0 : throwCCE(); | |
return this.result_0; | |
default: | |
this.state_0 = 1; | |
throw new Error('State Machine Unreachable execution'); | |
} | |
} catch (e) { | |
if (this.state_0 === 1) { | |
this.exceptionState_0 = this.state_0; | |
throw e; | |
} else { | |
this.state_0 = this.exceptionState_0; | |
this.exception_0 = e; | |
} | |
} while (true); | |
}; | |
function submitForm_0(T_0, isT, $receiver_1, url_1, formData, encodeInQuery, block, continuation, suspended) { | |
var instance = new Coroutine$submitForm_0(T_0, isT, $receiver_1, url_1, formData, encodeInQuery, block, continuation); | |
if (suspended) | |
return instance; | |
else | |
return instance.doResume(null); | |
} | |
defineInlineFunction('ktor-client-core.io.ktor.client.request.forms.submitForm_32veqj$', wrapFunction(function() { | |
var Parameters = _.$$importsForInline$$['ktor-http'].io.ktor.http.Parameters; | |
var Unit = Kotlin.kotlin.Unit; | |
var url = _.io.ktor.client.request.url_g8iu3v$; | |
function submitForm$lambda($receiver) { | |
return Unit; | |
} | |
var HttpMethod = _.$$importsForInline$$['ktor-http'].io.ktor.http.HttpMethod; | |
var FormDataContent_init = _.io.ktor.client.request.forms.FormDataContent; | |
var HttpRequestBuilder_init = _.io.ktor.client.request.HttpRequestBuilder; | |
var call = _.io.ktor.client.call.call_30bfl5$; | |
var throwCCE = Kotlin.throwCCE; | |
var getKClass = Kotlin.getKClass; | |
var call_0 = _.io.ktor.client.call; | |
var TypeInfo_init = _.io.ktor.client.call.TypeInfo; | |
return function(T_0, isT, $receiver_1, url_1, formData, encodeInQuery, block, continuation) { | |
if (formData === void 0) | |
formData = Parameters.Companion.Empty; | |
if (encodeInQuery === void 0) | |
encodeInQuery = false; | |
if (block === void 0) | |
block = submitForm$lambda; | |
var $receiver_2 = new HttpRequestBuilder_init(); | |
if (encodeInQuery) { | |
$receiver_2.method = HttpMethod.Companion.Get; | |
$receiver_2.url.parameters.appendAll_hb0ubp$(formData); | |
} else { | |
$receiver_2.method = HttpMethod.Companion.Post; | |
$receiver_2.body = new FormDataContent_init(formData); | |
} | |
url($receiver_2, url_1); | |
block($receiver_2); | |
Kotlin.suspendCall(call($receiver_1, $receiver_2, Kotlin.coroutineReceiver())); | |
var tmp$_0; | |
Kotlin.suspendCall(Kotlin.coroutineResult(Kotlin.coroutineReceiver()).receive_jo9acv$(new TypeInfo_init(getKClass(T_0), call_0.JsType), Kotlin.coroutineReceiver())); | |
Kotlin.setCoroutineResult(isT(tmp$_0 = Kotlin.coroutineResult(Kotlin.coroutineReceiver())) ? tmp$_0 : throwCCE(), Kotlin.coroutineReceiver()); | |
return Kotlin.coroutineResult(Kotlin.coroutineReceiver()); | |
}; | |
})); | |
function submitFormWithBinaryData$lambda($receiver) { | |
return Unit; | |
} | |
function Coroutine$submitFormWithBinaryData(T_0, isT, $receiver_1, formData, block, continuation) { | |
CoroutineImpl.call(this, continuation); | |
this.exceptionState_0 = 1; | |
this.local$T_0 = T_0; | |
this.local$isT = isT; | |
this.local$$receiver = $receiver_1; | |
this.local$formData = formData; | |
this.local$block = block; | |
} | |
Coroutine$submitFormWithBinaryData.$metadata$ = { | |
kind: Kotlin.Kind.CLASS, | |
simpleName: null, | |
interfaces: [CoroutineImpl]}; | |
Coroutine$submitFormWithBinaryData.prototype = Object.create(CoroutineImpl.prototype); | |
Coroutine$submitFormWithBinaryData.prototype.constructor = Coroutine$submitFormWithBinaryData; | |
Coroutine$submitFormWithBinaryData.prototype.doResume = function() { | |
do try { | |
switch (this.state_0) { | |
case 0: | |
if (this.local$block === void 0) | |
this.local$block = submitFormWithBinaryData$lambda; | |
var $receiver_2 = new HttpRequestBuilder(); | |
$receiver_2.method = HttpMethod.Companion.Post; | |
$receiver_2.body = new MultiPartFormDataContent(this.local$formData); | |
this.local$block($receiver_2); | |
this.state_0 = 2; | |
this.result_0 = call_0(this.local$$receiver, $receiver_2, this); | |
if (this.result_0 === COROUTINE_SUSPENDED) | |
return COROUTINE_SUSPENDED; | |
continue; | |
case 1: | |
throw this.exception_0; | |
case 2: | |
var tmp$_0; | |
this.state_0 = 3; | |
this.result_0 = this.result_0.receive_jo9acv$(new TypeInfo(getKClass(this.local$T_0), package$call.JsType), this); | |
if (this.result_0 === COROUTINE_SUSPENDED) | |
return COROUTINE_SUSPENDED; | |
continue; | |
case 3: | |
this.result_0 = this.local$isT(tmp$_0 = this.result_0) ? tmp$_0 : throwCCE(); | |
return this.result_0; | |
default: | |
this.state_0 = 1; | |
throw new Error('State Machine Unreachable execution'); | |
} | |
} catch (e) { | |
if (this.state_0 === 1) { | |
this.exceptionState_0 = this.state_0; | |
throw e; | |
} else { | |
this.state_0 = this.exceptionState_0; | |
this.exception_0 = e; | |
} | |
} while (true); | |
}; | |
function submitFormWithBinaryData(T_0, isT, $receiver_1, formData, block, continuation, suspended) { | |
var instance = new Coroutine$submitFormWithBinaryData(T_0, isT, $receiver_1, formData, block, continuation); | |
if (suspended) | |
return instance; | |
else | |
return instance.doResume(null); | |
} | |
defineInlineFunction('ktor-client-core.io.ktor.client.request.forms.submitFormWithBinaryData_k1tmp5$', wrapFunction(function() { | |
var Unit = Kotlin.kotlin.Unit; | |
var HttpMethod = _.$$importsForInline$$['ktor-http'].io.ktor.http.HttpMethod; | |
var MultiPartFormDataContent_init = _.io.ktor.client.request.forms.MultiPartFormDataContent; | |
function submitFormWithBinaryData$lambda($receiver) { | |
return Unit; | |
} | |
var HttpRequestBuilder_init = _.io.ktor.client.request.HttpRequestBuilder; | |
var call = _.io.ktor.client.call.call_30bfl5$; | |
var throwCCE = Kotlin.throwCCE; | |
var getKClass = Kotlin.getKClass; | |
var call_0 = _.io.ktor.client.call; | |
var TypeInfo_init = _.io.ktor.client.call.TypeInfo; | |
return function(T_0, isT, $receiver_1, formData, block, continuation) { | |
if (block === void 0) | |
block = submitFormWithBinaryData$lambda; | |
var $receiver_2 = new HttpRequestBuilder_init(); | |
$receiver_2.method = HttpMethod.Companion.Post; | |
$receiver_2.body = new MultiPartFormDataContent_init(formData); | |
block($receiver_2); | |
Kotlin.suspendCall(call($receiver_1, $receiver_2, Kotlin.coroutineReceiver())); | |
var tmp$_0; | |
Kotlin.suspendCall(Kotlin.coroutineResult(Kotlin.coroutineReceiver()).receive_jo9acv$(new TypeInfo_init(getKClass(T_0), call_0.JsType), Kotlin.coroutineReceiver())); | |
Kotlin.setCoroutineResult(isT(tmp$_0 = Kotlin.coroutineResult(Kotlin.coroutineReceiver())) ? tmp$_0 : throwCCE(), Kotlin.coroutineReceiver()); | |
return Kotlin.coroutineResult(Kotlin.coroutineReceiver()); | |
}; | |
})); | |
function submitFormWithBinaryData$lambda_0($receiver) { | |
return Unit; | |
} | |
function Coroutine$submitFormWithBinaryData_0(T_0, isT, $receiver_1, url_1, formData, block, continuation) { | |
CoroutineImpl.call(this, continuation); | |
this.exceptionState_0 = 1; | |
this.local$T_0 = T_0; | |
this.local$isT = isT; | |
this.local$$receiver = $receiver_1; | |
this.local$url = url_1; | |
this.local$formData = formData; | |
this.local$block = block; | |
} | |
Coroutine$submitFormWithBinaryData_0.$metadata$ = { | |
kind: Kotlin.Kind.CLASS, | |
simpleName: null, | |
interfaces: [CoroutineImpl]}; | |
Coroutine$submitFormWithBinaryData_0.prototype = Object.create(CoroutineImpl.prototype); | |
Coroutine$submitFormWithBinaryData_0.prototype.constructor = Coroutine$submitFormWithBinaryData_0; | |
Coroutine$submitFormWithBinaryData_0.prototype.doResume = function() { | |
do try { | |
switch (this.state_0) { | |
case 0: | |
if (this.local$block === void 0) | |
this.local$block = submitFormWithBinaryData$lambda_0; | |
var $receiver_2 = new HttpRequestBuilder(); | |
$receiver_2.method = HttpMethod.Companion.Post; | |
$receiver_2.body = new MultiPartFormDataContent(this.local$formData); | |
url_1($receiver_2, this.local$url); | |
this.local$block($receiver_2); | |
this.state_0 = 2; | |
this.result_0 = call_0(this.local$$receiver, $receiver_2, this); | |
if (this.result_0 === COROUTINE_SUSPENDED) | |
return COROUTINE_SUSPENDED; | |
continue; | |
case 1: | |
throw this.exception_0; | |
case 2: | |
var tmp$_0; | |
this.state_0 = 3; | |
this.result_0 = this.result_0.receive_jo9acv$(new TypeInfo(getKClass(this.local$T_0), package$call.JsType), this); | |
if (this.result_0 === COROUTINE_SUSPENDED) | |
return COROUTINE_SUSPENDED; | |
continue; | |
case 3: | |
this.result_0 = this.local$isT(tmp$_0 = this.result_0) ? tmp$_0 : throwCCE(); | |
return this.result_0; | |
default: | |
this.state_0 = 1; | |
throw new Error('State Machine Unreachable execution'); | |
} | |
} catch (e) { | |
if (this.state_0 === 1) { | |
this.exceptionState_0 = this.state_0; | |
throw e; | |
} else { | |
this.state_0 = this.exceptionState_0; | |
this.exception_0 = e; | |
} | |
} while (true); | |
}; | |
function submitFormWithBinaryData_0(T_0, isT, $receiver_1, url_1, formData, block, continuation, suspended) { | |
var instance = new Coroutine$submitFormWithBinaryData_0(T_0, isT, $receiver_1, url_1, formData, block, continuation); | |
if (suspended) | |
return instance; | |
else | |
return instance.doResume(null); | |
} | |
defineInlineFunction('ktor-client-core.io.ktor.client.request.forms.submitFormWithBinaryData_i2k1l1$', wrapFunction(function() { | |
var Unit = Kotlin.kotlin.Unit; | |
var url = _.io.ktor.client.request.url_g8iu3v$; | |
function submitFormWithBinaryData$lambda($receiver) { | |
return Unit; | |
} | |
var HttpMethod = _.$$importsForInline$$['ktor-http'].io.ktor.http.HttpMethod; | |
var MultiPartFormDataContent_init = _.io.ktor.client.request.forms.MultiPartFormDataContent; | |
var HttpRequestBuilder_init = _.io.ktor.client.request.HttpRequestBuilder; | |
var call = _.io.ktor.client.call.call_30bfl5$; | |
var throwCCE = Kotlin.throwCCE; | |
var getKClass = Kotlin.getKClass; | |
var call_0 = _.io.ktor.client.call; | |
var TypeInfo_init = _.io.ktor.client.call.TypeInfo; | |
return function(T_0, isT, $receiver_1, url_1, formData, block, continuation) { | |
if (block === void 0) | |
block = submitFormWithBinaryData$lambda; | |
var $receiver_2 = new HttpRequestBuilder_init(); | |
$receiver_2.method = HttpMethod.Companion.Post; | |
$receiver_2.body = new MultiPartFormDataContent_init(formData); | |
url($receiver_2, url_1); | |
block($receiver_2); | |
Kotlin.suspendCall(call($receiver_1, $receiver_2, Kotlin.coroutineReceiver())); | |
var tmp$_0; | |
Kotlin.suspendCall(Kotlin.coroutineResult(Kotlin.coroutineReceiver()).receive_jo9acv$(new TypeInfo_init(getKClass(T_0), call_0.JsType), Kotlin.coroutineReceiver())); | |
Kotlin.setCoroutineResult(isT(tmp$_0 = Kotlin.coroutineResult(Kotlin.coroutineReceiver())) ? tmp$_0 : throwCCE(), Kotlin.coroutineReceiver()); | |
return Kotlin.coroutineResult(Kotlin.coroutineReceiver()); | |
}; | |
})); | |
function submitForm$lambda_1($receiver) { | |
return Unit; | |
} | |
function Coroutine$submitForm_1(T_0, isT, $receiver_1, scheme, host, port, path, formData, encodeInQuery, block, continuation) { | |
CoroutineImpl.call(this, continuation); | |
this.exceptionState_0 = 1; | |
this.local$T_0 = T_0; | |
this.local$isT = isT; | |
this.local$$receiver = $receiver_1; | |
this.local$scheme = scheme; | |
this.local$host = host; | |
this.local$port = port; | |
this.local$path = path; | |
this.local$formData = formData; | |
this.local$encodeInQuery = encodeInQuery; | |
this.local$block = block; | |
} | |
Coroutine$submitForm_1.$metadata$ = { | |
kind: Kotlin.Kind.CLASS, | |
simpleName: null, | |
interfaces: [CoroutineImpl]}; | |
Coroutine$submitForm_1.prototype = Object.create(CoroutineImpl.prototype); | |
Coroutine$submitForm_1.prototype.constructor = Coroutine$submitForm_1; | |
Coroutine$submitForm_1.prototype.doResume = function() { | |
do try { | |
switch (this.state_0) { | |
case 0: | |
if (this.local$scheme === void 0) | |
this.local$scheme = 'http'; | |
if (this.local$host === void 0) | |
this.local$host = 'localhost'; | |
if (this.local$port === void 0) | |
this.local$port = 80; | |
if (this.local$path === void 0) | |
this.local$path = '/'; | |
if (this.local$formData === void 0) | |
this.local$formData = Parameters.Companion.Empty; | |
if (this.local$encodeInQuery === void 0) | |
this.local$encodeInQuery = false; | |
if (this.local$block === void 0) | |
this.local$block = submitForm$lambda_1; | |
var $receiver_2 = new HttpRequestBuilder(); | |
if (this.local$encodeInQuery) { | |
$receiver_2.method = HttpMethod.Companion.Get; | |
$receiver_2.url.parameters.appendAll_hb0ubp$(this.local$formData); | |
} else { | |
$receiver_2.method = HttpMethod.Companion.Post; | |
$receiver_2.body = new FormDataContent(this.local$formData); | |
} | |
url_0($receiver_2, this.local$scheme, this.local$host, this.local$port, this.local$path); | |
this.local$block($receiver_2); | |
this.state_0 = 2; | |
this.result_0 = call_0(this.local$$receiver, $receiver_2, this); | |
if (this.result_0 === COROUTINE_SUSPENDED) | |
return COROUTINE_SUSPENDED; | |
continue; | |
case 1: | |
throw this.exception_0; | |
case 2: | |
var tmp$_0; | |
this.state_0 = 3; | |
this.result_0 = this.result_0.receive_jo9acv$(new TypeInfo(getKClass(this.local$T_0), package$call.JsType), this); | |
if (this.result_0 === COROUTINE_SUSPENDED) | |
return COROUTINE_SUSPENDED; | |
continue; | |
case 3: | |
this.result_0 = this.local$isT(tmp$_0 = this.result_0) ? tmp$_0 : throwCCE(); | |
return this.result_0; | |
default: | |
this.state_0 = 1; | |
throw new Error('State Machine Unreachable execution'); | |
} | |
} catch (e) { | |
if (this.state_0 === 1) { | |
this.exceptionState_0 = this.state_0; | |
throw e; | |
} else { | |
this.state_0 = this.exceptionState_0; | |
this.exception_0 = e; | |
} | |
} while (true); | |
}; | |
function submitForm_1(T_0, isT, $receiver_1, scheme, host, port, path, formData, encodeInQuery, block, continuation, suspended) { | |
var instance = new Coroutine$submitForm_1(T_0, isT, $receiver_1, scheme, host, port, path, formData, encodeInQuery, block, continuation); | |
if (suspended) | |
return instance; | |
else | |
return instance.doResume(null); | |
} | |
defineInlineFunction('ktor-client-core.io.ktor.client.request.forms.submitForm_ejo4ot$', wrapFunction(function() { | |
var Parameters = _.$$importsForInline$$['ktor-http'].io.ktor.http.Parameters; | |
var Unit = Kotlin.kotlin.Unit; | |
var url = _.io.ktor.client.request.url_3rzbk2$; | |
function submitForm$lambda($receiver) { | |
return Unit; | |
} | |
var HttpMethod = _.$$importsForInline$$['ktor-http'].io.ktor.http.HttpMethod; | |
var FormDataContent_init = _.io.ktor.client.request.forms.FormDataContent; | |
var HttpRequestBuilder_init = _.io.ktor.client.request.HttpRequestBuilder; | |
var call = _.io.ktor.client.call.call_30bfl5$; | |
var throwCCE = Kotlin.throwCCE; | |
var getKClass = Kotlin.getKClass; | |
var call_0 = _.io.ktor.client.call; | |
var TypeInfo_init = _.io.ktor.client.call.TypeInfo; | |
return function(T_0, isT, $receiver_1, scheme, host, port, path, formData, encodeInQuery, block, continuation) { | |
if (scheme === void 0) | |
scheme = 'http'; | |
if (host === void 0) | |
host = 'localhost'; | |
if (port === void 0) | |
port = 80; | |
if (path === void 0) | |
path = '/'; | |
if (formData === void 0) | |
formData = Parameters.Companion.Empty; | |
if (encodeInQuery === void 0) | |
encodeInQuery = false; | |
if (block === void 0) | |
block = submitForm$lambda; | |
var $receiver_2 = new HttpRequestBuilder_init(); | |
if (encodeInQuery) { | |
$receiver_2.method = HttpMethod.Companion.Get; | |
$receiver_2.url.parameters.appendAll_hb0ubp$(formData); | |
} else { | |
$receiver_2.method = HttpMethod.Companion.Post; | |
$receiver_2.body = new FormDataContent_init(formData); | |
} | |
url($receiver_2, scheme, host, port, path); | |
block($receiver_2); | |
Kotlin.suspendCall(call($receiver_1, $receiver_2, Kotlin.coroutineReceiver())); | |
var tmp$_0; | |
Kotlin.suspendCall(Kotlin.coroutineResult(Kotlin.coroutineReceiver()).receive_jo9acv$(new TypeInfo_init(getKClass(T_0), call_0.JsType), Kotlin.coroutineReceiver())); | |
Kotlin.setCoroutineResult(isT(tmp$_0 = Kotlin.coroutineResult(Kotlin.coroutineReceiver())) ? tmp$_0 : throwCCE(), Kotlin.coroutineReceiver()); | |
return Kotlin.coroutineResult(Kotlin.coroutineReceiver()); | |
}; | |
})); | |
function submitFormWithBinaryData$lambda_1($receiver) { | |
return Unit; | |
} | |
function Coroutine$submitFormWithBinaryData_1(T_0, isT, $receiver_1, scheme, host, port, path, formData, block, continuation) { | |
CoroutineImpl.call(this, continuation); | |
this.exceptionState_0 = 1; | |
this.local$T_0 = T_0; | |
this.local$isT = isT; | |
this.local$$receiver = $receiver_1; | |
this.local$scheme = scheme; | |
this.local$host = host; | |
this.local$port = port; | |
this.local$path = path; | |
this.local$formData = formData; | |
this.local$block = block; | |
} | |
Coroutine$submitFormWithBinaryData_1.$metadata$ = { | |
kind: Kotlin.Kind.CLASS, | |
simpleName: null, | |
interfaces: [CoroutineImpl]}; | |
Coroutine$submitFormWithBinaryData_1.prototype = Object.create(CoroutineImpl.prototype); | |
Coroutine$submitFormWithBinaryData_1.prototype.constructor = Coroutine$submitFormWithBinaryData_1; | |
Coroutine$submitFormWithBinaryData_1.prototype.doResume = function() { | |
do try { | |
switch (this.state_0) { | |
case 0: | |
if (this.local$scheme === void 0) | |
this.local$scheme = 'http'; | |
if (this.local$host === void 0) | |
this.local$host = 'localhost'; | |
if (this.local$port === void 0) | |
this.local$port = 80; | |
if (this.local$path === void 0) | |
this.local$path = '/'; | |
if (this.local$formData === void 0) | |
this.local$formData = emptyList(); | |
if (this.local$block === void 0) | |
this.local$block = submitFormWithBinaryData$lambda_1; | |
var $receiver_2 = new HttpRequestBuilder(); | |
$receiver_2.method = HttpMethod.Companion.Post; | |
$receiver_2.body = new MultiPartFormDataContent(this.local$formData); | |
url_0($receiver_2, this.local$scheme, this.local$host, this.local$port, this.local$path); | |
this.local$block($receiver_2); | |
this.state_0 = 2; | |
this.result_0 = call_0(this.local$$receiver, $receiver_2, this); | |
if (this.result_0 === COROUTINE_SUSPENDED) | |
return COROUTINE_SUSPENDED; | |
continue; | |
case 1: | |
throw this.exception_0; | |
case 2: | |
var tmp$_0; | |
this.state_0 = 3; | |
this.result_0 = this.result_0.receive_jo9acv$(new TypeInfo(getKClass(this.local$T_0), package$call.JsType), this); | |
if (this.result_0 === COROUTINE_SUSPENDED) | |
return COROUTINE_SUSPENDED; | |
continue; | |
case 3: | |
this.result_0 = this.local$isT(tmp$_0 = this.result_0) ? tmp$_0 : throwCCE(); | |
return this.result_0; | |
default: | |
this.state_0 = 1; | |
throw new Error('State Machine Unreachable execution'); | |
} | |
} catch (e) { | |
if (this.state_0 === 1) { | |
this.exceptionState_0 = this.state_0; | |
throw e; | |
} else { | |
this.state_0 = this.exceptionState_0; | |
this.exception_0 = e; | |
} | |
} while (true); | |
}; | |
function submitFormWithBinaryData_1(T_0, isT, $receiver_1, scheme, host, port, path, formData, block, continuation, suspended) { | |
var instance = new Coroutine$submitFormWithBinaryData_1(T_0, isT, $receiver_1, scheme, host, port, path, formData, block, continuation); | |
if (suspended) | |
return instance; | |
else | |
return instance.doResume(null); | |
} | |
defineInlineFunction('ktor-client-core.io.ktor.client.request.forms.submitFormWithBinaryData_vcnbbn$', wrapFunction(function() { | |
var emptyList = Kotlin.kotlin.collections.emptyList_287e2$; | |
var Unit = Kotlin.kotlin.Unit; | |
var url = _.io.ktor.client.request.url_3rzbk2$; | |
function submitFormWithBinaryData$lambda($receiver) { | |
return Unit; | |
} | |
var HttpMethod = _.$$importsForInline$$['ktor-http'].io.ktor.http.HttpMethod; | |
var MultiPartFormDataContent_init = _.io.ktor.client.request.forms.MultiPartFormDataContent; | |
var HttpRequestBuilder_init = _.io.ktor.client.request.HttpRequestBuilder; | |
var call = _.io.ktor.client.call.call_30bfl5$; | |
var throwCCE = Kotlin.throwCCE; | |
var getKClass = Kotlin.getKClass; | |
var call_0 = _.io.ktor.client.call; | |
var TypeInfo_init = _.io.ktor.client.call.TypeInfo; | |
return function(T_0, isT, $receiver_1, scheme, host, port, path, formData, block, continuation) { | |
if (scheme === void 0) | |
scheme = 'http'; | |
if (host === void 0) | |
host = 'localhost'; | |
if (port === void 0) | |
port = 80; | |
if (path === void 0) | |
path = '/'; | |
if (formData === void 0) | |
formData = emptyList(); | |
if (block === void 0) | |
block = submitFormWithBinaryData$lambda; | |
var $receiver_2 = new HttpRequestBuilder_init(); | |
$receiver_2.method = HttpMethod.Companion.Post; | |
$receiver_2.body = new MultiPartFormDataContent_init(formData); | |
url($receiver_2, scheme, host, port, path); | |
block($receiver_2); | |
Kotlin.suspendCall(call($receiver_1, $receiver_2, Kotlin.coroutineReceiver())); | |
var tmp$_0; | |
Kotlin.suspendCall(Kotlin.coroutineResult(Kotlin.coroutineReceiver()).receive_jo9acv$(new TypeInfo_init(getKClass(T_0), call_0.JsType), Kotlin.coroutineReceiver())); | |
Kotlin.setCoroutineResult(isT(tmp$_0 = Kotlin.coroutineResult(Kotlin.coroutineReceiver())) ? tmp$_0 : throwCCE(), Kotlin.coroutineReceiver()); | |
return Kotlin.coroutineResult(Kotlin.coroutineReceiver()); | |
}; | |
})); | |
function FormPart(key, value, headers) { | |
if (headers === void 0) | |
headers = Headers.Companion.Empty; | |
this.key = key; | |
this.value = value; | |
this.headers = headers; | |
} | |
FormPart.$metadata$ = { | |
kind: Kind_CLASS, | |
simpleName: 'FormPart', | |
interfaces: []}; | |
FormPart.prototype.component1 = function() { | |
return this.key; | |
}; | |
FormPart.prototype.component2 = function() { | |
return this.value; | |
}; | |
FormPart.prototype.component3 = function() { | |
return this.headers; | |
}; | |
FormPart.prototype.copy_gtfma3$ = function(key, value, headers) { | |
return new FormPart(key === void 0 ? this.key : key, value === void 0 ? this.value : value, headers === void 0 ? this.headers : headers); | |
}; | |
FormPart.prototype.toString = function() { | |
return 'FormPart(key=' + Kotlin.toString(this.key) + (', value=' + Kotlin.toString(this.value)) + (', headers=' + Kotlin.toString(this.headers)) + ')'; | |
}; | |
FormPart.prototype.hashCode = function() { | |
var result = 0; | |
result = result * 31 + Kotlin.hashCode(this.key) | 0; | |
result = result * 31 + Kotlin.hashCode(this.value) | 0; | |
result = result * 31 + Kotlin.hashCode(this.headers) | 0; | |
return result; | |
}; | |
FormPart.prototype.equals = function(other) { | |
return this === other || (other !== null && (typeof other === 'object' && (Object.getPrototypeOf(this) === Object.getPrototypeOf(other) && (Kotlin.equals(this.key, other.key) && Kotlin.equals(this.value, other.value) && Kotlin.equals(this.headers, other.headers))))); | |
}; | |
function formData$lambda$lambda() { | |
return Unit; | |
} | |
function formData$lambda$lambda_0() { | |
return Unit; | |
} | |
var BytePacketBuilder = $module$kotlinx_io.kotlinx.io.core.BytePacketBuilder_za3lpa$; | |
function formData$lambda$lambda_1(closure$value) { | |
return function() { | |
var buildPacket$result; | |
var builder = BytePacketBuilder(0); | |
try { | |
writeFully_0(builder, closure$value); | |
buildPacket$result = builder.build(); | |
} catch (t) { | |
if (Kotlin.isType(t, Throwable)) { | |
builder.release(); | |
throw t; | |
} else | |
throw t; | |
} | |
return buildPacket$result; | |
}; | |
} | |
function formData$lambda$lambda_2() { | |
return Unit; | |
} | |
function formData$lambda$lambda_3(closure$value) { | |
return function() { | |
return closure$value; | |
}; | |
} | |
function formData$lambda$lambda_4() { | |
return Unit; | |
} | |
function formData(values) { | |
var result = ArrayList_init(); | |
var tmp$; | |
for (tmp$ = 0; tmp$ !== values.length; ++tmp$) { | |
var element = values[tmp$]; | |
var key = element.component1(), value = element.component2(), headers = element.component3(); | |
var tmp$_0; | |
var $receiver = new HeadersBuilder(); | |
$receiver.append_puj7f4$(http.HttpHeaders.ContentDisposition, 'form-data;name=' + key); | |
$receiver.appendAll_hb0ubp$(headers); | |
var partHeaders = $receiver.build(); | |
if (typeof value === 'string') | |
tmp$_0 = new PartData$FormItem(value, formData$lambda$lambda, partHeaders); | |
else if (Kotlin.isNumber(value)) | |
tmp$_0 = new PartData$FormItem(value.toString(), formData$lambda$lambda_0, partHeaders); | |
else if (Kotlin.isByteArray(value)) | |
tmp$_0 = new PartData$BinaryItem(formData$lambda$lambda_1(value), formData$lambda$lambda_2, partHeaders); | |
else if (Kotlin.isType(value, Input)) | |
tmp$_0 = new PartData$BinaryItem(formData$lambda$lambda_3(value), formData$lambda$lambda_4, partHeaders); | |
else { | |
throw IllegalStateException_init_0(('Unknown form content type: ' + value.toString()).toString()); | |
} | |
var part = tmp$_0; | |
result.add_11rb$(part); | |
} | |
return result; | |
} | |
var copyToArray = Kotlin.kotlin.collections.copyToArray; | |
function formData_0(block) { | |
var $receiver = new FormBuilder(); | |
block($receiver); | |
return formData(copyToArray($receiver.build_8be2vx$()).slice()); | |
} | |
function FormBuilder() { | |
this.parts_0 = ArrayList_init(); | |
} | |
FormBuilder.prototype.append_53xmxh$ = function(key, value, headers) { | |
if (headers === void 0) | |
headers = Headers.Companion.Empty; | |
var $receiver = this.parts_0; | |
var element = new FormPart(key, value, headers); | |
$receiver.add_11rb$(element); | |
}; | |
FormBuilder.prototype.append_ith9wd$ = function(part) { | |
this.parts_0.add_11rb$(part); | |
}; | |
FormBuilder.prototype.build_8be2vx$ = function() { | |
return this.parts_0; | |
}; | |
FormBuilder.$metadata$ = { | |
kind: Kind_CLASS, | |
simpleName: 'FormBuilder', | |
interfaces: []}; | |
var append = defineInlineFunction('ktor-client-core.io.ktor.client.request.forms.append_cnwqbb$', wrapFunction(function() { | |
var Headers = _.$$importsForInline$$['ktor-http'].io.ktor.http.Headers; | |
var FormPart_init = _.io.ktor.client.request.forms.FormPart; | |
var BytePacketBuilder = _.$$importsForInline$$['kotlinx-io'].kotlinx.io.core.BytePacketBuilder_za3lpa$; | |
var Throwable = Error; | |
return function($receiver, key, headers, bodyBuilder) { | |
if (headers === void 0) | |
headers = Headers.Companion.Empty; | |
var buildPacket$result; | |
var builder = BytePacketBuilder(0); | |
try { | |
bodyBuilder(builder); | |
buildPacket$result = builder.build(); | |
} catch (t) { | |
if (Kotlin.isType(t, Throwable)) { | |
builder.release(); | |
throw t; | |
} else | |
throw t; | |
} | |
$receiver.append_ith9wd$(new FormPart_init(key, buildPacket$result, headers)); | |
}; | |
})); | |
function append_0($receiver, key, filename, contentType, bodyBuilder) { | |
if (contentType === void 0) | |
contentType = null; | |
var headersBuilder = new HeadersBuilder(); | |
headersBuilder.set_puj7f4$(http.HttpHeaders.ContentDisposition, 'filename=' + filename); | |
if (contentType != null) { | |
headersBuilder.set_puj7f4$(http.HttpHeaders.ContentType, contentType.toString()); | |
} | |
var headers = headersBuilder.build(); | |
var buildPacket$result; | |
var builder = BytePacketBuilder(0); | |
try { | |
bodyBuilder(builder); | |
buildPacket$result = builder.build(); | |
} catch (t) { | |
if (Kotlin.isType(t, Throwable)) { | |
builder.release(); | |
throw t; | |
} else | |
throw t; | |
} | |
$receiver.append_ith9wd$(new FormPart(key, buildPacket$result, headers)); | |
} | |
function get_host($receiver) { | |
return $receiver.url.host; | |
} | |
function set_host($receiver, value) { | |
$receiver.url.host = value; | |
} | |
function get_port($receiver) { | |
return $receiver.url.port; | |
} | |
function set_port($receiver, value) { | |
$receiver.url.port = value; | |
} | |
function header($receiver, key, value) { | |
var tmp$; | |
var tmp$_0; | |
if (value != null) { | |
$receiver.headers.append_puj7f4$(key, value.toString()); | |
tmp$_0 = Unit; | |
} else | |
tmp$_0 = null; | |
(tmp$ = tmp$_0) != null ? tmp$ : Unit; | |
} | |
function parameter($receiver, key, value) { | |
var tmp$; | |
var tmp$_0; | |
if (value != null) { | |
$receiver.url.parameters.append_puj7f4$(key, value.toString()); | |
tmp$_0 = Unit; | |
} else | |
tmp$_0 = null; | |
(tmp$ = tmp$_0) != null ? tmp$ : Unit; | |
} | |
function accept($receiver, contentType) { | |
$receiver.headers.append_puj7f4$(http.HttpHeaders.Accept, contentType.toString()); | |
} | |
function HttpResponse() { | |
} | |
Object.defineProperty(HttpResponse.prototype, 'executionContext', { | |
get: function() { | |
return ensureNotNull(this.coroutineContext.get_j3r2sn$(Job.Key)); | |
}}); | |
HttpResponse.prototype.close = function() { | |
var tmp$; | |
(Kotlin.isType(tmp$ = this.coroutineContext.get_j3r2sn$(Job.Key), CompletableDeferred) ? tmp$ : throwCCE()).complete_11rb$(Unit); | |
}; | |
HttpResponse.$metadata$ = { | |
kind: Kind_INTERFACE, | |
simpleName: 'HttpResponse', | |
interfaces: [Closeable, CoroutineScope, HttpMessage]}; | |
function Coroutine$readText($receiver_0, charset_0, continuation_0) { | |
CoroutineImpl.call(this, continuation_0); | |
this.exceptionState_0 = 1; | |
this.local$$receiver = $receiver_0; | |
this.local$charset = charset_0; | |
} | |
Coroutine$readText.$metadata$ = { | |
kind: Kotlin.Kind.CLASS, | |
simpleName: null, | |
interfaces: [CoroutineImpl]}; | |
Coroutine$readText.prototype = Object.create(CoroutineImpl.prototype); | |
Coroutine$readText.prototype.constructor = Coroutine$readText; | |
Coroutine$readText.prototype.doResume = function() { | |
do try { | |
switch (this.state_0) { | |
case 0: | |
if (this.local$charset === void 0) | |
this.local$charset = null; | |
var tmp$, tmp$_0; | |
this.state_0 = 2; | |
this.result_0 = readRemaining(this.local$$receiver.content, Long$Companion$MAX_VALUE, this); | |
if (this.result_0 === COROUTINE_SUSPENDED) | |
return COROUTINE_SUSPENDED; | |
continue; | |
case 1: | |
throw this.exception_0; | |
case 2: | |
var packet = this.result_0; | |
var actualCharset = (tmp$_0 = (tmp$ = charset(this.local$$receiver)) != null ? tmp$ : this.local$charset) != null ? tmp$_0 : this.local$$receiver.call.responseConfig.defaultCharset; | |
return readText(packet, actualCharset); | |
default: | |
this.state_0 = 1; | |
throw new Error('State Machine Unreachable execution'); | |
} | |
} catch (e) { | |
if (this.state_0 === 1) { | |
this.exceptionState_0 = this.state_0; | |
throw e; | |
} else { | |
this.state_0 = this.exceptionState_0; | |
this.exception_0 = e; | |
} | |
} while (true); | |
}; | |
function readText_0($receiver_0, charset_0, continuation_0, suspended) { | |
var instance = new Coroutine$readText($receiver_0, charset_0, continuation_0); | |
if (suspended) | |
return instance; | |
else | |
return instance.doResume(null); | |
} | |
function HttpResponseConfig() { | |
var tmp$; | |
try { | |
tmp$ = Charset.Companion.forName_61zpoe$('ISO_8859_1'); | |
} catch (_) { | |
if (Kotlin.isType(_, Throwable)) { | |
tmp$ = charsets.Charsets.UTF_8; | |
} else | |
throw _; | |
} | |
this.defaultCharset = tmp$; | |
} | |
HttpResponseConfig.$metadata$ = { | |
kind: Kind_CLASS, | |
simpleName: 'HttpResponseConfig', | |
interfaces: []}; | |
function HttpResponsePipeline() { | |
HttpResponsePipeline$Phases_getInstance(); | |
Pipeline.call(this, [HttpResponsePipeline$Phases_getInstance().Receive, HttpResponsePipeline$Phases_getInstance().Parse, HttpResponsePipeline$Phases_getInstance().Transform, HttpResponsePipeline$Phases_getInstance().State, HttpResponsePipeline$Phases_getInstance().After]); | |
} | |
function HttpResponsePipeline$Phases() { | |
HttpResponsePipeline$Phases_instance = this; | |
this.Receive = new PipelinePhase('Receive'); | |
this.Parse = new PipelinePhase('Parse'); | |
this.Transform = new PipelinePhase('Transform'); | |
this.State = new PipelinePhase('State'); | |
this.After = new PipelinePhase('After'); | |
} | |
HttpResponsePipeline$Phases.$metadata$ = { | |
kind: Kind_OBJECT, | |
simpleName: 'Phases', | |
interfaces: []}; | |
var HttpResponsePipeline$Phases_instance = null; | |
function HttpResponsePipeline$Phases_getInstance() { | |
if (HttpResponsePipeline$Phases_instance === null) { | |
new HttpResponsePipeline$Phases(); | |
} | |
return HttpResponsePipeline$Phases_instance; | |
} | |
HttpResponsePipeline.$metadata$ = { | |
kind: Kind_CLASS, | |
simpleName: 'HttpResponsePipeline', | |
interfaces: [Pipeline]}; | |
function HttpReceivePipeline() { | |
HttpReceivePipeline$Phases_getInstance(); | |
Pipeline.call(this, [HttpReceivePipeline$Phases_getInstance().Before, HttpReceivePipeline$Phases_getInstance().State, HttpReceivePipeline$Phases_getInstance().After]); | |
} | |
function HttpReceivePipeline$Phases() { | |
HttpReceivePipeline$Phases_instance = this; | |
this.Before = new PipelinePhase('Before'); | |
this.State = new PipelinePhase('State'); | |
this.After = new PipelinePhase('After'); | |
} | |
HttpReceivePipeline$Phases.$metadata$ = { | |
kind: Kind_OBJECT, | |
simpleName: 'Phases', | |
interfaces: []}; | |
var HttpReceivePipeline$Phases_instance = null; | |
function HttpReceivePipeline$Phases_getInstance() { | |
if (HttpReceivePipeline$Phases_instance === null) { | |
new HttpReceivePipeline$Phases(); | |
} | |
return HttpReceivePipeline$Phases_instance; | |
} | |
HttpReceivePipeline.$metadata$ = { | |
kind: Kind_CLASS, | |
simpleName: 'HttpReceivePipeline', | |
interfaces: [Pipeline]}; | |
function HttpResponseContainer(expectedType, response) { | |
this.expectedType = expectedType; | |
this.response = response; | |
} | |
HttpResponseContainer.$metadata$ = { | |
kind: Kind_CLASS, | |
simpleName: 'HttpResponseContainer', | |
interfaces: []}; | |
HttpResponseContainer.prototype.component1 = function() { | |
return this.expectedType; | |
}; | |
HttpResponseContainer.prototype.component2 = function() { | |
return this.response; | |
}; | |
HttpResponseContainer.prototype.copy_ju9ok$ = function(expectedType, response) { | |
return new HttpResponseContainer(expectedType === void 0 ? this.expectedType : expectedType, response === void 0 ? this.response : response); | |
}; | |
HttpResponseContainer.prototype.toString = function() { | |
return 'HttpResponseContainer(expectedType=' + Kotlin.toString(this.expectedType) + (', response=' + Kotlin.toString(this.response)) + ')'; | |
}; | |
HttpResponseContainer.prototype.hashCode = function() { | |
var result = 0; | |
result = result * 31 + Kotlin.hashCode(this.expectedType) | 0; | |
result = result * 31 + Kotlin.hashCode(this.response) | 0; | |
return result; | |
}; | |
HttpResponseContainer.prototype.equals = function(other) { | |
return this === other || (other !== null && (typeof other === 'object' && (Object.getPrototypeOf(this) === Object.getPrototypeOf(other) && (Kotlin.equals(this.expectedType, other.expectedType) && Kotlin.equals(this.response, other.response))))); | |
}; | |
function Coroutine$readBytes($receiver_0, count_0, continuation_0) { | |
CoroutineImpl.call(this, continuation_0); | |
this.exceptionState_0 = 1; | |
this.local$$receiver = void 0; | |
this.local$$receiver_0 = $receiver_0; | |
this.local$count = count_0; | |
} | |
Coroutine$readBytes.$metadata$ = { | |
kind: Kotlin.Kind.CLASS, | |
simpleName: null, | |
interfaces: [CoroutineImpl]}; | |
Coroutine$readBytes.prototype = Object.create(CoroutineImpl.prototype); | |
Coroutine$readBytes.prototype.constructor = Coroutine$readBytes; | |
Coroutine$readBytes.prototype.doResume = function() { | |
do try { | |
switch (this.state_0) { | |
case 0: | |
this.local$$receiver = new Int8Array(this.local$count); | |
this.state_0 = 2; | |
this.result_0 = readFully(this.local$$receiver_0.content, this.local$$receiver, this); | |
if (this.result_0 === COROUTINE_SUSPENDED) | |
return COROUTINE_SUSPENDED; | |
continue; | |
case 1: | |
throw this.exception_0; | |
case 2: | |
return this.local$$receiver; | |
default: | |
this.state_0 = 1; | |
throw new Error('State Machine Unreachable execution'); | |
} | |
} catch (e) { | |
if (this.state_0 === 1) { | |
this.exceptionState_0 = this.state_0; | |
throw e; | |
} else { | |
this.state_0 = this.exceptionState_0; | |
this.exception_0 = e; | |
} | |
} while (true); | |
}; | |
function readBytes_1($receiver_0, count_0, continuation_0, suspended) { | |
var instance = new Coroutine$readBytes($receiver_0, count_0, continuation_0); | |
if (suspended) | |
return instance; | |
else | |
return instance.doResume(null); | |
} | |
function Coroutine$readBytes_0($receiver_0, continuation_0) { | |
CoroutineImpl.call(this, continuation_0); | |
this.exceptionState_0 = 1; | |
this.local$$receiver = $receiver_0; | |
} | |
Coroutine$readBytes_0.$metadata$ = { | |
kind: Kotlin.Kind.CLASS, | |
simpleName: null, | |
interfaces: [CoroutineImpl]}; | |
Coroutine$readBytes_0.prototype = Object.create(CoroutineImpl.prototype); | |
Coroutine$readBytes_0.prototype.constructor = Coroutine$readBytes_0; | |
Coroutine$readBytes_0.prototype.doResume = function() { | |
do try { | |
switch (this.state_0) { | |
case 0: | |
this.state_0 = 2; | |
this.result_0 = readRemaining(this.local$$receiver.content, Long$Companion$MAX_VALUE, this); | |
if (this.result_0 === COROUTINE_SUSPENDED) | |
return COROUTINE_SUSPENDED; | |
continue; | |
case 1: | |
throw this.exception_0; | |
case 2: | |
return readBytes(this.result_0); | |
default: | |
this.state_0 = 1; | |
throw new Error('State Machine Unreachable execution'); | |
} | |
} catch (e) { | |
if (this.state_0 === 1) { | |
this.exceptionState_0 = this.state_0; | |
throw e; | |
} else { | |
this.state_0 = this.exceptionState_0; | |
this.exception_0 = e; | |
} | |
} while (true); | |
}; | |
function readBytes_2($receiver_0, continuation_0, suspended) { | |
var instance = new Coroutine$readBytes_0($receiver_0, continuation_0); | |
if (suspended) | |
return instance; | |
else | |
return instance.doResume(null); | |
} | |
function Coroutine$discardRemaining($receiver_0, continuation_0) { | |
CoroutineImpl.call(this, continuation_0); | |
this.exceptionState_0 = 1; | |
this.local$$receiver = $receiver_0; | |
} | |
Coroutine$discardRemaining.$metadata$ = { | |
kind: Kotlin.Kind.CLASS, | |
simpleName: null, | |
interfaces: [CoroutineImpl]}; | |
Coroutine$discardRemaining.prototype = Object.create(CoroutineImpl.prototype); | |
Coroutine$discardRemaining.prototype.constructor = Coroutine$discardRemaining; | |
Coroutine$discardRemaining.prototype.doResume = function() { | |
do try { | |
switch (this.state_0) { | |
case 0: | |
this.state_0 = 2; | |
this.result_0 = discard(this.local$$receiver.content, this); | |
if (this.result_0 === COROUTINE_SUSPENDED) | |
return COROUTINE_SUSPENDED; | |
continue; | |
case 1: | |
throw this.exception_0; | |
case 2: | |
return; | |
default: | |
this.state_0 = 1; | |
throw new Error('State Machine Unreachable execution'); | |
} | |
} catch (e) { | |
if (this.state_0 === 1) { | |
this.exceptionState_0 = this.state_0; | |
throw e; | |
} else { | |
this.state_0 = this.exceptionState_0; | |
this.exception_0 = e; | |
} | |
} while (true); | |
}; | |
function discardRemaining($receiver_0, continuation_0, suspended) { | |
var instance = new Coroutine$discardRemaining($receiver_0, continuation_0); | |
if (suspended) | |
return instance; | |
else | |
return instance.doResume(null); | |
} | |
var DEFAULT_HTTP_POOL_SIZE; | |
var DEFAULT_HTTP_BUFFER_SIZE; | |
function EmptyContent() { | |
EmptyContent_instance = this; | |
OutgoingContent$NoContent.call(this); | |
} | |
EmptyContent.$metadata$ = { | |
kind: Kind_OBJECT, | |
simpleName: 'EmptyContent', | |
interfaces: [OutgoingContent$NoContent]}; | |
var EmptyContent_instance = null; | |
function EmptyContent_getInstance() { | |
if (EmptyContent_instance === null) { | |
new EmptyContent(); | |
} | |
return EmptyContent_instance; | |
} | |
function wrapHeaders$ObjectLiteral(this$wrapHeaders, closure$block) { | |
this.this$wrapHeaders = this$wrapHeaders; | |
OutgoingContent$NoContent.call(this); | |
this.headers_byaa2p$_0 = closure$block(this$wrapHeaders.headers); | |
} | |
Object.defineProperty(wrapHeaders$ObjectLiteral.prototype, 'contentLength', { | |
get: function() { | |
return this.this$wrapHeaders.contentLength; | |
}}); | |
Object.defineProperty(wrapHeaders$ObjectLiteral.prototype, 'contentType', { | |
get: function() { | |
return this.this$wrapHeaders.contentType; | |
}}); | |
Object.defineProperty(wrapHeaders$ObjectLiteral.prototype, 'status', { | |
get: function() { | |
return this.this$wrapHeaders.status; | |
}}); | |
Object.defineProperty(wrapHeaders$ObjectLiteral.prototype, 'headers', { | |
get: function() { | |
return this.headers_byaa2p$_0; | |
}}); | |
wrapHeaders$ObjectLiteral.$metadata$ = { | |
kind: Kind_CLASS, | |
interfaces: [OutgoingContent$NoContent]}; | |
function wrapHeaders$ObjectLiteral_0(this$wrapHeaders, closure$block) { | |
this.this$wrapHeaders = this$wrapHeaders; | |
OutgoingContent$ReadChannelContent.call(this); | |
this.headers_byaa2p$_0 = closure$block(this$wrapHeaders.headers); | |
} | |
Object.defineProperty(wrapHeaders$ObjectLiteral_0.prototype, 'contentLength', { | |
get: function() { | |
return this.this$wrapHeaders.contentLength; | |
}}); | |
Object.defineProperty(wrapHeaders$ObjectLiteral_0.prototype, 'contentType', { | |
get: function() { | |
return this.this$wrapHeaders.contentType; | |
}}); | |
Object.defineProperty(wrapHeaders$ObjectLiteral_0.prototype, 'status', { | |
get: function() { | |
return this.this$wrapHeaders.status; | |
}}); | |
Object.defineProperty(wrapHeaders$ObjectLiteral_0.prototype, 'headers', { | |
get: function() { | |
return this.headers_byaa2p$_0; | |
}}); | |
wrapHeaders$ObjectLiteral_0.prototype.readFrom = function() { | |
return this.this$wrapHeaders.readFrom(); | |
}; | |
wrapHeaders$ObjectLiteral_0.prototype.readFrom_6z6t3e$ = function(range) { | |
return this.this$wrapHeaders.readFrom_6z6t3e$(range); | |
}; | |
wrapHeaders$ObjectLiteral_0.$metadata$ = { | |
kind: Kind_CLASS, | |
interfaces: [OutgoingContent$ReadChannelContent]}; | |
function wrapHeaders$ObjectLiteral_1(this$wrapHeaders, closure$block) { | |
this.this$wrapHeaders = this$wrapHeaders; | |
OutgoingContent$WriteChannelContent.call(this); | |
this.headers_byaa2p$_0 = closure$block(this$wrapHeaders.headers); | |
} | |
Object.defineProperty(wrapHeaders$ObjectLiteral_1.prototype, 'contentLength', { | |
get: function() { | |
return this.this$wrapHeaders.contentLength; | |
}}); | |
Object.defineProperty(wrapHeaders$ObjectLiteral_1.prototype, 'contentType', { | |
get: function() { | |
return this.this$wrapHeaders.contentType; | |
}}); | |
Object.defineProperty(wrapHeaders$ObjectLiteral_1.prototype, 'status', { | |
get: function() { | |
return this.this$wrapHeaders.status; | |
}}); | |
Object.defineProperty(wrapHeaders$ObjectLiteral_1.prototype, 'headers', { | |
get: function() { | |
return this.headers_byaa2p$_0; | |
}}); | |
wrapHeaders$ObjectLiteral_1.prototype.writeTo_sfhht4$ = function(channel, continuation) { | |
return this.this$wrapHeaders.writeTo_sfhht4$(channel, continuation); | |
}; | |
wrapHeaders$ObjectLiteral_1.$metadata$ = { | |
kind: Kind_CLASS, | |
interfaces: [OutgoingContent$WriteChannelContent]}; | |
function wrapHeaders$ObjectLiteral_2(this$wrapHeaders, closure$block) { | |
this.this$wrapHeaders = this$wrapHeaders; | |
OutgoingContent$ByteArrayContent.call(this); | |
this.headers_byaa2p$_0 = closure$block(this$wrapHeaders.headers); | |
} | |
Object.defineProperty(wrapHeaders$ObjectLiteral_2.prototype, 'contentLength', { | |
get: function() { | |
return this.this$wrapHeaders.contentLength; | |
}}); | |
Object.defineProperty(wrapHeaders$ObjectLiteral_2.prototype, 'contentType', { | |
get: function() { | |
return this.this$wrapHeaders.contentType; | |
}}); | |
Object.defineProperty(wrapHeaders$ObjectLiteral_2.prototype, 'status', { | |
get: function() { | |
return this.this$wrapHeaders.status; | |
}}); | |
Object.defineProperty(wrapHeaders$ObjectLiteral_2.prototype, 'headers', { | |
get: function() { | |
return this.headers_byaa2p$_0; | |
}}); | |
wrapHeaders$ObjectLiteral_2.prototype.bytes = function() { | |
return this.this$wrapHeaders.bytes(); | |
}; | |
wrapHeaders$ObjectLiteral_2.$metadata$ = { | |
kind: Kind_CLASS, | |
interfaces: [OutgoingContent$ByteArrayContent]}; | |
function wrapHeaders$ObjectLiteral_3(this$wrapHeaders, closure$block) { | |
this.this$wrapHeaders = this$wrapHeaders; | |
OutgoingContent$ProtocolUpgrade.call(this); | |
this.headers_byaa2p$_0 = closure$block(this$wrapHeaders.headers); | |
} | |
Object.defineProperty(wrapHeaders$ObjectLiteral_3.prototype, 'contentLength', { | |
get: function() { | |
return this.this$wrapHeaders.contentLength; | |
}}); | |
Object.defineProperty(wrapHeaders$ObjectLiteral_3.prototype, 'contentType', { | |
get: function() { | |
return this.this$wrapHeaders.contentType; | |
}}); | |
Object.defineProperty(wrapHeaders$ObjectLiteral_3.prototype, 'headers', { | |
get: function() { | |
return this.headers_byaa2p$_0; | |
}}); | |
wrapHeaders$ObjectLiteral_3.prototype.upgrade_jtv4ff$ = function(input, output, engineContext, userContext, continuation) { | |
return this.this$wrapHeaders.upgrade_jtv4ff$(input, output, engineContext, userContext, continuation); | |
}; | |
wrapHeaders$ObjectLiteral_3.$metadata$ = { | |
kind: Kind_CLASS, | |
interfaces: [OutgoingContent$ProtocolUpgrade]}; | |
function wrapHeaders($receiver, block) { | |
if (Kotlin.isType($receiver, OutgoingContent$NoContent)) | |
return new wrapHeaders$ObjectLiteral($receiver, block); | |
else if (Kotlin.isType($receiver, OutgoingContent$ReadChannelContent)) | |
return new wrapHeaders$ObjectLiteral_0($receiver, block); | |
else if (Kotlin.isType($receiver, OutgoingContent$WriteChannelContent)) | |
return new wrapHeaders$ObjectLiteral_1($receiver, block); | |
else if (Kotlin.isType($receiver, OutgoingContent$ByteArrayContent)) | |
return new wrapHeaders$ObjectLiteral_2($receiver, block); | |
else if (Kotlin.isType($receiver, OutgoingContent$ProtocolUpgrade)) | |
return new wrapHeaders$ObjectLiteral_3($receiver, block); | |
else | |
return Kotlin.noWhenBranchMatched(); | |
} | |
function CacheControl() { | |
CacheControl_instance = this; | |
this.MAX_AGE = 'max-age'; | |
this.MIN_FRESH = 'min-fresh'; | |
this.ONLY_IF_CACHED = 'only-if-cached'; | |
this.MAX_STALE = 'max-stale'; | |
this.NO_CACHE = 'no-cache'; | |
this.NO_STORE = 'no-store'; | |
this.NO_TRANSFORM = 'no-transform'; | |
this.MUST_REVALIDATE = 'must-revalidate'; | |
this.PUBLIC = 'public'; | |
this.PRIVATE = 'private'; | |
this.PROXY_REVALIDATE = 'proxy-revalidate'; | |
this.S_MAX_AGE = 's-maxage'; | |
} | |
CacheControl.prototype.getMAX_AGE = function() { | |
return this.MAX_AGE; | |
}; | |
CacheControl.prototype.getMIN_FRESH = function() { | |
return this.MIN_FRESH; | |
}; | |
CacheControl.prototype.getONLY_IF_CACHED = function() { | |
return this.ONLY_IF_CACHED; | |
}; | |
CacheControl.prototype.getMAX_STALE = function() { | |
return this.MAX_STALE; | |
}; | |
CacheControl.prototype.getNO_CACHE = function() { | |
return this.NO_CACHE; | |
}; | |
CacheControl.prototype.getNO_STORE = function() { | |
return this.NO_STORE; | |
}; | |
CacheControl.prototype.getNO_TRANSFORM = function() { | |
return this.NO_TRANSFORM; | |
}; | |
CacheControl.prototype.getMUST_REVALIDATE = function() { | |
return this.MUST_REVALIDATE; | |
}; | |
CacheControl.prototype.getPUBLIC = function() { | |
return this.PUBLIC; | |
}; | |
CacheControl.prototype.getPRIVATE = function() { | |
return this.PRIVATE; | |
}; | |
CacheControl.prototype.getPROXY_REVALIDATE = function() { | |
return this.PROXY_REVALIDATE; | |
}; | |
CacheControl.prototype.getS_MAX_AGE = function() { | |
return this.S_MAX_AGE; | |
}; | |
CacheControl.$metadata$ = { | |
kind: Kind_OBJECT, | |
simpleName: 'CacheControl', | |
interfaces: []}; | |
var CacheControl_instance = null; | |
function CacheControl_getInstance() { | |
if (CacheControl_instance === null) { | |
new CacheControl(); | |
} | |
return CacheControl_instance; | |
} | |
function buildHeaders$lambda($receiver) { | |
return Unit; | |
} | |
function buildHeaders(block) { | |
if (block === void 0) | |
block = buildHeaders$lambda; | |
var $receiver = new HeadersBuilder(); | |
block($receiver); | |
return $receiver.build(); | |
} | |
function HttpClient$lambda_0($receiver) { | |
return Unit; | |
} | |
function HttpClient_2(block) { | |
if (block === void 0) | |
block = HttpClient$lambda_0; | |
return HttpClient(JsClient(), block); | |
} | |
function Type() { | |
} | |
Type.$metadata$ = { | |
kind: Kind_INTERFACE, | |
simpleName: 'Type', | |
interfaces: []}; | |
function JsType() { | |
JsType_instance = this; | |
} | |
JsType.$metadata$ = { | |
kind: Kind_OBJECT, | |
simpleName: 'JsType', | |
interfaces: [Type]}; | |
var JsType_instance = null; | |
function JsType_getInstance() { | |
if (JsType_instance === null) { | |
new JsType(); | |
} | |
return JsType_instance; | |
} | |
var typeInfo = defineInlineFunction('ktor-client-core.io.ktor.client.call.typeInfo_287e2$', wrapFunction(function() { | |
var getKClass = Kotlin.getKClass; | |
var call = _.io.ktor.client.call; | |
var TypeInfo_init = _.io.ktor.client.call.TypeInfo; | |
return function(T_0, isT) { | |
return new TypeInfo_init(getKClass(T_0), call.JsType); | |
}; | |
})); | |
function Js() { | |
Js_instance = this; | |
} | |
Js.prototype.create_dxyxif$$default = function(block) { | |
var $receiver = new HttpClientEngineConfig(); | |
block($receiver); | |
return new JsClientEngine($receiver); | |
}; | |
Js.$metadata$ = { | |
kind: Kind_OBJECT, | |
simpleName: 'Js', | |
interfaces: [HttpClientEngineFactory]}; | |
var Js_instance = null; | |
function Js_getInstance() { | |
if (Js_instance === null) { | |
new Js(); | |
} | |
return Js_instance; | |
} | |
function JsClient() { | |
return Js_getInstance(); | |
} | |
function JsClientEngine(config) { | |
this.config_2md4la$_0 = config; | |
this.utils_fdw65b$_0 = lazy(JsClientEngine$utils$lambda); | |
this.dispatcher_j9yf5v$_0 = coroutines.Dispatchers.Default; | |
this.coroutineContext_ynwhqr$_0 = this.dispatcher.plus_1fupul$(SupervisorJob()); | |
} | |
Object.defineProperty(JsClientEngine.prototype, 'config', { | |
get: function() { | |
return this.config_2md4la$_0; | |
}}); | |
Object.defineProperty(JsClientEngine.prototype, 'utils_0', { | |
get: function() { | |
return this.utils_fdw65b$_0.value; | |
}}); | |
Object.defineProperty(JsClientEngine.prototype, 'dispatcher', { | |
get: function() { | |
return this.dispatcher_j9yf5v$_0; | |
}}); | |
Object.defineProperty(JsClientEngine.prototype, 'coroutineContext', { | |
get: function() { | |
return this.coroutineContext_ynwhqr$_0; | |
}}); | |
function Coroutine$JsClientEngine$execute$lambda(this$JsClientEngine_0, closure$call_0, closure$data_0, $receiver_0, controller, continuation_0) { | |
CoroutineImpl.call(this, continuation_0); | |
this.$controller = controller; | |
this.exceptionState_0 = 1; | |
this.local$this$JsClientEngine = this$JsClientEngine_0; | |
this.local$closure$call = closure$call_0; | |
this.local$closure$data = closure$data_0; | |
this.local$tmp$ = void 0; | |
this.local$callContext = void 0; | |
this.local$requestTime = void 0; | |
this.local$request = void 0; | |
} | |
Coroutine$JsClientEngine$execute$lambda.$metadata$ = { | |
kind: Kotlin.Kind.CLASS, | |
simpleName: null, | |
interfaces: [CoroutineImpl]}; | |
Coroutine$JsClientEngine$execute$lambda.prototype = Object.create(CoroutineImpl.prototype); | |
Coroutine$JsClientEngine$execute$lambda.prototype.constructor = Coroutine$JsClientEngine$execute$lambda; | |
Coroutine$JsClientEngine$execute$lambda.prototype.doResume = function() { | |
do try { | |
switch (this.state_0) { | |
case 0: | |
var tmp$; | |
this.local$callContext = CompletableDeferred_0(this.local$this$JsClientEngine.coroutineContext.get_j3r2sn$(Job.Key)).plus_1fupul$(this.local$this$JsClientEngine.dispatcher); | |
this.local$requestTime = GMTDate(); | |
this.local$request = new DefaultHttpRequest(this.local$closure$call, this.local$closure$data); | |
this.local$tmp$ = this.local$request.url; | |
this.state_0 = 2; | |
this.result_0 = toRaw(CoroutineScope_0(this.local$callContext), this.local$request, this); | |
if (this.result_0 === COROUTINE_SUSPENDED) | |
return COROUTINE_SUSPENDED; | |
continue; | |
case 1: | |
throw this.exception_0; | |
case 2: | |
tmp$ = this.result_0; | |
this.state_0 = 3; | |
this.result_0 = this.local$this$JsClientEngine.fetch_0(this.local$tmp$, tmp$, this); | |
if (this.result_0 === COROUTINE_SUSPENDED) | |
return COROUTINE_SUSPENDED; | |
continue; | |
case 3: | |
var rawResponse = this.result_0; | |
var response = new JsHttpResponse(this.local$closure$call, this.local$requestTime, rawResponse, this.local$this$JsClientEngine.utils_0.getBodyContentAsChannel_7kadjx$(rawResponse, this.local$callContext), this.local$callContext); | |
return new HttpEngineCall(this.local$request, response); | |
default: | |
this.state_0 = 1; | |
throw new Error('State Machine Unreachable execution'); | |
} | |
} catch (e) { | |
if (this.state_0 === 1) { | |
this.exceptionState_0 = this.state_0; | |
throw e; | |
} else { | |
this.state_0 = this.exceptionState_0; | |
this.exception_0 = e; | |
} | |
} while (true); | |
}; | |
function JsClientEngine$execute$lambda(this$JsClientEngine_0, closure$call_0, closure$data_0) { | |
return function($receiver_0, continuation_0, suspended) { | |
var instance = new Coroutine$JsClientEngine$execute$lambda(this$JsClientEngine_0, closure$call_0, closure$data_0, $receiver_0, this, continuation_0); | |
if (suspended) | |
return instance; | |
else | |
return instance.doResume(null); | |
}; | |
} | |
JsClientEngine.prototype.execute_jw3znh$ = function(call, data, continuation) { | |
return withContext(this.dispatcher, JsClientEngine$execute$lambda(this, call, data), continuation); | |
}; | |
JsClientEngine.prototype.close = function() { | |
}; | |
var Result = Kotlin.kotlin.Result; | |
function JsClientEngine$fetch$lambda$lambda(closure$it) { | |
return function(response) { | |
closure$it.resumeWith_tl1gpc$(new Result(response)); | |
return Unit; | |
}; | |
} | |
var createFailure = Kotlin.kotlin.createFailure_tcv7n7$; | |
function JsClientEngine$fetch$lambda$lambda_0(closure$it) { | |
return function(cause) { | |
var $receiver = closure$it; | |
var exception = new JsError(cause); | |
$receiver.resumeWith_tl1gpc$(new Result(createFailure(exception))); | |
return Unit; | |
}; | |
} | |
function JsClientEngine$fetch$lambda(this$JsClientEngine, closure$url, closure$request) { | |
return function(it) { | |
this$JsClientEngine.utils_0.fetch_zcnqx8$(closure$url.toString(), closure$request).then(JsClientEngine$fetch$lambda$lambda(it), JsClientEngine$fetch$lambda$lambda_0(it)); | |
return Unit; | |
}; | |
} | |
var intercepted = Kotlin.kotlin.coroutines.intrinsics.intercepted_f9mg25$; | |
var CancellableContinuationImpl_init = $module$kotlinx_coroutines_core.kotlinx.coroutines.CancellableContinuationImpl; | |
function suspendCancellableCoroutine$lambda(closure$block) { | |
return function(uCont) { | |
var cancellable = new CancellableContinuationImpl_init(intercepted(uCont), 1); | |
closure$block(cancellable); | |
return cancellable.getResult(); | |
}; | |
} | |
function Coroutine$fetch_0($this, url_0, request_0, continuation_0) { | |
CoroutineImpl.call(this, continuation_0); | |
this.exceptionState_0 = 1; | |
this.$this = $this; | |
this.local$url = url_0; | |
this.local$request = request_0; | |
} | |
Coroutine$fetch_0.$metadata$ = { | |
kind: Kotlin.Kind.CLASS, | |
simpleName: null, | |
interfaces: [CoroutineImpl]}; | |
Coroutine$fetch_0.prototype = Object.create(CoroutineImpl.prototype); | |
Coroutine$fetch_0.prototype.constructor = Coroutine$fetch_0; | |
Coroutine$fetch_0.prototype.doResume = function() { | |
do try { | |
switch (this.state_0) { | |
case 0: | |
this.state_0 = 2; | |
this.result_0 = suspendCancellableCoroutine$lambda(JsClientEngine$fetch$lambda(this.$this, this.local$url, this.local$request))(this); | |
if (this.result_0 === COROUTINE_SUSPENDED) | |
return COROUTINE_SUSPENDED; | |
continue; | |
case 1: | |
throw this.exception_0; | |
case 2: | |
this.result_0; | |
return this.result_0; | |
default: | |
this.state_0 = 1; | |
throw new Error('State Machine Unreachable execution'); | |
} | |
} catch (e) { | |
if (this.state_0 === 1) { | |
this.exceptionState_0 = this.state_0; | |
throw e; | |
} else { | |
this.state_0 = this.exceptionState_0; | |
this.exception_0 = e; | |
} | |
} while (true); | |
}; | |
JsClientEngine.prototype.fetch_0 = function(url_0, request_0, continuation_0, suspended) { | |
var instance = new Coroutine$fetch_0(this, url_0, request_0, continuation_0); | |
if (suspended) | |
return instance; | |
else | |
return instance.doResume(null); | |
}; | |
function JsClientEngine$utils$lambda() { | |
return Utils$Companion_getInstance().get(); | |
} | |
JsClientEngine.$metadata$ = { | |
kind: Kind_CLASS, | |
simpleName: 'JsClientEngine', | |
interfaces: [HttpClientEngine]}; | |
function JsError(origin) { | |
Throwable.call(this); | |
this.message_9vnttw$_0 = 'Error from javascript[' + origin.toString() + '].'; | |
this.cause_kdow7y$_0 = null; | |
this.origin = origin; | |
Kotlin.captureStack(Throwable, this); | |
this.name = 'JsError'; | |
} | |
Object.defineProperty(JsError.prototype, 'message', { | |
get: function() { | |
return this.message_9vnttw$_0; | |
}}); | |
Object.defineProperty(JsError.prototype, 'cause', { | |
get: function() { | |
return this.cause_kdow7y$_0; | |
}}); | |
JsError.$metadata$ = { | |
kind: Kind_CLASS, | |
simpleName: 'JsError', | |
interfaces: [Throwable]}; | |
function JsHttpResponse(call, requestTime, response, content, coroutineContext) { | |
this.call_zbgs66$_0 = call; | |
this.requestTime_b7jft4$_0 = requestTime; | |
this.response_0 = response; | |
this.content_pzgpn$_0 = content; | |
this.coroutineContext_ygmdav$_0 = coroutineContext; | |
this.status_sr9zci$_0 = HttpStatusCode.Companion.fromValue_za3lpa$(this.response_0.status); | |
this.version_mq3fok$_0 = HttpProtocolVersion.Companion.HTTP_1_1; | |
this.responseTime_bpeqdu$_0 = GMTDate(); | |
var $receiver = new HeadersBuilder(); | |
this.response_0.headers.forEach(JsHttpResponse$headers$lambda$lambda($receiver)); | |
this.headers_8c8pw2$_0 = $receiver.build(); | |
} | |
Object.defineProperty(JsHttpResponse.prototype, 'call', { | |
get: function() { | |
return this.call_zbgs66$_0; | |
}}); | |
Object.defineProperty(JsHttpResponse.prototype, 'requestTime', { | |
get: function() { | |
return this.requestTime_b7jft4$_0; | |
}}); | |
Object.defineProperty(JsHttpResponse.prototype, 'content', { | |
get: function() { | |
return this.content_pzgpn$_0; | |
}}); | |
Object.defineProperty(JsHttpResponse.prototype, 'coroutineContext', { | |
get: function() { | |
return this.coroutineContext_ygmdav$_0; | |
}}); | |
Object.defineProperty(JsHttpResponse.prototype, 'status', { | |
get: function() { | |
return this.status_sr9zci$_0; | |
}}); | |
Object.defineProperty(JsHttpResponse.prototype, 'version', { | |
get: function() { | |
return this.version_mq3fok$_0; | |
}}); | |
Object.defineProperty(JsHttpResponse.prototype, 'responseTime', { | |
get: function() { | |
return this.responseTime_bpeqdu$_0; | |
}}); | |
Object.defineProperty(JsHttpResponse.prototype, 'headers', { | |
get: function() { | |
return this.headers_8c8pw2$_0; | |
}}); | |
JsHttpResponse.prototype.close = function() { | |
var tmp$; | |
(Kotlin.isType(tmp$ = this.coroutineContext.get_j3r2sn$(Job.Key), CompletableDeferred) ? tmp$ : throwCCE()).complete_11rb$(Unit); | |
}; | |
function JsHttpResponse$headers$lambda$lambda(this$) { | |
return function(value, key) { | |
this$.append_puj7f4$(key, value); | |
return Unit; | |
}; | |
} | |
JsHttpResponse.$metadata$ = { | |
kind: Kind_CLASS, | |
simpleName: 'JsHttpResponse', | |
interfaces: [HttpResponse]}; | |
function toRaw$lambda(closure$jsHeaders) { | |
return function(key, value) { | |
closure$jsHeaders[key] = value; | |
return Unit; | |
}; | |
} | |
function Coroutine$toRaw$lambda(closure$content_0, $receiver_0, controller, continuation_0) { | |
CoroutineImpl.call(this, continuation_0); | |
this.$controller = controller; | |
this.exceptionState_0 = 1; | |
this.local$closure$content = closure$content_0; | |
this.local$$receiver = $receiver_0; | |
} | |
Coroutine$toRaw$lambda.$metadata$ = { | |
kind: Kotlin.Kind.CLASS, | |
simpleName: null, | |
interfaces: [CoroutineImpl]}; | |
Coroutine$toRaw$lambda.prototype = Object.create(CoroutineImpl.prototype); | |
Coroutine$toRaw$lambda.prototype.constructor = Coroutine$toRaw$lambda; | |
Coroutine$toRaw$lambda.prototype.doResume = function() { | |
do try { | |
switch (this.state_0) { | |
case 0: | |
this.state_0 = 2; | |
this.result_0 = this.local$closure$content.writeTo_sfhht4$(this.local$$receiver.channel, this); | |
if (this.result_0 === COROUTINE_SUSPENDED) | |
return COROUTINE_SUSPENDED; | |
continue; | |
case 1: | |
throw this.exception_0; | |
case 2: | |
return this.result_0; | |
default: | |
this.state_0 = 1; | |
throw new Error('State Machine Unreachable execution'); | |
} | |
} catch (e) { | |
if (this.state_0 === 1) { | |
this.exceptionState_0 = this.state_0; | |
throw e; | |
} else { | |
this.state_0 = this.exceptionState_0; | |
this.exception_0 = e; | |
} | |
} while (true); | |
}; | |
function toRaw$lambda_0(closure$content_0) { | |
return function($receiver_0, continuation_0, suspended) { | |
var instance = new Coroutine$toRaw$lambda(closure$content_0, $receiver_0, this, continuation_0); | |
if (suspended) | |
return instance; | |
else | |
return instance.doResume(null); | |
}; | |
} | |
function toRaw$lambda_1(closure$clientRequest, closure$jsHeaders, closure$bodyBytes) { | |
return function($receiver) { | |
$receiver.method = closure$clientRequest.method.value; | |
$receiver.headers = closure$jsHeaders; | |
if (closure$bodyBytes != null) { | |
$receiver.body = new Uint8Array(toTypedArray(closure$bodyBytes)); | |
} | |
return Unit; | |
}; | |
} | |
function Coroutine$toRaw($receiver_0, clientRequest_0, continuation_0) { | |
CoroutineImpl.call(this, continuation_0); | |
this.exceptionState_0 = 1; | |
this.local$tmp$ = void 0; | |
this.local$jsHeaders = void 0; | |
this.local$$receiver = $receiver_0; | |
this.local$clientRequest = clientRequest_0; | |
} | |
Coroutine$toRaw.$metadata$ = { | |
kind: Kotlin.Kind.CLASS, | |
simpleName: null, | |
interfaces: [CoroutineImpl]}; | |
Coroutine$toRaw.prototype = Object.create(CoroutineImpl.prototype); | |
Coroutine$toRaw.prototype.constructor = Coroutine$toRaw; | |
Coroutine$toRaw.prototype.doResume = function() { | |
do try { | |
switch (this.state_0) { | |
case 0: | |
this.local$jsHeaders = {}; | |
mergeHeaders(this.local$clientRequest.headers, this.local$clientRequest.content, toRaw$lambda(this.local$jsHeaders)); | |
var content = this.local$clientRequest.content; | |
if (Kotlin.isType(content, OutgoingContent$ByteArrayContent)) { | |
this.local$tmp$ = content.bytes(); | |
this.state_0 = 6; | |
continue; | |
} else { | |
if (Kotlin.isType(content, OutgoingContent$ReadChannelContent)) { | |
this.state_0 = 4; | |
this.result_0 = readRemaining_0(content.readFrom(), this); | |
if (this.result_0 === COROUTINE_SUSPENDED) | |
return COROUTINE_SUSPENDED; | |
continue; | |
} else { | |
if (Kotlin.isType(content, OutgoingContent$WriteChannelContent)) { | |
this.state_0 = 2; | |
this.result_0 = readRemaining_0(writer(this.local$$receiver, this.local$$receiver.coroutineContext, void 0, toRaw$lambda_0(content)).channel, this); | |
if (this.result_0 === COROUTINE_SUSPENDED) | |
return COROUTINE_SUSPENDED; | |
continue; | |
} else { | |
this.local$tmp$ = null; | |
this.state_0 = 3; | |
continue; | |
} | |
} | |
} | |
case 1: | |
throw this.exception_0; | |
case 2: | |
this.local$tmp$ = readBytes(this.result_0); | |
this.state_0 = 3; | |
continue; | |
case 3: | |
this.state_0 = 5; | |
continue; | |
case 4: | |
this.local$tmp$ = readBytes(this.result_0); | |
this.state_0 = 5; | |
continue; | |
case 5: | |
this.state_0 = 6; | |
continue; | |
case 6: | |
var bodyBytes = this.local$tmp$; | |
return buildObject(toRaw$lambda_1(this.local$clientRequest, this.local$jsHeaders, bodyBytes)); | |
default: | |
this.state_0 = 1; | |
throw new Error('State Machine Unreachable execution'); | |
} | |
} catch (e) { | |
if (this.state_0 === 1) { | |
this.exceptionState_0 = this.state_0; | |
throw e; | |
} else { | |
this.state_0 = this.exceptionState_0; | |
this.exception_0 = e; | |
} | |
} while (true); | |
}; | |
function toRaw($receiver_0, clientRequest_0, continuation_0, suspended) { | |
var instance = new Coroutine$toRaw($receiver_0, clientRequest_0, continuation_0); | |
if (suspended) | |
return instance; | |
else | |
return instance.doResume(null); | |
} | |
function buildObject(block) { | |
var tmp$; | |
var $receiver = (tmp$ = {}) == null || Kotlin.isType(tmp$, Any) ? tmp$ : throwCCE(); | |
block($receiver); | |
return $receiver; | |
} | |
function readChunk$lambda$lambda(closure$continuation) { | |
return function(it) { | |
var chunk = it.value; | |
var result = it.done || chunk == null ? null : chunk; | |
closure$continuation.resumeWith_tl1gpc$(new Result(result)); | |
return Unit; | |
}; | |
} | |
function readChunk$lambda$lambda_0(closure$continuation) { | |
return function(cause) { | |
closure$continuation.resumeWith_tl1gpc$(new Result(createFailure(cause))); | |
return Unit; | |
}; | |
} | |
function readChunk$lambda(this$readChunk) { | |
return function(continuation) { | |
this$readChunk.read().then(readChunk$lambda$lambda(continuation)).catch(readChunk$lambda$lambda_0(continuation)); | |
return Unit; | |
}; | |
} | |
function suspendCancellableCoroutine$lambda_0(closure$block) { | |
return function(uCont) { | |
var cancellable = new CancellableContinuationImpl_init(intercepted(uCont), 1); | |
closure$block(cancellable); | |
return cancellable.getResult(); | |
}; | |
} | |
function Coroutine$readChunk($receiver_0, continuation_0) { | |
CoroutineImpl.call(this, continuation_0); | |
this.exceptionState_0 = 1; | |
this.local$$receiver = $receiver_0; | |
} | |
Coroutine$readChunk.$metadata$ = { | |
kind: Kotlin.Kind.CLASS, | |
simpleName: null, | |
interfaces: [CoroutineImpl]}; | |
Coroutine$readChunk.prototype = Object.create(CoroutineImpl.prototype); | |
Coroutine$readChunk.prototype.constructor = Coroutine$readChunk; | |
Coroutine$readChunk.prototype.doResume = function() { | |
do try { | |
switch (this.state_0) { | |
case 0: | |
this.state_0 = 2; | |
this.result_0 = suspendCancellableCoroutine$lambda_0(readChunk$lambda(this.local$$receiver))(this); | |
if (this.result_0 === COROUTINE_SUSPENDED) | |
return COROUTINE_SUSPENDED; | |
continue; | |
case 1: | |
throw this.exception_0; | |
case 2: | |
this.result_0; | |
return this.result_0; | |
default: | |
this.state_0 = 1; | |
throw new Error('State Machine Unreachable execution'); | |
} | |
} catch (e) { | |
if (this.state_0 === 1) { | |
this.exceptionState_0 = this.state_0; | |
throw e; | |
} else { | |
this.state_0 = this.exceptionState_0; | |
this.exception_0 = e; | |
} | |
} while (true); | |
}; | |
function readChunk($receiver_0, continuation_0, suspended) { | |
var instance = new Coroutine$readChunk($receiver_0, continuation_0); | |
if (suspended) | |
return instance; | |
else | |
return instance.doResume(null); | |
} | |
function asByteArray($receiver) { | |
return new Int8Array($receiver.buffer, $receiver.byteOffset, $receiver.length); | |
} | |
function Utils() { | |
Utils$Companion_getInstance(); | |
this.coroutineContext_eq22s2$_0 = SupervisorJob(); | |
} | |
Object.defineProperty(Utils.prototype, 'coroutineContext', { | |
get: function() { | |
return this.coroutineContext_eq22s2$_0; | |
}}); | |
function Utils$Companion() { | |
Utils$Companion_instance = this; | |
} | |
Utils$Companion.prototype.get = function() { | |
var tmp$; | |
if (this.hasFetchApi_0()) { | |
return BrowserUtils_getInstance(); | |
} else | |
tmp$ = NodeUtils_getInstance(); | |
return tmp$; | |
}; | |
Utils$Companion.prototype.hasFetchApi_0 = function() { | |
return typeof window !== 'undefined'; | |
}; | |
Utils$Companion.$metadata$ = { | |
kind: Kind_OBJECT, | |
simpleName: 'Companion', | |
interfaces: []}; | |
var Utils$Companion_instance = null; | |
function Utils$Companion_getInstance() { | |
if (Utils$Companion_instance === null) { | |
new Utils$Companion(); | |
} | |
return Utils$Companion_instance; | |
} | |
Utils.$metadata$ = { | |
kind: Kind_CLASS, | |
simpleName: 'Utils', | |
interfaces: [CoroutineScope]}; | |
function BrowserUtils() { | |
BrowserUtils_instance = this; | |
Utils.call(this); | |
} | |
BrowserUtils.prototype.getBodyContentAsChannel_7kadjx$ = function(resp, context) { | |
var tmp$, tmp$_0; | |
var tmp$_1; | |
if ((tmp$_0 = Kotlin.isType(tmp$ = resp.body, Object) ? tmp$ : null) != null) | |
tmp$_1 = tmp$_0; | |
else { | |
throw IllegalStateException_init_0(('Fail to obtain native stream: ' + resp).toString()); | |
} | |
var stream = tmp$_1; | |
return this.toByteChannel_fmru5z$(stream, context); | |
}; | |
BrowserUtils.prototype.fetch_zcnqx8$ = function(input, init) { | |
return window.fetch(input, init); | |
}; | |
function Coroutine$BrowserUtils$toByteChannel$lambda(this$toByteChannel_0, $receiver_0, controller, continuation_0) { | |
CoroutineImpl.call(this, continuation_0); | |
this.$controller = controller; | |
this.exceptionState_0 = 1; | |
this.local$this$toByteChannel = this$toByteChannel_0; | |
this.local$tmp$ = void 0; | |
this.local$reader = void 0; | |
this.local$$receiver = $receiver_0; | |
} | |
Coroutine$BrowserUtils$toByteChannel$lambda.$metadata$ = { | |
kind: Kotlin.Kind.CLASS, | |
simpleName: null, | |
interfaces: [CoroutineImpl]}; | |
Coroutine$BrowserUtils$toByteChannel$lambda.prototype = Object.create(CoroutineImpl.prototype); | |
Coroutine$BrowserUtils$toByteChannel$lambda.prototype.constructor = Coroutine$BrowserUtils$toByteChannel$lambda; | |
Coroutine$BrowserUtils$toByteChannel$lambda.prototype.doResume = function() { | |
do try { | |
switch (this.state_0) { | |
case 0: | |
this.local$reader = this.local$this$toByteChannel.getReader(); | |
this.state_0 = 2; | |
continue; | |
case 1: | |
throw this.exception_0; | |
case 2: | |
this.state_0 = 3; | |
this.result_0 = readChunk(this.local$reader, this); | |
if (this.result_0 === COROUTINE_SUSPENDED) | |
return COROUTINE_SUSPENDED; | |
continue; | |
case 3: | |
this.local$tmp$ = this.result_0; | |
if (this.local$tmp$ == null) { | |
this.state_0 = 6; | |
continue; | |
} else { | |
this.state_0 = 4; | |
continue; | |
} | |
case 4: | |
var chunk = this.local$tmp$; | |
this.state_0 = 5; | |
this.result_0 = writeFully(this.local$$receiver.channel, asByteArray(chunk), this); | |
if (this.result_0 === COROUTINE_SUSPENDED) | |
return COROUTINE_SUSPENDED; | |
continue; | |
case 5: | |
this.state_0 = 2; | |
continue; | |
case 6: | |
return Unit; | |
default: | |
this.state_0 = 1; | |
throw new Error('State Machine Unreachable execution'); | |
} | |
} catch (e) { | |
if (this.state_0 === 1) { | |
this.exceptionState_0 = this.state_0; | |
throw e; | |
} else { | |
this.state_0 = this.exceptionState_0; | |
this.exception_0 = e; | |
} | |
} while (true); | |
}; | |
function BrowserUtils$toByteChannel$lambda(this$toByteChannel_0) { | |
return function($receiver_0, continuation_0, suspended) { | |
var instance = new Coroutine$BrowserUtils$toByteChannel$lambda(this$toByteChannel_0, $receiver_0, this, continuation_0); | |
if (suspended) | |
return instance; | |
else | |
return instance.doResume(null); | |
}; | |
} | |
BrowserUtils.prototype.toByteChannel_fmru5z$ = function($receiver, callContext) { | |
return writer(this, callContext, void 0, BrowserUtils$toByteChannel$lambda($receiver)).channel; | |
}; | |
BrowserUtils.$metadata$ = { | |
kind: Kind_OBJECT, | |
simpleName: 'BrowserUtils', | |
interfaces: [Utils]}; | |
var BrowserUtils_instance = null; | |
function BrowserUtils_getInstance() { | |
if (BrowserUtils_instance === null) { | |
new BrowserUtils(); | |
} | |
return BrowserUtils_instance; | |
} | |
function NodeUtils() { | |
NodeUtils_instance = this; | |
Utils.call(this); | |
} | |
function NodeUtils$getBodyContentAsChannel$lambda$lambda$lambda(closure$con) { | |
return function(it) { | |
closure$con.resumeWith_tl1gpc$(new Result(it)); | |
return Unit; | |
}; | |
} | |
function NodeUtils$getBodyContentAsChannel$lambda$lambda$lambda_0(closure$con) { | |
return function(it) { | |
closure$con.resumeWith_tl1gpc$(new Result(createFailure(it))); | |
return Unit; | |
}; | |
} | |
function NodeUtils$getBodyContentAsChannel$lambda$lambda(closure$resp) { | |
return function(con) { | |
closure$resp.arrayBuffer().then(NodeUtils$getBodyContentAsChannel$lambda$lambda$lambda(con)).catch(NodeUtils$getBodyContentAsChannel$lambda$lambda$lambda_0(con)); | |
return Unit; | |
}; | |
} | |
function suspendCancellableCoroutine$lambda_1(closure$block) { | |
return function(uCont) { | |
var cancellable = new CancellableContinuationImpl_init(intercepted(uCont), 1); | |
closure$block(cancellable); | |
return cancellable.getResult(); | |
}; | |
} | |
function Coroutine$NodeUtils$getBodyContentAsChannel$lambda(closure$resp_0, $receiver_0, controller, continuation_0) { | |
CoroutineImpl.call(this, continuation_0); | |
this.$controller = controller; | |
this.exceptionState_0 = 1; | |
this.local$closure$resp = closure$resp_0; | |
this.local$$receiver = $receiver_0; | |
} | |
Coroutine$NodeUtils$getBodyContentAsChannel$lambda.$metadata$ = { | |
kind: Kotlin.Kind.CLASS, | |
simpleName: null, | |
interfaces: [CoroutineImpl]}; | |
Coroutine$NodeUtils$getBodyContentAsChannel$lambda.prototype = Object.create(CoroutineImpl.prototype); | |
Coroutine$NodeUtils$getBodyContentAsChannel$lambda.prototype.constructor = Coroutine$NodeUtils$getBodyContentAsChannel$lambda; | |
Coroutine$NodeUtils$getBodyContentAsChannel$lambda.prototype.doResume = function() { | |
do try { | |
switch (this.state_0) { | |
case 0: | |
this.state_0 = 2; | |
this.result_0 = suspendCancellableCoroutine$lambda_1(NodeUtils$getBodyContentAsChannel$lambda$lambda(this.local$closure$resp))(this); | |
if (this.result_0 === COROUTINE_SUSPENDED) | |
return COROUTINE_SUSPENDED; | |
continue; | |
case 1: | |
throw this.exception_0; | |
case 2: | |
this.result_0; | |
var buffer = this.result_0; | |
var byteArray = asByteArray(new Uint8Array(buffer)); | |
this.state_0 = 3; | |
this.result_0 = writeFully(this.local$$receiver.channel, byteArray, this); | |
if (this.result_0 === COROUTINE_SUSPENDED) | |
return COROUTINE_SUSPENDED; | |
continue; | |
case 3: | |
return this.result_0; | |
default: | |
this.state_0 = 1; | |
throw new Error('State Machine Unreachable execution'); | |
} | |
} catch (e) { | |
if (this.state_0 === 1) { | |
this.exceptionState_0 = this.state_0; | |
throw e; | |
} else { | |
this.state_0 = this.exceptionState_0; | |
this.exception_0 = e; | |
} | |
} while (true); | |
}; | |
function NodeUtils$getBodyContentAsChannel$lambda(closure$resp_0) { | |
return function($receiver_0, continuation_0, suspended) { | |
var instance = new Coroutine$NodeUtils$getBodyContentAsChannel$lambda(closure$resp_0, $receiver_0, this, continuation_0); | |
if (suspended) | |
return instance; | |
else | |
return instance.doResume(null); | |
}; | |
} | |
NodeUtils.prototype.getBodyContentAsChannel_7kadjx$ = function(resp, context) { | |
return writer(this, context, void 0, NodeUtils$getBodyContentAsChannel$lambda(resp)).channel; | |
}; | |
NodeUtils.prototype.fetch_zcnqx8$ = function(input, init) { | |
var nodeFetch = this.jeRequire_0('node-fetch'); | |
return nodeFetch(input, init); | |
}; | |
NodeUtils.prototype.jeRequire_0 = function(moduleName) { | |
try { | |
return require(moduleName); | |
} catch (e) { | |
throw Error_init("Error loading module '" + moduleName + "'."); | |
} | |
}; | |
NodeUtils.$metadata$ = { | |
kind: Kind_OBJECT, | |
simpleName: 'NodeUtils', | |
interfaces: [Utils]}; | |
var NodeUtils_instance = null; | |
function NodeUtils_getInstance() { | |
if (NodeUtils_instance === null) { | |
new NodeUtils(); | |
} | |
return NodeUtils_instance; | |
} | |
function platformDefaultTransformers($receiver) { | |
} | |
var package$io = _.io || (_.io = {}); | |
var package$ktor = package$io.ktor || (package$io.ktor = {}); | |
var package$client = package$ktor.client || (package$ktor.client = {}); | |
package$client.HttpClient_744i18$ = HttpClient; | |
package$client.HttpClient_rh9o9d$ = HttpClient_0; | |
package$client.HttpClient = HttpClient_1; | |
package$client.HttpClientConfig = HttpClientConfig; | |
package$client.HttpClientDsl = HttpClientDsl; | |
var package$call = package$client.call || (package$client.call = {}); | |
package$call.HttpClientCall = HttpClientCall; | |
package$call.HttpEngineCall = HttpEngineCall; | |
package$call.call_htnejk$ = call; | |
$$importsForInline$$['ktor-client-core'] = _; | |
package$call.DoubleReceiveException = DoubleReceiveException; | |
package$call.ReceivePipelineException = ReceivePipelineException; | |
package$call.NoTransformationFoundException = NoTransformationFoundException; | |
package$call.TypeInfo = TypeInfo; | |
package$call.UnsupportedContentTypeException = UnsupportedContentTypeException; | |
package$call.UnsupportedUpgradeProtocolException = UnsupportedUpgradeProtocolException; | |
package$call.call_30bfl5$ = call_0; | |
package$call.call_1t1q32$ = call_1; | |
package$call.call_p7i9r1$ = call_2; | |
var package$engine = package$client.engine || (package$client.engine = {}); | |
package$engine.HttpClientEngine = HttpClientEngine; | |
package$engine.HttpClientEngineFactory = HttpClientEngineFactory; | |
package$engine.config_qszf4x$ = config; | |
package$engine.HttpClientEngineConfig = HttpClientEngineConfig; | |
package$engine.mergeHeaders_kqv6tz$ = mergeHeaders; | |
Object.defineProperty(DefaultRequest, 'Feature', { | |
get: DefaultRequest$Feature_getInstance}); | |
var package$features = package$client.features || (package$client.features = {}); | |
package$features.DefaultRequest = DefaultRequest; | |
package$features.defaultRequest_fxc3ki$ = defaultRequest; | |
package$features.defaultTransformers_ejcypf$ = defaultTransformers; | |
Object.defineProperty(ExpectSuccess, 'Companion', { | |
get: ExpectSuccess$Companion_getInstance}); | |
package$features.ExpectSuccess = ExpectSuccess; | |
package$features.BadResponseStatusException = BadResponseStatusException; | |
Object.defineProperty(package$features, 'FEATURE_INSTALLED_LIST_8be2vx$', { | |
get: function() { | |
return FEATURE_INSTALLED_LIST; | |
}}); | |
package$features.HttpClientFeature = HttpClientFeature; | |
package$features.feature_ccg70z$ = feature; | |
$$importsForInline$$['kotlinx-io'] = $module$kotlinx_io; | |
HttpPlainText.Config = HttpPlainText$Config; | |
Object.defineProperty(HttpPlainText, 'Feature', { | |
get: HttpPlainText$Feature_getInstance}); | |
package$features.HttpPlainText = HttpPlainText; | |
Object.defineProperty(HttpRedirect, 'Feature', { | |
get: HttpRedirect$Feature_getInstance}); | |
package$features.HttpRedirect = HttpRedirect; | |
package$features.RedirectException = RedirectException; | |
package$features.Sender = Sender; | |
Object.defineProperty(HttpSend, 'Feature', { | |
get: HttpSend$Feature_getInstance}); | |
package$features.HttpSend = HttpSend; | |
package$features.SendCountExceedException = SendCountExceedException; | |
UserAgent.Config = UserAgent$Config; | |
Object.defineProperty(UserAgent, 'Feature', { | |
get: UserAgent$Feature_getInstance}); | |
package$features.UserAgent = UserAgent; | |
package$features.BrowserUserAgent_bbdm9p$ = BrowserUserAgent; | |
package$features.CurlUserAgent_bbdm9p$ = CurlUserAgent; | |
$$importsForInline$$['ktor-utils'] = $module$ktor_utils; | |
var package$cookies = package$features.cookies || (package$features.cookies = {}); | |
package$cookies.AcceptAllCookiesStorage = AcceptAllCookiesStorage; | |
package$cookies.ConstantCookiesStorage = ConstantCookiesStorage; | |
package$cookies.CookiesStorage = CookiesStorage; | |
package$cookies.addCookie_g29ije$ = addCookie; | |
package$cookies.matches_hkbsw1$ = matches; | |
package$cookies.fillDefaults_hkbsw1$ = fillDefaults; | |
HttpCookies.Config = HttpCookies$Config; | |
Object.defineProperty(HttpCookies, 'Companion', { | |
get: HttpCookies$Companion_getInstance}); | |
package$cookies.HttpCookies = HttpCookies; | |
package$cookies.cookies_4av9u2$ = cookies; | |
package$cookies.cookies_660qol$ = cookies_0; | |
package$cookies.get_h6ajkg$ = get_0; | |
var package$observer = package$features.observer || (package$features.observer = {}); | |
package$observer.wrapWithContent_xqjfkr$ = wrapWithContent; | |
package$observer.wrapWithContent_j79xlq$ = wrapWithContent_0; | |
package$observer.DelegatedRequest = DelegatedRequest; | |
package$observer.DelegatedResponse = DelegatedResponse; | |
ResponseObserver.Config = ResponseObserver$Config; | |
Object.defineProperty(ResponseObserver, 'Feature', { | |
get: ResponseObserver$Feature_getInstance}); | |
package$observer.ResponseObserver = ResponseObserver; | |
package$observer.ResponseObserver_5neev$ = ResponseObserver_0; | |
var package$request = package$client.request || (package$client.request = {}); | |
package$request.ClientUpgradeContent = ClientUpgradeContent; | |
package$request.HttpRequest = HttpRequest; | |
package$request.DefaultHttpRequest = DefaultHttpRequest; | |
Object.defineProperty(HttpRequestBuilder, 'Companion', { | |
get: HttpRequestBuilder$Companion_getInstance}); | |
package$request.HttpRequestBuilder = HttpRequestBuilder; | |
package$request.HttpRequestData = HttpRequestData; | |
package$request.headers_nc42ot$ = headers; | |
package$request.takeFrom_1c2elq$ = takeFrom_2; | |
package$request.url_vbrh3o$ = url; | |
package$request.takeFrom_kzlv8c$ = takeFrom_3; | |
package$request.invoke_qdb19q$ = invoke; | |
package$request.url_3rzbk2$ = url_0; | |
package$request.invoke_jmxlhc$ = invoke_0; | |
package$request.url_g8iu3v$ = url_1; | |
Object.defineProperty(HttpRequestPipeline, 'Phases', { | |
get: HttpRequestPipeline$Phases_getInstance}); | |
package$request.HttpRequestPipeline = HttpRequestPipeline; | |
Object.defineProperty(HttpSendPipeline, 'Phases', { | |
get: HttpSendPipeline$Phases_getInstance}); | |
package$request.HttpSendPipeline = HttpSendPipeline; | |
package$request.url_qpqkqe$ = url_2; | |
$$importsForInline$$['ktor-http'] = $module$ktor_http; | |
var package$utils = package$client.utils || (package$client.utils = {}); | |
package$request.request_2kdidn$ = request_3; | |
var package$forms = package$request.forms || (package$request.forms = {}); | |
package$forms.FormDataContent = FormDataContent; | |
package$forms.MultiPartFormDataContent = MultiPartFormDataContent; | |
package$forms.FormPart = FormPart; | |
package$forms.formData_l3ed5z$ = formData; | |
package$forms.formData_hut2op$ = formData_0; | |
package$forms.FormBuilder = FormBuilder; | |
package$forms.append_cnwqbb$ = append; | |
package$forms.append_rfaexf$ = append_0; | |
package$request.get_host_ocert9$ = get_host; | |
package$request.set_host_g8iu3v$ = set_host; | |
package$request.get_port_ocert9$ = get_port; | |
package$request.set_port_7bct3p$ = set_port; | |
package$request.header_xadl6p$ = header; | |
package$request.parameter_xadl6p$ = parameter; | |
package$request.accept_fohfhi$ = accept; | |
var package$response = package$client.response || (package$client.response = {}); | |
package$response.HttpResponse = HttpResponse; | |
package$response.readText_jsbrsb$ = readText_0; | |
package$response.HttpResponseConfig = HttpResponseConfig; | |
Object.defineProperty(HttpResponsePipeline, 'Phases', { | |
get: HttpResponsePipeline$Phases_getInstance}); | |
package$response.HttpResponsePipeline = HttpResponsePipeline; | |
Object.defineProperty(HttpReceivePipeline, 'Phases', { | |
get: HttpReceivePipeline$Phases_getInstance}); | |
package$response.HttpReceivePipeline = HttpReceivePipeline; | |
package$response.HttpResponseContainer = HttpResponseContainer; | |
package$response.readBytes_jkyc6c$ = readBytes_1; | |
package$response.readBytes_fcnupu$ = readBytes_2; | |
package$response.discardRemaining_fcnupu$ = discardRemaining; | |
Object.defineProperty(package$utils, 'DEFAULT_HTTP_POOL_SIZE', { | |
get: function() { | |
return DEFAULT_HTTP_POOL_SIZE; | |
}}); | |
Object.defineProperty(package$utils, 'DEFAULT_HTTP_BUFFER_SIZE', { | |
get: function() { | |
return DEFAULT_HTTP_BUFFER_SIZE; | |
}}); | |
Object.defineProperty(package$utils, 'EmptyContent', { | |
get: EmptyContent_getInstance}); | |
package$utils.wrapHeaders_j1n6iz$ = wrapHeaders; | |
Object.defineProperty(package$utils, 'CacheControl', { | |
get: CacheControl_getInstance}); | |
package$utils.buildHeaders_g6xk4w$ = buildHeaders; | |
package$client.HttpClient_f0veat$ = HttpClient_2; | |
package$call.Type = Type; | |
Object.defineProperty(package$call, 'JsType', { | |
get: JsType_getInstance}); | |
var package$js = package$engine.js || (package$engine.js = {}); | |
Object.defineProperty(package$js, 'Js', { | |
get: Js_getInstance}); | |
package$js.JsClient = JsClient; | |
$$importsForInline$$['kotlinx-coroutines-core'] = $module$kotlinx_coroutines_core; | |
package$js.JsClientEngine = JsClientEngine; | |
package$js.JsError = JsError; | |
package$js.JsHttpResponse = JsHttpResponse; | |
package$js.toRaw_4m9e5p$ = toRaw; | |
package$js.buildObject_ymnom6$ = buildObject; | |
package$js.readChunk_pggmy1$ = readChunk; | |
package$js.asByteArray_es0py6$ = asByteArray; | |
Object.defineProperty(Utils, 'Companion', { | |
get: Utils$Companion_getInstance}); | |
var package$compatible = package$js.compatible || (package$js.compatible = {}); | |
package$compatible.Utils = Utils; | |
var package$browser = package$compatible.browser || (package$compatible.browser = {}); | |
Object.defineProperty(package$browser, 'BrowserUtils', { | |
get: BrowserUtils_getInstance}); | |
var package$node = package$compatible.node || (package$compatible.node = {}); | |
Object.defineProperty(package$node, 'NodeUtils', { | |
get: NodeUtils_getInstance}); | |
package$features.platformDefaultTransformers_h1fxjk$ = platformDefaultTransformers; | |
config$ObjectLiteral.prototype.create_dxyxif$ = HttpClientEngineFactory.prototype.create_dxyxif$; | |
DefaultRequest$Feature.prototype.prepare_oh3mgy$ = HttpClientFeature.prototype.prepare_oh3mgy$; | |
ExpectSuccess$Companion.prototype.prepare_oh3mgy$ = HttpClientFeature.prototype.prepare_oh3mgy$; | |
HttpPlainText$Feature.prototype.prepare_oh3mgy$ = HttpClientFeature.prototype.prepare_oh3mgy$; | |
HttpRedirect$Feature.prototype.prepare_oh3mgy$ = HttpClientFeature.prototype.prepare_oh3mgy$; | |
HttpSend$Feature.prototype.prepare_oh3mgy$ = HttpClientFeature.prototype.prepare_oh3mgy$; | |
UserAgent$Feature.prototype.prepare_oh3mgy$ = HttpClientFeature.prototype.prepare_oh3mgy$; | |
HttpCookies$Companion.prototype.prepare_oh3mgy$ = HttpClientFeature.prototype.prepare_oh3mgy$; | |
Object.defineProperty(DelegatedResponse.prototype, 'executionContext', Object.getOwnPropertyDescriptor(HttpResponse.prototype, 'executionContext')); | |
ResponseObserver$Feature.prototype.prepare_oh3mgy$ = HttpClientFeature.prototype.prepare_oh3mgy$; | |
Object.defineProperty(DefaultHttpRequest.prototype, 'executionContext', Object.getOwnPropertyDescriptor(HttpRequest.prototype, 'executionContext')); | |
Js.prototype.create_dxyxif$ = HttpClientEngineFactory.prototype.create_dxyxif$; | |
Object.defineProperty(JsHttpResponse.prototype, 'executionContext', Object.getOwnPropertyDescriptor(HttpResponse.prototype, 'executionContext')); | |
FEATURE_INSTALLED_LIST = new AttributeKey('ApplicationFeatureRegistry'); | |
DEFAULT_HTTP_POOL_SIZE = 1000; | |
DEFAULT_HTTP_BUFFER_SIZE = 4096; | |
Kotlin.defineModule('ktor-client-core', _); | |
return _; | |
})); | |
//# sourceMappingURL=ktor-client-core.js.map |
This file has been truncated, but you can view the full file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"version": 3, | |
"file": "ktor-client-core.js", | |
"sources": [ | |
"../../../../../common/src/io/ktor/client/features/DefaultTransform.kt", | |
"../../../../../common/src/io/ktor/client/features/cookies/AcceptAllCookiesStorage.kt", | |
"../../../../../common/src/io/ktor/client/HttpClient.kt", | |
"util/Standard.kt", | |
"../../../../../../../../../../../../dummy.kt", | |
"generated/_Collections.kt", | |
"collections/Maps.kt", | |
"../../../../../common/src/io/ktor/client/HttpClientConfig.kt", | |
"../../../../../common/src/io/ktor/client/call/HttpClientCall.kt", | |
"../../../../../js/src/io/ktor/client/call/TypeInfoJs.kt", | |
"../../../../../common/src/io/ktor/client/call/TypeInfo.kt", | |
"../../../../../common/src/io/ktor/client/call/utils.kt", | |
"../../../../../common/src/io/ktor/client/engine/HttpClientEngine.kt", | |
"../../../../../common/src/io/ktor/client/engine/HttpClientEngineConfig.kt", | |
"../../../../../common/src/io/ktor/client/engine/Utils.kt", | |
"../../../../../common/src/io/ktor/client/features/DefaultRequest.kt", | |
"../../../../../common/src/io/ktor/client/features/ExpectSuccess.kt", | |
"../../../../../common/src/io/ktor/client/features/HttpClientFeature.kt", | |
"../../../../../common/src/io/ktor/client/features/HttpPlainText.kt", | |
"../../../../../common/src/kotlinx/io/core/Builder.kt", | |
"../../../../../common/src/kotlinx/io/core/ByteReadPacket.kt", | |
"../../../../../common/src/io/ktor/client/features/HttpRedirect.kt", | |
"collections/Collections.kt", | |
"../../../../../common/src/io/ktor/client/features/HttpSend.kt", | |
"collections/MutableCollections.kt", | |
"../../../../../common/src/io/ktor/client/features/UserAgent.kt", | |
"kotlin/math.kt", | |
"generated/_Arrays.kt", | |
"../../../../../common/src/io/ktor/client/features/cookies/ConstantCookiesStorage.kt", | |
"../../../../../common/src/io/ktor/client/features/cookies/CookiesStorage.kt", | |
"kotlin/string.kt", | |
"util/Preconditions.kt", | |
"text/Strings.kt", | |
"../../../../../common/src/io/ktor/client/features/cookies/HttpCookies.kt", | |
"text/StringBuilder.kt", | |
"../../../../../common/src/io/ktor/client/features/observer/DelegatedCall.kt", | |
"../../../../../common/src/io/ktor/client/features/observer/ResponseObserver.kt", | |
"../../../../../common/src/io/ktor/client/request/Content.kt", | |
"util/Lazy.kt", | |
"../../../../../common/src/io/ktor/client/request/HttpRequest.kt", | |
"../../../../../common/src/io/ktor/client/request/HttpRequestPipeline.kt", | |
"../../../../../common/src/io/ktor/client/request/builders.kt", | |
"../../../../../common/src/io/ktor/client/request/buildersWithUrl.kt", | |
"../../../../../common/src/kotlinx/io/core/Scanner.kt", | |
"../../../../../common/src/io/ktor/client/request/forms/FormDataContent.kt", | |
"../../../../../common/src/kotlinx/io/core/Input.kt", | |
"../../../../../common/src/io/ktor/client/request/forms/formBuilders.kt", | |
"../../../../../common/src/io/ktor/client/request/forms/formDsl.kt", | |
"../../../../../common/src/io/ktor/http/HeaderValueWithParameters.kt", | |
"kotlin/collections.kt", | |
"../../../../../common/src/io/ktor/client/request/utils.kt", | |
"../../../../../common/src/io/ktor/client/response/HttpResponse.kt", | |
"../../../../../common/src/io/ktor/client/response/HttpResponseConfig.kt", | |
"../../../../../common/src/io/ktor/client/response/HttpResponsePipeline.kt", | |
"../../../../../common/src/io/ktor/client/response/readers.kt", | |
"../../../../../common/src/io/ktor/client/utils/Content.kt", | |
"../../../../../common/src/io/ktor/client/utils/HttpCacheControl.kt", | |
"../../../../../common/src/io/ktor/client/utils/headers.kt", | |
"../../../../../js/src/io/ktor/client/HttpClientJs.kt", | |
"../../../../../js/src/io/ktor/client/engine/js/Js.kt", | |
"../../../../../js/src/io/ktor/client/engine/js/JsClientEngine.kt", | |
"coroutines/Continuation.kt", | |
"util/Result.kt", | |
"../../../../../../common/kotlinx-coroutines-core-common/src/Builders.common.kt", | |
"../../../../../js/src/io/ktor/client/engine/js/JsHttpResponse.kt", | |
"../../../../../js/src/io/ktor/client/engine/js/JsUtils.kt", | |
"../../../../../js/src/io/ktor/client/engine/js/ReadableStream.kt", | |
"../../../../../js/src/io/ktor/client/engine/js/compatible/Utils.kt", | |
"../../../../../js/src/io/ktor/client/engine/js/compatible/browser/BrowserUtils.kt", | |
"../../../../../js/src/io/ktor/client/engine/js/compatible/node/NodeUtils.kt", | |
"../../../../../js/src/io/ktor/client/features/DefaultTransformJs.kt", | |
"../../../../../common/src/io/ktor/client/utils/CIO.kt" | |
], | |
"sourcesContent": [ | |
"package io.ktor.client.features\n\nimport io.ktor.client.*\nimport io.ktor.client.request.*\nimport io.ktor.client.response.*\nimport io.ktor.http.*\nimport io.ktor.http.content.*\nimport io.ktor.util.*\nimport kotlinx.coroutines.io.*\nimport kotlinx.io.core.*\n\n/**\n * Install default transformers.\n * Usually installed by default so there is no need to use it\n * unless you have disabled it via [HttpClientConfig.useDefaultTransformers].\n */\nfun HttpClient.defaultTransformers() {\n requestPipeline.intercept(HttpRequestPipeline.Render) { body ->\n\n if (context.headers[HttpHeaders.Accept] == null) {\n context.headers.append(HttpHeaders.Accept, \"*/*\")\n }\n\n when (body) {\n is ByteArray -> proceedWith(object : OutgoingContent.ByteArrayContent() {\n override val contentLength: Long = body.size.toLong()\n override fun bytes(): ByteArray = body\n })\n }\n }\n\n responsePipeline.intercept(HttpResponsePipeline.Parse) { (info, response) ->\n if (response !is HttpResponse) return@intercept\n val contentLength = response.headers[HttpHeaders.ContentLength]?.toLong() ?: Long.MAX_VALUE\n when (info.type) {\n Unit::class -> {\n response.content.cancel()\n response.close()\n proceedWith(HttpResponseContainer(info, Unit))\n }\n ByteReadChannel::class -> proceedWith(HttpResponseContainer(info, response.content))\n ByteArray::class -> {\n val readRemaining = response.content.readRemaining(contentLength)\n proceedWith(HttpResponseContainer(info, readRemaining.readBytes()))\n }\n }\n }\n\n platformDefaultTransformers()\n}\n\ninternal expect fun HttpClient.platformDefaultTransformers()\n", | |
"package io.ktor.client.features.cookies\n\nimport io.ktor.http.*\nimport io.ktor.util.*\nimport io.ktor.util.date.*\nimport kotlinx.atomicfu.*\nimport kotlin.math.*\n\n/**\n * [CookiesStorage] that stores all the cookies in an in-memory map.\n */\nclass AcceptAllCookiesStorage() : CookiesStorage {\n private val container: MutableList<Cookie> = mutableListOf()\n private val oldestCookie: AtomicLong = atomic(0L)\n private val mutex = Lock()\n\n override suspend fun get(requestUrl: Url): List<Cookie> = mutex.use {\n val date = GMTDate()\n if (date.timestamp < oldestCookie.value) cleanup(date.timestamp)\n\n return container.filter { it.matches(requestUrl) }\n }\n\n override suspend fun addCookie(requestUrl: Url, cookie: Cookie): Unit = mutex.use {\n with(cookie) {\n if (name.isBlank()) return@use\n }\n\n container.removeAll { it.name == cookie.name && it.matches(requestUrl) }\n container.add(cookie.fillDefaults(requestUrl))\n }\n\n private fun cleanup(timestamp: Long) {\n container.removeAll { cookie ->\n val expires = cookie.expires?.timestamp ?: return@removeAll false\n expires < timestamp\n }\n\n val newOldest = container.fold(Long.MAX_VALUE) { acc, cookie ->\n cookie.expires?.timestamp?.let { min(acc, it) } ?: acc\n }\n\n oldestCookie.value = newOldest\n }\n}\n", | |
"package io.ktor.client\n\nimport io.ktor.client.call.*\nimport io.ktor.client.engine.*\nimport io.ktor.client.features.*\nimport io.ktor.client.request.*\nimport io.ktor.client.response.*\nimport io.ktor.http.*\nimport io.ktor.util.*\nimport kotlinx.atomicfu.*\nimport kotlinx.coroutines.*\nimport kotlinx.io.core.*\nimport kotlin.coroutines.*\n\n/**\n * Constructs an asynchronous [HttpClient] using optional [block] for configuring this client.\n *\n * The [HttpClientEngine] is selected from the dependencies.\n * https://ktor.io/clients/http-client/engines.html\n */\n@HttpClientDsl\nexpect fun HttpClient(\n block: HttpClientConfig<*>.() -> Unit = {}\n): HttpClient\n\n/**\n * Constructs an asynchronous [HttpClient] using the specified [engineFactory]\n * and an optional [block] for configuring this client.\n */\n@HttpClientDsl\nfun <T : HttpClientEngineConfig> HttpClient(\n engineFactory: HttpClientEngineFactory<T>,\n block: HttpClientConfig<T>.() -> Unit = {}\n): HttpClient {\n val config: HttpClientConfig<T> = HttpClientConfig<T>().apply(block)\n val engine = engineFactory.create(config.engineConfig)\n\n return HttpClient(engine, config)\n}\n\n/**\n * Constructs an asynchronous [HttpClient] using the specified [engine]\n * and a [block] for configuring this client.\n */\n@HttpClientDsl\nfun HttpClient(\n engine: HttpClientEngine,\n block: HttpClientConfig<*>.() -> Unit\n): HttpClient = HttpClient(engine, HttpClientConfig<HttpClientEngineConfig>().apply(block))\n\n/**\n * Asynchronous client to perform HTTP requests.\n *\n * This is a generic implementation that uses a specific engine [HttpClientEngine].\n * @property engine: [HttpClientEngine] for executing requests.\n */\nclass HttpClient(\n @InternalAPI val engine: HttpClientEngine,\n private val userConfig: HttpClientConfig<out HttpClientEngineConfig> = HttpClientConfig()\n) : CoroutineScope, Closeable {\n private val closed = atomic(false)\n\n override val coroutineContext: CoroutineContext get() = engine.coroutineContext\n\n /**\n * Pipeline used for processing all the requests sent by this client.\n */\n val requestPipeline: HttpRequestPipeline = HttpRequestPipeline()\n\n /**\n * Pipeline used for processing all the responses sent by the server.\n */\n val responsePipeline: HttpResponsePipeline = HttpResponsePipeline()\n\n /**\n * Pipeline used for sending the request\n */\n val sendPipeline: HttpSendPipeline = HttpSendPipeline().apply {\n intercept(HttpSendPipeline.Engine) { content ->\n val call = HttpClientCall(this@HttpClient)\n val requestData = HttpRequestBuilder().apply {\n takeFrom(context)\n body = content\n }.build()\n\n validateHeaders(requestData)\n\n val (request, response) = engine.execute(call, requestData)\n\n call.request = request\n call.response = response\n\n response.coroutineContext[Job]!!.invokeOnCompletion { cause ->\n @Suppress(\"UNCHECKED_CAST\")\n val childContext = requestData.executionContext as CompletableDeferred<Unit>\n if (cause == null) childContext.complete(Unit) else childContext.completeExceptionally(cause)\n }\n\n val receivedCall = receivePipeline.execute(call, call.response).call\n proceedWith(receivedCall)\n }\n }\n\n /**\n * Pipeline used for receiving request\n */\n val receivePipeline: HttpReceivePipeline = HttpReceivePipeline()\n\n /**\n * Typed attributes used as a lightweight container for this client.\n */\n val attributes: Attributes = Attributes()\n\n /**\n * Dispatcher handles io operations\n */\n @Deprecated(\n \"[dispatcher] is deprecated. Use coroutineContext instead.\",\n replaceWith = ReplaceWith(\"coroutineContext\"),\n level = DeprecationLevel.ERROR\n )\n val dispatcher: CoroutineDispatcher\n get() = engine.dispatcher\n\n /**\n * Client engine config\n */\n val engineConfig: HttpClientEngineConfig = engine.config\n\n private val config = HttpClientConfig<HttpClientEngineConfig>()\n\n init {\n with(userConfig) {\n if (useDefaultTransformers) {\n config.install(HttpPlainText)\n config.install(\"DefaultTransformers\") { defaultTransformers() }\n }\n\n if (expectSuccess) config.install(ExpectSuccess)\n\n config.install(HttpSend)\n\n if (followRedirects) config.install(HttpRedirect)\n\n config += this\n config.install(this@HttpClient)\n }\n }\n\n /**\n * Creates a new [HttpRequest] from a request [data] and a specific client [call].\n */\n suspend fun execute(builder: HttpRequestBuilder): HttpClientCall =\n requestPipeline.execute(builder, builder.body) as HttpClientCall\n\n /**\n * Returns a new [HttpClient] copying this client configuration,\n * and additionally configured by the [block] parameter.\n */\n fun config(block: HttpClientConfig<*>.() -> Unit): HttpClient = HttpClient(\n engine, HttpClientConfig<HttpClientEngineConfig>().apply {\n this += userConfig\n block()\n }\n )\n\n /**\n * Closes the underlying [engine].\n */\n override fun close() {\n val success = closed.compareAndSet(false, true)\n if (!success) return\n\n attributes.allKeys.forEach { key ->\n @Suppress(\"UNCHECKED_CAST\")\n val feature = attributes[key as AttributeKey<Any>]\n\n if (feature is Closeable) {\n feature.close()\n }\n }\n\n engine.close()\n }\n\n}\n\n/**\n * Validates request headers and fails if there are unsafe headers supplied\n */\nprivate fun validateHeaders(request: HttpRequestData) {\n val requestHeaders = request.headers\n for (header in HttpHeaders.UnsafeHeaders) {\n if (header in requestHeaders) {\n throw UnsafeHeaderException(header)\n }\n }\n}\n", | |
"/*\n * Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license\n * that can be found in the license/LICENSE.txt file.\n */\n\n@file:kotlin.jvm.JvmMultifileClass\n@file:kotlin.jvm.JvmName(\"StandardKt\")\npackage kotlin\n\nimport kotlin.contracts.*\n\n/**\n * An exception is thrown to indicate that a method body remains to be implemented.\n */\npublic class NotImplementedError(message: String = \"An operation is not implemented.\") : Error(message)\n\n/**\n * Always throws [NotImplementedError] stating that operation is not implemented.\n */\n\[email protected]\npublic inline fun TODO(): Nothing = throw NotImplementedError()\n\n/**\n * Always throws [NotImplementedError] stating that operation is not implemented.\n *\n * @param reason a string explaining why the implementation is missing.\n */\[email protected]\npublic inline fun TODO(reason: String): Nothing = throw NotImplementedError(\"An operation is not implemented: $reason\")\n\n\n\n/**\n * Calls the specified function [block] and returns its result.\n */\[email protected]\npublic inline fun <R> run(block: () -> R): R {\n contract {\n callsInPlace(block, InvocationKind.EXACTLY_ONCE)\n }\n return block()\n}\n\n/**\n * Calls the specified function [block] with `this` value as its receiver and returns its result.\n */\[email protected]\npublic inline fun <T, R> T.run(block: T.() -> R): R {\n contract {\n callsInPlace(block, InvocationKind.EXACTLY_ONCE)\n }\n return block()\n}\n\n/**\n * Calls the specified function [block] with the given [receiver] as its receiver and returns its result.\n */\[email protected]\npublic inline fun <T, R> with(receiver: T, block: T.() -> R): R {\n contract {\n callsInPlace(block, InvocationKind.EXACTLY_ONCE)\n }\n return receiver.block()\n}\n\n/**\n * Calls the specified function [block] with `this` value as its receiver and returns `this` value.\n */\[email protected]\npublic inline fun <T> T.apply(block: T.() -> Unit): T {\n contract {\n callsInPlace(block, InvocationKind.EXACTLY_ONCE)\n }\n block()\n return this\n}\n\n/**\n * Calls the specified function [block] with `this` value as its argument and returns `this` value.\n */\[email protected]\n@SinceKotlin(\"1.1\")\npublic inline fun <T> T.also(block: (T) -> Unit): T {\n contract {\n callsInPlace(block, InvocationKind.EXACTLY_ONCE)\n }\n block(this)\n return this\n}\n\n/**\n * Calls the specified function [block] with `this` value as its argument and returns its result.\n */\[email protected]\npublic inline fun <T, R> T.let(block: (T) -> R): R {\n contract {\n callsInPlace(block, InvocationKind.EXACTLY_ONCE)\n }\n return block(this)\n}\n\n/**\n * Returns `this` value if it satisfies the given [predicate] or `null`, if it doesn't.\n */\[email protected]\n@SinceKotlin(\"1.1\")\npublic inline fun <T> T.takeIf(predicate: (T) -> Boolean): T? {\n contract {\n callsInPlace(predicate, InvocationKind.EXACTLY_ONCE)\n }\n return if (predicate(this)) this else null\n}\n\n/**\n * Returns `this` value if it _does not_ satisfy the given [predicate] or `null`, if it does.\n */\[email protected]\n@SinceKotlin(\"1.1\")\npublic inline fun <T> T.takeUnless(predicate: (T) -> Boolean): T? {\n contract {\n callsInPlace(predicate, InvocationKind.EXACTLY_ONCE)\n }\n return if (!predicate(this)) this else null\n}\n\n/**\n * Executes the given function [action] specified number of [times].\n *\n * A zero-based index of current iteration is passed as a parameter to [action].\n *\n * @sample samples.misc.ControlFlow.repeat\n */\[email protected]\npublic inline fun repeat(times: Int, action: (Int) -> Unit) {\n contract { callsInPlace(action) }\n\n for (index in 0 until times) {\n action(index)\n }\n}\n", | |
null, | |
"/*\n * Copyright 2010-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license \n * that can be found in the license/LICENSE.txt file.\n */\n\n@file:kotlin.jvm.JvmMultifileClass\n@file:kotlin.jvm.JvmName(\"CollectionsKt\")\n\npackage kotlin.collections\n\n//\n// NOTE: THIS FILE IS AUTO-GENERATED by the GenerateStandardLib.kt\n// See: https://github.com/JetBrains/kotlin/tree/master/libraries/stdlib\n//\n\nimport kotlin.random.*\n\n/**\n * Returns 1st *element* from the collection.\n */\[email protected]\npublic inline operator fun <T> List<T>.component1(): T {\n return get(0)\n}\n\n/**\n * Returns 2nd *element* from the collection.\n */\[email protected]\npublic inline operator fun <T> List<T>.component2(): T {\n return get(1)\n}\n\n/**\n * Returns 3rd *element* from the collection.\n */\[email protected]\npublic inline operator fun <T> List<T>.component3(): T {\n return get(2)\n}\n\n/**\n * Returns 4th *element* from the collection.\n */\[email protected]\npublic inline operator fun <T> List<T>.component4(): T {\n return get(3)\n}\n\n/**\n * Returns 5th *element* from the collection.\n */\[email protected]\npublic inline operator fun <T> List<T>.component5(): T {\n return get(4)\n}\n\n/**\n * Returns `true` if [element] is found in the collection.\n */\npublic operator fun <@kotlin.internal.OnlyInputTypes T> Iterable<T>.contains(element: T): Boolean {\n if (this is Collection)\n return contains(element)\n return indexOf(element) >= 0\n}\n\n/**\n * Returns an element at the given [index] or throws an [IndexOutOfBoundsException] if the [index] is out of bounds of this collection.\n * \n * @sample samples.collections.Collections.Elements.elementAt\n */\npublic fun <T> Iterable<T>.elementAt(index: Int): T {\n if (this is List)\n return get(index)\n return elementAtOrElse(index) { throw IndexOutOfBoundsException(\"Collection doesn't contain element at index $index.\") }\n}\n\n/**\n * Returns an element at the given [index] or throws an [IndexOutOfBoundsException] if the [index] is out of bounds of this list.\n * \n * @sample samples.collections.Collections.Elements.elementAt\n */\[email protected]\npublic inline fun <T> List<T>.elementAt(index: Int): T {\n return get(index)\n}\n\n/**\n * Returns an element at the given [index] or the result of calling the [defaultValue] function if the [index] is out of bounds of this collection.\n * \n * @sample samples.collections.Collections.Elements.elementAtOrElse\n */\npublic fun <T> Iterable<T>.elementAtOrElse(index: Int, defaultValue: (Int) -> T): T {\n if (this is List)\n return this.getOrElse(index, defaultValue)\n if (index < 0)\n return defaultValue(index)\n val iterator = iterator()\n var count = 0\n while (iterator.hasNext()) {\n val element = iterator.next()\n if (index == count++)\n return element\n }\n return defaultValue(index)\n}\n\n/**\n * Returns an element at the given [index] or the result of calling the [defaultValue] function if the [index] is out of bounds of this list.\n * \n * @sample samples.collections.Collections.Elements.elementAtOrElse\n */\[email protected]\npublic inline fun <T> List<T>.elementAtOrElse(index: Int, defaultValue: (Int) -> T): T {\n return if (index >= 0 && index <= lastIndex) get(index) else defaultValue(index)\n}\n\n/**\n * Returns an element at the given [index] or `null` if the [index] is out of bounds of this collection.\n * \n * @sample samples.collections.Collections.Elements.elementAtOrNull\n */\npublic fun <T> Iterable<T>.elementAtOrNull(index: Int): T? {\n if (this is List)\n return this.getOrNull(index)\n if (index < 0)\n return null\n val iterator = iterator()\n var count = 0\n while (iterator.hasNext()) {\n val element = iterator.next()\n if (index == count++)\n return element\n }\n return null\n}\n\n/**\n * Returns an element at the given [index] or `null` if the [index] is out of bounds of this list.\n * \n * @sample samples.collections.Collections.Elements.elementAtOrNull\n */\[email protected]\npublic inline fun <T> List<T>.elementAtOrNull(index: Int): T? {\n return this.getOrNull(index)\n}\n\n/**\n * Returns the first element matching the given [predicate], or `null` if no such element was found.\n */\[email protected]\npublic inline fun <T> Iterable<T>.find(predicate: (T) -> Boolean): T? {\n return firstOrNull(predicate)\n}\n\n/**\n * Returns the last element matching the given [predicate], or `null` if no such element was found.\n */\[email protected]\npublic inline fun <T> Iterable<T>.findLast(predicate: (T) -> Boolean): T? {\n return lastOrNull(predicate)\n}\n\n/**\n * Returns the last element matching the given [predicate], or `null` if no such element was found.\n */\[email protected]\npublic inline fun <T> List<T>.findLast(predicate: (T) -> Boolean): T? {\n return lastOrNull(predicate)\n}\n\n/**\n * Returns first element.\n * @throws [NoSuchElementException] if the collection is empty.\n */\npublic fun <T> Iterable<T>.first(): T {\n when (this) {\n is List -> return this.first()\n else -> {\n val iterator = iterator()\n if (!iterator.hasNext())\n throw NoSuchElementException(\"Collection is empty.\")\n return iterator.next()\n }\n }\n}\n\n/**\n * Returns first element.\n * @throws [NoSuchElementException] if the list is empty.\n */\npublic fun <T> List<T>.first(): T {\n if (isEmpty())\n throw NoSuchElementException(\"List is empty.\")\n return this[0]\n}\n\n/**\n * Returns the first element matching the given [predicate].\n * @throws [NoSuchElementException] if no such element is found.\n */\npublic inline fun <T> Iterable<T>.first(predicate: (T) -> Boolean): T {\n for (element in this) if (predicate(element)) return element\n throw NoSuchElementException(\"Collection contains no element matching the predicate.\")\n}\n\n/**\n * Returns the first element, or `null` if the collection is empty.\n */\npublic fun <T> Iterable<T>.firstOrNull(): T? {\n when (this) {\n is List -> {\n if (isEmpty())\n return null\n else\n return this[0]\n }\n else -> {\n val iterator = iterator()\n if (!iterator.hasNext())\n return null\n return iterator.next()\n }\n }\n}\n\n/**\n * Returns the first element, or `null` if the list is empty.\n */\npublic fun <T> List<T>.firstOrNull(): T? {\n return if (isEmpty()) null else this[0]\n}\n\n/**\n * Returns the first element matching the given [predicate], or `null` if element was not found.\n */\npublic inline fun <T> Iterable<T>.firstOrNull(predicate: (T) -> Boolean): T? {\n for (element in this) if (predicate(element)) return element\n return null\n}\n\n/**\n * Returns an element at the given [index] or the result of calling the [defaultValue] function if the [index] is out of bounds of this list.\n */\[email protected]\npublic inline fun <T> List<T>.getOrElse(index: Int, defaultValue: (Int) -> T): T {\n return if (index >= 0 && index <= lastIndex) get(index) else defaultValue(index)\n}\n\n/**\n * Returns an element at the given [index] or `null` if the [index] is out of bounds of this list.\n */\npublic fun <T> List<T>.getOrNull(index: Int): T? {\n return if (index >= 0 && index <= lastIndex) get(index) else null\n}\n\n/**\n * Returns first index of [element], or -1 if the collection does not contain element.\n */\npublic fun <@kotlin.internal.OnlyInputTypes T> Iterable<T>.indexOf(element: T): Int {\n if (this is List) return this.indexOf(element)\n var index = 0\n for (item in this) {\n checkIndexOverflow(index)\n if (element == item)\n return index\n index++\n }\n return -1\n}\n\n/**\n * Returns first index of [element], or -1 if the list does not contain element.\n */\n@Suppress(\"EXTENSION_SHADOWED_BY_MEMBER\") // false warning, extension takes precedence in some cases\npublic fun <@kotlin.internal.OnlyInputTypes T> List<T>.indexOf(element: T): Int {\n return indexOf(element)\n}\n\n/**\n * Returns index of the first element matching the given [predicate], or -1 if the collection does not contain such element.\n */\npublic inline fun <T> Iterable<T>.indexOfFirst(predicate: (T) -> Boolean): Int {\n var index = 0\n for (item in this) {\n checkIndexOverflow(index)\n if (predicate(item))\n return index\n index++\n }\n return -1\n}\n\n/**\n * Returns index of the first element matching the given [predicate], or -1 if the list does not contain such element.\n */\npublic inline fun <T> List<T>.indexOfFirst(predicate: (T) -> Boolean): Int {\n var index = 0\n for (item in this) {\n if (predicate(item))\n return index\n index++\n }\n return -1\n}\n\n/**\n * Returns index of the last element matching the given [predicate], or -1 if the collection does not contain such element.\n */\npublic inline fun <T> Iterable<T>.indexOfLast(predicate: (T) -> Boolean): Int {\n var lastIndex = -1\n var index = 0\n for (item in this) {\n checkIndexOverflow(index)\n if (predicate(item))\n lastIndex = index\n index++\n }\n return lastIndex\n}\n\n/**\n * Returns index of the last element matching the given [predicate], or -1 if the list does not contain such element.\n */\npublic inline fun <T> List<T>.indexOfLast(predicate: (T) -> Boolean): Int {\n val iterator = this.listIterator(size)\n while (iterator.hasPrevious()) {\n if (predicate(iterator.previous())) {\n return iterator.nextIndex()\n }\n }\n return -1\n}\n\n/**\n * Returns the last element.\n * @throws [NoSuchElementException] if the collection is empty.\n */\npublic fun <T> Iterable<T>.last(): T {\n when (this) {\n is List -> return this.last()\n else -> {\n val iterator = iterator()\n if (!iterator.hasNext())\n throw NoSuchElementException(\"Collection is empty.\")\n var last = iterator.next()\n while (iterator.hasNext())\n last = iterator.next()\n return last\n }\n }\n}\n\n/**\n * Returns the last element.\n * @throws [NoSuchElementException] if the list is empty.\n */\npublic fun <T> List<T>.last(): T {\n if (isEmpty())\n throw NoSuchElementException(\"List is empty.\")\n return this[lastIndex]\n}\n\n/**\n * Returns the last element matching the given [predicate].\n * @throws [NoSuchElementException] if no such element is found.\n */\npublic inline fun <T> Iterable<T>.last(predicate: (T) -> Boolean): T {\n var last: T? = null\n var found = false\n for (element in this) {\n if (predicate(element)) {\n last = element\n found = true\n }\n }\n if (!found) throw NoSuchElementException(\"Collection contains no element matching the predicate.\")\n @Suppress(\"UNCHECKED_CAST\")\n return last as T\n}\n\n/**\n * Returns the last element matching the given [predicate].\n * @throws [NoSuchElementException] if no such element is found.\n */\npublic inline fun <T> List<T>.last(predicate: (T) -> Boolean): T {\n val iterator = this.listIterator(size)\n while (iterator.hasPrevious()) {\n val element = iterator.previous()\n if (predicate(element)) return element\n }\n throw NoSuchElementException(\"List contains no element matching the predicate.\")\n}\n\n/**\n * Returns last index of [element], or -1 if the collection does not contain element.\n */\npublic fun <@kotlin.internal.OnlyInputTypes T> Iterable<T>.lastIndexOf(element: T): Int {\n if (this is List) return this.lastIndexOf(element)\n var lastIndex = -1\n var index = 0\n for (item in this) {\n checkIndexOverflow(index)\n if (element == item)\n lastIndex = index\n index++\n }\n return lastIndex\n}\n\n/**\n * Returns last index of [element], or -1 if the list does not contain element.\n */\n@Suppress(\"EXTENSION_SHADOWED_BY_MEMBER\") // false warning, extension takes precedence in some cases\npublic fun <@kotlin.internal.OnlyInputTypes T> List<T>.lastIndexOf(element: T): Int {\n return lastIndexOf(element)\n}\n\n/**\n * Returns the last element, or `null` if the collection is empty.\n */\npublic fun <T> Iterable<T>.lastOrNull(): T? {\n when (this) {\n is List -> return if (isEmpty()) null else this[size - 1]\n else -> {\n val iterator = iterator()\n if (!iterator.hasNext())\n return null\n var last = iterator.next()\n while (iterator.hasNext())\n last = iterator.next()\n return last\n }\n }\n}\n\n/**\n * Returns the last element, or `null` if the list is empty.\n */\npublic fun <T> List<T>.lastOrNull(): T? {\n return if (isEmpty()) null else this[size - 1]\n}\n\n/**\n * Returns the last element matching the given [predicate], or `null` if no such element was found.\n */\npublic inline fun <T> Iterable<T>.lastOrNull(predicate: (T) -> Boolean): T? {\n var last: T? = null\n for (element in this) {\n if (predicate(element)) {\n last = element\n }\n }\n return last\n}\n\n/**\n * Returns the last element matching the given [predicate], or `null` if no such element was found.\n */\npublic inline fun <T> List<T>.lastOrNull(predicate: (T) -> Boolean): T? {\n val iterator = this.listIterator(size)\n while (iterator.hasPrevious()) {\n val element = iterator.previous()\n if (predicate(element)) return element\n }\n return null\n}\n\n/**\n * Returns a random element from this collection.\n * \n * @throws NoSuchElementException if this collection is empty.\n */\n@SinceKotlin(\"1.3\")\[email protected]\npublic inline fun <T> Collection<T>.random(): T {\n return random(Random)\n}\n\n/**\n * Returns a random element from this collection using the specified source of randomness.\n * \n * @throws NoSuchElementException if this collection is empty.\n */\n@SinceKotlin(\"1.3\")\npublic fun <T> Collection<T>.random(random: Random): T {\n if (isEmpty())\n throw NoSuchElementException(\"Collection is empty.\")\n return elementAt(random.nextInt(size))\n}\n\n/**\n * Returns the single element, or throws an exception if the collection is empty or has more than one element.\n */\npublic fun <T> Iterable<T>.single(): T {\n when (this) {\n is List -> return this.single()\n else -> {\n val iterator = iterator()\n if (!iterator.hasNext())\n throw NoSuchElementException(\"Collection is empty.\")\n val single = iterator.next()\n if (iterator.hasNext())\n throw IllegalArgumentException(\"Collection has more than one element.\")\n return single\n }\n }\n}\n\n/**\n * Returns the single element, or throws an exception if the list is empty or has more than one element.\n */\npublic fun <T> List<T>.single(): T {\n return when (size) {\n 0 -> throw NoSuchElementException(\"List is empty.\")\n 1 -> this[0]\n else -> throw IllegalArgumentException(\"List has more than one element.\")\n }\n}\n\n/**\n * Returns the single element matching the given [predicate], or throws exception if there is no or more than one matching element.\n */\npublic inline fun <T> Iterable<T>.single(predicate: (T) -> Boolean): T {\n var single: T? = null\n var found = false\n for (element in this) {\n if (predicate(element)) {\n if (found) throw IllegalArgumentException(\"Collection contains more than one matching element.\")\n single = element\n found = true\n }\n }\n if (!found) throw NoSuchElementException(\"Collection contains no element matching the predicate.\")\n @Suppress(\"UNCHECKED_CAST\")\n return single as T\n}\n\n/**\n * Returns single element, or `null` if the collection is empty or has more than one element.\n */\npublic fun <T> Iterable<T>.singleOrNull(): T? {\n when (this) {\n is List -> return if (size == 1) this[0] else null\n else -> {\n val iterator = iterator()\n if (!iterator.hasNext())\n return null\n val single = iterator.next()\n if (iterator.hasNext())\n return null\n return single\n }\n }\n}\n\n/**\n * Returns single element, or `null` if the list is empty or has more than one element.\n */\npublic fun <T> List<T>.singleOrNull(): T? {\n return if (size == 1) this[0] else null\n}\n\n/**\n * Returns the single element matching the given [predicate], or `null` if element was not found or more than one element was found.\n */\npublic inline fun <T> Iterable<T>.singleOrNull(predicate: (T) -> Boolean): T? {\n var single: T? = null\n var found = false\n for (element in this) {\n if (predicate(element)) {\n if (found) return null\n single = element\n found = true\n }\n }\n if (!found) return null\n return single\n}\n\n/**\n * Returns a list containing all elements except first [n] elements.\n * \n * @sample samples.collections.Collections.Transformations.drop\n */\npublic fun <T> Iterable<T>.drop(n: Int): List<T> {\n require(n >= 0) { \"Requested element count $n is less than zero.\" }\n if (n == 0) return toList()\n val list: ArrayList<T>\n if (this is Collection<*>) {\n val resultSize = size - n\n if (resultSize <= 0)\n return emptyList()\n if (resultSize == 1)\n return listOf(last())\n list = ArrayList<T>(resultSize)\n if (this is List<T>) {\n if (this is RandomAccess) {\n for (index in n until size)\n list.add(this[index])\n } else {\n for (item in listIterator(n))\n list.add(item)\n }\n return list\n }\n }\n else {\n list = ArrayList<T>()\n }\n var count = 0\n for (item in this) {\n if (count++ >= n) list.add(item)\n }\n return list.optimizeReadOnlyList()\n}\n\n/**\n * Returns a list containing all elements except last [n] elements.\n * \n * @sample samples.collections.Collections.Transformations.drop\n */\npublic fun <T> List<T>.dropLast(n: Int): List<T> {\n require(n >= 0) { \"Requested element count $n is less than zero.\" }\n return take((size - n).coerceAtLeast(0))\n}\n\n/**\n * Returns a list containing all elements except last elements that satisfy the given [predicate].\n * \n * @sample samples.collections.Collections.Transformations.drop\n */\npublic inline fun <T> List<T>.dropLastWhile(predicate: (T) -> Boolean): List<T> {\n if (!isEmpty()) {\n val iterator = listIterator(size)\n while (iterator.hasPrevious()) {\n if (!predicate(iterator.previous())) {\n return take(iterator.nextIndex() + 1)\n }\n }\n }\n return emptyList()\n}\n\n/**\n * Returns a list containing all elements except first elements that satisfy the given [predicate].\n * \n * @sample samples.collections.Collections.Transformations.drop\n */\npublic inline fun <T> Iterable<T>.dropWhile(predicate: (T) -> Boolean): List<T> {\n var yielding = false\n val list = ArrayList<T>()\n for (item in this)\n if (yielding)\n list.add(item)\n else if (!predicate(item)) {\n list.add(item)\n yielding = true\n }\n return list\n}\n\n/**\n * Returns a list containing only elements matching the given [predicate].\n */\npublic inline fun <T> Iterable<T>.filter(predicate: (T) -> Boolean): List<T> {\n return filterTo(ArrayList<T>(), predicate)\n}\n\n/**\n * Returns a list containing only elements matching the given [predicate].\n * @param [predicate] function that takes the index of an element and the element itself\n * and returns the result of predicate evaluation on the element.\n */\npublic inline fun <T> Iterable<T>.filterIndexed(predicate: (index: Int, T) -> Boolean): List<T> {\n return filterIndexedTo(ArrayList<T>(), predicate)\n}\n\n/**\n * Appends all elements matching the given [predicate] to the given [destination].\n * @param [predicate] function that takes the index of an element and the element itself\n * and returns the result of predicate evaluation on the element.\n */\npublic inline fun <T, C : MutableCollection<in T>> Iterable<T>.filterIndexedTo(destination: C, predicate: (index: Int, T) -> Boolean): C {\n forEachIndexed { index, element ->\n if (predicate(index, element)) destination.add(element)\n }\n return destination\n}\n\n/**\n * Returns a list containing all elements that are instances of specified type parameter R.\n */\npublic inline fun <reified R> Iterable<*>.filterIsInstance(): List<@kotlin.internal.NoInfer R> {\n return filterIsInstanceTo(ArrayList<R>())\n}\n\n/**\n * Appends all elements that are instances of specified type parameter R to the given [destination].\n */\npublic inline fun <reified R, C : MutableCollection<in R>> Iterable<*>.filterIsInstanceTo(destination: C): C {\n for (element in this) if (element is R) destination.add(element)\n return destination\n}\n\n/**\n * Returns a list containing all elements not matching the given [predicate].\n */\npublic inline fun <T> Iterable<T>.filterNot(predicate: (T) -> Boolean): List<T> {\n return filterNotTo(ArrayList<T>(), predicate)\n}\n\n/**\n * Returns a list containing all elements that are not `null`.\n */\npublic fun <T : Any> Iterable<T?>.filterNotNull(): List<T> {\n return filterNotNullTo(ArrayList<T>())\n}\n\n/**\n * Appends all elements that are not `null` to the given [destination].\n */\npublic fun <C : MutableCollection<in T>, T : Any> Iterable<T?>.filterNotNullTo(destination: C): C {\n for (element in this) if (element != null) destination.add(element)\n return destination\n}\n\n/**\n * Appends all elements not matching the given [predicate] to the given [destination].\n */\npublic inline fun <T, C : MutableCollection<in T>> Iterable<T>.filterNotTo(destination: C, predicate: (T) -> Boolean): C {\n for (element in this) if (!predicate(element)) destination.add(element)\n return destination\n}\n\n/**\n * Appends all elements matching the given [predicate] to the given [destination].\n */\npublic inline fun <T, C : MutableCollection<in T>> Iterable<T>.filterTo(destination: C, predicate: (T) -> Boolean): C {\n for (element in this) if (predicate(element)) destination.add(element)\n return destination\n}\n\n/**\n * Returns a list containing elements at indices in the specified [indices] range.\n */\npublic fun <T> List<T>.slice(indices: IntRange): List<T> {\n if (indices.isEmpty()) return listOf()\n return this.subList(indices.start, indices.endInclusive + 1).toList()\n}\n\n/**\n * Returns a list containing elements at specified [indices].\n */\npublic fun <T> List<T>.slice(indices: Iterable<Int>): List<T> {\n val size = indices.collectionSizeOrDefault(10)\n if (size == 0) return emptyList()\n val list = ArrayList<T>(size)\n for (index in indices) {\n list.add(get(index))\n }\n return list\n}\n\n/**\n * Returns a list containing first [n] elements.\n * \n * @sample samples.collections.Collections.Transformations.take\n */\npublic fun <T> Iterable<T>.take(n: Int): List<T> {\n require(n >= 0) { \"Requested element count $n is less than zero.\" }\n if (n == 0) return emptyList()\n if (this is Collection<T>) {\n if (n >= size) return toList()\n if (n == 1) return listOf(first())\n }\n var count = 0\n val list = ArrayList<T>(n)\n for (item in this) {\n if (count++ == n)\n break\n list.add(item)\n }\n return list.optimizeReadOnlyList()\n}\n\n/**\n * Returns a list containing last [n] elements.\n * \n * @sample samples.collections.Collections.Transformations.take\n */\npublic fun <T> List<T>.takeLast(n: Int): List<T> {\n require(n >= 0) { \"Requested element count $n is less than zero.\" }\n if (n == 0) return emptyList()\n val size = size\n if (n >= size) return toList()\n if (n == 1) return listOf(last())\n val list = ArrayList<T>(n)\n if (this is RandomAccess) {\n for (index in size - n until size)\n list.add(this[index])\n } else {\n for (item in listIterator(size - n))\n list.add(item)\n }\n return list\n}\n\n/**\n * Returns a list containing last elements satisfying the given [predicate].\n * \n * @sample samples.collections.Collections.Transformations.take\n */\npublic inline fun <T> List<T>.takeLastWhile(predicate: (T) -> Boolean): List<T> {\n if (isEmpty())\n return emptyList()\n val iterator = listIterator(size)\n while (iterator.hasPrevious()) {\n if (!predicate(iterator.previous())) {\n iterator.next()\n val expectedSize = size - iterator.nextIndex()\n if (expectedSize == 0) return emptyList()\n return ArrayList<T>(expectedSize).apply {\n while (iterator.hasNext())\n add(iterator.next())\n }\n }\n }\n return toList()\n}\n\n/**\n * Returns a list containing first elements satisfying the given [predicate].\n * \n * @sample samples.collections.Collections.Transformations.take\n */\npublic inline fun <T> Iterable<T>.takeWhile(predicate: (T) -> Boolean): List<T> {\n val list = ArrayList<T>()\n for (item in this) {\n if (!predicate(item))\n break\n list.add(item)\n }\n return list\n}\n\n/**\n * Reverses elements in the list in-place.\n */\npublic expect fun <T> MutableList<T>.reverse(): Unit\n\n/**\n * Returns a list with elements in reversed order.\n */\npublic fun <T> Iterable<T>.reversed(): List<T> {\n if (this is Collection && size <= 1) return toList()\n val list = toMutableList()\n list.reverse()\n return list\n}\n\n/**\n * Sorts elements in the list in-place according to natural sort order of the value returned by specified [selector] function.\n * \n * The sort is _stable_. It means that equal elements preserve their order relative to each other after sorting.\n */\npublic inline fun <T, R : Comparable<R>> MutableList<T>.sortBy(crossinline selector: (T) -> R?): Unit {\n if (size > 1) sortWith(compareBy(selector))\n}\n\n/**\n * Sorts elements in the list in-place descending according to natural sort order of the value returned by specified [selector] function.\n * \n * The sort is _stable_. It means that equal elements preserve their order relative to each other after sorting.\n */\npublic inline fun <T, R : Comparable<R>> MutableList<T>.sortByDescending(crossinline selector: (T) -> R?): Unit {\n if (size > 1) sortWith(compareByDescending(selector))\n}\n\n/**\n * Sorts elements in the list in-place descending according to their natural sort order.\n * \n * The sort is _stable_. It means that equal elements preserve their order relative to each other after sorting.\n */\npublic fun <T : Comparable<T>> MutableList<T>.sortDescending(): Unit {\n sortWith(reverseOrder())\n}\n\n/**\n * Returns a list of all elements sorted according to their natural sort order.\n * \n * The sort is _stable_. It means that equal elements preserve their order relative to each other after sorting.\n */\npublic fun <T : Comparable<T>> Iterable<T>.sorted(): List<T> {\n if (this is Collection) {\n if (size <= 1) return this.toList()\n @Suppress(\"UNCHECKED_CAST\")\n return (toTypedArray<Comparable<T>>() as Array<T>).apply { sort() }.asList()\n }\n return toMutableList().apply { sort() }\n}\n\n/**\n * Returns a list of all elements sorted according to natural sort order of the value returned by specified [selector] function.\n * \n * The sort is _stable_. It means that equal elements preserve their order relative to each other after sorting.\n */\npublic inline fun <T, R : Comparable<R>> Iterable<T>.sortedBy(crossinline selector: (T) -> R?): List<T> {\n return sortedWith(compareBy(selector))\n}\n\n/**\n * Returns a list of all elements sorted descending according to natural sort order of the value returned by specified [selector] function.\n * \n * The sort is _stable_. It means that equal elements preserve their order relative to each other after sorting.\n */\npublic inline fun <T, R : Comparable<R>> Iterable<T>.sortedByDescending(crossinline selector: (T) -> R?): List<T> {\n return sortedWith(compareByDescending(selector))\n}\n\n/**\n * Returns a list of all elements sorted descending according to their natural sort order.\n * \n * The sort is _stable_. It means that equal elements preserve their order relative to each other after sorting.\n */\npublic fun <T : Comparable<T>> Iterable<T>.sortedDescending(): List<T> {\n return sortedWith(reverseOrder())\n}\n\n/**\n * Returns a list of all elements sorted according to the specified [comparator].\n * \n * The sort is _stable_. It means that equal elements preserve their order relative to each other after sorting.\n */\npublic fun <T> Iterable<T>.sortedWith(comparator: Comparator<in T>): List<T> {\n if (this is Collection) {\n if (size <= 1) return this.toList()\n @Suppress(\"UNCHECKED_CAST\")\n return (toTypedArray<Any?>() as Array<T>).apply { sortWith(comparator) }.asList()\n }\n return toMutableList().apply { sortWith(comparator) }\n}\n\n/**\n * Returns an array of Boolean containing all of the elements of this collection.\n */\npublic fun Collection<Boolean>.toBooleanArray(): BooleanArray {\n val result = BooleanArray(size)\n var index = 0\n for (element in this)\n result[index++] = element\n return result\n}\n\n/**\n * Returns an array of Byte containing all of the elements of this collection.\n */\npublic fun Collection<Byte>.toByteArray(): ByteArray {\n val result = ByteArray(size)\n var index = 0\n for (element in this)\n result[index++] = element\n return result\n}\n\n/**\n * Returns an array of Char containing all of the elements of this collection.\n */\npublic fun Collection<Char>.toCharArray(): CharArray {\n val result = CharArray(size)\n var index = 0\n for (element in this)\n result[index++] = element\n return result\n}\n\n/**\n * Returns an array of Double containing all of the elements of this collection.\n */\npublic fun Collection<Double>.toDoubleArray(): DoubleArray {\n val result = DoubleArray(size)\n var index = 0\n for (element in this)\n result[index++] = element\n return result\n}\n\n/**\n * Returns an array of Float containing all of the elements of this collection.\n */\npublic fun Collection<Float>.toFloatArray(): FloatArray {\n val result = FloatArray(size)\n var index = 0\n for (element in this)\n result[index++] = element\n return result\n}\n\n/**\n * Returns an array of Int containing all of the elements of this collection.\n */\npublic fun Collection<Int>.toIntArray(): IntArray {\n val result = IntArray(size)\n var index = 0\n for (element in this)\n result[index++] = element\n return result\n}\n\n/**\n * Returns an array of Long containing all of the elements of this collection.\n */\npublic fun Collection<Long>.toLongArray(): LongArray {\n val result = LongArray(size)\n var index = 0\n for (element in this)\n result[index++] = element\n return result\n}\n\n/**\n * Returns an array of Short containing all of the elements of this collection.\n */\npublic fun Collection<Short>.toShortArray(): ShortArray {\n val result = ShortArray(size)\n var index = 0\n for (element in this)\n result[index++] = element\n return result\n}\n\n/**\n * Returns a [Map] containing key-value pairs provided by [transform] function\n * applied to elements of the given collection.\n * \n * If any of two pairs would have the same key the last one gets added to the map.\n * \n * The returned map preserves the entry iteration order of the original collection.\n */\npublic inline fun <T, K, V> Iterable<T>.associate(transform: (T) -> Pair<K, V>): Map<K, V> {\n val capacity = mapCapacity(collectionSizeOrDefault(10)).coerceAtLeast(16)\n return associateTo(LinkedHashMap<K, V>(capacity), transform)\n}\n\n/**\n * Returns a [Map] containing the elements from the given collection indexed by the key\n * returned from [keySelector] function applied to each element.\n * \n * If any two elements would have the same key returned by [keySelector] the last one gets added to the map.\n * \n * The returned map preserves the entry iteration order of the original collection.\n */\npublic inline fun <T, K> Iterable<T>.associateBy(keySelector: (T) -> K): Map<K, T> {\n val capacity = mapCapacity(collectionSizeOrDefault(10)).coerceAtLeast(16)\n return associateByTo(LinkedHashMap<K, T>(capacity), keySelector)\n}\n\n/**\n * Returns a [Map] containing the values provided by [valueTransform] and indexed by [keySelector] functions applied to elements of the given collection.\n * \n * If any two elements would have the same key returned by [keySelector] the last one gets added to the map.\n * \n * The returned map preserves the entry iteration order of the original collection.\n */\npublic inline fun <T, K, V> Iterable<T>.associateBy(keySelector: (T) -> K, valueTransform: (T) -> V): Map<K, V> {\n val capacity = mapCapacity(collectionSizeOrDefault(10)).coerceAtLeast(16)\n return associateByTo(LinkedHashMap<K, V>(capacity), keySelector, valueTransform)\n}\n\n/**\n * Populates and returns the [destination] mutable map with key-value pairs,\n * where key is provided by the [keySelector] function applied to each element of the given collection\n * and value is the element itself.\n * \n * If any two elements would have the same key returned by [keySelector] the last one gets added to the map.\n */\npublic inline fun <T, K, M : MutableMap<in K, in T>> Iterable<T>.associateByTo(destination: M, keySelector: (T) -> K): M {\n for (element in this) {\n destination.put(keySelector(element), element)\n }\n return destination\n}\n\n/**\n * Populates and returns the [destination] mutable map with key-value pairs,\n * where key is provided by the [keySelector] function and\n * and value is provided by the [valueTransform] function applied to elements of the given collection.\n * \n * If any two elements would have the same key returned by [keySelector] the last one gets added to the map.\n */\npublic inline fun <T, K, V, M : MutableMap<in K, in V>> Iterable<T>.associateByTo(destination: M, keySelector: (T) -> K, valueTransform: (T) -> V): M {\n for (element in this) {\n destination.put(keySelector(element), valueTransform(element))\n }\n return destination\n}\n\n/**\n * Populates and returns the [destination] mutable map with key-value pairs\n * provided by [transform] function applied to each element of the given collection.\n * \n * If any of two pairs would have the same key the last one gets added to the map.\n */\npublic inline fun <T, K, V, M : MutableMap<in K, in V>> Iterable<T>.associateTo(destination: M, transform: (T) -> Pair<K, V>): M {\n for (element in this) {\n destination += transform(element)\n }\n return destination\n}\n\n/**\n * Returns a [Map] where keys are elements from the given collection and values are\n * produced by the [valueSelector] function applied to each element.\n * \n * If any two elements are equal, the last one gets added to the map.\n * \n * The returned map preserves the entry iteration order of the original collection.\n * \n * @sample samples.collections.Collections.Transformations.associateWith\n */\n@SinceKotlin(\"1.3\")\npublic inline fun <K, V> Iterable<K>.associateWith(valueSelector: (K) -> V): Map<K, V> {\n val result = LinkedHashMap<K, V>(mapCapacity(collectionSizeOrDefault(10)).coerceAtLeast(16))\n return associateWithTo(result, valueSelector)\n}\n\n/**\n * Populates and returns the [destination] mutable map with key-value pairs for each element of the given collection,\n * where key is the element itself and value is provided by the [valueSelector] function applied to that key.\n * \n * If any two elements are equal, the last one overwrites the former value in the map.\n */\n@SinceKotlin(\"1.3\")\npublic inline fun <K, V, M : MutableMap<in K, in V>> Iterable<K>.associateWithTo(destination: M, valueSelector: (K) -> V): M {\n for (element in this) {\n destination.put(element, valueSelector(element))\n }\n return destination\n}\n\n/**\n * Appends all elements to the given [destination] collection.\n */\npublic fun <T, C : MutableCollection<in T>> Iterable<T>.toCollection(destination: C): C {\n for (item in this) {\n destination.add(item)\n }\n return destination\n}\n\n/**\n * Returns a [HashSet] of all elements.\n */\npublic fun <T> Iterable<T>.toHashSet(): HashSet<T> {\n return toCollection(HashSet<T>(mapCapacity(collectionSizeOrDefault(12))))\n}\n\n/**\n * Returns a [List] containing all elements.\n */\npublic fun <T> Iterable<T>.toList(): List<T> {\n if (this is Collection) {\n return when (size) {\n 0 -> emptyList()\n 1 -> listOf(if (this is List) get(0) else iterator().next())\n else -> this.toMutableList()\n }\n }\n return this.toMutableList().optimizeReadOnlyList()\n}\n\n/**\n * Returns a [MutableList] filled with all elements of this collection.\n */\npublic fun <T> Iterable<T>.toMutableList(): MutableList<T> {\n if (this is Collection<T>)\n return this.toMutableList()\n return toCollection(ArrayList<T>())\n}\n\n/**\n * Returns a [MutableList] filled with all elements of this collection.\n */\npublic fun <T> Collection<T>.toMutableList(): MutableList<T> {\n return ArrayList(this)\n}\n\n/**\n * Returns a [Set] of all elements.\n * \n * The returned set preserves the element iteration order of the original collection.\n */\npublic fun <T> Iterable<T>.toSet(): Set<T> {\n if (this is Collection) {\n return when (size) {\n 0 -> emptySet()\n 1 -> setOf(if (this is List) this[0] else iterator().next())\n else -> toCollection(LinkedHashSet<T>(mapCapacity(size)))\n }\n }\n return toCollection(LinkedHashSet<T>()).optimizeReadOnlySet()\n}\n\n/**\n * Returns a single list of all elements yielded from results of [transform] function being invoked on each element of original collection.\n */\npublic inline fun <T, R> Iterable<T>.flatMap(transform: (T) -> Iterable<R>): List<R> {\n return flatMapTo(ArrayList<R>(), transform)\n}\n\n/**\n * Appends all elements yielded from results of [transform] function being invoked on each element of original collection, to the given [destination].\n */\npublic inline fun <T, R, C : MutableCollection<in R>> Iterable<T>.flatMapTo(destination: C, transform: (T) -> Iterable<R>): C {\n for (element in this) {\n val list = transform(element)\n destination.addAll(list)\n }\n return destination\n}\n\n/**\n * Groups elements of the original collection by the key returned by the given [keySelector] function\n * applied to each element and returns a map where each group key is associated with a list of corresponding elements.\n * \n * The returned map preserves the entry iteration order of the keys produced from the original collection.\n * \n * @sample samples.collections.Collections.Transformations.groupBy\n */\npublic inline fun <T, K> Iterable<T>.groupBy(keySelector: (T) -> K): Map<K, List<T>> {\n return groupByTo(LinkedHashMap<K, MutableList<T>>(), keySelector)\n}\n\n/**\n * Groups values returned by the [valueTransform] function applied to each element of the original collection\n * by the key returned by the given [keySelector] function applied to the element\n * and returns a map where each group key is associated with a list of corresponding values.\n * \n * The returned map preserves the entry iteration order of the keys produced from the original collection.\n * \n * @sample samples.collections.Collections.Transformations.groupByKeysAndValues\n */\npublic inline fun <T, K, V> Iterable<T>.groupBy(keySelector: (T) -> K, valueTransform: (T) -> V): Map<K, List<V>> {\n return groupByTo(LinkedHashMap<K, MutableList<V>>(), keySelector, valueTransform)\n}\n\n/**\n * Groups elements of the original collection by the key returned by the given [keySelector] function\n * applied to each element and puts to the [destination] map each group key associated with a list of corresponding elements.\n * \n * @return The [destination] map.\n * \n * @sample samples.collections.Collections.Transformations.groupBy\n */\npublic inline fun <T, K, M : MutableMap<in K, MutableList<T>>> Iterable<T>.groupByTo(destination: M, keySelector: (T) -> K): M {\n for (element in this) {\n val key = keySelector(element)\n val list = destination.getOrPut(key) { ArrayList<T>() }\n list.add(element)\n }\n return destination\n}\n\n/**\n * Groups values returned by the [valueTransform] function applied to each element of the original collection\n * by the key returned by the given [keySelector] function applied to the element\n * and puts to the [destination] map each group key associated with a list of corresponding values.\n * \n * @return The [destination] map.\n * \n * @sample samples.collections.Collections.Transformations.groupByKeysAndValues\n */\npublic inline fun <T, K, V, M : MutableMap<in K, MutableList<V>>> Iterable<T>.groupByTo(destination: M, keySelector: (T) -> K, valueTransform: (T) -> V): M {\n for (element in this) {\n val key = keySelector(element)\n val list = destination.getOrPut(key) { ArrayList<V>() }\n list.add(valueTransform(element))\n }\n return destination\n}\n\n/**\n * Creates a [Grouping] source from a collection to be used later with one of group-and-fold operations\n * using the specified [keySelector] function to extract a key from each element.\n * \n * @sample samples.collections.Grouping.groupingByEachCount\n */\n@SinceKotlin(\"1.1\")\npublic inline fun <T, K> Iterable<T>.groupingBy(crossinline keySelector: (T) -> K): Grouping<T, K> {\n return object : Grouping<T, K> {\n override fun sourceIterator(): Iterator<T> = [email protected]()\n override fun keyOf(element: T): K = keySelector(element)\n }\n}\n\n/**\n * Returns a list containing the results of applying the given [transform] function\n * to each element in the original collection.\n */\npublic inline fun <T, R> Iterable<T>.map(transform: (T) -> R): List<R> {\n return mapTo(ArrayList<R>(collectionSizeOrDefault(10)), transform)\n}\n\n/**\n * Returns a list containing the results of applying the given [transform] function\n * to each element and its index in the original collection.\n * @param [transform] function that takes the index of an element and the element itself\n * and returns the result of the transform applied to the element.\n */\npublic inline fun <T, R> Iterable<T>.mapIndexed(transform: (index: Int, T) -> R): List<R> {\n return mapIndexedTo(ArrayList<R>(collectionSizeOrDefault(10)), transform)\n}\n\n/**\n * Returns a list containing only the non-null results of applying the given [transform] function\n * to each element and its index in the original collection.\n * @param [transform] function that takes the index of an element and the element itself\n * and returns the result of the transform applied to the element.\n */\npublic inline fun <T, R : Any> Iterable<T>.mapIndexedNotNull(transform: (index: Int, T) -> R?): List<R> {\n return mapIndexedNotNullTo(ArrayList<R>(), transform)\n}\n\n/**\n * Applies the given [transform] function to each element and its index in the original collection\n * and appends only the non-null results to the given [destination].\n * @param [transform] function that takes the index of an element and the element itself\n * and returns the result of the transform applied to the element.\n */\npublic inline fun <T, R : Any, C : MutableCollection<in R>> Iterable<T>.mapIndexedNotNullTo(destination: C, transform: (index: Int, T) -> R?): C {\n forEachIndexed { index, element -> transform(index, element)?.let { destination.add(it) } }\n return destination\n}\n\n/**\n * Applies the given [transform] function to each element and its index in the original collection\n * and appends the results to the given [destination].\n * @param [transform] function that takes the index of an element and the element itself\n * and returns the result of the transform applied to the element.\n */\npublic inline fun <T, R, C : MutableCollection<in R>> Iterable<T>.mapIndexedTo(destination: C, transform: (index: Int, T) -> R): C {\n var index = 0\n for (item in this)\n destination.add(transform(checkIndexOverflow(index++), item))\n return destination\n}\n\n/**\n * Returns a list containing only the non-null results of applying the given [transform] function\n * to each element in the original collection.\n */\npublic inline fun <T, R : Any> Iterable<T>.mapNotNull(transform: (T) -> R?): List<R> {\n return mapNotNullTo(ArrayList<R>(), transform)\n}\n\n/**\n * Applies the given [transform] function to each element in the original collection\n * and appends only the non-null results to the given [destination].\n */\npublic inline fun <T, R : Any, C : MutableCollection<in R>> Iterable<T>.mapNotNullTo(destination: C, transform: (T) -> R?): C {\n forEach { element -> transform(element)?.let { destination.add(it) } }\n return destination\n}\n\n/**\n * Applies the given [transform] function to each element of the original collection\n * and appends the results to the given [destination].\n */\npublic inline fun <T, R, C : MutableCollection<in R>> Iterable<T>.mapTo(destination: C, transform: (T) -> R): C {\n for (item in this)\n destination.add(transform(item))\n return destination\n}\n\n/**\n * Returns a lazy [Iterable] of [IndexedValue] for each element of the original collection.\n */\npublic fun <T> Iterable<T>.withIndex(): Iterable<IndexedValue<T>> {\n return IndexingIterable { iterator() }\n}\n\n/**\n * Returns a list containing only distinct elements from the given collection.\n * \n * The elements in the resulting list are in the same order as they were in the source collection.\n */\npublic fun <T> Iterable<T>.distinct(): List<T> {\n return this.toMutableSet().toList()\n}\n\n/**\n * Returns a list containing only elements from the given collection\n * having distinct keys returned by the given [selector] function.\n * \n * The elements in the resulting list are in the same order as they were in the source collection.\n */\npublic inline fun <T, K> Iterable<T>.distinctBy(selector: (T) -> K): List<T> {\n val set = HashSet<K>()\n val list = ArrayList<T>()\n for (e in this) {\n val key = selector(e)\n if (set.add(key))\n list.add(e)\n }\n return list\n}\n\n/**\n * Returns a set containing all elements that are contained by both this set and the specified collection.\n * \n * The returned set preserves the element iteration order of the original collection.\n */\npublic infix fun <T> Iterable<T>.intersect(other: Iterable<T>): Set<T> {\n val set = this.toMutableSet()\n set.retainAll(other)\n return set\n}\n\n/**\n * Returns a set containing all elements that are contained by this collection and not contained by the specified collection.\n * \n * The returned set preserves the element iteration order of the original collection.\n */\npublic infix fun <T> Iterable<T>.subtract(other: Iterable<T>): Set<T> {\n val set = this.toMutableSet()\n set.removeAll(other)\n return set\n}\n\n/**\n * Returns a mutable set containing all distinct elements from the given collection.\n * \n * The returned set preserves the element iteration order of the original collection.\n */\npublic fun <T> Iterable<T>.toMutableSet(): MutableSet<T> {\n return when (this) {\n is Collection<T> -> LinkedHashSet(this)\n else -> toCollection(LinkedHashSet<T>())\n }\n}\n\n/**\n * Returns a set containing all distinct elements from both collections.\n * \n * The returned set preserves the element iteration order of the original collection.\n * Those elements of the [other] collection that are unique are iterated in the end\n * in the order of the [other] collection.\n */\npublic infix fun <T> Iterable<T>.union(other: Iterable<T>): Set<T> {\n val set = this.toMutableSet()\n set.addAll(other)\n return set\n}\n\n/**\n * Returns `true` if all elements match the given [predicate].\n * \n * @sample samples.collections.Collections.Aggregates.all\n */\npublic inline fun <T> Iterable<T>.all(predicate: (T) -> Boolean): Boolean {\n if (this is Collection && isEmpty()) return true\n for (element in this) if (!predicate(element)) return false\n return true\n}\n\n/**\n * Returns `true` if collection has at least one element.\n * \n * @sample samples.collections.Collections.Aggregates.any\n */\npublic fun <T> Iterable<T>.any(): Boolean {\n if (this is Collection) return !isEmpty()\n return iterator().hasNext()\n}\n\n/**\n * Returns `true` if at least one element matches the given [predicate].\n * \n * @sample samples.collections.Collections.Aggregates.anyWithPredicate\n */\npublic inline fun <T> Iterable<T>.any(predicate: (T) -> Boolean): Boolean {\n if (this is Collection && isEmpty()) return false\n for (element in this) if (predicate(element)) return true\n return false\n}\n\n/**\n * Returns the number of elements in this collection.\n */\npublic fun <T> Iterable<T>.count(): Int {\n if (this is Collection) return size\n var count = 0\n for (element in this) checkCountOverflow(++count)\n return count\n}\n\n/**\n * Returns the number of elements in this collection.\n */\[email protected]\npublic inline fun <T> Collection<T>.count(): Int {\n return size\n}\n\n/**\n * Returns the number of elements matching the given [predicate].\n */\npublic inline fun <T> Iterable<T>.count(predicate: (T) -> Boolean): Int {\n if (this is Collection && isEmpty()) return 0\n var count = 0\n for (element in this) if (predicate(element)) checkCountOverflow(++count)\n return count\n}\n\n/**\n * Accumulates value starting with [initial] value and applying [operation] from left to right to current accumulator value and each element.\n */\npublic inline fun <T, R> Iterable<T>.fold(initial: R, operation: (acc: R, T) -> R): R {\n var accumulator = initial\n for (element in this) accumulator = operation(accumulator, element)\n return accumulator\n}\n\n/**\n * Accumulates value starting with [initial] value and applying [operation] from left to right\n * to current accumulator value and each element with its index in the original collection.\n * @param [operation] function that takes the index of an element, current accumulator value\n * and the element itself, and calculates the next accumulator value.\n */\npublic inline fun <T, R> Iterable<T>.foldIndexed(initial: R, operation: (index: Int, acc: R, T) -> R): R {\n var index = 0\n var accumulator = initial\n for (element in this) accumulator = operation(checkIndexOverflow(index++), accumulator, element)\n return accumulator\n}\n\n/**\n * Accumulates value starting with [initial] value and applying [operation] from right to left to each element and current accumulator value.\n */\npublic inline fun <T, R> List<T>.foldRight(initial: R, operation: (T, acc: R) -> R): R {\n var accumulator = initial\n if (!isEmpty()) {\n val iterator = listIterator(size)\n while (iterator.hasPrevious()) {\n accumulator = operation(iterator.previous(), accumulator)\n }\n }\n return accumulator\n}\n\n/**\n * Accumulates value starting with [initial] value and applying [operation] from right to left\n * to each element with its index in the original list and current accumulator value.\n * @param [operation] function that takes the index of an element, the element itself\n * and current accumulator value, and calculates the next accumulator value.\n */\npublic inline fun <T, R> List<T>.foldRightIndexed(initial: R, operation: (index: Int, T, acc: R) -> R): R {\n var accumulator = initial\n if (!isEmpty()) {\n val iterator = listIterator(size)\n while (iterator.hasPrevious()) {\n val index = iterator.previousIndex()\n accumulator = operation(index, iterator.previous(), accumulator)\n }\n }\n return accumulator\n}\n\n/**\n * Performs the given [action] on each element.\n */\[email protected]\npublic inline fun <T> Iterable<T>.forEach(action: (T) -> Unit): Unit {\n for (element in this) action(element)\n}\n\n/**\n * Performs the given [action] on each element, providing sequential index with the element.\n * @param [action] function that takes the index of an element and the element itself\n * and performs the desired action on the element.\n */\npublic inline fun <T> Iterable<T>.forEachIndexed(action: (index: Int, T) -> Unit): Unit {\n var index = 0\n for (item in this) action(checkIndexOverflow(index++), item)\n}\n\n/**\n * Returns the largest element or `null` if there are no elements.\n * \n * If any of elements is `NaN` returns `NaN`.\n */\n@SinceKotlin(\"1.1\")\npublic fun Iterable<Double>.max(): Double? {\n val iterator = iterator()\n if (!iterator.hasNext()) return null\n var max = iterator.next()\n if (max.isNaN()) return max\n while (iterator.hasNext()) {\n val e = iterator.next()\n if (e.isNaN()) return e\n if (max < e) max = e\n }\n return max\n}\n\n/**\n * Returns the largest element or `null` if there are no elements.\n * \n * If any of elements is `NaN` returns `NaN`.\n */\n@SinceKotlin(\"1.1\")\npublic fun Iterable<Float>.max(): Float? {\n val iterator = iterator()\n if (!iterator.hasNext()) return null\n var max = iterator.next()\n if (max.isNaN()) return max\n while (iterator.hasNext()) {\n val e = iterator.next()\n if (e.isNaN()) return e\n if (max < e) max = e\n }\n return max\n}\n\n/**\n * Returns the largest element or `null` if there are no elements.\n */\npublic fun <T : Comparable<T>> Iterable<T>.max(): T? {\n val iterator = iterator()\n if (!iterator.hasNext()) return null\n var max = iterator.next()\n while (iterator.hasNext()) {\n val e = iterator.next()\n if (max < e) max = e\n }\n return max\n}\n\n/**\n * Returns the first element yielding the largest value of the given function or `null` if there are no elements.\n * \n * @sample samples.collections.Collections.Aggregates.maxBy\n */\npublic inline fun <T, R : Comparable<R>> Iterable<T>.maxBy(selector: (T) -> R): T? {\n val iterator = iterator()\n if (!iterator.hasNext()) return null\n var maxElem = iterator.next()\n var maxValue = selector(maxElem)\n while (iterator.hasNext()) {\n val e = iterator.next()\n val v = selector(e)\n if (maxValue < v) {\n maxElem = e\n maxValue = v\n }\n }\n return maxElem\n}\n\n/**\n * Returns the first element having the largest value according to the provided [comparator] or `null` if there are no elements.\n */\npublic fun <T> Iterable<T>.maxWith(comparator: Comparator<in T>): T? {\n val iterator = iterator()\n if (!iterator.hasNext()) return null\n var max = iterator.next()\n while (iterator.hasNext()) {\n val e = iterator.next()\n if (comparator.compare(max, e) < 0) max = e\n }\n return max\n}\n\n/**\n * Returns the smallest element or `null` if there are no elements.\n * \n * If any of elements is `NaN` returns `NaN`.\n */\n@SinceKotlin(\"1.1\")\npublic fun Iterable<Double>.min(): Double? {\n val iterator = iterator()\n if (!iterator.hasNext()) return null\n var min = iterator.next()\n if (min.isNaN()) return min\n while (iterator.hasNext()) {\n val e = iterator.next()\n if (e.isNaN()) return e\n if (min > e) min = e\n }\n return min\n}\n\n/**\n * Returns the smallest element or `null` if there are no elements.\n * \n * If any of elements is `NaN` returns `NaN`.\n */\n@SinceKotlin(\"1.1\")\npublic fun Iterable<Float>.min(): Float? {\n val iterator = iterator()\n if (!iterator.hasNext()) return null\n var min = iterator.next()\n if (min.isNaN()) return min\n while (iterator.hasNext()) {\n val e = iterator.next()\n if (e.isNaN()) return e\n if (min > e) min = e\n }\n return min\n}\n\n/**\n * Returns the smallest element or `null` if there are no elements.\n */\npublic fun <T : Comparable<T>> Iterable<T>.min(): T? {\n val iterator = iterator()\n if (!iterator.hasNext()) return null\n var min = iterator.next()\n while (iterator.hasNext()) {\n val e = iterator.next()\n if (min > e) min = e\n }\n return min\n}\n\n/**\n * Returns the first element yielding the smallest value of the given function or `null` if there are no elements.\n * \n * @sample samples.collections.Collections.Aggregates.minBy\n */\npublic inline fun <T, R : Comparable<R>> Iterable<T>.minBy(selector: (T) -> R): T? {\n val iterator = iterator()\n if (!iterator.hasNext()) return null\n var minElem = iterator.next()\n var minValue = selector(minElem)\n while (iterator.hasNext()) {\n val e = iterator.next()\n val v = selector(e)\n if (minValue > v) {\n minElem = e\n minValue = v\n }\n }\n return minElem\n}\n\n/**\n * Returns the first element having the smallest value according to the provided [comparator] or `null` if there are no elements.\n */\npublic fun <T> Iterable<T>.minWith(comparator: Comparator<in T>): T? {\n val iterator = iterator()\n if (!iterator.hasNext()) return null\n var min = iterator.next()\n while (iterator.hasNext()) {\n val e = iterator.next()\n if (comparator.compare(min, e) > 0) min = e\n }\n return min\n}\n\n/**\n * Returns `true` if the collection has no elements.\n * \n * @sample samples.collections.Collections.Aggregates.none\n */\npublic fun <T> Iterable<T>.none(): Boolean {\n if (this is Collection) return isEmpty()\n return !iterator().hasNext()\n}\n\n/**\n * Returns `true` if no elements match the given [predicate].\n * \n * @sample samples.collections.Collections.Aggregates.noneWithPredicate\n */\npublic inline fun <T> Iterable<T>.none(predicate: (T) -> Boolean): Boolean {\n if (this is Collection && isEmpty()) return true\n for (element in this) if (predicate(element)) return false\n return true\n}\n\n/**\n * Performs the given [action] on each element and returns the collection itself afterwards.\n */\n@SinceKotlin(\"1.1\")\npublic inline fun <T, C : Iterable<T>> C.onEach(action: (T) -> Unit): C {\n return apply { for (element in this) action(element) }\n}\n\n/**\n * Accumulates value starting with the first element and applying [operation] from left to right to current accumulator value and each element.\n */\npublic inline fun <S, T : S> Iterable<T>.reduce(operation: (acc: S, T) -> S): S {\n val iterator = this.iterator()\n if (!iterator.hasNext()) throw UnsupportedOperationException(\"Empty collection can't be reduced.\")\n var accumulator: S = iterator.next()\n while (iterator.hasNext()) {\n accumulator = operation(accumulator, iterator.next())\n }\n return accumulator\n}\n\n/**\n * Accumulates value starting with the first element and applying [operation] from left to right\n * to current accumulator value and each element with its index in the original collection.\n * @param [operation] function that takes the index of an element, current accumulator value\n * and the element itself and calculates the next accumulator value.\n */\npublic inline fun <S, T : S> Iterable<T>.reduceIndexed(operation: (index: Int, acc: S, T) -> S): S {\n val iterator = this.iterator()\n if (!iterator.hasNext()) throw UnsupportedOperationException(\"Empty collection can't be reduced.\")\n var index = 1\n var accumulator: S = iterator.next()\n while (iterator.hasNext()) {\n accumulator = operation(checkIndexOverflow(index++), accumulator, iterator.next())\n }\n return accumulator\n}\n\n/**\n * Accumulates value starting with last element and applying [operation] from right to left to each element and current accumulator value.\n */\npublic inline fun <S, T : S> List<T>.reduceRight(operation: (T, acc: S) -> S): S {\n val iterator = listIterator(size)\n if (!iterator.hasPrevious())\n throw UnsupportedOperationException(\"Empty list can't be reduced.\")\n var accumulator: S = iterator.previous()\n while (iterator.hasPrevious()) {\n accumulator = operation(iterator.previous(), accumulator)\n }\n return accumulator\n}\n\n/**\n * Accumulates value starting with last element and applying [operation] from right to left\n * to each element with its index in the original list and current accumulator value.\n * @param [operation] function that takes the index of an element, the element itself\n * and current accumulator value, and calculates the next accumulator value.\n */\npublic inline fun <S, T : S> List<T>.reduceRightIndexed(operation: (index: Int, T, acc: S) -> S): S {\n val iterator = listIterator(size)\n if (!iterator.hasPrevious())\n throw UnsupportedOperationException(\"Empty list can't be reduced.\")\n var accumulator: S = iterator.previous()\n while (iterator.hasPrevious()) {\n val index = iterator.previousIndex()\n accumulator = operation(index, iterator.previous(), accumulator)\n }\n return accumulator\n}\n\n/**\n * Returns the sum of all values produced by [selector] function applied to each element in the collection.\n */\npublic inline fun <T> Iterable<T>.sumBy(selector: (T) -> Int): Int {\n var sum: Int = 0\n for (element in this) {\n sum += selector(element)\n }\n return sum\n}\n\n/**\n * Returns the sum of all values produced by [selector] function applied to each element in the collection.\n */\npublic inline fun <T> Iterable<T>.sumByDouble(selector: (T) -> Double): Double {\n var sum: Double = 0.0\n for (element in this) {\n sum += selector(element)\n }\n return sum\n}\n\n/**\n * Returns an original collection containing all the non-`null` elements, throwing an [IllegalArgumentException] if there are any `null` elements.\n */\npublic fun <T : Any> Iterable<T?>.requireNoNulls(): Iterable<T> {\n for (element in this) {\n if (element == null) {\n throw IllegalArgumentException(\"null element found in $this.\")\n }\n }\n @Suppress(\"UNCHECKED_CAST\")\n return this as Iterable<T>\n}\n\n/**\n * Returns an original collection containing all the non-`null` elements, throwing an [IllegalArgumentException] if there are any `null` elements.\n */\npublic fun <T : Any> List<T?>.requireNoNulls(): List<T> {\n for (element in this) {\n if (element == null) {\n throw IllegalArgumentException(\"null element found in $this.\")\n }\n }\n @Suppress(\"UNCHECKED_CAST\")\n return this as List<T>\n}\n\n/**\n * Splits this collection into a list of lists each not exceeding the given [size].\n * \n * The last list in the resulting list may have less elements than the given [size].\n * \n * @param size the number of elements to take in each list, must be positive and can be greater than the number of elements in this collection.\n * \n * @sample samples.collections.Collections.Transformations.chunked\n */\n@SinceKotlin(\"1.2\")\npublic fun <T> Iterable<T>.chunked(size: Int): List<List<T>> {\n return windowed(size, size, partialWindows = true)\n}\n\n/**\n * Splits this collection into several lists each not exceeding the given [size]\n * and applies the given [transform] function to an each.\n * \n * @return list of results of the [transform] applied to an each list.\n * \n * Note that the list passed to the [transform] function is ephemeral and is valid only inside that function.\n * You should not store it or allow it to escape in some way, unless you made a snapshot of it.\n * The last list may have less elements than the given [size].\n * \n * @param size the number of elements to take in each list, must be positive and can be greater than the number of elements in this collection.\n * \n * @sample samples.text.Strings.chunkedTransform\n */\n@SinceKotlin(\"1.2\")\npublic fun <T, R> Iterable<T>.chunked(size: Int, transform: (List<T>) -> R): List<R> {\n return windowed(size, size, partialWindows = true, transform = transform)\n}\n\n/**\n * Returns a list containing all elements of the original collection without the first occurrence of the given [element].\n */\npublic operator fun <T> Iterable<T>.minus(element: T): List<T> {\n val result = ArrayList<T>(collectionSizeOrDefault(10))\n var removed = false\n return this.filterTo(result) { if (!removed && it == element) { removed = true; false } else true }\n}\n\n/**\n * Returns a list containing all elements of the original collection except the elements contained in the given [elements] array.\n * \n * The [elements] array may be converted to a [HashSet] to speed up the operation, thus the elements are required to have\n * a correct and stable implementation of `hashCode()` that doesn't change between successive invocations.\n */\npublic operator fun <T> Iterable<T>.minus(elements: Array<out T>): List<T> {\n if (elements.isEmpty()) return this.toList()\n val other = elements.toHashSet()\n return this.filterNot { it in other }\n}\n\n/**\n * Returns a list containing all elements of the original collection except the elements contained in the given [elements] collection.\n * \n * The [elements] collection may be converted to a [HashSet] to speed up the operation, thus the elements are required to have\n * a correct and stable implementation of `hashCode()` that doesn't change between successive invocations.\n */\npublic operator fun <T> Iterable<T>.minus(elements: Iterable<T>): List<T> {\n val other = elements.convertToSetForSetOperationWith(this)\n if (other.isEmpty())\n return this.toList()\n return this.filterNot { it in other }\n}\n\n/**\n * Returns a list containing all elements of the original collection except the elements contained in the given [elements] sequence.\n * \n * The [elements] sequence may be converted to a [HashSet] to speed up the operation, thus the elements are required to have\n * a correct and stable implementation of `hashCode()` that doesn't change between successive invocations.\n */\npublic operator fun <T> Iterable<T>.minus(elements: Sequence<T>): List<T> {\n val other = elements.toHashSet()\n if (other.isEmpty())\n return this.toList()\n return this.filterNot { it in other }\n}\n\n/**\n * Returns a list containing all elements of the original collection without the first occurrence of the given [element].\n */\[email protected]\npublic inline fun <T> Iterable<T>.minusElement(element: T): List<T> {\n return minus(element)\n}\n\n/**\n * Splits the original collection into pair of lists,\n * where *first* list contains elements for which [predicate] yielded `true`,\n * while *second* list contains elements for which [predicate] yielded `false`.\n */\npublic inline fun <T> Iterable<T>.partition(predicate: (T) -> Boolean): Pair<List<T>, List<T>> {\n val first = ArrayList<T>()\n val second = ArrayList<T>()\n for (element in this) {\n if (predicate(element)) {\n first.add(element)\n } else {\n second.add(element)\n }\n }\n return Pair(first, second)\n}\n\n/**\n * Returns a list containing all elements of the original collection and then the given [element].\n */\npublic operator fun <T> Iterable<T>.plus(element: T): List<T> {\n if (this is Collection) return this.plus(element)\n val result = ArrayList<T>()\n result.addAll(this)\n result.add(element)\n return result\n}\n\n/**\n * Returns a list containing all elements of the original collection and then the given [element].\n */\npublic operator fun <T> Collection<T>.plus(element: T): List<T> {\n val result = ArrayList<T>(size + 1)\n result.addAll(this)\n result.add(element)\n return result\n}\n\n/**\n * Returns a list containing all elements of the original collection and then all elements of the given [elements] array.\n */\npublic operator fun <T> Iterable<T>.plus(elements: Array<out T>): List<T> {\n if (this is Collection) return this.plus(elements)\n val result = ArrayList<T>()\n result.addAll(this)\n result.addAll(elements)\n return result\n}\n\n/**\n * Returns a list containing all elements of the original collection and then all elements of the given [elements] array.\n */\npublic operator fun <T> Collection<T>.plus(elements: Array<out T>): List<T> {\n val result = ArrayList<T>(this.size + elements.size)\n result.addAll(this)\n result.addAll(elements)\n return result\n}\n\n/**\n * Returns a list containing all elements of the original collection and then all elements of the given [elements] collection.\n */\npublic operator fun <T> Iterable<T>.plus(elements: Iterable<T>): List<T> {\n if (this is Collection) return this.plus(elements)\n val result = ArrayList<T>()\n result.addAll(this)\n result.addAll(elements)\n return result\n}\n\n/**\n * Returns a list containing all elements of the original collection and then all elements of the given [elements] collection.\n */\npublic operator fun <T> Collection<T>.plus(elements: Iterable<T>): List<T> {\n if (elements is Collection) {\n val result = ArrayList<T>(this.size + elements.size)\n result.addAll(this)\n result.addAll(elements)\n return result\n } else {\n val result = ArrayList<T>(this)\n result.addAll(elements)\n return result\n }\n}\n\n/**\n * Returns a list containing all elements of the original collection and then all elements of the given [elements] sequence.\n */\npublic operator fun <T> Iterable<T>.plus(elements: Sequence<T>): List<T> {\n val result = ArrayList<T>()\n result.addAll(this)\n result.addAll(elements)\n return result\n}\n\n/**\n * Returns a list containing all elements of the original collection and then all elements of the given [elements] sequence.\n */\npublic operator fun <T> Collection<T>.plus(elements: Sequence<T>): List<T> {\n val result = ArrayList<T>(this.size + 10)\n result.addAll(this)\n result.addAll(elements)\n return result\n}\n\n/**\n * Returns a list containing all elements of the original collection and then the given [element].\n */\[email protected]\npublic inline fun <T> Iterable<T>.plusElement(element: T): List<T> {\n return plus(element)\n}\n\n/**\n * Returns a list containing all elements of the original collection and then the given [element].\n */\[email protected]\npublic inline fun <T> Collection<T>.plusElement(element: T): List<T> {\n return plus(element)\n}\n\n/**\n * Returns a list of snapshots of the window of the given [size]\n * sliding along this collection with the given [step], where each\n * snapshot is a list.\n * \n * Several last lists may have less elements than the given [size].\n * \n * Both [size] and [step] must be positive and can be greater than the number of elements in this collection.\n * @param size the number of elements to take in each window\n * @param step the number of elements to move the window forward by on an each step, by default 1\n * @param partialWindows controls whether or not to keep partial windows in the end if any,\n * by default `false` which means partial windows won't be preserved\n * \n * @sample samples.collections.Sequences.Transformations.takeWindows\n */\n@SinceKotlin(\"1.2\")\npublic fun <T> Iterable<T>.windowed(size: Int, step: Int = 1, partialWindows: Boolean = false): List<List<T>> {\n checkWindowSizeStep(size, step)\n if (this is RandomAccess && this is List) {\n val thisSize = this.size\n val result = ArrayList<List<T>>((thisSize + step - 1) / step)\n var index = 0\n while (index < thisSize) {\n val windowSize = size.coerceAtMost(thisSize - index)\n if (windowSize < size && !partialWindows) break\n result.add(List(windowSize) { this[it + index] })\n index += step\n }\n return result\n }\n val result = ArrayList<List<T>>()\n windowedIterator(iterator(), size, step, partialWindows, reuseBuffer = false).forEach {\n result.add(it)\n }\n return result\n}\n\n/**\n * Returns a list of results of applying the given [transform] function to\n * an each list representing a view over the window of the given [size]\n * sliding along this collection with the given [step].\n * \n * Note that the list passed to the [transform] function is ephemeral and is valid only inside that function.\n * You should not store it or allow it to escape in some way, unless you made a snapshot of it.\n * Several last lists may have less elements than the given [size].\n * \n * Both [size] and [step] must be positive and can be greater than the number of elements in this collection.\n * @param size the number of elements to take in each window\n * @param step the number of elements to move the window forward by on an each step, by default 1\n * @param partialWindows controls whether or not to keep partial windows in the end if any,\n * by default `false` which means partial windows won't be preserved\n * \n * @sample samples.collections.Sequences.Transformations.averageWindows\n */\n@SinceKotlin(\"1.2\")\npublic fun <T, R> Iterable<T>.windowed(size: Int, step: Int = 1, partialWindows: Boolean = false, transform: (List<T>) -> R): List<R> {\n checkWindowSizeStep(size, step)\n if (this is RandomAccess && this is List) {\n val thisSize = this.size\n val result = ArrayList<R>((thisSize + step - 1) / step)\n val window = MovingSubList(this)\n var index = 0\n while (index < thisSize) {\n window.move(index, (index + size).coerceAtMost(thisSize))\n if (!partialWindows && window.size < size) break\n result.add(transform(window))\n index += step\n }\n return result\n }\n val result = ArrayList<R>()\n windowedIterator(iterator(), size, step, partialWindows, reuseBuffer = true).forEach {\n result.add(transform(it))\n }\n return result\n}\n\n/**\n * Returns a list of pairs built from the elements of `this` collection and the [other] array with the same index.\n * The returned list has length of the shortest collection.\n * \n * @sample samples.collections.Iterables.Operations.zipIterable\n */\npublic infix fun <T, R> Iterable<T>.zip(other: Array<out R>): List<Pair<T, R>> {\n return zip(other) { t1, t2 -> t1 to t2 }\n}\n\n/**\n * Returns a list of values built from the elements of `this` collection and the [other] array with the same index\n * using the provided [transform] function applied to each pair of elements.\n * The returned list has length of the shortest collection.\n * \n * @sample samples.collections.Iterables.Operations.zipIterableWithTransform\n */\npublic inline fun <T, R, V> Iterable<T>.zip(other: Array<out R>, transform: (a: T, b: R) -> V): List<V> {\n val arraySize = other.size\n val list = ArrayList<V>(minOf(collectionSizeOrDefault(10), arraySize))\n var i = 0\n for (element in this) {\n if (i >= arraySize) break\n list.add(transform(element, other[i++]))\n }\n return list\n}\n\n/**\n * Returns a list of pairs built from the elements of `this` collection and [other] collection with the same index.\n * The returned list has length of the shortest collection.\n * \n * @sample samples.collections.Iterables.Operations.zipIterable\n */\npublic infix fun <T, R> Iterable<T>.zip(other: Iterable<R>): List<Pair<T, R>> {\n return zip(other) { t1, t2 -> t1 to t2 }\n}\n\n/**\n * Returns a list of values built from the elements of `this` collection and the [other] collection with the same index\n * using the provided [transform] function applied to each pair of elements.\n * The returned list has length of the shortest collection.\n * \n * @sample samples.collections.Iterables.Operations.zipIterableWithTransform\n */\npublic inline fun <T, R, V> Iterable<T>.zip(other: Iterable<R>, transform: (a: T, b: R) -> V): List<V> {\n val first = iterator()\n val second = other.iterator()\n val list = ArrayList<V>(minOf(collectionSizeOrDefault(10), other.collectionSizeOrDefault(10)))\n while (first.hasNext() && second.hasNext()) {\n list.add(transform(first.next(), second.next()))\n }\n return list\n}\n\n/**\n * Returns a list of pairs of each two adjacent elements in this collection.\n * \n * The returned list is empty if this collection contains less than two elements.\n * \n * @sample samples.collections.Collections.Transformations.zipWithNext\n */\n@SinceKotlin(\"1.2\")\npublic fun <T> Iterable<T>.zipWithNext(): List<Pair<T, T>> {\n return zipWithNext { a, b -> a to b }\n}\n\n/**\n * Returns a list containing the results of applying the given [transform] function\n * to an each pair of two adjacent elements in this collection.\n * \n * The returned list is empty if this collection contains less than two elements.\n * \n * @sample samples.collections.Collections.Transformations.zipWithNextToFindDeltas\n */\n@SinceKotlin(\"1.2\")\npublic inline fun <T, R> Iterable<T>.zipWithNext(transform: (a: T, b: T) -> R): List<R> {\n val iterator = iterator()\n if (!iterator.hasNext()) return emptyList()\n val result = mutableListOf<R>()\n var current = iterator.next()\n while (iterator.hasNext()) {\n val next = iterator.next()\n result.add(transform(current, next))\n current = next\n }\n return result\n}\n\n/**\n * Appends the string from all the elements separated using [separator] and using the given [prefix] and [postfix] if supplied.\n * \n * If the collection could be huge, you can specify a non-negative value of [limit], in which case only the first [limit]\n * elements will be appended, followed by the [truncated] string (which defaults to \"...\").\n * \n * @sample samples.collections.Collections.Transformations.joinTo\n */\npublic fun <T, A : Appendable> Iterable<T>.joinTo(buffer: A, separator: CharSequence = \", \", prefix: CharSequence = \"\", postfix: CharSequence = \"\", limit: Int = -1, truncated: CharSequence = \"...\", transform: ((T) -> CharSequence)? = null): A {\n buffer.append(prefix)\n var count = 0\n for (element in this) {\n if (++count > 1) buffer.append(separator)\n if (limit < 0 || count <= limit) {\n buffer.appendElement(element, transform)\n } else break\n }\n if (limit >= 0 && count > limit) buffer.append(truncated)\n buffer.append(postfix)\n return buffer\n}\n\n/**\n * Creates a string from all the elements separated using [separator] and using the given [prefix] and [postfix] if supplied.\n * \n * If the collection could be huge, you can specify a non-negative value of [limit], in which case only the first [limit]\n * elements will be appended, followed by the [truncated] string (which defaults to \"...\").\n * \n * @sample samples.collections.Collections.Transformations.joinToString\n */\npublic fun <T> Iterable<T>.joinToString(separator: CharSequence = \", \", prefix: CharSequence = \"\", postfix: CharSequence = \"\", limit: Int = -1, truncated: CharSequence = \"...\", transform: ((T) -> CharSequence)? = null): String {\n return joinTo(StringBuilder(), separator, prefix, postfix, limit, truncated, transform).toString()\n}\n\n/**\n * Returns this collection as an [Iterable].\n */\[email protected]\npublic inline fun <T> Iterable<T>.asIterable(): Iterable<T> {\n return this\n}\n\n/**\n * Creates a [Sequence] instance that wraps the original collection returning its elements when being iterated.\n * \n * @sample samples.collections.Sequences.Building.sequenceFromCollection\n */\npublic fun <T> Iterable<T>.asSequence(): Sequence<T> {\n return Sequence { this.iterator() }\n}\n\n/**\n * Returns an average value of elements in the collection.\n */\[email protected](\"averageOfByte\")\npublic fun Iterable<Byte>.average(): Double {\n var sum: Double = 0.0\n var count: Int = 0\n for (element in this) {\n sum += element\n checkCountOverflow(++count)\n }\n return if (count == 0) Double.NaN else sum / count\n}\n\n/**\n * Returns an average value of elements in the collection.\n */\[email protected](\"averageOfShort\")\npublic fun Iterable<Short>.average(): Double {\n var sum: Double = 0.0\n var count: Int = 0\n for (element in this) {\n sum += element\n checkCountOverflow(++count)\n }\n return if (count == 0) Double.NaN else sum / count\n}\n\n/**\n * Returns an average value of elements in the collection.\n */\[email protected](\"averageOfInt\")\npublic fun Iterable<Int>.average(): Double {\n var sum: Double = 0.0\n var count: Int = 0\n for (element in this) {\n sum += element\n checkCountOverflow(++count)\n }\n return if (count == 0) Double.NaN else sum / count\n}\n\n/**\n * Returns an average value of elements in the collection.\n */\[email protected](\"averageOfLong\")\npublic fun Iterable<Long>.average(): Double {\n var sum: Double = 0.0\n var count: Int = 0\n for (element in this) {\n sum += element\n checkCountOverflow(++count)\n }\n return if (count == 0) Double.NaN else sum / count\n}\n\n/**\n * Returns an average value of elements in the collection.\n */\[email protected](\"averageOfFloat\")\npublic fun Iterable<Float>.average(): Double {\n var sum: Double = 0.0\n var count: Int = 0\n for (element in this) {\n sum += element\n checkCountOverflow(++count)\n }\n return if (count == 0) Double.NaN else sum / count\n}\n\n/**\n * Returns an average value of elements in the collection.\n */\[email protected](\"averageOfDouble\")\npublic fun Iterable<Double>.average(): Double {\n var sum: Double = 0.0\n var count: Int = 0\n for (element in this) {\n sum += element\n checkCountOverflow(++count)\n }\n return if (count == 0) Double.NaN else sum / count\n}\n\n/**\n * Returns the sum of all elements in the collection.\n */\[email protected](\"sumOfByte\")\npublic fun Iterable<Byte>.sum(): Int {\n var sum: Int = 0\n for (element in this) {\n sum += element\n }\n return sum\n}\n\n/**\n * Returns the sum of all elements in the collection.\n */\[email protected](\"sumOfShort\")\npublic fun Iterable<Short>.sum(): Int {\n var sum: Int = 0\n for (element in this) {\n sum += element\n }\n return sum\n}\n\n/**\n * Returns the sum of all elements in the collection.\n */\[email protected](\"sumOfInt\")\npublic fun Iterable<Int>.sum(): Int {\n var sum: Int = 0\n for (element in this) {\n sum += element\n }\n return sum\n}\n\n/**\n * Returns the sum of all elements in the collection.\n */\[email protected](\"sumOfLong\")\npublic fun Iterable<Long>.sum(): Long {\n var sum: Long = 0L\n for (element in this) {\n sum += element\n }\n return sum\n}\n\n/**\n * Returns the sum of all elements in the collection.\n */\[email protected](\"sumOfFloat\")\npublic fun Iterable<Float>.sum(): Float {\n var sum: Float = 0.0f\n for (element in this) {\n sum += element\n }\n return sum\n}\n\n/**\n * Returns the sum of all elements in the collection.\n */\[email protected](\"sumOfDouble\")\npublic fun Iterable<Double>.sum(): Double {\n var sum: Double = 0.0\n for (element in this) {\n sum += element\n }\n return sum\n}\n\n", | |
"/*\n * Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license\n * that can be found in the license/LICENSE.txt file.\n */\n\n@file:kotlin.jvm.JvmMultifileClass\n@file:kotlin.jvm.JvmName(\"MapsKt\")\n\npackage kotlin.collections\n\nimport kotlin.contracts.*\n\nprivate object EmptyMap : Map<Any?, Nothing>, Serializable {\n private const val serialVersionUID: Long = 8246714829545688274\n\n override fun equals(other: Any?): Boolean = other is Map<*, *> && other.isEmpty()\n override fun hashCode(): Int = 0\n override fun toString(): String = \"{}\"\n\n override val size: Int get() = 0\n override fun isEmpty(): Boolean = true\n\n override fun containsKey(key: Any?): Boolean = false\n override fun containsValue(value: Nothing): Boolean = false\n override fun get(key: Any?): Nothing? = null\n override val entries: Set<Map.Entry<Any?, Nothing>> get() = EmptySet\n override val keys: Set<Any?> get() = EmptySet\n override val values: Collection<Nothing> get() = EmptyList\n\n private fun readResolve(): Any = EmptyMap\n}\n\n/**\n * Returns an empty read-only map of specified type.\n *\n * The returned map is serializable (JVM).\n * @sample samples.collections.Maps.Instantiation.emptyReadOnlyMap\n */\npublic fun <K, V> emptyMap(): Map<K, V> = @Suppress(\"UNCHECKED_CAST\") (EmptyMap as Map<K, V>)\n\n/**\n * Returns a new read-only map with the specified contents, given as a list of pairs\n * where the first value is the key and the second is the value.\n *\n * If multiple pairs have the same key, the resulting map will contain the value from the last of those pairs.\n *\n * Entries of the map are iterated in the order they were specified.\n *\n * The returned map is serializable (JVM).\n *\n * @sample samples.collections.Maps.Instantiation.mapFromPairs\n */\npublic fun <K, V> mapOf(vararg pairs: Pair<K, V>): Map<K, V> =\n if (pairs.size > 0) pairs.toMap(LinkedHashMap(mapCapacity(pairs.size))) else emptyMap()\n\n/**\n * Returns an empty read-only map.\n *\n * The returned map is serializable (JVM).\n * @sample samples.collections.Maps.Instantiation.emptyReadOnlyMap\n */\[email protected]\npublic inline fun <K, V> mapOf(): Map<K, V> = emptyMap()\n\n/**\n * Returns an empty new [MutableMap].\n *\n * The returned map preserves the entry iteration order.\n * @sample samples.collections.Maps.Instantiation.emptyMutableMap\n */\n@SinceKotlin(\"1.1\")\[email protected]\npublic inline fun <K, V> mutableMapOf(): MutableMap<K, V> = LinkedHashMap()\n\n/**\n * Returns a new [MutableMap] with the specified contents, given as a list of pairs\n * where the first component is the key and the second is the value.\n *\n * If multiple pairs have the same key, the resulting map will contain the value from the last of those pairs.\n *\n * Entries of the map are iterated in the order they were specified.\n *\n * @sample samples.collections.Maps.Instantiation.mutableMapFromPairs\n * @sample samples.collections.Maps.Instantiation.emptyMutableMap\n */\npublic fun <K, V> mutableMapOf(vararg pairs: Pair<K, V>): MutableMap<K, V> =\n LinkedHashMap<K, V>(mapCapacity(pairs.size)).apply { putAll(pairs) }\n\n/**\n * Returns an empty new [HashMap].\n */\n@SinceKotlin(\"1.1\")\[email protected]\npublic inline fun <K, V> hashMapOf(): HashMap<K, V> = HashMap<K, V>()\n\n/**\n * Returns a new [HashMap] with the specified contents, given as a list of pairs\n * where the first component is the key and the second is the value.\n *\n * @sample samples.collections.Maps.Instantiation.hashMapFromPairs\n */\npublic fun <K, V> hashMapOf(vararg pairs: Pair<K, V>): HashMap<K, V> = HashMap<K, V>(mapCapacity(pairs.size)).apply { putAll(pairs) }\n\n/**\n * Returns an empty new [LinkedHashMap].\n */\n@SinceKotlin(\"1.1\")\[email protected]\npublic inline fun <K, V> linkedMapOf(): LinkedHashMap<K, V> = LinkedHashMap<K, V>()\n\n/**\n * Returns a new [LinkedHashMap] with the specified contents, given as a list of pairs\n * where the first component is the key and the second is the value.\n *\n * If multiple pairs have the same key, the resulting map will contain the value from the last of those pairs.\n *\n * Entries of the map are iterated in the order they were specified.\n *\n * @sample samples.collections.Maps.Instantiation.linkedMapFromPairs\n */\npublic fun <K, V> linkedMapOf(vararg pairs: Pair<K, V>): LinkedHashMap<K, V> = pairs.toMap(LinkedHashMap(mapCapacity(pairs.size)))\n\n/**\n * Calculate the initial capacity of a map, based on Guava's com.google.common.collect.Maps approach. This is equivalent\n * to the Collection constructor for HashSet, (c.size()/.75f) + 1, but provides further optimisations for very small or\n * very large sizes, allows support non-collection classes, and provides consistency for all map based class construction.\n */\n@PublishedApi\ninternal fun mapCapacity(expectedSize: Int): Int {\n if (expectedSize < 3) {\n return expectedSize + 1\n }\n if (expectedSize < INT_MAX_POWER_OF_TWO) {\n return expectedSize + expectedSize / 3\n }\n return Int.MAX_VALUE // any large value\n}\n\nprivate const val INT_MAX_POWER_OF_TWO: Int = Int.MAX_VALUE / 2 + 1\n\n/** Returns `true` if this map is not empty. */\[email protected]\npublic inline fun <K, V> Map<out K, V>.isNotEmpty(): Boolean = !isEmpty()\n\n/**\n * Returns `true` if this nullable map is either null or empty.\n * @sample samples.collections.Maps.Usage.mapIsNullOrEmpty\n */\n@SinceKotlin(\"1.3\")\[email protected]\npublic inline fun <K, V> Map<out K, V>?.isNullOrEmpty(): Boolean {\n contract {\n returns(false) implies (this@isNullOrEmpty != null)\n }\n\n return this == null || isEmpty()\n}\n\n/**\n * Returns the [Map] if its not `null`, or the empty [Map] otherwise.\n *\n * @sample samples.collections.Maps.Usage.mapOrEmpty\n */\[email protected]\npublic inline fun <K, V> Map<K, V>?.orEmpty(): Map<K, V> = this ?: emptyMap()\n\n/**\n * Returns this map if it's not empty\n * or the result of calling [defaultValue] function if the map is empty.\n *\n * @sample samples.collections.Maps.Usage.mapIfEmpty\n */\n@SinceKotlin(\"1.3\")\[email protected]\npublic inline fun <M, R> M.ifEmpty(defaultValue: () -> R): R where M : Map<*, *>, M : R =\n if (isEmpty()) defaultValue() else this\n\n/**\n * Checks if the map contains the given key.\n *\n * This method allows to use the `x in map` syntax for checking whether an object is contained in the map.\n */\[email protected]\npublic inline operator fun <@kotlin.internal.OnlyInputTypes K, V> Map<out K, V>.contains(key: K): Boolean = containsKey(key)\n\n/**\n * Returns the value corresponding to the given [key], or `null` if such a key is not present in the map.\n */\[email protected]\npublic inline operator fun <@kotlin.internal.OnlyInputTypes K, V> Map<out K, V>.get(key: K): V? =\n @Suppress(\"UNCHECKED_CAST\") (this as Map<K, V>).get(key)\n\n/**\n * Allows to use the index operator for storing values in a mutable map.\n */\[email protected]\npublic inline operator fun <K, V> MutableMap<K, V>.set(key: K, value: V): Unit {\n put(key, value)\n}\n\n/**\n * Returns `true` if the map contains the specified [key].\n *\n * Allows to overcome type-safety restriction of `containsKey` that requires to pass a key of type `K`.\n */\[email protected]\npublic inline fun <@kotlin.internal.OnlyInputTypes K> Map<out K, *>.containsKey(key: K): Boolean =\n @Suppress(\"UNCHECKED_CAST\") (this as Map<K, *>).containsKey(key)\n\n/**\n * Returns `true` if the map maps one or more keys to the specified [value].\n *\n * Allows to overcome type-safety restriction of `containsValue` that requires to pass a value of type `V`.\n *\n * @sample samples.collections.Maps.Usage.containsValue\n */\n@Suppress(\"EXTENSION_SHADOWED_BY_MEMBER\") // false warning, extension takes precedence in some cases\[email protected]\npublic inline fun <K, @kotlin.internal.OnlyInputTypes V> Map<K, V>.containsValue(value: V): Boolean = this.containsValue(value)\n\n\n/**\n * Removes the specified key and its corresponding value from this map.\n *\n * @return the previous value associated with the key, or `null` if the key was not present in the map.\n\n * Allows to overcome type-safety restriction of `remove` that requires to pass a key of type `K`.\n */\[email protected]\npublic inline fun <@kotlin.internal.OnlyInputTypes K, V> MutableMap<out K, V>.remove(key: K): V? =\n @Suppress(\"UNCHECKED_CAST\") (this as MutableMap<K, V>).remove(key)\n\n/**\n * Returns the key component of the map entry.\n *\n * This method allows to use destructuring declarations when working with maps, for example:\n * ```\n * for ((key, value) in map) {\n * // do something with the key and the value\n * }\n * ```\n */\[email protected]\npublic inline operator fun <K, V> Map.Entry<K, V>.component1(): K = key\n\n/**\n * Returns the value component of the map entry.\n *\n * This method allows to use destructuring declarations when working with maps, for example:\n * ```\n * for ((key, value) in map) {\n * // do something with the key and the value\n * }\n * ```\n */\[email protected]\npublic inline operator fun <K, V> Map.Entry<K, V>.component2(): V = value\n\n/**\n * Converts entry to [Pair] with key being first component and value being second.\n */\[email protected]\npublic inline fun <K, V> Map.Entry<K, V>.toPair(): Pair<K, V> = Pair(key, value)\n\n/**\n * Returns the value for the given key, or the result of the [defaultValue] function if there was no entry for the given key.\n *\n * @sample samples.collections.Maps.Usage.getOrElse\n */\[email protected]\npublic inline fun <K, V> Map<K, V>.getOrElse(key: K, defaultValue: () -> V): V = get(key) ?: defaultValue()\n\n\ninternal inline fun <K, V> Map<K, V>.getOrElseNullable(key: K, defaultValue: () -> V): V {\n val value = get(key)\n if (value == null && !containsKey(key)) {\n return defaultValue()\n } else {\n @Suppress(\"UNCHECKED_CAST\")\n return value as V\n }\n}\n\n/**\n * Returns the value for the given [key] or throws an exception if there is no such key in the map.\n *\n * If the map was created by [withDefault], resorts to its `defaultValue` provider function\n * instead of throwing an exception.\n *\n * @throws NoSuchElementException when the map doesn't contain a value for the specified key and\n * no implicit default value was provided for that map.\n */\n@SinceKotlin(\"1.1\")\npublic fun <K, V> Map<K, V>.getValue(key: K): V = getOrImplicitDefault(key)\n\n/**\n * Returns the value for the given key. If the key is not found in the map, calls the [defaultValue] function,\n * puts its result into the map under the given key and returns it.\n *\n * Note that the operation is not guaranteed to be atomic if the map is being modified concurrently.\n *\n * @sample samples.collections.Maps.Usage.getOrPut\n */\npublic inline fun <K, V> MutableMap<K, V>.getOrPut(key: K, defaultValue: () -> V): V {\n val value = get(key)\n return if (value == null) {\n val answer = defaultValue()\n put(key, answer)\n answer\n } else {\n value\n }\n}\n\n/**\n * Returns an [Iterator] over the entries in the [Map].\n *\n * @sample samples.collections.Maps.Usage.forOverEntries\n */\[email protected]\npublic inline operator fun <K, V> Map<out K, V>.iterator(): Iterator<Map.Entry<K, V>> = entries.iterator()\n\n/**\n * Returns a [MutableIterator] over the mutable entries in the [MutableMap].\n *\n */\[email protected](\"mutableIterator\")\[email protected]\npublic inline operator fun <K, V> MutableMap<K, V>.iterator(): MutableIterator<MutableMap.MutableEntry<K, V>> = entries.iterator()\n\n/**\n * Populates the given [destination] map with entries having the keys of this map and the values obtained\n * by applying the [transform] function to each entry in this [Map].\n */\npublic inline fun <K, V, R, M : MutableMap<in K, in R>> Map<out K, V>.mapValuesTo(destination: M, transform: (Map.Entry<K, V>) -> R): M {\n return entries.associateByTo(destination, { it.key }, transform)\n}\n\n/**\n * Populates the given [destination] map with entries having the keys obtained\n * by applying the [transform] function to each entry in this [Map] and the values of this map.\n *\n * In case if any two entries are mapped to the equal keys, the value of the latter one will overwrite\n * the value associated with the former one.\n */\npublic inline fun <K, V, R, M : MutableMap<in R, in V>> Map<out K, V>.mapKeysTo(destination: M, transform: (Map.Entry<K, V>) -> R): M {\n return entries.associateByTo(destination, transform, { it.value })\n}\n\n/**\n * Puts all the given [pairs] into this [MutableMap] with the first component in the pair being the key and the second the value.\n */\npublic fun <K, V> MutableMap<in K, in V>.putAll(pairs: Array<out Pair<K, V>>): Unit {\n for ((key, value) in pairs) {\n put(key, value)\n }\n}\n\n/**\n * Puts all the elements of the given collection into this [MutableMap] with the first component in the pair being the key and the second the value.\n */\npublic fun <K, V> MutableMap<in K, in V>.putAll(pairs: Iterable<Pair<K, V>>): Unit {\n for ((key, value) in pairs) {\n put(key, value)\n }\n}\n\n/**\n * Puts all the elements of the given sequence into this [MutableMap] with the first component in the pair being the key and the second the value.\n */\npublic fun <K, V> MutableMap<in K, in V>.putAll(pairs: Sequence<Pair<K, V>>): Unit {\n for ((key, value) in pairs) {\n put(key, value)\n }\n}\n\n/**\n * Returns a new map with entries having the keys of this map and the values obtained by applying the [transform]\n * function to each entry in this [Map].\n *\n * The returned map preserves the entry iteration order of the original map.\n *\n * @sample samples.collections.Maps.Transformations.mapValues\n */\npublic inline fun <K, V, R> Map<out K, V>.mapValues(transform: (Map.Entry<K, V>) -> R): Map<K, R> {\n return mapValuesTo(LinkedHashMap<K, R>(mapCapacity(size)), transform) // .optimizeReadOnlyMap()\n}\n\n/**\n * Returns a new Map with entries having the keys obtained by applying the [transform] function to each entry in this\n * [Map] and the values of this map.\n *\n * In case if any two entries are mapped to the equal keys, the value of the latter one will overwrite\n * the value associated with the former one.\n *\n * The returned map preserves the entry iteration order of the original map.\n *\n * @sample samples.collections.Maps.Transformations.mapKeys\n */\npublic inline fun <K, V, R> Map<out K, V>.mapKeys(transform: (Map.Entry<K, V>) -> R): Map<R, V> {\n return mapKeysTo(LinkedHashMap<R, V>(mapCapacity(size)), transform) // .optimizeReadOnlyMap()\n}\n\n/**\n * Returns a map containing all key-value pairs with keys matching the given [predicate].\n *\n * The returned map preserves the entry iteration order of the original map.\n * @sample samples.collections.Maps.Filtering.filterKeys\n */\npublic inline fun <K, V> Map<out K, V>.filterKeys(predicate: (K) -> Boolean): Map<K, V> {\n val result = LinkedHashMap<K, V>()\n for (entry in this) {\n if (predicate(entry.key)) {\n result.put(entry.key, entry.value)\n }\n }\n return result\n}\n\n/**\n * Returns a map containing all key-value pairs with values matching the given [predicate].\n *\n * The returned map preserves the entry iteration order of the original map.\n * @sample samples.collections.Maps.Filtering.filterValues\n */\npublic inline fun <K, V> Map<out K, V>.filterValues(predicate: (V) -> Boolean): Map<K, V> {\n val result = LinkedHashMap<K, V>()\n for (entry in this) {\n if (predicate(entry.value)) {\n result.put(entry.key, entry.value)\n }\n }\n return result\n}\n\n\n/**\n * Appends all entries matching the given [predicate] into the mutable map given as [destination] parameter.\n *\n * @return the destination map.\n * @sample samples.collections.Maps.Filtering.filterTo\n */\npublic inline fun <K, V, M : MutableMap<in K, in V>> Map<out K, V>.filterTo(destination: M, predicate: (Map.Entry<K, V>) -> Boolean): M {\n for (element in this) {\n if (predicate(element)) {\n destination.put(element.key, element.value)\n }\n }\n return destination\n}\n\n/**\n * Returns a new map containing all key-value pairs matching the given [predicate].\n *\n * The returned map preserves the entry iteration order of the original map.\n * @sample samples.collections.Maps.Filtering.filter\n */\npublic inline fun <K, V> Map<out K, V>.filter(predicate: (Map.Entry<K, V>) -> Boolean): Map<K, V> {\n return filterTo(LinkedHashMap<K, V>(), predicate)\n}\n\n/**\n * Appends all entries not matching the given [predicate] into the given [destination].\n *\n * @return the destination map.\n * @sample samples.collections.Maps.Filtering.filterNotTo\n */\npublic inline fun <K, V, M : MutableMap<in K, in V>> Map<out K, V>.filterNotTo(destination: M, predicate: (Map.Entry<K, V>) -> Boolean): M {\n for (element in this) {\n if (!predicate(element)) {\n destination.put(element.key, element.value)\n }\n }\n return destination\n}\n\n/**\n * Returns a new map containing all key-value pairs not matching the given [predicate].\n *\n * The returned map preserves the entry iteration order of the original map.\n * @sample samples.collections.Maps.Filtering.filterNot\n */\npublic inline fun <K, V> Map<out K, V>.filterNot(predicate: (Map.Entry<K, V>) -> Boolean): Map<K, V> {\n return filterNotTo(LinkedHashMap<K, V>(), predicate)\n}\n\n/**\n * Returns a new map containing all key-value pairs from the given collection of pairs.\n *\n * The returned map preserves the entry iteration order of the original collection.\n * If any of two pairs would have the same key the last one gets added to the map.\n */\npublic fun <K, V> Iterable<Pair<K, V>>.toMap(): Map<K, V> {\n if (this is Collection) {\n return when (size) {\n 0 -> emptyMap()\n 1 -> mapOf(if (this is List) this[0] else iterator().next())\n else -> toMap(LinkedHashMap<K, V>(mapCapacity(size)))\n }\n }\n return toMap(LinkedHashMap<K, V>()).optimizeReadOnlyMap()\n}\n\n/**\n * Populates and returns the [destination] mutable map with key-value pairs from the given collection of pairs.\n */\npublic fun <K, V, M : MutableMap<in K, in V>> Iterable<Pair<K, V>>.toMap(destination: M): M =\n destination.apply { putAll(this@toMap) }\n\n/**\n * Returns a new map containing all key-value pairs from the given array of pairs.\n *\n * The returned map preserves the entry iteration order of the original array.\n * If any of two pairs would have the same key the last one gets added to the map.\n */\npublic fun <K, V> Array<out Pair<K, V>>.toMap(): Map<K, V> = when (size) {\n 0 -> emptyMap()\n 1 -> mapOf(this[0])\n else -> toMap(LinkedHashMap<K, V>(mapCapacity(size)))\n}\n\n/**\n * Populates and returns the [destination] mutable map with key-value pairs from the given array of pairs.\n */\npublic fun <K, V, M : MutableMap<in K, in V>> Array<out Pair<K, V>>.toMap(destination: M): M =\n destination.apply { putAll(this@toMap) }\n\n/**\n * Returns a new map containing all key-value pairs from the given sequence of pairs.\n *\n * The returned map preserves the entry iteration order of the original sequence.\n * If any of two pairs would have the same key the last one gets added to the map.\n */\npublic fun <K, V> Sequence<Pair<K, V>>.toMap(): Map<K, V> = toMap(LinkedHashMap<K, V>()).optimizeReadOnlyMap()\n\n/**\n * Populates and returns the [destination] mutable map with key-value pairs from the given sequence of pairs.\n */\npublic fun <K, V, M : MutableMap<in K, in V>> Sequence<Pair<K, V>>.toMap(destination: M): M =\n destination.apply { putAll(this@toMap) }\n\n/**\n * Returns a new read-only map containing all key-value pairs from the original map.\n *\n * The returned map preserves the entry iteration order of the original map.\n */\n@SinceKotlin(\"1.1\")\npublic fun <K, V> Map<out K, V>.toMap(): Map<K, V> = when (size) {\n 0 -> emptyMap()\n 1 -> toSingletonMap()\n else -> toMutableMap()\n}\n\n/**\n * Returns a new mutable map containing all key-value pairs from the original map.\n *\n * The returned map preserves the entry iteration order of the original map.\n */\n@SinceKotlin(\"1.1\")\npublic fun <K, V> Map<out K, V>.toMutableMap(): MutableMap<K, V> = LinkedHashMap(this)\n\n/**\n * Populates and returns the [destination] mutable map with key-value pairs from the given map.\n */\n@SinceKotlin(\"1.1\")\npublic fun <K, V, M : MutableMap<in K, in V>> Map<out K, V>.toMap(destination: M): M =\n destination.apply { putAll(this@toMap) }\n\n/**\n * Creates a new read-only map by replacing or adding an entry to this map from a given key-value [pair].\n *\n * The returned map preserves the entry iteration order of the original map.\n * The [pair] is iterated in the end if it has a unique key.\n */\npublic operator fun <K, V> Map<out K, V>.plus(pair: Pair<K, V>): Map<K, V> =\n if (this.isEmpty()) mapOf(pair) else LinkedHashMap(this).apply { put(pair.first, pair.second) }\n\n/**\n * Creates a new read-only map by replacing or adding entries to this map from a given collection of key-value [pairs].\n *\n * The returned map preserves the entry iteration order of the original map.\n * Those [pairs] with unique keys are iterated in the end in the order of [pairs] collection.\n */\npublic operator fun <K, V> Map<out K, V>.plus(pairs: Iterable<Pair<K, V>>): Map<K, V> =\n if (this.isEmpty()) pairs.toMap() else LinkedHashMap(this).apply { putAll(pairs) }\n\n/**\n * Creates a new read-only map by replacing or adding entries to this map from a given array of key-value [pairs].\n *\n * The returned map preserves the entry iteration order of the original map.\n * Those [pairs] with unique keys are iterated in the end in the order of [pairs] array.\n */\npublic operator fun <K, V> Map<out K, V>.plus(pairs: Array<out Pair<K, V>>): Map<K, V> =\n if (this.isEmpty()) pairs.toMap() else LinkedHashMap(this).apply { putAll(pairs) }\n\n/**\n * Creates a new read-only map by replacing or adding entries to this map from a given sequence of key-value [pairs].\n *\n * The returned map preserves the entry iteration order of the original map.\n * Those [pairs] with unique keys are iterated in the end in the order of [pairs] sequence.\n */\npublic operator fun <K, V> Map<out K, V>.plus(pairs: Sequence<Pair<K, V>>): Map<K, V> =\n LinkedHashMap(this).apply { putAll(pairs) }.optimizeReadOnlyMap()\n\n/**\n * Creates a new read-only map by replacing or adding entries to this map from another [map].\n *\n * The returned map preserves the entry iteration order of the original map.\n * Those entries of another [map] that are missing in this map are iterated in the end in the order of that [map].\n */\npublic operator fun <K, V> Map<out K, V>.plus(map: Map<out K, V>): Map<K, V> =\n LinkedHashMap(this).apply { putAll(map) }\n\n\n/**\n * Appends or replaces the given [pair] in this mutable map.\n */\[email protected]\npublic inline operator fun <K, V> MutableMap<in K, in V>.plusAssign(pair: Pair<K, V>) {\n put(pair.first, pair.second)\n}\n\n/**\n * Appends or replaces all pairs from the given collection of [pairs] in this mutable map.\n */\[email protected]\npublic inline operator fun <K, V> MutableMap<in K, in V>.plusAssign(pairs: Iterable<Pair<K, V>>) {\n putAll(pairs)\n}\n\n/**\n * Appends or replaces all pairs from the given array of [pairs] in this mutable map.\n */\[email protected]\npublic inline operator fun <K, V> MutableMap<in K, in V>.plusAssign(pairs: Array<out Pair<K, V>>) {\n putAll(pairs)\n}\n\n/**\n * Appends or replaces all pairs from the given sequence of [pairs] in this mutable map.\n */\[email protected]\npublic inline operator fun <K, V> MutableMap<in K, in V>.plusAssign(pairs: Sequence<Pair<K, V>>) {\n putAll(pairs)\n}\n\n/**\n * Appends or replaces all entries from the given [map] in this mutable map.\n */\[email protected]\npublic inline operator fun <K, V> MutableMap<in K, in V>.plusAssign(map: Map<K, V>) {\n putAll(map)\n}\n\n/**\n * Returns a map containing all entries of the original map except the entry with the given [key].\n *\n * The returned map preserves the entry iteration order of the original map.\n */\n@SinceKotlin(\"1.1\")\npublic operator fun <K, V> Map<out K, V>.minus(key: K): Map<K, V> =\n this.toMutableMap().apply { minusAssign(key) }.optimizeReadOnlyMap()\n\n/**\n * Returns a map containing all entries of the original map except those entries\n * the keys of which are contained in the given [keys] collection.\n *\n * The returned map preserves the entry iteration order of the original map.\n */\n@SinceKotlin(\"1.1\")\npublic operator fun <K, V> Map<out K, V>.minus(keys: Iterable<K>): Map<K, V> =\n this.toMutableMap().apply { minusAssign(keys) }.optimizeReadOnlyMap()\n\n/**\n * Returns a map containing all entries of the original map except those entries\n * the keys of which are contained in the given [keys] array.\n *\n * The returned map preserves the entry iteration order of the original map.\n */\n@SinceKotlin(\"1.1\")\npublic operator fun <K, V> Map<out K, V>.minus(keys: Array<out K>): Map<K, V> =\n this.toMutableMap().apply { minusAssign(keys) }.optimizeReadOnlyMap()\n\n/**\n * Returns a map containing all entries of the original map except those entries\n * the keys of which are contained in the given [keys] sequence.\n *\n * The returned map preserves the entry iteration order of the original map.\n */\n@SinceKotlin(\"1.1\")\npublic operator fun <K, V> Map<out K, V>.minus(keys: Sequence<K>): Map<K, V> =\n this.toMutableMap().apply { minusAssign(keys) }.optimizeReadOnlyMap()\n\n/**\n * Removes the entry with the given [key] from this mutable map.\n */\n@SinceKotlin(\"1.1\")\[email protected]\npublic inline operator fun <K, V> MutableMap<K, V>.minusAssign(key: K) {\n remove(key)\n}\n\n/**\n * Removes all entries the keys of which are contained in the given [keys] collection from this mutable map.\n */\n@SinceKotlin(\"1.1\")\[email protected]\npublic inline operator fun <K, V> MutableMap<K, V>.minusAssign(keys: Iterable<K>) {\n this.keys.removeAll(keys)\n}\n\n/**\n * Removes all entries the keys of which are contained in the given [keys] array from this mutable map.\n */\n@SinceKotlin(\"1.1\")\[email protected]\npublic inline operator fun <K, V> MutableMap<K, V>.minusAssign(keys: Array<out K>) {\n this.keys.removeAll(keys)\n}\n\n/**\n * Removes all entries from the keys of which are contained in the given [keys] sequence from this mutable map.\n */\n@SinceKotlin(\"1.1\")\[email protected]\npublic inline operator fun <K, V> MutableMap<K, V>.minusAssign(keys: Sequence<K>) {\n this.keys.removeAll(keys)\n}\n\n\n// do not expose for now @PublishedApi\ninternal fun <K, V> Map<K, V>.optimizeReadOnlyMap() = when (size) {\n 0 -> emptyMap()\n 1 -> toSingletonMapOrSelf()\n else -> this\n}\n", | |
"package io.ktor.client\n\nimport io.ktor.client.engine.*\nimport io.ktor.client.features.*\nimport io.ktor.util.*\nimport kotlin.collections.set\n\n/**\n * Mutable configuration used by [HttpClient].\n */\n@HttpClientDsl\nclass HttpClientConfig<T : HttpClientEngineConfig> {\n private val features = mutableMapOf<AttributeKey<*>, (HttpClient) -> Unit>()\n private val customInterceptors = mutableMapOf<String, (HttpClient) -> Unit>()\n\n internal var engineConfig: T.() -> Unit = {}\n\n /**\n * Configure engine parameters.\n */\n fun engine(block: T.() -> Unit) {\n val oldConfig = engineConfig\n engineConfig = {\n oldConfig()\n block()\n }\n }\n\n /**\n * Use [HttpRedirect] feature to automatically follow redirects.\n */\n var followRedirects: Boolean = true\n\n /**\n * Use [defaultTransformers] to automatically handle simple [ContentType].\n */\n var useDefaultTransformers: Boolean = true\n\n /**\n * Terminate [HttpClient.responsePipeline] if status code is not success(>=300).\n */\n var expectSuccess: Boolean = true\n\n /**\n * Installs a specific [feature] and optionally [configure] it.\n */\n fun <TBuilder : Any, TFeature : Any> install(\n feature: HttpClientFeature<TBuilder, TFeature>,\n configure: TBuilder.() -> Unit = {}\n ) {\n val featureData = feature.prepare(configure)\n\n features[feature.key] = { scope ->\n val attributes = scope.attributes.computeIfAbsent(FEATURE_INSTALLED_LIST) { Attributes() }\n\n feature.install(featureData, scope)\n attributes.put(feature.key, featureData)\n }\n }\n\n /**\n * Installs an interceptor defined by [block].\n * The [key] parameter is used as a unique name, that also prevents installing duplicated interceptors.\n */\n fun install(key: String, block: HttpClient.() -> Unit) {\n customInterceptors[key] = block\n }\n\n /**\n * Applies all the installed [features] and [customInterceptors] from this configuration\n * into the specified [client].\n */\n fun install(client: HttpClient) {\n features.values.forEach { client.apply(it) }\n customInterceptors.values.forEach { client.apply(it) }\n }\n\n /**\n * Clones this [HttpClientConfig] duplicating all the [features] and [customInterceptors].\n */\n fun clone(): HttpClientConfig<T> {\n val result = HttpClientConfig<T>()\n result.features.putAll(features)\n result.customInterceptors.putAll(customInterceptors)\n result.engineConfig = engineConfig\n\n return result\n }\n\n /**\n * Install features from [other] client config.\n */\n operator fun plusAssign(other: HttpClientConfig<out T>) {\n followRedirects = other.followRedirects\n useDefaultTransformers = other.useDefaultTransformers\n expectSuccess = other.expectSuccess\n\n features += other.features\n customInterceptors += other.customInterceptors\n }\n}\n\n/**\n * Dsl marker for [HttpClient] dsl.\n */\n@DslMarker\nannotation class HttpClientDsl()\n", | |
"package io.ktor.client.call\n\nimport io.ktor.client.*\nimport io.ktor.client.features.*\nimport io.ktor.client.request.*\nimport io.ktor.client.response.*\nimport io.ktor.util.*\nimport kotlinx.atomicfu.*\nimport kotlinx.coroutines.*\nimport kotlinx.io.core.*\nimport kotlin.coroutines.*\nimport kotlin.reflect.*\n\n/**\n * A class that represents a single pair of [request] and [response] for a specific [HttpClient].\n *\n * @property client: client that executed the call.\n */\nopen class HttpClientCall constructor(\n val client: HttpClient\n) : CoroutineScope, Closeable {\n private val received = atomic(false)\n\n override val coroutineContext: CoroutineContext get() = response.coroutineContext\n\n /**\n * Typed [Attributes] associated to this call serving as a lightweight container.\n */\n val attributes: Attributes get() = request.attributes\n\n /**\n * Represents the [request] sent by the client\n */\n lateinit var request: HttpRequest\n internal set\n\n /**\n * Represents the [response] sent by the server.\n */\n lateinit var response: HttpResponse\n internal set\n\n /**\n * Configuration for the [response].\n */\n val responseConfig: HttpResponseConfig = client.engineConfig.response\n\n /**\n * Tries to receive the payload of the [response] as an specific [expectedType].\n * Returns [response] if [expectedType] is [HttpResponse].\n *\n * @throws NoTransformationFoundException If no transformation is found for the [expectedType].\n * @throws DoubleReceiveException If already called [receive].\n */\n suspend fun receive(info: TypeInfo): Any {\n if (info.type.isInstance(response)) return response\n if (!received.compareAndSet(false, true)) throw DoubleReceiveException(this)\n\n val subject = HttpResponseContainer(info, response)\n try {\n val result = client.responsePipeline.execute(this, subject).response\n if (!info.type.isInstance(result)) throw NoTransformationFoundException(result::class, info.type)\n return result\n } catch (cause: BadResponseStatusException) {\n throw cause\n } catch (cause: Throwable) {\n throw ReceivePipelineException(response.call, info, cause)\n }\n }\n\n /**\n * Closes the underlying [response].\n */\n override fun close() {\n response.close()\n }\n}\n\n/**\n * Raw http call produced by engine.\n *\n * @property request - executed http request.\n * @property response - raw http response\n */\ndata class HttpEngineCall(val request: HttpRequest, val response: HttpResponse)\n\n/**\n * Constructs a [HttpClientCall] from this [HttpClient] and with the specified [HttpRequestBuilder]\n * configured inside the [block].\n */\nsuspend fun HttpClient.call(block: suspend HttpRequestBuilder.() -> Unit = {}): HttpClientCall =\n execute(HttpRequestBuilder().apply { block() })\n\n/**\n * Tries to receive the payload of the [response] as an specific type [T].\n *\n * @throws NoTransformationFoundException If no transformation is found for the type [T].\n * @throws DoubleReceiveException If already called [receive].\n */\nsuspend inline fun <reified T> HttpClientCall.receive(): T = receive(typeInfo<T>()) as T\n\n/**\n * Tries to receive the payload of the [response] as an specific type [T].\n *\n * @throws NoTransformationFoundException If no transformation is found for the type [T].\n * @throws DoubleReceiveException If already called [receive].\n */\nsuspend inline fun <reified T> HttpResponse.receive(): T = call.receive(typeInfo<T>()) as T\n\n/**\n * Exception representing that the response payload has already been received.\n */\n@Suppress(\"KDocMissingDocumentation\")\nclass DoubleReceiveException(call: HttpClientCall) : IllegalStateException() {\n override val message: String = \"Response already received: $call\"\n}\n\n/**\n * Exception representing fail of the response pipeline\n * [cause] contains origin pipeline exception\n */\n@Suppress(\"KDocMissingDocumentation\")\nclass ReceivePipelineException(\n val request: HttpClientCall,\n val info: TypeInfo,\n override val cause: Throwable\n) : IllegalStateException(\"Fail to run receive pipeline\")\n\n/**\n * Exception representing the no transformation was found.\n * It includes the received type and the expected type as part of the message.\n */\n@Suppress(\"KDocMissingDocumentation\")\nclass NoTransformationFoundException(from: KClass<*>, to: KClass<*>) : UnsupportedOperationException() {\n override val message: String? = \"No transformation found: $from -> $to\"\n}\n\n@Deprecated(\n \"[NoTransformationFound] is deprecated. Use [NoTransformationFoundException] instead\",\n ReplaceWith(\"NoTransformationFoundException\"),\n DeprecationLevel.ERROR\n)\n@Suppress(\"KDocMissingDocumentation\")\ntypealias NoTransformationFound = NoTransformationFoundException\n", | |
"package io.ktor.client.call\n\n\nactual interface Type\n\nobject JsType : Type\n\nactual inline fun <reified T> typeInfo(): TypeInfo {\n return TypeInfo(T::class, JsType)\n}\n", | |
"package io.ktor.client.call\n\nimport kotlin.reflect.*\n\n/**\n * Information about type.\n */\nexpect interface Type\n\n/**\n * Ktor type information.\n * [type]: source KClass<*>\n * [reifiedType]: type with substituted generics\n */\ndata class TypeInfo(val type: KClass<*>, val reifiedType: Type)\n\n/**\n * Returns [TypeInfo] for the specified type [T]\n */\nexpect inline fun <reified T> typeInfo(): TypeInfo\n", | |
"package io.ktor.client.call\n\nimport io.ktor.client.*\nimport io.ktor.client.request.*\nimport io.ktor.http.*\nimport io.ktor.http.content.*\n\n\n@Suppress(\"KDocMissingDocumentation\")\nclass UnsupportedContentTypeException(content: OutgoingContent) :\n IllegalStateException(\"Failed to write body: ${content::class}\")\n\n@Suppress(\"KDocMissingDocumentation\")\nclass UnsupportedUpgradeProtocolException(\n url: Url\n) : IllegalArgumentException(\"Unsupported upgrade protocol exception: $url\")\n\n/**\n * Constructs a [HttpClientCall] from this [HttpClient] and\n * with the specified HTTP request [builder].\n */\nsuspend fun HttpClient.call(builder: HttpRequestBuilder): HttpClientCall = call { takeFrom(builder) }\n\n/**\n * Constructs a [HttpClientCall] from this [HttpClient],\n * an [url] and an optional [block] configuring a [HttpRequestBuilder].\n */\nsuspend fun HttpClient.call(\n urlString: String,\n block: suspend HttpRequestBuilder.() -> Unit = {}\n): HttpClientCall = call {\n url.takeFrom(urlString)\n block()\n}\n\n/**\n * Constructs a [HttpClientCall] from this [HttpClient],\n * an [url] and an optional [block] configuring a [HttpRequestBuilder].\n */\nsuspend fun HttpClient.call(\n url: Url,\n block: suspend HttpRequestBuilder.() -> Unit = {}\n): HttpClientCall = call {\n this.url.takeFrom(url)\n block()\n}\n", | |
"package io.ktor.client.engine\n\nimport io.ktor.client.call.*\nimport io.ktor.client.request.*\nimport kotlinx.coroutines.*\nimport kotlinx.io.core.*\n\n/**\n * Base interface use to define engines for [HttpClient].\n */\ninterface HttpClientEngine : CoroutineScope, Closeable {\n\n /**\n * [CoroutineDispatcher] specified for io operations.\n */\n val dispatcher: CoroutineDispatcher\n\n /**\n * Engine configuration\n */\n val config: HttpClientEngineConfig\n\n /**\n * Creates a new [HttpClientCall] specific for this engine, using a request [data].\n */\n suspend fun execute(call: HttpClientCall, data: HttpRequestData): HttpEngineCall\n}\n\n/**\n * Factory of [HttpClientEngine] with a specific [T] of [HttpClientEngineConfig].\n */\ninterface HttpClientEngineFactory<out T : HttpClientEngineConfig> {\n /**\n * Creates a new [HttpClientEngine] optionally specifying a [block] configuring [T].\n */\n fun create(block: T.() -> Unit = {}): HttpClientEngine\n}\n\n/**\n * Creates a new [HttpClientEngineFactory] based on this one\n * with further configurations from the [nested] block.\n */\nfun <T : HttpClientEngineConfig> HttpClientEngineFactory<T>.config(nested: T.() -> Unit): HttpClientEngineFactory<T> {\n val parent = this\n\n return object : HttpClientEngineFactory<T> {\n override fun create(block: T.() -> Unit): HttpClientEngine = parent.create {\n nested()\n block()\n }\n }\n}\n", | |
"package io.ktor.client.engine\n\nimport io.ktor.client.*\nimport io.ktor.client.response.*\nimport io.ktor.util.*\nimport kotlinx.coroutines.*\n\n/**\n * Base configuration for [HttpClientEngine].\n */\n@HttpClientDsl\nopen class HttpClientEngineConfig {\n /**\n * The [CoroutineDispatcher] that will be used for the client requests.\n */\n @Deprecated(\n \"Custom dispatcher is deprecated. Consider using threadsCount instead.\",\n level = DeprecationLevel.ERROR\n )\n var dispatcher: CoroutineDispatcher? = null\n\n /**\n * Network threads count\n */\n @KtorExperimentalAPI\n var threadsCount: Int = 4\n\n /**\n * Enable http pipelining\n */\n var pipelining: Boolean = false\n\n /**\n * Configuration for http response.\n */\n val response: HttpResponseConfig = HttpResponseConfig()\n}\n", | |
"package io.ktor.client.engine\n\nimport io.ktor.client.utils.*\nimport io.ktor.http.*\nimport io.ktor.http.content.*\nimport io.ktor.util.*\n\n/**\n * Merge headers from [content] and [requestHeaders] according to [OutgoingContent] properties\n */\n@InternalAPI\nfun mergeHeaders(\n requestHeaders: Headers,\n content: OutgoingContent,\n block: (key: String, value: String) -> Unit\n) {\n buildHeaders {\n appendAll(requestHeaders)\n appendAll(content.headers)\n }.forEach { key, values ->\n if (HttpHeaders.ContentLength == key) return@forEach // set later\n if (HttpHeaders.ContentType == key) return@forEach // set later\n\n block(key, values.joinToString(\";\"))\n }\n\n if (requestHeaders[HttpHeaders.UserAgent] == null && content.headers[HttpHeaders.UserAgent] == null) {\n block(HttpHeaders.UserAgent, \"Ktor client\")\n }\n\n val type = content.contentType?.toString() ?: content.headers[HttpHeaders.ContentType]\n val length = content.contentLength?.toString() ?: content.headers[HttpHeaders.ContentLength]\n\n type?.let { block(HttpHeaders.ContentType, it) }\n length?.let { block(HttpHeaders.ContentLength, it) }\n}\n", | |
"package io.ktor.client.features\n\nimport io.ktor.client.*\nimport io.ktor.client.request.*\nimport io.ktor.util.*\n\n\n/**\n * [Feature] is used to set request default parameters.\n */\nclass DefaultRequest(private val builder: HttpRequestBuilder.() -> Unit) {\n\n companion object Feature : HttpClientFeature<HttpRequestBuilder, DefaultRequest> {\n override val key: AttributeKey<DefaultRequest> = AttributeKey(\"DefaultRequest\")\n\n override fun prepare(block: HttpRequestBuilder.() -> Unit): DefaultRequest =\n DefaultRequest(block)\n\n override fun install(feature: DefaultRequest, scope: HttpClient) {\n scope.requestPipeline.intercept(HttpRequestPipeline.Before) {\n context.apply(feature.builder)\n }\n }\n }\n\n}\n\n/**\n * Set request default parameters.\n */\nfun HttpClientConfig<*>.defaultRequest(block: HttpRequestBuilder.() -> Unit) {\n install(DefaultRequest) {\n block()\n }\n}\n", | |
"package io.ktor.client.features\n\nimport io.ktor.client.*\nimport io.ktor.client.response.*\nimport io.ktor.http.*\nimport io.ktor.util.*\nimport kotlinx.atomicfu.*\n\n/**\n * Terminate response pipeline with fail status code in response.\n */\nclass ExpectSuccess(\n) {\n companion object : HttpClientFeature<Unit, ExpectSuccess> {\n override val key: AttributeKey<ExpectSuccess> = AttributeKey(\"ExpectSuccess\")\n\n override fun prepare(block: Unit.() -> Unit): ExpectSuccess = ExpectSuccess()\n\n override fun install(feature: ExpectSuccess, scope: HttpClient) {\n scope.responsePipeline.intercept(HttpResponsePipeline.Receive) {\n val response = context.response\n if (response.status.value >= 300) throw BadResponseStatusException(response.status, response)\n }\n }\n }\n}\n\nclass BadResponseStatusException(\n val statusCode: HttpStatusCode,\n val response: HttpResponse\n) : IllegalStateException(\"Received bad status code: $statusCode. Expected status code < 300.\")\n\n@Deprecated(\n \"[BadResponseStatus] is deprecated. Use [BadResponseStatusException] instead.\",\n ReplaceWith(\"BadResponseStatusException\"),\n DeprecationLevel.ERROR\n)\ntypealias BadResponseStatus = BadResponseStatusException\n", | |
"package io.ktor.client.features\n\nimport io.ktor.client.*\nimport io.ktor.util.*\n\n\ninternal val FEATURE_INSTALLED_LIST = AttributeKey<Attributes>(\"ApplicationFeatureRegistry\")\n\n/**\n * Base interface representing a [HttpClient] feature.\n */\ninterface HttpClientFeature<out TConfig : Any, TFeature : Any> {\n /**\n * The [AttributeKey] for this feature.\n */\n val key: AttributeKey<TFeature>\n\n /**\n * Builds a [TFeature] by calling the [block] with a [TConfig] config instance as receiver.\n */\n fun prepare(block: TConfig.() -> Unit = {}): TFeature\n\n /**\n * Installs the [feature] class for a [HttpClient] defined at [scope].\n */\n fun install(feature: TFeature, scope: HttpClient)\n}\n\n/**\n * Try to get a [feature] installed in this client. Returns `null` if the feature was not previously installed.\n */\nfun <B : Any, F : Any> HttpClient.feature(feature: HttpClientFeature<B, F>): F? =\n attributes.getOrNull(FEATURE_INSTALLED_LIST)?.getOrNull(feature.key)\n", | |
"package io.ktor.client.features\n\nimport io.ktor.client.*\nimport io.ktor.client.request.*\nimport io.ktor.client.response.*\nimport io.ktor.http.*\nimport io.ktor.http.content.*\nimport io.ktor.util.*\nimport kotlinx.io.charsets.*\nimport kotlinx.io.core.*\n\n/**\n * [HttpClient] feature that encodes [String] request bodies to [TextContent]\n * using a specific charset defined at [HttpPlainText.defaultCharset].\n * And also processes the response body as [String].\n *\n * NOTE: the [HttpPlainText.defaultCharset] is the default one for your JVM so can change between servers!\n * So please, specify one if you want consistent results in all your deployments.\n */\nclass HttpPlainText(var defaultCharset: Charset) {\n\n internal suspend fun read(response: HttpResponse): String = response.use {\n it.readText(charset = defaultCharset)\n }\n\n class Config {\n var defaultCharset: Charset = Charsets.UTF_8\n\n internal fun build(): HttpPlainText = HttpPlainText(defaultCharset)\n }\n\n companion object Feature : HttpClientFeature<Config, HttpPlainText> {\n override val key = AttributeKey<HttpPlainText>(\"HttpPlainText\")\n\n override fun prepare(block: Config.() -> Unit): HttpPlainText = Config().apply(block).build()\n\n override fun install(feature: HttpPlainText, scope: HttpClient) {\n scope.requestPipeline.intercept(HttpRequestPipeline.Render) { content ->\n if (content !is String) return@intercept\n val contentType = ContentType.Text.Plain.withCharset(feature.defaultCharset)\n proceedWith(TextContent(content, contentType))\n }\n\n scope.responsePipeline.intercept(HttpResponsePipeline.Parse) { (info, response) ->\n if (info.type != String::class || response !is HttpResponse) return@intercept\n\n val content = feature.read(response)\n proceedWith(HttpResponseContainer(info, content))\n }\n }\n }\n}\n", | |
"package kotlinx.io.core\n\nimport kotlinx.io.core.internal.*\nimport kotlinx.io.pool.*\n\nexpect val PACKET_MAX_COPY_SIZE: Int\n\n/**\n * Build a byte packet in [block] lambda. Creates a temporary builder and releases it in case of failure\n */\ninline fun buildPacket(headerSizeHint: Int = 0, block: BytePacketBuilder.() -> Unit): ByteReadPacket {\n val builder = BytePacketBuilder(headerSizeHint)\n try {\n block(builder)\n return builder.build()\n } catch (t: Throwable) {\n builder.release()\n throw t\n }\n}\n\nexpect fun BytePacketBuilder(headerSizeHint: Int = 0): BytePacketBuilder\n\n/**\n * A builder that provides ability to build byte packets with no knowledge of it's size.\n * Unlike Java's ByteArrayOutputStream it doesn't copy the whole content every time it's internal buffer overflows\n * but chunks buffers instead. Packet building via [build] function is O(1) operation and only does instantiate\n * a new [ByteReadPacket]. Once a byte packet has been built via [build] function call, the builder could be\n * reused again. You also can discard all written bytes via [reset] or [release]. Please note that an instance of\n * builder need to be terminated either via [build] function invocation or via [release] call otherwise it will\n * cause byte buffer leak so that may have performance impact.\n *\n * Byte packet builder is also an [Appendable] so it does append UTF-8 characters to a packet\n *\n * ```\n * buildPacket {\n * listOf(1,2,3).joinTo(this, separator = \",\")\n * }\n * ```\n */\nclass BytePacketBuilder(private var headerSizeHint: Int, pool: ObjectPool<IoBuffer>) :\n @Suppress(\"DEPRECATION\") BytePacketBuilderPlatformBase(pool) {\n init {\n require(headerSizeHint >= 0) { \"shouldn't be negative: headerSizeHint = $headerSizeHint\" }\n }\n\n /**\n * Number of bytes written to the builder\n */\n val size: Int get() {\n val size = _size\n if (size == -1) {\n _size = head.remainingAll().toInt()\n return _size\n }\n return size\n }\n\n val isEmpty: Boolean get() {\n val _size = _size\n return when {\n _size > 0 -> false\n _size == 0 -> true\n head.canRead() -> false\n size == 0 -> true\n else -> false\n }\n }\n\n val isNotEmpty: Boolean get() {\n val _size = _size\n return when {\n _size > 0 -> true\n _size == 0 -> false\n head.canRead() -> true\n size > 0 -> true\n else -> false\n }\n }\n\n @PublishedApi\n internal var head: IoBuffer = IoBuffer.Empty\n\n override fun append(c: Char): BytePacketBuilder {\n return super.append(c) as BytePacketBuilder\n }\n\n override fun append(csq: CharSequence?): BytePacketBuilder {\n return super.append(csq) as BytePacketBuilder\n }\n\n override fun append(csq: CharSequence?, start: Int, end: Int): BytePacketBuilder {\n return super.append(csq, start, end) as BytePacketBuilder\n }\n\n /**\n * Release any resources that the builder holds. Builder shouldn't be used after release\n */\n override fun release() {\n val head = this.head\n val empty = IoBuffer.Empty\n\n if (head !== empty) {\n this.head = empty\n this.tail = empty\n head.releaseAll(pool)\n _size = 0\n }\n }\n\n override fun flush() {\n }\n\n override fun close() {\n release()\n }\n\n /**\n * Creates a temporary packet view of the packet being build without discarding any bytes from the builder.\n * This is similar to `build().copy()` except that the builder keeps already written bytes untouched.\n * A temporary view packet is passed as argument to [block] function and it shouldn't leak outside of this block\n * otherwise an unexpected behaviour may occur.\n */\n fun <R> preview(block: (tmp: ByteReadPacket) -> R): R {\n val head = head.copyAll()\n val pool = if (head === IoBuffer.Empty) IoBuffer.EmptyPool else pool\n val packet = ByteReadPacket(head, pool)\n\n return try {\n block(packet)\n } finally {\n packet.release()\n }\n }\n\n /**\n * Builds byte packet instance and resets builder's state to be able to build another one packet if needed\n */\n fun build(): ByteReadPacket {\n val size = size\n val head = stealAll()\n\n return when (head) {\n null -> ByteReadPacket.Empty\n else -> ByteReadPacket(head, size.toLong(), pool)\n }\n }\n\n /**\n * Detach all chunks and cleanup all internal state so builder could be reusable again\n * @return a chain of buffer views or `null` of it is empty\n */\n internal fun stealAll(): IoBuffer? {\n val head = this.head\n val empty = IoBuffer.Empty\n\n this.head = empty\n this.tail = empty\n this._size = 0\n\n return if (head === empty) null else head\n }\n\n internal fun afterBytesStolen() {\n val head = head\n check(head.next == null)\n _size = 0\n head.resetForWrite()\n head.reserveStartGap(headerSizeHint)\n head.reserveEndGap(IoBuffer.ReservedSize)\n }\n\n /**\n * Writes another packet to the end. Please note that the instance [p] gets consumed so you don't need to release it\n */\n override fun writePacket(p: ByteReadPacket) {\n val foreignStolen = p.stealAll()\n if (foreignStolen == null) {\n p.release()\n return\n }\n\n val tail = tail\n if (tail === IoBuffer.Empty) {\n head = foreignStolen\n this.tail = foreignStolen.findTail()\n _size = foreignStolen.remainingAll().toInt()\n return\n }\n\n writePacketSlow(tail, foreignStolen, p)\n }\n\n private fun writePacketSlow(tail: IoBuffer, foreignStolen: IoBuffer, p: ByteReadPacket) {\n val lastSize = tail.readRemaining\n val nextSize = foreignStolen.readRemaining\n\n val maxCopySize = PACKET_MAX_COPY_SIZE\n val appendSize = if (nextSize < maxCopySize && nextSize <= (tail.endGap + tail.writeRemaining)) {\n nextSize\n } else -1\n\n val prependSize = if (lastSize < maxCopySize && lastSize <= foreignStolen.startGap && foreignStolen.isExclusivelyOwned()) {\n lastSize\n } else -1\n\n if (appendSize == -1 && prependSize == -1) {\n // simply enqueue\n tail.next = foreignStolen\n this.tail = foreignStolen.findTail()\n _size = head.remainingAll().toInt()\n } else if (prependSize == -1 || appendSize <= prependSize) {\n // do append\n tail.writeBufferAppend(foreignStolen, tail.writeRemaining + tail.endGap)\n tail.next = foreignStolen.next\n this.tail = foreignStolen.findTail().takeUnless { it === foreignStolen } ?: tail\n foreignStolen.release(p.pool)\n _size = head.remainingAll().toInt()\n } else if (appendSize == -1 || prependSize < appendSize) {\n writePacketSlowPrepend(foreignStolen, tail)\n } else {\n throw IllegalStateException(\"prep = $prependSize, app = $appendSize\")\n }\n }\n\n private fun writePacketSlowPrepend(foreignStolen: IoBuffer, tail: IoBuffer) {\n // do prepend\n foreignStolen.writeBufferPrepend(tail)\n\n if (head === tail) {\n head = foreignStolen\n } else {\n var pre = head\n while (true) {\n val next = pre.next!!\n if (next === tail) break\n pre = next\n }\n\n pre.next = foreignStolen\n }\n tail.release(pool)\n\n this.tail = foreignStolen.findTail()\n _size = head.remainingAll().toInt()\n }\n\n override fun last(buffer: IoBuffer) {\n if (head === IoBuffer.Empty) {\n if (buffer.isEmpty()) { // headerSize is just a hint so we shouldn't force to reserve space\n buffer.reserveStartGap(headerSizeHint) // it will always fail for non-empty buffer\n }\n tail = buffer\n head = buffer\n _size = buffer.remainingAll().toInt()\n } else {\n tail.next = buffer\n tail = buffer\n _size = -1\n }\n }\n}\n\n@DangerousInternalIoApi\n@Deprecated(\"Will be removed in future releases.\")\n@Suppress(\"DEPRECATION\")\nexpect abstract class BytePacketBuilderPlatformBase\ninternal constructor(pool: ObjectPool<IoBuffer>) : BytePacketBuilderBase\n\n/**\n * This is the default [Output] implementation\n */\n@ExperimentalIoApi\nabstract class AbstractOutput(pool: ObjectPool<IoBuffer> = IoBuffer.Pool) :\n @Suppress(\"DEPRECATION\") BytePacketBuilderPlatformBase(pool) {\n @Deprecated(\"Will be removed. Override flush(buffer) properly.\")\n protected var currentTail: IoBuffer\n get() = this.tail\n set(newValue) {\n this.tail = newValue\n }\n\n /**\n * An implementation should write the whole [buffer] to the destination. It should never capture the [buffer] instance\n * longer than this method execution since it will be disposed after return.\n * There is no need to follow [buffer]'s next chunk: this function is invoked for every chunk.\n */\n protected abstract fun flush(buffer: IoBuffer)\n\n /**\n * An implementation should only close the destination.\n */\n protected abstract fun closeDestination()\n\n /**\n * Invoked when a new [buffer] is appended for writing (usually it's empty)\n */\n final override fun last(buffer: IoBuffer) {\n var current = tail\n tail = buffer\n\n if (current === IoBuffer.Empty) return\n\n do {\n val next = current.next\n current.next = null\n\n try {\n flush(current)\n } catch (t: Throwable) {\n next?.releaseAll(pool)\n throw t\n } finally {\n current.release(pool)\n }\n\n if (next == null) break\n current = next\n } while (true)\n }\n\n final override fun release() {\n val tail = tail\n this.tail = IoBuffer.Empty\n if (tail !== IoBuffer.Empty) {\n tail.release(pool)\n }\n closeDestination()\n }\n\n final override fun flush() {\n last(IoBuffer.Empty)\n }\n\n /**\n * Should flush and close the destination\n */\n final override fun close() {\n try {\n flush()\n } finally {\n release()\n }\n }\n}\n\n@DangerousInternalIoApi\n@Deprecated(\"Will be removed in future releases\")\n@Suppress(\"DEPRECATION\")\nabstract class BytePacketBuilderBase internal constructor(protected val pool: ObjectPool<IoBuffer>) : Appendable, Output {\n\n /**\n * Number of bytes currently buffered or -1 if not known (need to be recomputed)\n */\n protected var _size: Int = 0\n\n /**\n * Byte order (Endianness) to be used by future write functions calls on this builder instance. Doesn't affect any\n * previously written values. Note that [reset] doesn't change this value back to the default byte order.\n * @default [ByteOrder.BIG_ENDIAN]\n */\n final override var byteOrder: ByteOrder = ByteOrder.BIG_ENDIAN\n set(value) {\n field = value\n val tail = tail\n if (tail.canWrite()) {\n // it is important to not set byte order for IoBuffer.Empty as it will crash on native\n tail.byteOrder = value\n }\n }\n\n @PublishedApi\n internal var tail: IoBuffer = IoBuffer.Empty\n\n final override fun writeFully(src: ByteArray, offset: Int, length: Int) {\n if (length == 0) return\n\n var copied = 0\n\n writeLoop(1, { copied < length }) { buffer, bufferRemaining ->\n val size = minOf(bufferRemaining, length - copied)\n buffer.writeFully(src, offset + copied, size)\n copied += size\n size\n }\n }\n\n final override fun writeLong(v: Long) {\n write(8) { it.writeLong(v); 8 }\n }\n\n final override fun writeInt(v: Int) {\n write(4) { it.writeInt(v); 4 }\n }\n\n final override fun writeShort(v: Short) {\n write(2) { it.writeShort(v); 2 }\n }\n\n final override fun writeByte(v: Byte) {\n write(1) { it.writeByte(v); 1 }\n }\n\n final override fun writeDouble(v: Double) {\n write(8) { it.writeDouble(v); 8 }\n }\n\n final override fun writeFloat(v: Float) {\n write(4) { it.writeFloat(v); 4 }\n }\n\n override fun writeFully(src: ShortArray, offset: Int, length: Int) {\n require(length >= 0) { \"length shouldn't be negative: $length\" }\n require(offset + length < src.lastIndex) { \"offset ($offset) + length ($length) >= src.lastIndex (${src.lastIndex})\" }\n\n if (length == 0) return\n\n var start = offset\n var remaining = length\n\n writeLoop(2, { remaining > 0 }) { buffer, chunkRemaining ->\n val qty = minOf(chunkRemaining shr 1, remaining)\n buffer.writeFully(src, start, qty)\n start += qty\n remaining -= qty\n qty * 2\n }\n }\n\n override fun writeFully(src: IntArray, offset: Int, length: Int) {\n require(length >= 0) { \"length shouldn't be negative: $length\" }\n require(offset + length < src.lastIndex) { \"offset ($offset) + length ($length) >= src.lastIndex (${src.lastIndex})\" }\n\n var start = offset\n var remaining = length\n\n writeLoop(4, { remaining > 0 }) { buffer, chunkRemaining ->\n val qty = minOf(chunkRemaining shr 2, remaining)\n buffer.writeFully(src, start, qty)\n start += qty\n remaining -= qty\n qty * 4\n }\n }\n\n override fun writeFully(src: LongArray, offset: Int, length: Int) {\n require(length >= 0) { \"length shouldn't be negative: $length\" }\n require(offset + length < src.lastIndex) { \"offset ($offset) + length ($length) >= src.lastIndex (${src.lastIndex})\" }\n\n var start = offset\n var remaining = length\n\n writeLoop(8, { remaining > 0 }) { buffer, chunkRemaining ->\n val qty = minOf(chunkRemaining shr 3, remaining)\n buffer.writeFully(src, start, qty)\n start += qty\n remaining -= qty\n qty * 8\n }\n }\n\n override fun writeFully(src: FloatArray, offset: Int, length: Int) {\n require(length >= 0) { \"length shouldn't be negative: $length\" }\n require(offset + length < src.lastIndex) { \"offset ($offset) + length ($length) >= src.lastIndex (${src.lastIndex})\" }\n\n var start = offset\n var remaining = length\n\n writeLoop(4, { remaining > 0 }) { buffer, chunkRemaining ->\n val qty = minOf(chunkRemaining shr 2, remaining)\n buffer.writeFully(src, start, qty)\n start += qty\n remaining -= qty\n qty * 4\n }\n }\n\n override fun writeFully(src: DoubleArray, offset: Int, length: Int) {\n require(length >= 0) { \"length shouldn't be negative: $length\" }\n require(offset + length < src.lastIndex) { \"offset ($offset) + length ($length) >= src.lastIndex (${src.lastIndex})\" }\n\n var start = offset\n var remaining = length\n\n writeLoop(8, { remaining > 0 }) { buffer, chunkRemaining ->\n val qty = minOf(chunkRemaining shr 3, remaining)\n buffer.writeFully(src, start, qty)\n start += qty\n remaining -= qty\n qty * 8\n }\n }\n\n override fun writeFully(src: IoBuffer, length: Int) {\n require(length >= 0) { \"length shouldn't be negative: $length\" }\n require(length <= src.readRemaining) { \"Not enough bytes available in src buffer to read $length bytes\" }\n\n val totalSize = minOf(src.readRemaining, length)\n if (totalSize == 0) return\n var remaining = totalSize\n\n var tail = tail\n if (!tail.canWrite()) {\n tail = appendNewBuffer()\n }\n\n do {\n val size = minOf(tail.writeRemaining, remaining)\n tail.writeFully(src, size)\n remaining -= size\n\n if (remaining == 0) break\n tail = appendNewBuffer()\n } while (true)\n\n addSize(totalSize)\n }\n\n override fun fill(n: Long, v: Byte) {\n require(n >= 0L) { \"n shouldn't be negative: $n\" }\n\n var rem = n\n writeLoop(1, { rem > 0L }) { buffer, chunkRemaining ->\n val size = minOf(chunkRemaining.toLong(), n).toInt()\n buffer.fill(size.toLong(), v)\n rem -= size\n size\n }\n }\n\n /**\n * Append single UTF-8 character\n */\n override fun append(c: Char): BytePacketBuilderBase {\n write(3) {\n it.putUtf8Char(c.toInt())\n }\n return this\n }\n\n override fun append(csq: CharSequence?): BytePacketBuilderBase {\n if (csq == null) {\n appendChars(\"null\", 0, 4)\n } else {\n appendChars(csq, 0, csq.length)\n }\n return this\n }\n\n override fun append(csq: CharSequence?, start: Int, end: Int): BytePacketBuilderBase {\n if (csq == null) {\n return append(\"null\", start, end)\n }\n\n appendChars(csq, start, end)\n\n return this\n }\n\n open fun writePacket(p: ByteReadPacket) {\n while (true) {\n val buffer = p.steal() ?: break\n last(buffer)\n }\n }\n\n /**\n * Write exact [n] bytes from packet to the builder\n */\n fun writePacket(p: ByteReadPacket, n: Int) {\n var remaining = n\n\n while (remaining > 0) {\n val headRemaining = p.headRemaining\n if (headRemaining <= remaining) {\n remaining -= headRemaining\n last(p.steal() ?: throw EOFException(\"Unexpected end of packet\"))\n } else {\n p.read { view ->\n writeFully(view, remaining)\n }\n break\n }\n }\n }\n\n /**\n * Write exact [n] bytes from packet to the builder\n */\n fun writePacket(p: ByteReadPacket, n: Long) {\n var remaining = n\n\n while (remaining > 0L) {\n val headRemaining = p.headRemaining.toLong()\n if (headRemaining <= remaining) {\n remaining -= headRemaining\n last(p.steal() ?: throw EOFException(\"Unexpected end of packet\"))\n } else {\n p.read { view ->\n writeFully(view, remaining.toInt())\n }\n break\n }\n }\n }\n\n override fun append(csq: CharArray, start: Int, end: Int): Appendable {\n appendChars(csq, start, end)\n return this\n }\n\n private fun appendChars(csq: CharSequence, start: Int, end: Int): Int {\n var idx = start\n if (idx >= end) return idx\n val tail = tail\n if (tail.canWrite()) {\n idx = tail.appendChars(csq, idx, end)\n }\n\n while (idx < end) {\n idx = appendNewBuffer().appendChars(csq, idx, end)\n }\n\n this._size = -1\n return idx\n }\n\n private fun appendChars(csq: CharArray, start: Int, end: Int): Int {\n var idx = start\n if (idx >= end) return idx\n val tail = tail\n if (tail.canWrite()) {\n idx = tail.appendChars(csq, idx, end)\n }\n\n while (idx < end) {\n idx = appendNewBuffer().appendChars(csq, idx, end)\n }\n\n this._size = -1\n return idx\n }\n\n fun writeStringUtf8(s: String) {\n append(s, 0, s.length)\n }\n\n fun writeStringUtf8(cs: CharSequence) {\n append(cs, 0, cs.length)\n }\n\n// fun writeStringUtf8(cb: CharBuffer) {\n// append(cb, 0, cb.remaining())\n// }\n\n @Suppress(\"NOTHING_TO_INLINE\")\n private inline fun IoBuffer.putUtf8Char(v: Int) = when {\n v in 1..0x7f -> {\n writeByte(v.toByte())\n 1\n }\n v > 0x7ff -> {\n writeByte((0xe0 or ((v shr 12) and 0x0f)).toByte())\n writeByte((0x80 or ((v shr 6) and 0x3f)).toByte())\n writeByte((0x80 or ( v and 0x3f)).toByte())\n 3\n }\n else -> {\n writeByte((0xc0 or ((v shr 6) and 0x1f)).toByte())\n writeByte((0x80 or ( v and 0x3f)).toByte())\n 2\n }\n }\n\n /**\n * Release any resources that the builder holds. Builder shouldn't be used after release\n */\n abstract fun release()\n\n @DangerousInternalIoApi\n fun prepareWriteHead(n: Int): IoBuffer {\n if (tail.writeRemaining >= n) return tail\n return appendNewBuffer()\n }\n\n @DangerousInternalIoApi\n fun afterHeadWrite() {\n _size = -1\n }\n\n /**\n * Discard all written bytes and prepare to build another packet.\n */\n fun reset() {\n release()\n }\n\n @PublishedApi\n internal inline fun write(size: Int, block: (IoBuffer) -> Int) {\n var buffer = tail\n if (buffer.writeRemaining < size) {\n buffer = appendNewBuffer()\n }\n\n addSize(block(buffer))\n }\n\n private inline fun writeLoop(size: Int, predicate: () -> Boolean, block: (IoBuffer, Int) -> Int) {\n if (!predicate()) return\n var written = 0\n var buffer = tail\n var rem = buffer.writeRemaining\n\n do {\n if (rem < size) {\n buffer = appendNewBuffer()\n rem = buffer.writeRemaining\n }\n\n val result = block(buffer, rem)\n written += result\n rem -= result\n } while (predicate())\n\n addSize(written)\n }\n\n @PublishedApi\n internal fun addSize(n: Int) {\n val size = _size\n if (size != -1) {\n _size = size + n\n }\n }\n\n internal abstract fun last(buffer: IoBuffer)\n\n @PublishedApi\n internal fun appendNewBuffer(): IoBuffer {\n val new = pool.borrow()\n new.reserveEndGap(IoBuffer.ReservedSize)\n new.byteOrder = byteOrder\n\n last(new)\n\n return new\n }\n}\n\nprivate inline fun <T> T.takeUnless(predicate: (T) -> Boolean): T? {\n return if (!predicate(this)) this else null\n}\n\n\n", | |
"package kotlinx.io.core\n\nimport kotlinx.io.core.internal.*\nimport kotlinx.io.pool.*\n\nexpect class ByteReadPacket internal constructor(head: IoBuffer, remaining: Long, pool: ObjectPool<IoBuffer>) :\n ByteReadPacketPlatformBase {\n constructor(head: IoBuffer, pool: ObjectPool<IoBuffer>)\n\n companion object {\n val Empty: ByteReadPacket\n val ReservedSize: Int\n }\n}\n\n@DangerousInternalIoApi\nexpect abstract class ByteReadPacketPlatformBase protected constructor(\n head: IoBuffer,\n remaining: Long,\n pool: ObjectPool<IoBuffer>\n) : ByteReadPacketBase\n\n/**\n * The default abstract base class for implementing [Input] interface.\n * @see [AbstractInput.fill] amd [AbstractInput.closeSource]\n */\n@ExperimentalIoApi\nabstract class AbstractInput(\n head: IoBuffer = IoBuffer.Empty,\n remaining: Long = head.remainingAll(),\n pool: ObjectPool<IoBuffer> = IoBuffer.Pool\n) : ByteReadPacketPlatformBase(head, remaining, pool) {\n /**\n * Reads the next chunk suitable for reading or `null` if no more chunks available. It is also allowed\n * to return a chain of chunks linked through [IoBuffer.next]. The last chunk should have `null` next reference.\n * Could rethrow exceptions from the underlying source.\n */\n abstract override fun fill(): IoBuffer?\n\n /**\n * Should close the underlying bytes source. Could do nothing or throw exceptions.\n */\n abstract override fun closeSource()\n}\n\nexpect fun ByteReadPacket(\n array: ByteArray, offset: Int = 0, length: Int = array.size,\n block: (ByteArray) -> Unit\n): ByteReadPacket\n\n@Suppress(\"NOTHING_TO_INLINE\")\ninline fun ByteReadPacket(array: ByteArray, offset: Int = 0, length: Int = array.size): ByteReadPacket {\n return ByteReadPacket(array, offset, length) {}\n}\n", | |
"package io.ktor.client.features\n\nimport io.ktor.client.*\nimport io.ktor.client.call.*\nimport io.ktor.client.request.*\nimport io.ktor.http.*\nimport io.ktor.http.content.*\nimport io.ktor.util.pipeline.*\nimport io.ktor.util.*\n\n/**\n * [HttpClient] feature that handles http redirect\n */\nclass HttpRedirect {\n\n companion object Feature : HttpClientFeature<Unit, HttpRedirect> {\n override val key: AttributeKey<HttpRedirect> = AttributeKey(\"HttpRedirect\")\n\n override fun prepare(block: Unit.() -> Unit): HttpRedirect = HttpRedirect()\n\n override fun install(feature: HttpRedirect, scope: HttpClient) {\n scope.feature(HttpSend)!!.intercept { origin ->\n handleCall(origin)\n }\n }\n\n private suspend fun Sender.handleCall(origin: HttpClientCall): HttpClientCall {\n if (!origin.response.status.isRedirect()) return origin\n\n var call = origin\n while (true) {\n val location = call.response.headers[HttpHeaders.Location]\n\n call = execute(HttpRequestBuilder().apply {\n takeFrom(origin.request)\n url.parameters.clear()\n\n location?.let { url.takeFrom(it) }\n })\n\n if (!call.response.status.isRedirect()) return call\n }\n }\n }\n}\n\nprivate fun HttpStatusCode.isRedirect(): Boolean = when (value) {\n HttpStatusCode.MovedPermanently.value,\n HttpStatusCode.Found.value,\n HttpStatusCode.TemporaryRedirect.value,\n HttpStatusCode.PermanentRedirect.value -> true\n else -> false\n}\n\n@Deprecated(\n \"Not thrown anymore. Use SendCountExceedException\",\n replaceWith = ReplaceWith(\n \"SendCountExceedException\",\n \"io.ktor.client.features.SendCountExceedException\"\n ),\n level = DeprecationLevel.ERROR\n)\n@Suppress(\"KDocMissingDocumentation\")\nclass RedirectException(val request: HttpRequest, cause: String) : IllegalStateException(cause)\n", | |
"/*\n * Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license\n * that can be found in the license/LICENSE.txt file.\n */\n\n@file:kotlin.jvm.JvmMultifileClass\n@file:kotlin.jvm.JvmName(\"CollectionsKt\")\n\npackage kotlin.collections\n\nimport kotlin.contracts.*\n\ninternal object EmptyIterator : ListIterator<Nothing> {\n override fun hasNext(): Boolean = false\n override fun hasPrevious(): Boolean = false\n override fun nextIndex(): Int = 0\n override fun previousIndex(): Int = -1\n override fun next(): Nothing = throw NoSuchElementException()\n override fun previous(): Nothing = throw NoSuchElementException()\n}\n\ninternal object EmptyList : List<Nothing>, Serializable, RandomAccess {\n private const val serialVersionUID: Long = -7390468764508069838L\n\n override fun equals(other: Any?): Boolean = other is List<*> && other.isEmpty()\n override fun hashCode(): Int = 1\n override fun toString(): String = \"[]\"\n\n override val size: Int get() = 0\n override fun isEmpty(): Boolean = true\n override fun contains(element: Nothing): Boolean = false\n override fun containsAll(elements: Collection<Nothing>): Boolean = elements.isEmpty()\n\n override fun get(index: Int): Nothing = throw IndexOutOfBoundsException(\"Empty list doesn't contain element at index $index.\")\n override fun indexOf(element: Nothing): Int = -1\n override fun lastIndexOf(element: Nothing): Int = -1\n\n override fun iterator(): Iterator<Nothing> = EmptyIterator\n override fun listIterator(): ListIterator<Nothing> = EmptyIterator\n override fun listIterator(index: Int): ListIterator<Nothing> {\n if (index != 0) throw IndexOutOfBoundsException(\"Index: $index\")\n return EmptyIterator\n }\n\n override fun subList(fromIndex: Int, toIndex: Int): List<Nothing> {\n if (fromIndex == 0 && toIndex == 0) return this\n throw IndexOutOfBoundsException(\"fromIndex: $fromIndex, toIndex: $toIndex\")\n }\n\n private fun readResolve(): Any = EmptyList\n}\n\ninternal fun <T> Array<out T>.asCollection(): Collection<T> = ArrayAsCollection(this, isVarargs = false)\n\nprivate class ArrayAsCollection<T>(val values: Array<out T>, val isVarargs: Boolean) : Collection<T> {\n override val size: Int get() = values.size\n override fun isEmpty(): Boolean = values.isEmpty()\n override fun contains(element: T): Boolean = values.contains(element)\n override fun containsAll(elements: Collection<T>): Boolean = elements.all { contains(it) }\n override fun iterator(): Iterator<T> = values.iterator()\n // override hidden toArray implementation to prevent copying of values array\n public fun toArray(): Array<out Any?> = values.copyToArrayOfAny(isVarargs)\n}\n\n/**\n * Returns an empty read-only list. The returned list is serializable (JVM).\n * @sample samples.collections.Collections.Lists.emptyReadOnlyList\n */\npublic fun <T> emptyList(): List<T> = EmptyList\n\n/**\n * Returns a new read-only list of given elements. The returned list is serializable (JVM).\n * @sample samples.collections.Collections.Lists.readOnlyList\n */\npublic fun <T> listOf(vararg elements: T): List<T> = if (elements.size > 0) elements.asList() else emptyList()\n\n/**\n * Returns an empty read-only list. The returned list is serializable (JVM).\n * @sample samples.collections.Collections.Lists.emptyReadOnlyList\n */\[email protected]\npublic inline fun <T> listOf(): List<T> = emptyList()\n\n/**\n * Returns an empty new [MutableList].\n * @sample samples.collections.Collections.Lists.emptyMutableList\n */\n@SinceKotlin(\"1.1\")\[email protected]\npublic inline fun <T> mutableListOf(): MutableList<T> = ArrayList()\n\n/**\n * Returns an empty new [ArrayList].\n * @sample samples.collections.Collections.Lists.emptyArrayList\n */\n@SinceKotlin(\"1.1\")\[email protected]\npublic inline fun <T> arrayListOf(): ArrayList<T> = ArrayList()\n\n/**\n * Returns a new [MutableList] with the given elements.\n * @sample samples.collections.Collections.Lists.mutableList\n */\npublic fun <T> mutableListOf(vararg elements: T): MutableList<T> =\n if (elements.size == 0) ArrayList() else ArrayList(ArrayAsCollection(elements, isVarargs = true))\n\n/**\n * Returns a new [ArrayList] with the given elements.\n * @sample samples.collections.Collections.Lists.arrayList\n */\npublic fun <T> arrayListOf(vararg elements: T): ArrayList<T> =\n if (elements.size == 0) ArrayList() else ArrayList(ArrayAsCollection(elements, isVarargs = true))\n\n/**\n * Returns a new read-only list either of single given element, if it is not null, or empty list if the element is null. The returned list is serializable (JVM).\n * @sample samples.collections.Collections.Lists.listOfNotNull\n */\npublic fun <T : Any> listOfNotNull(element: T?): List<T> = if (element != null) listOf(element) else emptyList()\n\n/**\n * Returns a new read-only list only of those given elements, that are not null. The returned list is serializable (JVM).\n * @sample samples.collections.Collections.Lists.listOfNotNull\n */\npublic fun <T : Any> listOfNotNull(vararg elements: T?): List<T> = elements.filterNotNull()\n\n/**\n * Creates a new read-only list with the specified [size], where each element is calculated by calling the specified\n * [init] function. The [init] function returns a list element given its index.\n * @sample samples.collections.Collections.Lists.readOnlyListFromInitializer\n */\n@SinceKotlin(\"1.1\")\[email protected]\npublic inline fun <T> List(size: Int, init: (index: Int) -> T): List<T> = MutableList(size, init)\n\n/**\n * Creates a new mutable list with the specified [size], where each element is calculated by calling the specified\n * [init] function. The [init] function returns a list element given its index.\n * @sample samples.collections.Collections.Lists.mutableListFromInitializer\n */\n@SinceKotlin(\"1.1\")\[email protected]\npublic inline fun <T> MutableList(size: Int, init: (index: Int) -> T): MutableList<T> {\n val list = ArrayList<T>(size)\n repeat(size) { index -> list.add(init(index)) }\n return list\n}\n\n/**\n * Returns an [IntRange] of the valid indices for this collection.\n * @sample samples.collections.Collections.Collections.indicesOfCollection\n */\npublic val Collection<*>.indices: IntRange\n get() = 0..size - 1\n\n/**\n * Returns the index of the last item in the list or -1 if the list is empty.\n *\n * @sample samples.collections.Collections.Lists.lastIndexOfList\n */\npublic val <T> List<T>.lastIndex: Int\n get() = this.size - 1\n\n/**\n * Returns `true` if the collection is not empty.\n * @sample samples.collections.Collections.Collections.collectionIsNotEmpty\n */\[email protected]\npublic inline fun <T> Collection<T>.isNotEmpty(): Boolean = !isEmpty()\n\n/**\n * Returns `true` if this nullable collection is either null or empty.\n * @sample samples.collections.Collections.Collections.collectionIsNullOrEmpty\n */\n@SinceKotlin(\"1.3\")\[email protected]\npublic inline fun <T> Collection<T>?.isNullOrEmpty(): Boolean {\n contract {\n returns(false) implies (this@isNullOrEmpty != null)\n }\n\n return this == null || this.isEmpty()\n}\n\n/**\n * Returns this Collection if it's not `null` and the empty list otherwise.\n * @sample samples.collections.Collections.Collections.collectionOrEmpty\n */\[email protected]\npublic inline fun <T> Collection<T>?.orEmpty(): Collection<T> = this ?: emptyList()\n\n/**\n * Returns this List if it's not `null` and the empty list otherwise.\n * @sample samples.collections.Collections.Lists.listOrEmpty\n */\[email protected]\npublic inline fun <T> List<T>?.orEmpty(): List<T> = this ?: emptyList()\n\n/**\n * Returns this collection if it's not empty\n * or the result of calling [defaultValue] function if the collection is empty.\n *\n * @sample samples.collections.Collections.Collections.collectionIfEmpty\n */\n@SinceKotlin(\"1.3\")\[email protected]\npublic inline fun <C, R> C.ifEmpty(defaultValue: () -> R): R where C : Collection<*>, C : R =\n if (isEmpty()) defaultValue() else this\n\n\n/**\n * Checks if all elements in the specified collection are contained in this collection.\n *\n * Allows to overcome type-safety restriction of `containsAll` that requires to pass a collection of type `Collection<E>`.\n * @sample samples.collections.Collections.Collections.collectionContainsAll\n */\n@Suppress(\"EXTENSION_SHADOWED_BY_MEMBER\") // false warning, extension takes precedence in some cases\[email protected]\npublic inline fun <@kotlin.internal.OnlyInputTypes T> Collection<T>.containsAll(elements: Collection<T>): Boolean = this.containsAll(elements)\n\ninternal fun <T> List<T>.optimizeReadOnlyList() = when (size) {\n 0 -> emptyList()\n 1 -> listOf(this[0])\n else -> this\n}\n\n/**\n * Searches this list or its range for the provided [element] using the binary search algorithm.\n * The list is expected to be sorted into ascending order according to the Comparable natural ordering of its elements,\n * otherwise the result is undefined.\n *\n * If the list contains multiple elements equal to the specified [element], there is no guarantee which one will be found.\n *\n * `null` value is considered to be less than any non-null value.\n *\n * @return the index of the element, if it is contained in the list within the specified range;\n * otherwise, the inverted insertion point `(-insertion point - 1)`.\n * The insertion point is defined as the index at which the element should be inserted,\n * so that the list (or the specified subrange of list) still remains sorted.\n * @sample samples.collections.Collections.Lists.binarySearchOnComparable\n * @sample samples.collections.Collections.Lists.binarySearchWithBoundaries\n */\npublic fun <T : Comparable<T>> List<T?>.binarySearch(element: T?, fromIndex: Int = 0, toIndex: Int = size): Int {\n rangeCheck(size, fromIndex, toIndex)\n\n var low = fromIndex\n var high = toIndex - 1\n\n while (low <= high) {\n val mid = (low + high).ushr(1) // safe from overflows\n val midVal = get(mid)\n val cmp = compareValues(midVal, element)\n\n if (cmp < 0)\n low = mid + 1\n else if (cmp > 0)\n high = mid - 1\n else\n return mid // key found\n }\n return -(low + 1) // key not found\n}\n\n/**\n * Searches this list or its range for the provided [element] using the binary search algorithm.\n * The list is expected to be sorted into ascending order according to the specified [comparator],\n * otherwise the result is undefined.\n *\n * If the list contains multiple elements equal to the specified [element], there is no guarantee which one will be found.\n *\n * `null` value is considered to be less than any non-null value.\n *\n * @return the index of the element, if it is contained in the list within the specified range;\n * otherwise, the inverted insertion point `(-insertion point - 1)`.\n * The insertion point is defined as the index at which the element should be inserted,\n * so that the list (or the specified subrange of list) still remains sorted according to the specified [comparator].\n * @sample samples.collections.Collections.Lists.binarySearchWithComparator\n */\npublic fun <T> List<T>.binarySearch(element: T, comparator: Comparator<in T>, fromIndex: Int = 0, toIndex: Int = size): Int {\n rangeCheck(size, fromIndex, toIndex)\n\n var low = fromIndex\n var high = toIndex - 1\n\n while (low <= high) {\n val mid = (low + high).ushr(1) // safe from overflows\n val midVal = get(mid)\n val cmp = comparator.compare(midVal, element)\n\n if (cmp < 0)\n low = mid + 1\n else if (cmp > 0)\n high = mid - 1\n else\n return mid // key found\n }\n return -(low + 1) // key not found\n}\n\n/**\n * Searches this list or its range for an element having the key returned by the specified [selector] function\n * equal to the provided [key] value using the binary search algorithm.\n * The list is expected to be sorted into ascending order according to the Comparable natural ordering of keys of its elements.\n * otherwise the result is undefined.\n *\n * If the list contains multiple elements with the specified [key], there is no guarantee which one will be found.\n *\n * `null` value is considered to be less than any non-null value.\n *\n * @return the index of the element with the specified [key], if it is contained in the list within the specified range;\n * otherwise, the inverted insertion point `(-insertion point - 1)`.\n * The insertion point is defined as the index at which the element should be inserted,\n * so that the list (or the specified subrange of list) still remains sorted.\n * @sample samples.collections.Collections.Lists.binarySearchByKey\n */\npublic inline fun <T, K : Comparable<K>> List<T>.binarySearchBy(\n key: K?,\n fromIndex: Int = 0,\n toIndex: Int = size,\n crossinline selector: (T) -> K?\n): Int =\n binarySearch(fromIndex, toIndex) { compareValues(selector(it), key) }\n\n// do not introduce this overload --- too rare\n//public fun <T, K> List<T>.binarySearchBy(key: K, comparator: Comparator<K>, fromIndex: Int = 0, toIndex: Int = size(), selector: (T) -> K): Int =\n// binarySearch(fromIndex, toIndex) { comparator.compare(selector(it), key) }\n\n\n/**\n * Searches this list or its range for an element for which [comparison] function returns zero using the binary search algorithm.\n * The list is expected to be sorted into ascending order according to the provided [comparison],\n * otherwise the result is undefined.\n *\n * If the list contains multiple elements for which [comparison] returns zero, there is no guarantee which one will be found.\n *\n * @param comparison function that compares an element of the list with the element being searched.\n *\n * @return the index of the found element, if it is contained in the list within the specified range;\n * otherwise, the inverted insertion point `(-insertion point - 1)`.\n * The insertion point is defined as the index at which the element should be inserted,\n * so that the list (or the specified subrange of list) still remains sorted.\n * @sample samples.collections.Collections.Lists.binarySearchWithComparisonFunction\n */\npublic fun <T> List<T>.binarySearch(fromIndex: Int = 0, toIndex: Int = size, comparison: (T) -> Int): Int {\n rangeCheck(size, fromIndex, toIndex)\n\n var low = fromIndex\n var high = toIndex - 1\n\n while (low <= high) {\n val mid = (low + high).ushr(1) // safe from overflows\n val midVal = get(mid)\n val cmp = comparison(midVal)\n\n if (cmp < 0)\n low = mid + 1\n else if (cmp > 0)\n high = mid - 1\n else\n return mid // key found\n }\n return -(low + 1) // key not found\n}\n\n/**\n * Checks that `from` and `to` are in\n * the range of [0..size] and throws an appropriate exception, if they aren't.\n */\nprivate fun rangeCheck(size: Int, fromIndex: Int, toIndex: Int) {\n when {\n fromIndex > toIndex -> throw IllegalArgumentException(\"fromIndex ($fromIndex) is greater than toIndex ($toIndex).\")\n fromIndex < 0 -> throw IndexOutOfBoundsException(\"fromIndex ($fromIndex) is less than zero.\")\n toIndex > size -> throw IndexOutOfBoundsException(\"toIndex ($toIndex) is greater than size ($size).\")\n }\n}\n\n\n@PublishedApi\n@SinceKotlin(\"1.3\")\ninternal expect fun checkIndexOverflow(index: Int): Int\n\n@PublishedApi\n@SinceKotlin(\"1.3\")\ninternal expect fun checkCountOverflow(count: Int): Int\n\n\n@PublishedApi\n@SinceKotlin(\"1.3\")\ninternal fun throwIndexOverflow() { throw ArithmeticException(\"Index overflow has happened.\") }\n\n@PublishedApi\n@SinceKotlin(\"1.3\")\ninternal fun throwCountOverflow() { throw ArithmeticException(\"Count overflow has happened.\") }\n\n", | |
"package io.ktor.client.features\n\nimport io.ktor.client.*\nimport io.ktor.client.call.*\nimport io.ktor.client.request.*\nimport io.ktor.http.content.*\nimport io.ktor.util.*\n\n/**\n * HttpSend pipeline interceptor function\n */\ntypealias HttpSendInterceptor = suspend Sender.(HttpClientCall) -> HttpClientCall\n\n/**\n * This interface represents a request send pipeline interceptor chain\n */\n@KtorExperimentalAPI\ninterface Sender {\n /**\n * Execute send pipeline. It could start pipeline execution or replace the call\n */\n suspend fun execute(requestBuilder: HttpRequestBuilder): HttpClientCall\n}\n\n/**\n * This is internal feature that is always installed.\n * @property maxSendCount is a maximum number of requests that can be sent during a call\n */\n@KtorExperimentalAPI\nclass HttpSend(\n var maxSendCount: Int = 20\n) {\n private val interceptors: MutableList<HttpSendInterceptor> = mutableListOf()\n\n /**\n * Install send pipeline starter interceptor\n */\n fun intercept(block: HttpSendInterceptor) {\n interceptors += block\n }\n\n /**\n * Feature installation object\n */\n companion object Feature : HttpClientFeature<HttpSend, HttpSend> {\n override val key: AttributeKey<HttpSend> = AttributeKey(\"HttpSend\")\n\n override fun prepare(block: HttpSend.() -> Unit): HttpSend = HttpSend().apply(block)\n\n override fun install(feature: HttpSend, scope: HttpClient) {\n // default send scenario\n scope.requestPipeline.intercept(HttpRequestPipeline.Send) { content ->\n if (content !is OutgoingContent) return@intercept\n context.body = content\n\n val sender = DefaultSender(feature.maxSendCount, scope)\n\n var currentCall = sender.execute(context)\n var callChanged: Boolean\n\n do {\n callChanged = false\n\n passInterceptors@ for (interceptor in feature.interceptors) {\n val transformed = interceptor(sender, currentCall)\n if (transformed === currentCall) continue@passInterceptors\n\n currentCall = transformed\n callChanged = true\n break@passInterceptors\n }\n } while (callChanged)\n\n proceedWith(currentCall)\n }\n }\n }\n\n private class DefaultSender(private val maxSendCount: Int, private val client: HttpClient) : Sender {\n private var sentCount: Int = 0\n\n override suspend fun execute(requestBuilder: HttpRequestBuilder): HttpClientCall {\n if (sentCount >= maxSendCount) throw SendCountExceedException(\"Max send count $maxSendCount exceeded\")\n sentCount++\n\n return client.sendPipeline.execute(requestBuilder, requestBuilder.body) as HttpClientCall\n }\n }\n}\n\n/**\n * Thrown when too many actual requests were sent during a client call.\n * It could be caused by infinite or too long redirect sequence.\n * Maximum number of requests is limited by [HttpSend.maxSendCount]\n */\nclass SendCountExceedException(message: String) : IllegalStateException(message)\n", | |
"/*\n * Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license\n * that can be found in the license/LICENSE.txt file.\n */\n\n@file:kotlin.jvm.JvmMultifileClass\n@file:kotlin.jvm.JvmName(\"CollectionsKt\")\n\npackage kotlin.collections\n\nimport kotlin.random.Random\n\n/**\n * Removes a single instance of the specified element from this\n * collection, if it is present.\n *\n * Allows to overcome type-safety restriction of `remove` that requires to pass an element of type `E`.\n *\n * @return `true` if the element has been successfully removed; `false` if it was not present in the collection.\n */\[email protected]\npublic inline fun <@kotlin.internal.OnlyInputTypes T> MutableCollection<out T>.remove(element: T): Boolean =\n @Suppress(\"UNCHECKED_CAST\") (this as MutableCollection<T>).remove(element)\n\n/**\n * Removes all of this collection's elements that are also contained in the specified collection.\n\n * Allows to overcome type-safety restriction of `removeAll` that requires to pass a collection of type `Collection<E>`.\n *\n * @return `true` if any of the specified elements was removed from the collection, `false` if the collection was not modified.\n */\[email protected]\npublic inline fun <@kotlin.internal.OnlyInputTypes T> MutableCollection<out T>.removeAll(elements: Collection<T>): Boolean =\n @Suppress(\"UNCHECKED_CAST\") (this as MutableCollection<T>).removeAll(elements)\n\n/**\n * Retains only the elements in this collection that are contained in the specified collection.\n *\n * Allows to overcome type-safety restriction of `retainAll` that requires to pass a collection of type `Collection<E>`.\n *\n * @return `true` if any element was removed from the collection, `false` if the collection was not modified.\n */\[email protected]\npublic inline fun <@kotlin.internal.OnlyInputTypes T> MutableCollection<out T>.retainAll(elements: Collection<T>): Boolean =\n @Suppress(\"UNCHECKED_CAST\") (this as MutableCollection<T>).retainAll(elements)\n\n/**\n * Removes the element at the specified [index] from this list.\n * In Kotlin one should use the [MutableList.removeAt] function instead.\n */\n@Deprecated(\"Use removeAt(index) instead.\", ReplaceWith(\"removeAt(index)\"), level = DeprecationLevel.ERROR)\[email protected]\npublic inline fun <T> MutableList<T>.remove(index: Int): T = removeAt(index)\n\n/**\n * Adds the specified [element] to this mutable collection.\n */\[email protected]\npublic inline operator fun <T> MutableCollection<in T>.plusAssign(element: T) {\n this.add(element)\n}\n\n/**\n * Adds all elements of the given [elements] collection to this mutable collection.\n */\[email protected]\npublic inline operator fun <T> MutableCollection<in T>.plusAssign(elements: Iterable<T>) {\n this.addAll(elements)\n}\n\n/**\n * Adds all elements of the given [elements] array to this mutable collection.\n */\[email protected]\npublic inline operator fun <T> MutableCollection<in T>.plusAssign(elements: Array<T>) {\n this.addAll(elements)\n}\n\n/**\n * Adds all elements of the given [elements] sequence to this mutable collection.\n */\[email protected]\npublic inline operator fun <T> MutableCollection<in T>.plusAssign(elements: Sequence<T>) {\n this.addAll(elements)\n}\n\n/**\n * Removes a single instance of the specified [element] from this mutable collection.\n */\[email protected]\npublic inline operator fun <T> MutableCollection<in T>.minusAssign(element: T) {\n this.remove(element)\n}\n\n/**\n * Removes all elements contained in the given [elements] collection from this mutable collection.\n */\[email protected]\npublic inline operator fun <T> MutableCollection<in T>.minusAssign(elements: Iterable<T>) {\n this.removeAll(elements)\n}\n\n/**\n * Removes all elements contained in the given [elements] array from this mutable collection.\n */\[email protected]\npublic inline operator fun <T> MutableCollection<in T>.minusAssign(elements: Array<T>) {\n this.removeAll(elements)\n}\n\n/**\n * Removes all elements contained in the given [elements] sequence from this mutable collection.\n */\[email protected]\npublic inline operator fun <T> MutableCollection<in T>.minusAssign(elements: Sequence<T>) {\n this.removeAll(elements)\n}\n\n/**\n * Adds all elements of the given [elements] collection to this [MutableCollection].\n */\npublic fun <T> MutableCollection<in T>.addAll(elements: Iterable<T>): Boolean {\n when (elements) {\n is Collection -> return addAll(elements)\n else -> {\n var result: Boolean = false\n for (item in elements)\n if (add(item)) result = true\n return result\n }\n }\n}\n\n/**\n * Adds all elements of the given [elements] sequence to this [MutableCollection].\n */\npublic fun <T> MutableCollection<in T>.addAll(elements: Sequence<T>): Boolean {\n var result: Boolean = false\n for (item in elements) {\n if (add(item)) result = true\n }\n return result\n}\n\n/**\n * Adds all elements of the given [elements] array to this [MutableCollection].\n */\npublic fun <T> MutableCollection<in T>.addAll(elements: Array<out T>): Boolean {\n return addAll(elements.asList())\n}\n\n/**\n * Removes all elements from this [MutableIterable] that match the given [predicate].\n */\npublic fun <T> MutableIterable<T>.removeAll(predicate: (T) -> Boolean): Boolean = filterInPlace(predicate, true)\n\n/**\n * Retains only elements of this [MutableIterable] that match the given [predicate].\n */\npublic fun <T> MutableIterable<T>.retainAll(predicate: (T) -> Boolean): Boolean = filterInPlace(predicate, false)\n\nprivate fun <T> MutableIterable<T>.filterInPlace(predicate: (T) -> Boolean, predicateResultToRemove: Boolean): Boolean {\n var result = false\n with(iterator()) {\n while (hasNext())\n if (predicate(next()) == predicateResultToRemove) {\n remove()\n result = true\n }\n }\n return result\n}\n\n/**\n * Removes all elements from this [MutableList] that match the given [predicate].\n */\npublic fun <T> MutableList<T>.removeAll(predicate: (T) -> Boolean): Boolean = filterInPlace(predicate, true)\n\n/**\n * Retains only elements of this [MutableList] that match the given [predicate].\n */\npublic fun <T> MutableList<T>.retainAll(predicate: (T) -> Boolean): Boolean = filterInPlace(predicate, false)\n\nprivate fun <T> MutableList<T>.filterInPlace(predicate: (T) -> Boolean, predicateResultToRemove: Boolean): Boolean {\n if (this !is RandomAccess)\n return (this as MutableIterable<T>).filterInPlace(predicate, predicateResultToRemove)\n\n var writeIndex: Int = 0\n for (readIndex in 0..lastIndex) {\n val element = this[readIndex]\n if (predicate(element) == predicateResultToRemove)\n continue\n\n if (writeIndex != readIndex)\n this[writeIndex] = element\n\n writeIndex++\n }\n if (writeIndex < size) {\n for (removeIndex in lastIndex downTo writeIndex)\n removeAt(removeIndex)\n\n return true\n } else {\n return false\n }\n}\n\n/**\n * Removes all elements from this [MutableCollection] that are also contained in the given [elements] collection.\n */\npublic fun <T> MutableCollection<in T>.removeAll(elements: Iterable<T>): Boolean {\n return removeAll(elements.convertToSetForSetOperationWith(this))\n}\n\n/**\n * Removes all elements from this [MutableCollection] that are also contained in the given [elements] sequence.\n */\npublic fun <T> MutableCollection<in T>.removeAll(elements: Sequence<T>): Boolean {\n val set = elements.toHashSet()\n return set.isNotEmpty() && removeAll(set)\n}\n\n/**\n * Removes all elements from this [MutableCollection] that are also contained in the given [elements] array.\n */\npublic fun <T> MutableCollection<in T>.removeAll(elements: Array<out T>): Boolean {\n return elements.isNotEmpty() && removeAll(elements.toHashSet())\n}\n\n/**\n * Retains only elements of this [MutableCollection] that are contained in the given [elements] collection.\n */\npublic fun <T> MutableCollection<in T>.retainAll(elements: Iterable<T>): Boolean {\n return retainAll(elements.convertToSetForSetOperationWith(this))\n}\n\n/**\n * Retains only elements of this [MutableCollection] that are contained in the given [elements] array.\n */\npublic fun <T> MutableCollection<in T>.retainAll(elements: Array<out T>): Boolean {\n if (elements.isNotEmpty())\n return retainAll(elements.toHashSet())\n else\n return retainNothing()\n}\n\n/**\n * Retains only elements of this [MutableCollection] that are contained in the given [elements] sequence.\n */\npublic fun <T> MutableCollection<in T>.retainAll(elements: Sequence<T>): Boolean {\n val set = elements.toHashSet()\n if (set.isNotEmpty())\n return retainAll(set)\n else\n return retainNothing()\n}\n\nprivate fun MutableCollection<*>.retainNothing(): Boolean {\n val result = isNotEmpty()\n clear()\n return result\n}\n\n/**\n * Randomly shuffles elements in this mutable list using the specified [random] instance as the source of randomness.\n *\n * See: https://en.wikipedia.org/wiki/Fisher%E2%80%93Yates_shuffle#The_modern_algorithm\n */\n@SinceKotlin(\"1.3\")\npublic fun <T> MutableList<T>.shuffle(random: Random): Unit {\n for (i in lastIndex downTo 1) {\n val j = random.nextInt(i + 1)\n val copy = this[i]\n this[i] = this[j]\n this[j] = copy\n }\n}\n\n/**\n * Returns a new list with the elements of this list randomly shuffled\n * using the specified [random] instance as the source of randomness.\n */\n@SinceKotlin(\"1.3\")\npublic fun <T> Iterable<T>.shuffled(random: Random): List<T> = toMutableList().apply { shuffle(random) }\n\n", | |
"package io.ktor.client.features\n\nimport io.ktor.client.*\nimport io.ktor.client.request.*\nimport io.ktor.http.*\nimport io.ktor.util.*\n\n/**\n * Default user-agent feature for [HttpClient].\n *\n * @property agent: value of user-agent header to set.\n */\nclass UserAgent(val agent: String) {\n\n class Config(var agent: String = \"Ktor http-client\")\n\n companion object Feature : HttpClientFeature<Config, UserAgent> {\n override val key: AttributeKey<UserAgent> = AttributeKey(\"UserAgent\")\n\n override fun prepare(block: Config.() -> Unit): UserAgent = UserAgent(Config().apply(block).agent)\n\n override fun install(feature: UserAgent, scope: HttpClient) {\n scope.requestPipeline.intercept(HttpRequestPipeline.State) {\n context.header(HttpHeaders.UserAgent, feature.agent)\n }\n }\n }\n}\n\n/**\n * Install [UserAgent] feature with browser-like user agent.\n */\nfun HttpClientConfig<*>.BrowserUserAgent() {\n install(UserAgent) {\n agent = \"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/70.0.3538.77 Chrome/70.0.3538.77 Safari/537.36\"\n }\n}\n\n/**\n * Install [UserAgent] feature with browser-like user agent.\n */\nfun HttpClientConfig<*>.CurlUserAgent() {\n install(UserAgent) {\n agent = \"curl/7.61.0\"\n }\n}\n\n", | |
"/*\n * Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license\n * that can be found in the license/LICENSE.txt file.\n */\n@file:Suppress(\"DEPRECATION\", \"DEPRECATION_ERROR\")\npackage kotlin.math\n\n\nimport kotlin.internal.InlineOnly\nimport kotlin.js.Math as nativeMath\n\n\n// region ================ Double Math ========================================\n\n/** Computes the sine of the angle [x] given in radians.\n *\n * Special cases:\n * - `sin(NaN|+Inf|-Inf)` is `NaN`\n */\n@SinceKotlin(\"1.2\")\n@InlineOnly\npublic actual inline fun sin(x: Double): Double = nativeMath.sin(x)\n\n/** Computes the cosine of the angle [x] given in radians.\n *\n * Special cases:\n * - `cos(NaN|+Inf|-Inf)` is `NaN`\n */\n@SinceKotlin(\"1.2\")\n@InlineOnly\npublic actual inline fun cos(x: Double): Double = nativeMath.cos(x)\n\n/** Computes the tangent of the angle [x] given in radians.\n *\n * Special cases:\n * - `tan(NaN|+Inf|-Inf)` is `NaN`\n */\n@SinceKotlin(\"1.2\")\n@InlineOnly\npublic actual inline fun tan(x: Double): Double = nativeMath.tan(x)\n\n/**\n * Computes the arc sine of the value [x];\n * the returned value is an angle in the range from `-PI/2` to `PI/2` radians.\n *\n * Special cases:\n * - `asin(x)` is `NaN`, when `abs(x) > 1` or x is `NaN`\n */\n@SinceKotlin(\"1.2\")\n@InlineOnly\npublic actual inline fun asin(x: Double): Double = nativeMath.asin(x)\n\n/**\n * Computes the arc cosine of the value [x];\n * the returned value is an angle in the range from `0.0` to `PI` radians.\n *\n * Special cases:\n * - `acos(x)` is `NaN`, when `abs(x) > 1` or x is `NaN`\n */\n@SinceKotlin(\"1.2\")\n@InlineOnly\npublic actual inline fun acos(x: Double): Double = nativeMath.acos(x)\n\n/**\n * Computes the arc tangent of the value [x];\n * the returned value is an angle in the range from `-PI/2` to `PI/2` radians.\n *\n * Special cases:\n * - `atan(NaN)` is `NaN`\n */\n@SinceKotlin(\"1.2\")\n@InlineOnly\npublic actual inline fun atan(x: Double): Double = nativeMath.atan(x)\n\n/**\n * Returns the angle `theta` of the polar coordinates `(r, theta)` that correspond\n * to the rectangular coordinates `(x, y)` by computing the arc tangent of the value [y] / [x];\n * the returned value is an angle in the range from `-PI` to `PI` radians.\n *\n * Special cases:\n * - `atan2(0.0, 0.0)` is `0.0`\n * - `atan2(0.0, x)` is `0.0` for `x > 0` and `PI` for `x < 0`\n * - `atan2(-0.0, x)` is `-0.0` for 'x > 0` and `-PI` for `x < 0`\n * - `atan2(y, +Inf)` is `0.0` for `0 < y < +Inf` and `-0.0` for '-Inf < y < 0`\n * - `atan2(y, -Inf)` is `PI` for `0 < y < +Inf` and `-PI` for `-Inf < y < 0`\n * - `atan2(y, 0.0)` is `PI/2` for `y > 0` and `-PI/2` for `y < 0`\n * - `atan2(+Inf, x)` is `PI/2` for finite `x`y\n * - `atan2(-Inf, x)` is `-PI/2` for finite `x`\n * - `atan2(NaN, x)` and `atan2(y, NaN)` is `NaN`\n */\n@SinceKotlin(\"1.2\")\n@InlineOnly\npublic actual inline fun atan2(y: Double, x: Double): Double = nativeMath.atan2(y, x)\n\n/**\n * Computes the hyperbolic sine of the value [x].\n *\n * Special cases:\n * - `sinh(NaN)` is `NaN`\n * - `sinh(+Inf)` is `+Inf`\n * - `sinh(-Inf)` is `-Inf`\n */\n@SinceKotlin(\"1.2\")\n@InlineOnly\npublic actual inline fun sinh(x: Double): Double = nativeMath.sinh(x)\n\n/**\n * Computes the hyperbolic cosine of the value [x].\n *\n * Special cases:\n * - `cosh(NaN)` is `NaN`\n * - `cosh(+Inf|-Inf)` is `+Inf`\n */\n@SinceKotlin(\"1.2\")\n@InlineOnly\npublic actual inline fun cosh(x: Double): Double = nativeMath.cosh(x)\n\n/**\n * Computes the hyperbolic tangent of the value [x].\n *\n * Special cases:\n * - `tanh(NaN)` is `NaN`\n * - `tanh(+Inf)` is `1.0`\n * - `tanh(-Inf)` is `-1.0`\n */\n@SinceKotlin(\"1.2\")\n@InlineOnly\npublic actual inline fun tanh(x: Double): Double = nativeMath.tanh(x)\n\n/**\n * Computes the inverse hyperbolic sine of the value [x].\n *\n * The returned value is `y` such that `sinh(y) == x`.\n *\n * Special cases:\n * - `asinh(NaN)` is `NaN`\n * - `asinh(+Inf)` is `+Inf`\n * - `asinh(-Inf)` is `-Inf`\n */\n@SinceKotlin(\"1.2\")\n@InlineOnly\npublic actual inline fun asinh(x: Double): Double = nativeMath.asinh(x)\n\n/**\n * Computes the inverse hyperbolic cosine of the value [x].\n *\n * The returned value is positive `y` such that `cosh(y) == x`.\n *\n * Special cases:\n * - `acosh(NaN)` is `NaN`\n * - `acosh(x)` is `NaN` when `x < 1`\n * - `acosh(+Inf)` is `+Inf`\n */\n@SinceKotlin(\"1.2\")\n@InlineOnly\npublic actual inline fun acosh(x: Double): Double = nativeMath.acosh(x)\n\n/**\n * Computes the inverse hyperbolic tangent of the value [x].\n *\n * The returned value is `y` such that `tanh(y) == x`.\n *\n * Special cases:\n * - `tanh(NaN)` is `NaN`\n * - `tanh(x)` is `NaN` when `x > 1` or `x < -1`\n * - `tanh(1.0)` is `+Inf`\n * - `tanh(-1.0)` is `-Inf`\n */\n@SinceKotlin(\"1.2\")\n@InlineOnly\npublic actual inline fun atanh(x: Double): Double = nativeMath.atanh(x)\n\n/**\n * Computes `sqrt(x^2 + y^2)` without intermediate overflow or underflow.\n *\n * Special cases:\n * - returns `+Inf` if any of arguments is infinite\n * - returns `NaN` if any of arguments is `NaN` and the other is not infinite\n */\n@SinceKotlin(\"1.2\")\n@InlineOnly\npublic actual inline fun hypot(x: Double, y: Double): Double = nativeMath.hypot(x, y)\n\n/**\n * Computes the positive square root of the value [x].\n *\n * Special cases:\n * - `sqrt(x)` is `NaN` when `x < 0` or `x` is `NaN`\n */\n@SinceKotlin(\"1.2\")\n@InlineOnly\npublic actual inline fun sqrt(x: Double): Double = nativeMath.sqrt(x)\n\n/**\n * Computes Euler's number `e` raised to the power of the value [x].\n *\n * Special cases:\n * - `exp(NaN)` is `NaN`\n * - `exp(+Inf)` is `+Inf`\n * - `exp(-Inf)` is `0.0`\n */\n@SinceKotlin(\"1.2\")\n@InlineOnly\npublic actual inline fun exp(x: Double): Double = nativeMath.exp(x)\n\n/**\n * Computes `exp(x) - 1`.\n *\n * This function can be implemented to produce more precise result for [x] near zero.\n *\n * Special cases:\n * - `expm1(NaN)` is `NaN`\n * - `expm1(+Inf)` is `+Inf`\n * - `expm1(-Inf)` is `-1.0`\n *\n * @see [exp] function.\n */\n@SinceKotlin(\"1.2\")\n@InlineOnly\npublic actual inline fun expm1(x: Double): Double = nativeMath.expm1(x)\n\n/**\n * Computes the logarithm of the value [x] to the given [base].\n *\n * Special cases:\n * - `log(x, b)` is `NaN` if either `x` or `b` are `NaN`\n * - `log(x, b)` is `NaN` when `x < 0` or `b <= 0` or `b == 1.0`\n * - `log(+Inf, +Inf)` is `NaN`\n * - `log(+Inf, b)` is `+Inf` for `b > 1` and `-Inf` for `b < 1`\n * - `log(0.0, b)` is `-Inf` for `b > 1` and `+Inf` for `b > 1`\n *\n * See also logarithm functions for common fixed bases: [ln], [log10] and [log2].\n */\n@SinceKotlin(\"1.2\")\npublic actual fun log(x: Double, base: Double): Double {\n if (base <= 0.0 || base == 1.0) return Double.NaN\n return nativeMath.log(x) / nativeMath.log(base)\n}\n\n/**\n * Computes the natural logarithm (base `E`) of the value [x].\n *\n * Special cases:\n * - `ln(NaN)` is `NaN`\n * - `ln(x)` is `NaN` when `x < 0.0`\n * - `ln(+Inf)` is `+Inf`\n * - `ln(0.0)` is `-Inf`\n */\n@SinceKotlin(\"1.2\")\n@InlineOnly\npublic actual inline fun ln(x: Double): Double = nativeMath.log(x)\n\n/**\n * Computes the common logarithm (base 10) of the value [x].\n *\n * @see [ln] function for special cases.\n */\n@SinceKotlin(\"1.2\")\n@InlineOnly\npublic actual inline fun log10(x: Double): Double = nativeMath.log10(x)\n\n/**\n * Computes the binary logarithm (base 2) of the value [x].\n *\n * @see [ln] function for special cases.\n */\n@SinceKotlin(\"1.2\")\n@InlineOnly\npublic actual inline fun log2(x: Double): Double = nativeMath.log2(x)\n\n/**\n * Computes `ln(x + 1)`.\n *\n * This function can be implemented to produce more precise result for [x] near zero.\n *\n * Special cases:\n * - `ln1p(NaN)` is `NaN`\n * - `ln1p(x)` is `NaN` where `x < -1.0`\n * - `ln1p(-1.0)` is `-Inf`\n * - `ln1p(+Inf)` is `+Inf`\n *\n * @see [ln] function\n * @see [expm1] function\n */\n@SinceKotlin(\"1.2\")\n@InlineOnly\npublic actual inline fun ln1p(x: Double): Double = nativeMath.log1p(x)\n\n/**\n * Rounds the given value [x] to an integer towards positive infinity.\n\n * @return the smallest double value that is greater than the given value [x] and is a mathematical integer.\n *\n * Special cases:\n * - `ceil(x)` is `x` where `x` is `NaN` or `+Inf` or `-Inf` or already a mathematical integer.\n */\n@SinceKotlin(\"1.2\")\n@InlineOnly\npublic actual inline fun ceil(x: Double): Double = nativeMath.ceil(x).unsafeCast<Double>() // TODO: Remove unsafe cast after removing public js.math\n\n/**\n * Rounds the given value [x] to an integer towards negative infinity.\n\n * @return the largest double value that is smaller than the given value [x] and is a mathematical integer.\n *\n * Special cases:\n * - `floor(x)` is `x` where `x` is `NaN` or `+Inf` or `-Inf` or already a mathematical integer.\n */\n@SinceKotlin(\"1.2\")\n@InlineOnly\npublic actual inline fun floor(x: Double): Double = nativeMath.floor(x).unsafeCast<Double>()\n\n/**\n * Rounds the given value [x] to an integer towards zero.\n *\n * @return the value [x] having its fractional part truncated.\n *\n * Special cases:\n * - `truncate(x)` is `x` where `x` is `NaN` or `+Inf` or `-Inf` or already a mathematical integer.\n */\n@SinceKotlin(\"1.2\")\n@InlineOnly\npublic actual inline fun truncate(x: Double): Double = nativeMath.trunc(x)\n\n/**\n * Rounds the given value [x] towards the closest integer with ties rounded towards even integer.\n *\n * Special cases:\n * - `round(x)` is `x` where `x` is `NaN` or `+Inf` or `-Inf` or already a mathematical integer.\n */\n@SinceKotlin(\"1.2\")\npublic actual fun round(x: Double): Double {\n if (x % 0.5 != 0.0) {\n return nativeMath.round(x).unsafeCast<Double>()\n }\n val floor = floor(x)\n return if (floor % 2 == 0.0) floor else ceil(x)\n}\n\n/**\n * Returns the absolute value of the given value [x].\n *\n * Special cases:\n * - `abs(NaN)` is `NaN`\n *\n * @see absoluteValue extension property for [Double]\n */\n@SinceKotlin(\"1.2\")\n@InlineOnly\npublic actual inline fun abs(x: Double): Double = nativeMath.abs(x)\n\n/**\n * Returns the sign of the given value [x]:\n * - `-1.0` if the value is negative,\n * - zero if the value is zero,\n * - `1.0` if the value is positive\n *\n * Special case:\n * - `sign(NaN)` is `NaN`\n */\n@SinceKotlin(\"1.2\")\n@InlineOnly\npublic actual inline fun sign(x: Double): Double = nativeMath.sign(x)\n\n\n/**\n * Returns the smaller of two values.\n *\n * If either value is `NaN`, then the result is `NaN`.\n */\n@SinceKotlin(\"1.2\")\n@InlineOnly\npublic actual inline fun min(a: Double, b: Double): Double = nativeMath.min(a, b)\n\n/**\n * Returns the greater of two values.\n *\n * If either value is `NaN`, then the result is `NaN`.\n */\n@SinceKotlin(\"1.2\")\n@InlineOnly\npublic actual inline fun max(a: Double, b: Double): Double = nativeMath.max(a, b)\n\n// extensions\n\n/**\n * Raises this value to the power [x].\n *\n * Special cases:\n * - `b.pow(0.0)` is `1.0`\n * - `b.pow(1.0) == b`\n * - `b.pow(NaN)` is `NaN`\n * - `NaN.pow(x)` is `NaN` for `x != 0.0`\n * - `b.pow(Inf)` is `NaN` for `abs(b) == 1.0`\n * - `b.pow(x)` is `NaN` for `b < 0` and `x` is finite and not an integer\n */\n@SinceKotlin(\"1.2\")\n@InlineOnly\npublic actual inline fun Double.pow(x: Double): Double = nativeMath.pow(this, x)\n\n/**\n * Raises this value to the integer power [n].\n *\n * See the other overload of [pow] for details.\n */\n@SinceKotlin(\"1.2\")\n@InlineOnly\npublic actual inline fun Double.pow(n: Int): Double = nativeMath.pow(this, n.toDouble())\n\n/**\n * Returns the absolute value of this value.\n *\n * Special cases:\n * - `NaN.absoluteValue` is `NaN`\n *\n * @see abs function\n */\n@SinceKotlin(\"1.2\")\n@InlineOnly\npublic actual inline val Double.absoluteValue: Double get() = nativeMath.abs(this)\n\n/**\n * Returns the sign of this value:\n * - `-1.0` if the value is negative,\n * - zero if the value is zero,\n * - `1.0` if the value is positive\n *\n * Special case:\n * - `NaN.sign` is `NaN`\n */\n@SinceKotlin(\"1.2\")\n@InlineOnly\npublic actual inline val Double.sign: Double get() = nativeMath.sign(this)\n\n/**\n * Returns this value with the sign bit same as of the [sign] value.\n *\n * If [sign] is `NaN` the sign of the result is undefined.\n */\n@SinceKotlin(\"1.2\")\npublic actual fun Double.withSign(sign: Double): Double {\n val thisSignBit = js(\"Kotlin\").doubleSignBit(this).unsafeCast<Int>()\n val newSignBit = js(\"Kotlin\").doubleSignBit(sign).unsafeCast<Int>()\n return if (thisSignBit == newSignBit) this else -this\n}\n\n/**\n * Returns this value with the sign bit same as of the [sign] value.\n */\n@SinceKotlin(\"1.2\")\n@InlineOnly\npublic actual inline fun Double.withSign(sign: Int): Double = this.withSign(sign.toDouble())\n\n/**\n * Returns the ulp (unit in the last place) of this value.\n *\n * An ulp is a positive distance between this value and the next nearest [Double] value larger in magnitude.\n *\n * Special Cases:\n * - `NaN.ulp` is `NaN`\n * - `x.ulp` is `+Inf` when `x` is `+Inf` or `-Inf`\n * - `0.0.ulp` is `Double.MIN_VALUE`\n */\n@SinceKotlin(\"1.2\")\npublic actual val Double.ulp: Double get() = when {\n this < 0 -> (-this).ulp\n this.isNaN() || this == Double.POSITIVE_INFINITY -> this\n this == Double.MAX_VALUE -> this - this.nextDown()\n else -> this.nextUp() - this\n}\n\n/**\n * Returns the [Double] value nearest to this value in direction of positive infinity.\n */\n@SinceKotlin(\"1.2\")\npublic actual fun Double.nextUp(): Double = when {\n this.isNaN() || this == Double.POSITIVE_INFINITY -> this\n this == 0.0 -> Double.MIN_VALUE\n else -> Double.fromBits(this.toRawBits() + if (this > 0) 1 else -1)\n}\n\n/**\n * Returns the [Double] value nearest to this value in direction of negative infinity.\n */\n@SinceKotlin(\"1.2\")\npublic actual fun Double.nextDown(): Double = when {\n this.isNaN() || this == Double.NEGATIVE_INFINITY -> this\n this == 0.0 -> -Double.MIN_VALUE\n else -> Double.fromBits(this.toRawBits() + if (this > 0) -1 else 1)\n}\n\n\n/**\n * Returns the [Double] value nearest to this value in direction from this value towards the value [to].\n *\n * Special cases:\n * - `x.nextTowards(y)` is `NaN` if either `x` or `y` are `NaN`\n * - `x.nextTowards(x) == x`\n *\n */\n@SinceKotlin(\"1.2\")\npublic actual fun Double.nextTowards(to: Double): Double = when {\n this.isNaN() || to.isNaN() -> Double.NaN\n to == this -> to\n to > this -> this.nextUp()\n else /* to < this */ -> this.nextDown()\n}\n\n\n/**\n * Rounds this [Double] value to the nearest integer and converts the result to [Int].\n * Ties are rounded towards positive infinity.\n *\n * Special cases:\n * - `x.roundToInt() == Int.MAX_VALUE` when `x > Int.MAX_VALUE`\n * - `x.roundToInt() == Int.MIN_VALUE` when `x < Int.MIN_VALUE`\n *\n * @throws IllegalArgumentException when this value is `NaN`\n */\n@SinceKotlin(\"1.2\")\npublic actual fun Double.roundToInt(): Int = when {\n isNaN() -> throw IllegalArgumentException(\"Cannot round NaN value.\")\n this > Int.MAX_VALUE -> Int.MAX_VALUE\n this < Int.MIN_VALUE -> Int.MIN_VALUE\n else -> nativeMath.round(this).unsafeCast<Double>().toInt()\n}\n\n/**\n * Rounds this [Double] value to the nearest integer and converts the result to [Long].\n * Ties are rounded towards positive infinity.\n *\n * Special cases:\n * - `x.roundToLong() == Long.MAX_VALUE` when `x > Long.MAX_VALUE`\n * - `x.roundToLong() == Long.MIN_VALUE` when `x < Long.MIN_VALUE`\n *\n * @throws IllegalArgumentException when this value is `NaN`\n */\n@SinceKotlin(\"1.2\")\npublic actual fun Double.roundToLong(): Long = when {\n isNaN() -> throw IllegalArgumentException(\"Cannot round NaN value.\")\n this > Long.MAX_VALUE -> Long.MAX_VALUE\n this < Long.MIN_VALUE -> Long.MIN_VALUE\n else -> nativeMath.round(this).unsafeCast<Double>().toLong()\n}\n\n// endregion\n\n\n\n// region ================ Float Math ========================================\n\n/** Computes the sine of the angle [x] given in radians.\n *\n * Special cases:\n * - `sin(NaN|+Inf|-Inf)` is `NaN`\n */\n@SinceKotlin(\"1.2\")\n@InlineOnly\npublic actual inline fun sin(x: Float): Float = nativeMath.sin(x.toDouble()).toFloat()\n\n/** Computes the cosine of the angle [x] given in radians.\n *\n * Special cases:\n * - `cos(NaN|+Inf|-Inf)` is `NaN`\n */\n@SinceKotlin(\"1.2\")\n@InlineOnly\npublic actual inline fun cos(x: Float): Float = nativeMath.cos(x.toDouble()).toFloat()\n\n/** Computes the tangent of the angle [x] given in radians.\n *\n * Special cases:\n * - `tan(NaN|+Inf|-Inf)` is `NaN`\n */\n@SinceKotlin(\"1.2\")\n@InlineOnly\npublic actual inline fun tan(x: Float): Float = nativeMath.tan(x.toDouble()).toFloat()\n\n/**\n * Computes the arc sine of the value [x];\n * the returned value is an angle in the range from `-PI/2` to `PI/2` radians.\n *\n * Special cases:\n * - `asin(x)` is `NaN`, when `abs(x) > 1` or x is `NaN`\n */\n@SinceKotlin(\"1.2\")\n@InlineOnly\npublic actual inline fun asin(x: Float): Float = nativeMath.asin(x.toDouble()).toFloat()\n\n/**\n * Computes the arc cosine of the value [x];\n * the returned value is an angle in the range from `0.0` to `PI` radians.\n *\n * Special cases:\n * - `acos(x)` is `NaN`, when `abs(x) > 1` or x is `NaN`\n */\n@SinceKotlin(\"1.2\")\n@InlineOnly\npublic actual inline fun acos(x: Float): Float = nativeMath.acos(x.toDouble()).toFloat()\n\n/**\n * Computes the arc tangent of the value [x];\n * the returned value is an angle in the range from `-PI/2` to `PI/2` radians.\n *\n * Special cases:\n * - `atan(NaN)` is `NaN`\n */\n@SinceKotlin(\"1.2\")\n@InlineOnly\npublic actual inline fun atan(x: Float): Float = nativeMath.atan(x.toDouble()).toFloat()\n\n/**\n * Returns the angle `theta` of the polar coordinates `(r, theta)` that correspond\n * to the rectangular coordinates `(x, y)` by computing the arc tangent of the value [y] / [x];\n * the returned value is an angle in the range from `-PI` to `PI` radians.\n *\n * Special cases:\n * - `atan2(0.0, 0.0)` is `0.0`\n * - `atan2(0.0, x)` is `0.0` for `x > 0` and `PI` for `x < 0`\n * - `atan2(-0.0, x)` is `-0.0` for 'x > 0` and `-PI` for `x < 0`\n * - `atan2(y, +Inf)` is `0.0` for `0 < y < +Inf` and `-0.0` for '-Inf < y < 0`\n * - `atan2(y, -Inf)` is `PI` for `0 < y < +Inf` and `-PI` for `-Inf < y < 0`\n * - `atan2(y, 0.0)` is `PI/2` for `y > 0` and `-PI/2` for `y < 0`\n * - `atan2(+Inf, x)` is `PI/2` for finite `x`y\n * - `atan2(-Inf, x)` is `-PI/2` for finite `x`\n * - `atan2(NaN, x)` and `atan2(y, NaN)` is `NaN`\n */\n@SinceKotlin(\"1.2\")\n@InlineOnly\npublic actual inline fun atan2(y: Float, x: Float): Float = nativeMath.atan2(y.toDouble(), x.toDouble()).toFloat()\n\n/**\n * Computes the hyperbolic sine of the value [x].\n *\n * Special cases:\n * - `sinh(NaN)` is `NaN`\n * - `sinh(+Inf)` is `+Inf`\n * - `sinh(-Inf)` is `-Inf`\n */\n@SinceKotlin(\"1.2\")\n@InlineOnly\npublic actual inline fun sinh(x: Float): Float = nativeMath.sinh(x.toDouble()).toFloat()\n\n/**\n * Computes the hyperbolic cosine of the value [x].\n *\n * Special cases:\n * - `cosh(NaN)` is `NaN`\n * - `cosh(+Inf|-Inf)` is `+Inf`\n */\n@SinceKotlin(\"1.2\")\n@InlineOnly\npublic actual inline fun cosh(x: Float): Float = nativeMath.cosh(x.toDouble()).toFloat()\n\n/**\n * Computes the hyperbolic tangent of the value [x].\n *\n * Special cases:\n * - `tanh(NaN)` is `NaN`\n * - `tanh(+Inf)` is `1.0`\n * - `tanh(-Inf)` is `-1.0`\n */\n@SinceKotlin(\"1.2\")\n@InlineOnly\npublic actual inline fun tanh(x: Float): Float = nativeMath.tanh(x.toDouble()).toFloat()\n\n/**\n * Computes the inverse hyperbolic sine of the value [x].\n *\n * The returned value is `y` such that `sinh(y) == x`.\n *\n * Special cases:\n * - `asinh(NaN)` is `NaN`\n * - `asinh(+Inf)` is `+Inf`\n * - `asinh(-Inf)` is `-Inf`\n */\n@SinceKotlin(\"1.2\")\n@InlineOnly\npublic actual inline fun asinh(x: Float): Float = nativeMath.asinh(x.toDouble()).toFloat()\n\n/**\n * Computes the inverse hyperbolic cosine of the value [x].\n *\n * The returned value is positive `y` such that `cosh(y) == x`.\n *\n * Special cases:\n * - `acosh(NaN)` is `NaN`\n * - `acosh(x)` is `NaN` when `x < 1`\n * - `acosh(+Inf)` is `+Inf`\n */\n@SinceKotlin(\"1.2\")\n@InlineOnly\npublic actual inline fun acosh(x: Float): Float = nativeMath.acosh(x.toDouble()).toFloat()\n\n/**\n * Computes the inverse hyperbolic tangent of the value [x].\n *\n * The returned value is `y` such that `tanh(y) == x`.\n *\n * Special cases:\n * - `tanh(NaN)` is `NaN`\n * - `tanh(x)` is `NaN` when `x > 1` or `x < -1`\n * - `tanh(1.0)` is `+Inf`\n * - `tanh(-1.0)` is `-Inf`\n */\n@SinceKotlin(\"1.2\")\n@InlineOnly\npublic actual inline fun atanh(x: Float): Float = nativeMath.atanh(x.toDouble()).toFloat()\n\n/**\n * Computes `sqrt(x^2 + y^2)` without intermediate overflow or underflow.\n *\n * Special cases:\n * - returns `+Inf` if any of arguments is infinite\n * - returns `NaN` if any of arguments is `NaN` and the other is not infinite\n */\n@SinceKotlin(\"1.2\")\n@InlineOnly\npublic actual inline fun hypot(x: Float, y: Float): Float = nativeMath.hypot(x.toDouble(), y.toDouble()).toFloat()\n\n/**\n * Computes the positive square root of the value [x].\n *\n * Special cases:\n * - `sqrt(x)` is `NaN` when `x < 0` or `x` is `NaN`\n */\n@SinceKotlin(\"1.2\")\n@InlineOnly\npublic actual inline fun sqrt(x: Float): Float = nativeMath.sqrt(x.toDouble()).toFloat()\n\n/**\n * Computes Euler's number `e` raised to the power of the value [x].\n *\n * Special cases:\n * - `exp(NaN)` is `NaN`\n * - `exp(+Inf)` is `+Inf`\n * - `exp(-Inf)` is `0.0`\n */\n@SinceKotlin(\"1.2\")\n@InlineOnly\npublic actual inline fun exp(x: Float): Float = nativeMath.exp(x.toDouble()).toFloat()\n\n/**\n * Computes `exp(x) - 1`.\n *\n * This function can be implemented to produce more precise result for [x] near zero.\n *\n * Special cases:\n * - `expm1(NaN)` is `NaN`\n * - `expm1(+Inf)` is `+Inf`\n * - `expm1(-Inf)` is `-1.0`\n *\n * @see [exp] function.\n */\n@SinceKotlin(\"1.2\")\n@InlineOnly\npublic actual inline fun expm1(x: Float): Float = nativeMath.expm1(x.toDouble()).toFloat()\n\n/**\n * Computes the logarithm of the value [x] to the given [base].\n *\n * Special cases:\n * - `log(x, b)` is `NaN` if either `x` or `b` are `NaN`\n * - `log(x, b)` is `NaN` when `x < 0` or `b <= 0` or `b == 1.0`\n * - `log(+Inf, +Inf)` is `NaN`\n * - `log(+Inf, b)` is `+Inf` for `b > 1` and `-Inf` for `b < 1`\n * - `log(0.0, b)` is `-Inf` for `b > 1` and `+Inf` for `b > 1`\n *\n * See also logarithm functions for common fixed bases: [ln], [log10] and [log2].\n */\n@SinceKotlin(\"1.2\")\n@InlineOnly\npublic actual inline fun log(x: Float, base: Float): Float = log(x.toDouble(), base.toDouble()).toFloat()\n\n/**\n * Computes the natural logarithm (base `E`) of the value [x].\n *\n * Special cases:\n * - `ln(NaN)` is `NaN`\n * - `ln(x)` is `NaN` when `x < 0.0`\n * - `ln(+Inf)` is `+Inf`\n * - `ln(0.0)` is `-Inf`\n */\n@SinceKotlin(\"1.2\")\n@InlineOnly\npublic actual inline fun ln(x: Float): Float = nativeMath.log(x.toDouble()).toFloat()\n\n/**\n * Computes the common logarithm (base 10) of the value [x].\n *\n * @see [ln] function for special cases.\n */\n@SinceKotlin(\"1.2\")\n@InlineOnly\npublic actual inline fun log10(x: Float): Float = nativeMath.log10(x.toDouble()).toFloat()\n\n/**\n * Computes the binary logarithm (base 2) of the value [x].\n *\n * @see [ln] function for special cases.\n */\n@SinceKotlin(\"1.2\")\n@InlineOnly\npublic actual inline fun log2(x: Float): Float = nativeMath.log2(x.toDouble()).toFloat()\n\n/**\n * Computes `ln(a + 1)`.\n *\n * This function can be implemented to produce more precise result for [x] near zero.\n *\n * Special cases:\n * - `ln1p(NaN)` is `NaN`\n * - `ln1p(x)` is `NaN` where `x < -1.0`\n * - `ln1p(-1.0)` is `-Inf`\n * - `ln1p(+Inf)` is `+Inf`\n *\n * @see [ln] function\n * @see [expm1] function\n */\n@SinceKotlin(\"1.2\")\n@InlineOnly\npublic actual inline fun ln1p(x: Float): Float = nativeMath.log1p(x.toDouble()).toFloat()\n\n/**\n * Rounds the given value [x] to an integer towards positive infinity.\n\n * @return the smallest Float value that is greater than the given value [x] and is a mathematical integer.\n *\n * Special cases:\n * - `ceil(x)` is `x` where `x` is `NaN` or `+Inf` or `-Inf` or already a mathematical integer.\n */\n@SinceKotlin(\"1.2\")\n@InlineOnly\npublic actual inline fun ceil(x: Float): Float = nativeMath.ceil(x.toDouble()).toFloat()\n\n/**\n * Rounds the given value [x] to an integer towards negative infinity.\n\n * @return the largest Float value that is smaller than the given value [x] and is a mathematical integer.\n *\n * Special cases:\n * - `floor(x)` is `x` where `x` is `NaN` or `+Inf` or `-Inf` or already a mathematical integer.\n */\n@SinceKotlin(\"1.2\")\n@InlineOnly\npublic actual inline fun floor(x: Float): Float = nativeMath.floor(x.toDouble()).toFloat()\n\n/**\n * Rounds the given value [x] to an integer towards zero.\n *\n * @return the value [x] having its fractional part truncated.\n *\n * Special cases:\n * - `truncate(x)` is `x` where `x` is `NaN` or `+Inf` or `-Inf` or already a mathematical integer.\n */\n@SinceKotlin(\"1.2\")\n@InlineOnly\npublic actual inline fun truncate(x: Float): Float = truncate(x.toDouble()).toFloat()\n\n/**\n * Rounds the given value [x] towards the closest integer with ties rounded towards even integer.\n *\n * Special cases:\n * - `round(x)` is `x` where `x` is `NaN` or `+Inf` or `-Inf` or already a mathematical integer.\n */\n@SinceKotlin(\"1.2\")\n@InlineOnly\npublic actual inline fun round(x: Float): Float = round(x.toDouble()).toFloat()\n\n\n/**\n * Returns the absolute value of the given value [x].\n *\n * Special cases:\n * - `abs(NaN)` is `NaN`\n *\n * @see absoluteValue extension property for [Float]\n */\n@SinceKotlin(\"1.2\")\n@InlineOnly\npublic actual inline fun abs(x: Float): Float = nativeMath.abs(x.toDouble()).toFloat()\n\n/**\n * Returns the sign of the given value [x]:\n * - `-1.0` if the value is negative,\n * - zero if the value is zero,\n * - `1.0` if the value is positive\n *\n * Special case:\n * - `sign(NaN)` is `NaN`\n */\n@SinceKotlin(\"1.2\")\n@InlineOnly\npublic actual inline fun sign(x: Float): Float = nativeMath.sign(x.toDouble()).toFloat()\n\n\n\n/**\n * Returns the smaller of two values.\n *\n * If either value is `NaN`, then the result is `NaN`.\n */\n@SinceKotlin(\"1.2\")\n@InlineOnly\npublic actual inline fun min(a: Float, b: Float): Float = nativeMath.min(a, b)\n\n/**\n * Returns the greater of two values.\n *\n * If either value is `NaN`, then the result is `NaN`.\n */\n@SinceKotlin(\"1.2\")\n@InlineOnly\npublic actual inline fun max(a: Float, b: Float): Float = nativeMath.max(a, b)\n\n// extensions\n\n\n/**\n * Raises this value to the power [x].\n *\n * Special cases:\n * - `b.pow(0.0)` is `1.0`\n * - `b.pow(1.0) == b`\n * - `b.pow(NaN)` is `NaN`\n * - `NaN.pow(x)` is `NaN` for `x != 0.0`\n * - `b.pow(Inf)` is `NaN` for `abs(b) == 1.0`\n * - `b.pow(x)` is `NaN` for `b < 0` and `x` is finite and not an integer\n */\n@SinceKotlin(\"1.2\")\n@InlineOnly\npublic actual inline fun Float.pow(x: Float): Float = nativeMath.pow(this.toDouble(), x.toDouble()).toFloat()\n\n/**\n * Raises this value to the integer power [n].\n *\n * See the other overload of [pow] for details.\n */\n@SinceKotlin(\"1.2\")\n@InlineOnly\npublic actual inline fun Float.pow(n: Int): Float = nativeMath.pow(this.toDouble(), n.toDouble()).toFloat()\n\n/**\n * Returns the absolute value of this value.\n *\n * Special cases:\n * - `NaN.absoluteValue` is `NaN`\n *\n * @see abs function\n */\n@SinceKotlin(\"1.2\")\n@InlineOnly\npublic actual inline val Float.absoluteValue: Float get() = nativeMath.abs(this.toDouble()).toFloat()\n\n/**\n * Returns the sign of this value:\n * - `-1.0` if the value is negative,\n * - zero if the value is zero,\n * - `1.0` if the value is positive\n *\n * Special case:\n * - `NaN.sign` is `NaN`\n */\n@SinceKotlin(\"1.2\")\n@InlineOnly\npublic actual inline val Float.sign: Float get() = nativeMath.sign(this.toDouble()).toFloat()\n\n/**\n * Returns this value with the sign bit same as of the [sign] value.\n *\n * If [sign] is `NaN` the sign of the result is undefined.\n */\n@SinceKotlin(\"1.2\")\n@InlineOnly\npublic actual inline fun Float.withSign(sign: Float): Float = this.toDouble().withSign(sign.toDouble()).toFloat()\n\n/**\n * Returns this value with the sign bit same as of the [sign] value.\n */\n@SinceKotlin(\"1.2\")\n@InlineOnly\npublic actual inline fun Float.withSign(sign: Int): Float = this.toDouble().withSign(sign.toDouble()).toFloat()\n\n\n/**\n * Rounds this [Float] value to the nearest integer and converts the result to [Int].\n * Ties are rounded towards positive infinity.\n *\n * Special cases:\n * - `x.roundToInt() == Int.MAX_VALUE` when `x > Int.MAX_VALUE`\n * - `x.roundToInt() == Int.MIN_VALUE` when `x < Int.MIN_VALUE`\n *\n * @throws IllegalArgumentException when this value is `NaN`\n */\n@SinceKotlin(\"1.2\")\n@InlineOnly\npublic actual inline fun Float.roundToInt(): Int = toDouble().roundToInt()\n\n/**\n * Rounds this [Float] value to the nearest integer and converts the result to [Long].\n * Ties are rounded towards positive infinity.\n *\n * Special cases:\n * - `x.roundToLong() == Long.MAX_VALUE` when `x > Long.MAX_VALUE`\n * - `x.roundToLong() == Long.MIN_VALUE` when `x < Long.MIN_VALUE`\n *\n * @throws IllegalArgumentException when this value is `NaN`\n */\n@SinceKotlin(\"1.2\")\n@InlineOnly\npublic actual inline fun Float.roundToLong(): Long = toDouble().roundToLong()\n\n\n// endregion\n\n// region ================ Integer Math ========================================\n\n\n/**\n * Returns the absolute value of the given value [n].\n *\n * Special cases:\n * - `abs(Int.MIN_VALUE)` is `Int.MIN_VALUE` due to an overflow\n *\n * @see absoluteValue extension property for [Int]\n */\n// TODO: remove manual 'or' when KT-19290 is fixed\n@SinceKotlin(\"1.2\")\npublic actual fun abs(n: Int): Int = if (n < 0) (-n or 0) else n\n\n/**\n * Returns the smaller of two values.\n */\n@SinceKotlin(\"1.2\")\n@InlineOnly\npublic actual inline fun min(a: Int, b: Int): Int = nativeMath.min(a, b)\n\n/**\n * Returns the greater of two values.\n */\n@SinceKotlin(\"1.2\")\n@InlineOnly\npublic actual inline fun max(a: Int, b: Int): Int = nativeMath.max(a, b)\n\n/**\n * Returns the absolute value of this value.\n *\n * Special cases:\n * - `Int.MIN_VALUE.absoluteValue` is `Int.MIN_VALUE` due to an overflow\n *\n * @see abs function\n */\n@SinceKotlin(\"1.2\")\n@InlineOnly\npublic actual inline val Int.absoluteValue: Int get() = abs(this)\n\n/**\n * Returns the sign of this value:\n * - `-1` if the value is negative,\n * - `0` if the value is zero,\n * - `1` if the value is positive\n */\n@SinceKotlin(\"1.2\")\npublic actual val Int.sign: Int get() = when {\n this < 0 -> -1\n this > 0 -> 1\n else -> 0\n}\n\n\n\n/**\n * Returns the absolute value of the given value [n].\n *\n * Special cases:\n * - `abs(Long.MIN_VALUE)` is `Long.MIN_VALUE` due to an overflow\n *\n * @see absoluteValue extension property for [Long]\n */\n@SinceKotlin(\"1.2\")\npublic actual fun abs(n: Long): Long = if (n < 0) -n else n\n\n/**\n * Returns the smaller of two values.\n */\n@SinceKotlin(\"1.2\")\n@Suppress(\"NOTHING_TO_INLINE\")\npublic actual inline fun min(a: Long, b: Long): Long = if (a <= b) a else b\n\n/**\n * Returns the greater of two values.\n */\n@SinceKotlin(\"1.2\")\n@Suppress(\"NOTHING_TO_INLINE\")\npublic actual inline fun max(a: Long, b: Long): Long = if (a >= b) a else b\n\n/**\n * Returns the absolute value of this value.\n *\n * Special cases:\n * - `Long.MIN_VALUE.absoluteValue` is `Long.MIN_VALUE` due to an overflow\n *\n * @see abs function\n */\n@SinceKotlin(\"1.2\")\n@InlineOnly\npublic actual inline val Long.absoluteValue: Long get() = abs(this)\n\n/**\n * Returns the sign of this value:\n * - `-1` if the value is negative,\n * - `0` if the value is zero,\n * - `1` if the value is positive\n */\n@SinceKotlin(\"1.2\")\npublic actual val Long.sign: Int get() = when {\n this < 0 -> -1\n this > 0 -> 1\n else -> 0\n}\n\n\n// endregion\n", | |
"/*\n * Copyright 2010-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license \n * that can be found in the license/LICENSE.txt file.\n */\n\n@file:kotlin.jvm.JvmMultifileClass\n@file:kotlin.jvm.JvmName(\"ArraysKt\")\n\npackage kotlin.collections\n\n//\n// NOTE: THIS FILE IS AUTO-GENERATED by the GenerateStandardLib.kt\n// See: https://github.com/JetBrains/kotlin/tree/master/libraries/stdlib\n//\n\nimport kotlin.random.*\n\n/**\n * Returns 1st *element* from the collection.\n */\[email protected]\npublic inline operator fun <T> Array<out T>.component1(): T {\n return get(0)\n}\n\n/**\n * Returns 1st *element* from the collection.\n */\[email protected]\npublic inline operator fun ByteArray.component1(): Byte {\n return get(0)\n}\n\n/**\n * Returns 1st *element* from the collection.\n */\[email protected]\npublic inline operator fun ShortArray.component1(): Short {\n return get(0)\n}\n\n/**\n * Returns 1st *element* from the collection.\n */\[email protected]\npublic inline operator fun IntArray.component1(): Int {\n return get(0)\n}\n\n/**\n * Returns 1st *element* from the collection.\n */\[email protected]\npublic inline operator fun LongArray.component1(): Long {\n return get(0)\n}\n\n/**\n * Returns 1st *element* from the collection.\n */\[email protected]\npublic inline operator fun FloatArray.component1(): Float {\n return get(0)\n}\n\n/**\n * Returns 1st *element* from the collection.\n */\[email protected]\npublic inline operator fun DoubleArray.component1(): Double {\n return get(0)\n}\n\n/**\n * Returns 1st *element* from the collection.\n */\[email protected]\npublic inline operator fun BooleanArray.component1(): Boolean {\n return get(0)\n}\n\n/**\n * Returns 1st *element* from the collection.\n */\[email protected]\npublic inline operator fun CharArray.component1(): Char {\n return get(0)\n}\n\n/**\n * Returns 2nd *element* from the collection.\n */\[email protected]\npublic inline operator fun <T> Array<out T>.component2(): T {\n return get(1)\n}\n\n/**\n * Returns 2nd *element* from the collection.\n */\[email protected]\npublic inline operator fun ByteArray.component2(): Byte {\n return get(1)\n}\n\n/**\n * Returns 2nd *element* from the collection.\n */\[email protected]\npublic inline operator fun ShortArray.component2(): Short {\n return get(1)\n}\n\n/**\n * Returns 2nd *element* from the collection.\n */\[email protected]\npublic inline operator fun IntArray.component2(): Int {\n return get(1)\n}\n\n/**\n * Returns 2nd *element* from the collection.\n */\[email protected]\npublic inline operator fun LongArray.component2(): Long {\n return get(1)\n}\n\n/**\n * Returns 2nd *element* from the collection.\n */\[email protected]\npublic inline operator fun FloatArray.component2(): Float {\n return get(1)\n}\n\n/**\n * Returns 2nd *element* from the collection.\n */\[email protected]\npublic inline operator fun DoubleArray.component2(): Double {\n return get(1)\n}\n\n/**\n * Returns 2nd *element* from the collection.\n */\[email protected]\npublic inline operator fun BooleanArray.component2(): Boolean {\n return get(1)\n}\n\n/**\n * Returns 2nd *element* from the collection.\n */\[email protected]\npublic inline operator fun CharArray.component2(): Char {\n return get(1)\n}\n\n/**\n * Returns 3rd *element* from the collection.\n */\[email protected]\npublic inline operator fun <T> Array<out T>.component3(): T {\n return get(2)\n}\n\n/**\n * Returns 3rd *element* from the collection.\n */\[email protected]\npublic inline operator fun ByteArray.component3(): Byte {\n return get(2)\n}\n\n/**\n * Returns 3rd *element* from the collection.\n */\[email protected]\npublic inline operator fun ShortArray.component3(): Short {\n return get(2)\n}\n\n/**\n * Returns 3rd *element* from the collection.\n */\[email protected]\npublic inline operator fun IntArray.component3(): Int {\n return get(2)\n}\n\n/**\n * Returns 3rd *element* from the collection.\n */\[email protected]\npublic inline operator fun LongArray.component3(): Long {\n return get(2)\n}\n\n/**\n * Returns 3rd *element* from the collection.\n */\[email protected]\npublic inline operator fun FloatArray.component3(): Float {\n return get(2)\n}\n\n/**\n * Returns 3rd *element* from the collection.\n */\[email protected]\npublic inline operator fun DoubleArray.component3(): Double {\n return get(2)\n}\n\n/**\n * Returns 3rd *element* from the collection.\n */\[email protected]\npublic inline operator fun BooleanArray.component3(): Boolean {\n return get(2)\n}\n\n/**\n * Returns 3rd *element* from the collection.\n */\[email protected]\npublic inline operator fun CharArray.component3(): Char {\n return get(2)\n}\n\n/**\n * Returns 4th *element* from the collection.\n */\[email protected]\npublic inline operator fun <T> Array<out T>.component4(): T {\n return get(3)\n}\n\n/**\n * Returns 4th *element* from the collection.\n */\[email protected]\npublic inline operator fun ByteArray.component4(): Byte {\n return get(3)\n}\n\n/**\n * Returns 4th *element* from the collection.\n */\[email protected]\npublic inline operator fun ShortArray.component4(): Short {\n return get(3)\n}\n\n/**\n * Returns 4th *element* from the collection.\n */\[email protected]\npublic inline operator fun IntArray.component4(): Int {\n return get(3)\n}\n\n/**\n * Returns 4th *element* from the collection.\n */\[email protected]\npublic inline operator fun LongArray.component4(): Long {\n return get(3)\n}\n\n/**\n * Returns 4th *element* from the collection.\n */\[email protected]\npublic inline operator fun FloatArray.component4(): Float {\n return get(3)\n}\n\n/**\n * Returns 4th *element* from the collection.\n */\[email protected]\npublic inline operator fun DoubleArray.component4(): Double {\n return get(3)\n}\n\n/**\n * Returns 4th *element* from the collection.\n */\[email protected]\npublic inline operator fun BooleanArray.component4(): Boolean {\n return get(3)\n}\n\n/**\n * Returns 4th *element* from the collection.\n */\[email protected]\npublic inline operator fun CharArray.component4(): Char {\n return get(3)\n}\n\n/**\n * Returns 5th *element* from the collection.\n */\[email protected]\npublic inline operator fun <T> Array<out T>.component5(): T {\n return get(4)\n}\n\n/**\n * Returns 5th *element* from the collection.\n */\[email protected]\npublic inline operator fun ByteArray.component5(): Byte {\n return get(4)\n}\n\n/**\n * Returns 5th *element* from the collection.\n */\[email protected]\npublic inline operator fun ShortArray.component5(): Short {\n return get(4)\n}\n\n/**\n * Returns 5th *element* from the collection.\n */\[email protected]\npublic inline operator fun IntArray.component5(): Int {\n return get(4)\n}\n\n/**\n * Returns 5th *element* from the collection.\n */\[email protected]\npublic inline operator fun LongArray.component5(): Long {\n return get(4)\n}\n\n/**\n * Returns 5th *element* from the collection.\n */\[email protected]\npublic inline operator fun FloatArray.component5(): Float {\n return get(4)\n}\n\n/**\n * Returns 5th *element* from the collection.\n */\[email protected]\npublic inline operator fun DoubleArray.component5(): Double {\n return get(4)\n}\n\n/**\n * Returns 5th *element* from the collection.\n */\[email protected]\npublic inline operator fun BooleanArray.component5(): Boolean {\n return get(4)\n}\n\n/**\n * Returns 5th *element* from the collection.\n */\[email protected]\npublic inline operator fun CharArray.component5(): Char {\n return get(4)\n}\n\n/**\n * Returns `true` if [element] is found in the array.\n */\npublic operator fun <@kotlin.internal.OnlyInputTypes T> Array<out T>.contains(element: T): Boolean {\n return indexOf(element) >= 0\n}\n\n/**\n * Returns `true` if [element] is found in the array.\n */\npublic operator fun ByteArray.contains(element: Byte): Boolean {\n return indexOf(element) >= 0\n}\n\n/**\n * Returns `true` if [element] is found in the array.\n */\npublic operator fun ShortArray.contains(element: Short): Boolean {\n return indexOf(element) >= 0\n}\n\n/**\n * Returns `true` if [element] is found in the array.\n */\npublic operator fun IntArray.contains(element: Int): Boolean {\n return indexOf(element) >= 0\n}\n\n/**\n * Returns `true` if [element] is found in the array.\n */\npublic operator fun LongArray.contains(element: Long): Boolean {\n return indexOf(element) >= 0\n}\n\n/**\n * Returns `true` if [element] is found in the array.\n */\npublic operator fun FloatArray.contains(element: Float): Boolean {\n return indexOf(element) >= 0\n}\n\n/**\n * Returns `true` if [element] is found in the array.\n */\npublic operator fun DoubleArray.contains(element: Double): Boolean {\n return indexOf(element) >= 0\n}\n\n/**\n * Returns `true` if [element] is found in the array.\n */\npublic operator fun BooleanArray.contains(element: Boolean): Boolean {\n return indexOf(element) >= 0\n}\n\n/**\n * Returns `true` if [element] is found in the array.\n */\npublic operator fun CharArray.contains(element: Char): Boolean {\n return indexOf(element) >= 0\n}\n\n/**\n * Returns an element at the given [index] or throws an [IndexOutOfBoundsException] if the [index] is out of bounds of this array.\n * \n * @sample samples.collections.Collections.Elements.elementAt\n */\[email protected]\npublic inline fun <T> Array<out T>.elementAt(index: Int): T {\n return get(index)\n}\n\n/**\n * Returns an element at the given [index] or throws an [IndexOutOfBoundsException] if the [index] is out of bounds of this array.\n * \n * @sample samples.collections.Collections.Elements.elementAt\n */\[email protected]\npublic inline fun ByteArray.elementAt(index: Int): Byte {\n return get(index)\n}\n\n/**\n * Returns an element at the given [index] or throws an [IndexOutOfBoundsException] if the [index] is out of bounds of this array.\n * \n * @sample samples.collections.Collections.Elements.elementAt\n */\[email protected]\npublic inline fun ShortArray.elementAt(index: Int): Short {\n return get(index)\n}\n\n/**\n * Returns an element at the given [index] or throws an [IndexOutOfBoundsException] if the [index] is out of bounds of this array.\n * \n * @sample samples.collections.Collections.Elements.elementAt\n */\[email protected]\npublic inline fun IntArray.elementAt(index: Int): Int {\n return get(index)\n}\n\n/**\n * Returns an element at the given [index] or throws an [IndexOutOfBoundsException] if the [index] is out of bounds of this array.\n * \n * @sample samples.collections.Collections.Elements.elementAt\n */\[email protected]\npublic inline fun LongArray.elementAt(index: Int): Long {\n return get(index)\n}\n\n/**\n * Returns an element at the given [index] or throws an [IndexOutOfBoundsException] if the [index] is out of bounds of this array.\n * \n * @sample samples.collections.Collections.Elements.elementAt\n */\[email protected]\npublic inline fun FloatArray.elementAt(index: Int): Float {\n return get(index)\n}\n\n/**\n * Returns an element at the given [index] or throws an [IndexOutOfBoundsException] if the [index] is out of bounds of this array.\n * \n * @sample samples.collections.Collections.Elements.elementAt\n */\[email protected]\npublic inline fun DoubleArray.elementAt(index: Int): Double {\n return get(index)\n}\n\n/**\n * Returns an element at the given [index] or throws an [IndexOutOfBoundsException] if the [index] is out of bounds of this array.\n * \n * @sample samples.collections.Collections.Elements.elementAt\n */\[email protected]\npublic inline fun BooleanArray.elementAt(index: Int): Boolean {\n return get(index)\n}\n\n/**\n * Returns an element at the given [index] or throws an [IndexOutOfBoundsException] if the [index] is out of bounds of this array.\n * \n * @sample samples.collections.Collections.Elements.elementAt\n */\[email protected]\npublic inline fun CharArray.elementAt(index: Int): Char {\n return get(index)\n}\n\n/**\n * Returns an element at the given [index] or the result of calling the [defaultValue] function if the [index] is out of bounds of this array.\n * \n * @sample samples.collections.Collections.Elements.elementAtOrElse\n */\[email protected]\npublic inline fun <T> Array<out T>.elementAtOrElse(index: Int, defaultValue: (Int) -> T): T {\n return if (index >= 0 && index <= lastIndex) get(index) else defaultValue(index)\n}\n\n/**\n * Returns an element at the given [index] or the result of calling the [defaultValue] function if the [index] is out of bounds of this array.\n * \n * @sample samples.collections.Collections.Elements.elementAtOrElse\n */\[email protected]\npublic inline fun ByteArray.elementAtOrElse(index: Int, defaultValue: (Int) -> Byte): Byte {\n return if (index >= 0 && index <= lastIndex) get(index) else defaultValue(index)\n}\n\n/**\n * Returns an element at the given [index] or the result of calling the [defaultValue] function if the [index] is out of bounds of this array.\n * \n * @sample samples.collections.Collections.Elements.elementAtOrElse\n */\[email protected]\npublic inline fun ShortArray.elementAtOrElse(index: Int, defaultValue: (Int) -> Short): Short {\n return if (index >= 0 && index <= lastIndex) get(index) else defaultValue(index)\n}\n\n/**\n * Returns an element at the given [index] or the result of calling the [defaultValue] function if the [index] is out of bounds of this array.\n * \n * @sample samples.collections.Collections.Elements.elementAtOrElse\n */\[email protected]\npublic inline fun IntArray.elementAtOrElse(index: Int, defaultValue: (Int) -> Int): Int {\n return if (index >= 0 && index <= lastIndex) get(index) else defaultValue(index)\n}\n\n/**\n * Returns an element at the given [index] or the result of calling the [defaultValue] function if the [index] is out of bounds of this array.\n * \n * @sample samples.collections.Collections.Elements.elementAtOrElse\n */\[email protected]\npublic inline fun LongArray.elementAtOrElse(index: Int, defaultValue: (Int) -> Long): Long {\n return if (index >= 0 && index <= lastIndex) get(index) else defaultValue(index)\n}\n\n/**\n * Returns an element at the given [index] or the result of calling the [defaultValue] function if the [index] is out of bounds of this array.\n * \n * @sample samples.collections.Collections.Elements.elementAtOrElse\n */\[email protected]\npublic inline fun FloatArray.elementAtOrElse(index: Int, defaultValue: (Int) -> Float): Float {\n return if (index >= 0 && index <= lastIndex) get(index) else defaultValue(index)\n}\n\n/**\n * Returns an element at the given [index] or the result of calling the [defaultValue] function if the [index] is out of bounds of this array.\n * \n * @sample samples.collections.Collections.Elements.elementAtOrElse\n */\[email protected]\npublic inline fun DoubleArray.elementAtOrElse(index: Int, defaultValue: (Int) -> Double): Double {\n return if (index >= 0 && index <= lastIndex) get(index) else defaultValue(index)\n}\n\n/**\n * Returns an element at the given [index] or the result of calling the [defaultValue] function if the [index] is out of bounds of this array.\n * \n * @sample samples.collections.Collections.Elements.elementAtOrElse\n */\[email protected]\npublic inline fun BooleanArray.elementAtOrElse(index: Int, defaultValue: (Int) -> Boolean): Boolean {\n return if (index >= 0 && index <= lastIndex) get(index) else defaultValue(index)\n}\n\n/**\n * Returns an element at the given [index] or the result of calling the [defaultValue] function if the [index] is out of bounds of this array.\n * \n * @sample samples.collections.Collections.Elements.elementAtOrElse\n */\[email protected]\npublic inline fun CharArray.elementAtOrElse(index: Int, defaultValue: (Int) -> Char): Char {\n return if (index >= 0 && index <= lastIndex) get(index) else defaultValue(index)\n}\n\n/**\n * Returns an element at the given [index] or `null` if the [index] is out of bounds of this array.\n * \n * @sample samples.collections.Collections.Elements.elementAtOrNull\n */\[email protected]\npublic inline fun <T> Array<out T>.elementAtOrNull(index: Int): T? {\n return this.getOrNull(index)\n}\n\n/**\n * Returns an element at the given [index] or `null` if the [index] is out of bounds of this array.\n * \n * @sample samples.collections.Collections.Elements.elementAtOrNull\n */\[email protected]\npublic inline fun ByteArray.elementAtOrNull(index: Int): Byte? {\n return this.getOrNull(index)\n}\n\n/**\n * Returns an element at the given [index] or `null` if the [index] is out of bounds of this array.\n * \n * @sample samples.collections.Collections.Elements.elementAtOrNull\n */\[email protected]\npublic inline fun ShortArray.elementAtOrNull(index: Int): Short? {\n return this.getOrNull(index)\n}\n\n/**\n * Returns an element at the given [index] or `null` if the [index] is out of bounds of this array.\n * \n * @sample samples.collections.Collections.Elements.elementAtOrNull\n */\[email protected]\npublic inline fun IntArray.elementAtOrNull(index: Int): Int? {\n return this.getOrNull(index)\n}\n\n/**\n * Returns an element at the given [index] or `null` if the [index] is out of bounds of this array.\n * \n * @sample samples.collections.Collections.Elements.elementAtOrNull\n */\[email protected]\npublic inline fun LongArray.elementAtOrNull(index: Int): Long? {\n return this.getOrNull(index)\n}\n\n/**\n * Returns an element at the given [index] or `null` if the [index] is out of bounds of this array.\n * \n * @sample samples.collections.Collections.Elements.elementAtOrNull\n */\[email protected]\npublic inline fun FloatArray.elementAtOrNull(index: Int): Float? {\n return this.getOrNull(index)\n}\n\n/**\n * Returns an element at the given [index] or `null` if the [index] is out of bounds of this array.\n * \n * @sample samples.collections.Collections.Elements.elementAtOrNull\n */\[email protected]\npublic inline fun DoubleArray.elementAtOrNull(index: Int): Double? {\n return this.getOrNull(index)\n}\n\n/**\n * Returns an element at the given [index] or `null` if the [index] is out of bounds of this array.\n * \n * @sample samples.collections.Collections.Elements.elementAtOrNull\n */\[email protected]\npublic inline fun BooleanArray.elementAtOrNull(index: Int): Boolean? {\n return this.getOrNull(index)\n}\n\n/**\n * Returns an element at the given [index] or `null` if the [index] is out of bounds of this array.\n * \n * @sample samples.collections.Collections.Elements.elementAtOrNull\n */\[email protected]\npublic inline fun CharArray.elementAtOrNull(index: Int): Char? {\n return this.getOrNull(index)\n}\n\n/**\n * Returns the first element matching the given [predicate], or `null` if no such element was found.\n */\[email protected]\npublic inline fun <T> Array<out T>.find(predicate: (T) -> Boolean): T? {\n return firstOrNull(predicate)\n}\n\n/**\n * Returns the first element matching the given [predicate], or `null` if no such element was found.\n */\[email protected]\npublic inline fun ByteArray.find(predicate: (Byte) -> Boolean): Byte? {\n return firstOrNull(predicate)\n}\n\n/**\n * Returns the first element matching the given [predicate], or `null` if no such element was found.\n */\[email protected]\npublic inline fun ShortArray.find(predicate: (Short) -> Boolean): Short? {\n return firstOrNull(predicate)\n}\n\n/**\n * Returns the first element matching the given [predicate], or `null` if no such element was found.\n */\[email protected]\npublic inline fun IntArray.find(predicate: (Int) -> Boolean): Int? {\n return firstOrNull(predicate)\n}\n\n/**\n * Returns the first element matching the given [predicate], or `null` if no such element was found.\n */\[email protected]\npublic inline fun LongArray.find(predicate: (Long) -> Boolean): Long? {\n return firstOrNull(predicate)\n}\n\n/**\n * Returns the first element matching the given [predicate], or `null` if no such element was found.\n */\[email protected]\npublic inline fun FloatArray.find(predicate: (Float) -> Boolean): Float? {\n return firstOrNull(predicate)\n}\n\n/**\n * Returns the first element matching the given [predicate], or `null` if no such element was found.\n */\[email protected]\npublic inline fun DoubleArray.find(predicate: (Double) -> Boolean): Double? {\n return firstOrNull(predicate)\n}\n\n/**\n * Returns the first element matching the given [predicate], or `null` if no such element was found.\n */\[email protected]\npublic inline fun BooleanArray.find(predicate: (Boolean) -> Boolean): Boolean? {\n return firstOrNull(predicate)\n}\n\n/**\n * Returns the first element matching the given [predicate], or `null` if no such element was found.\n */\[email protected]\npublic inline fun CharArray.find(predicate: (Char) -> Boolean): Char? {\n return firstOrNull(predicate)\n}\n\n/**\n * Returns the last element matching the given [predicate], or `null` if no such element was found.\n */\[email protected]\npublic inline fun <T> Array<out T>.findLast(predicate: (T) -> Boolean): T? {\n return lastOrNull(predicate)\n}\n\n/**\n * Returns the last element matching the given [predicate], or `null` if no such element was found.\n */\[email protected]\npublic inline fun ByteArray.findLast(predicate: (Byte) -> Boolean): Byte? {\n return lastOrNull(predicate)\n}\n\n/**\n * Returns the last element matching the given [predicate], or `null` if no such element was found.\n */\[email protected]\npublic inline fun ShortArray.findLast(predicate: (Short) -> Boolean): Short? {\n return lastOrNull(predicate)\n}\n\n/**\n * Returns the last element matching the given [predicate], or `null` if no such element was found.\n */\[email protected]\npublic inline fun IntArray.findLast(predicate: (Int) -> Boolean): Int? {\n return lastOrNull(predicate)\n}\n\n/**\n * Returns the last element matching the given [predicate], or `null` if no such element was found.\n */\[email protected]\npublic inline fun LongArray.findLast(predicate: (Long) -> Boolean): Long? {\n return lastOrNull(predicate)\n}\n\n/**\n * Returns the last element matching the given [predicate], or `null` if no such element was found.\n */\[email protected]\npublic inline fun FloatArray.findLast(predicate: (Float) -> Boolean): Float? {\n return lastOrNull(predicate)\n}\n\n/**\n * Returns the last element matching the given [predicate], or `null` if no such element was found.\n */\[email protected]\npublic inline fun DoubleArray.findLast(predicate: (Double) -> Boolean): Double? {\n return lastOrNull(predicate)\n}\n\n/**\n * Returns the last element matching the given [predicate], or `null` if no such element was found.\n */\[email protected]\npublic inline fun BooleanArray.findLast(predicate: (Boolean) -> Boolean): Boolean? {\n return lastOrNull(predicate)\n}\n\n/**\n * Returns the last element matching the given [predicate], or `null` if no such element was found.\n */\[email protected]\npublic inline fun CharArray.findLast(predicate: (Char) -> Boolean): Char? {\n return lastOrNull(predicate)\n}\n\n/**\n * Returns first element.\n * @throws [NoSuchElementException] if the array is empty.\n */\npublic fun <T> Array<out T>.first(): T {\n if (isEmpty())\n throw NoSuchElementException(\"Array is empty.\")\n return this[0]\n}\n\n/**\n * Returns first element.\n * @throws [NoSuchElementException] if the array is empty.\n */\npublic fun ByteArray.first(): Byte {\n if (isEmpty())\n throw NoSuchElementException(\"Array is empty.\")\n return this[0]\n}\n\n/**\n * Returns first element.\n * @throws [NoSuchElementException] if the array is empty.\n */\npublic fun ShortArray.first(): Short {\n if (isEmpty())\n throw NoSuchElementException(\"Array is empty.\")\n return this[0]\n}\n\n/**\n * Returns first element.\n * @throws [NoSuchElementException] if the array is empty.\n */\npublic fun IntArray.first(): Int {\n if (isEmpty())\n throw NoSuchElementException(\"Array is empty.\")\n return this[0]\n}\n\n/**\n * Returns first element.\n * @throws [NoSuchElementException] if the array is empty.\n */\npublic fun LongArray.first(): Long {\n if (isEmpty())\n throw NoSuchElementException(\"Array is empty.\")\n return this[0]\n}\n\n/**\n * Returns first element.\n * @throws [NoSuchElementException] if the array is empty.\n */\npublic fun FloatArray.first(): Float {\n if (isEmpty())\n throw NoSuchElementException(\"Array is empty.\")\n return this[0]\n}\n\n/**\n * Returns first element.\n * @throws [NoSuchElementException] if the array is empty.\n */\npublic fun DoubleArray.first(): Double {\n if (isEmpty())\n throw NoSuchElementException(\"Array is empty.\")\n return this[0]\n}\n\n/**\n * Returns first element.\n * @throws [NoSuchElementException] if the array is empty.\n */\npublic fun BooleanArray.first(): Boolean {\n if (isEmpty())\n throw NoSuchElementException(\"Array is empty.\")\n return this[0]\n}\n\n/**\n * Returns first element.\n * @throws [NoSuchElementException] if the array is empty.\n */\npublic fun CharArray.first(): Char {\n if (isEmpty())\n throw NoSuchElementException(\"Array is empty.\")\n return this[0]\n}\n\n/**\n * Returns the first element matching the given [predicate].\n * @throws [NoSuchElementException] if no such element is found.\n */\npublic inline fun <T> Array<out T>.first(predicate: (T) -> Boolean): T {\n for (element in this) if (predicate(element)) return element\n throw NoSuchElementException(\"Array contains no element matching the predicate.\")\n}\n\n/**\n * Returns the first element matching the given [predicate].\n * @throws [NoSuchElementException] if no such element is found.\n */\npublic inline fun ByteArray.first(predicate: (Byte) -> Boolean): Byte {\n for (element in this) if (predicate(element)) return element\n throw NoSuchElementException(\"Array contains no element matching the predicate.\")\n}\n\n/**\n * Returns the first element matching the given [predicate].\n * @throws [NoSuchElementException] if no such element is found.\n */\npublic inline fun ShortArray.first(predicate: (Short) -> Boolean): Short {\n for (element in this) if (predicate(element)) return element\n throw NoSuchElementException(\"Array contains no element matching the predicate.\")\n}\n\n/**\n * Returns the first element matching the given [predicate].\n * @throws [NoSuchElementException] if no such element is found.\n */\npublic inline fun IntArray.first(predicate: (Int) -> Boolean): Int {\n for (element in this) if (predicate(element)) return element\n throw NoSuchElementException(\"Array contains no element matching the predicate.\")\n}\n\n/**\n * Returns the first element matching the given [predicate].\n * @throws [NoSuchElementException] if no such element is found.\n */\npublic inline fun LongArray.first(predicate: (Long) -> Boolean): Long {\n for (element in this) if (predicate(element)) return element\n throw NoSuchElementException(\"Array contains no element matching the predicate.\")\n}\n\n/**\n * Returns the first element matching the given [predicate].\n * @throws [NoSuchElementException] if no such element is found.\n */\npublic inline fun FloatArray.first(predicate: (Float) -> Boolean): Float {\n for (element in this) if (predicate(element)) return element\n throw NoSuchElementException(\"Array contains no element matching the predicate.\")\n}\n\n/**\n * Returns the first element matching the given [predicate].\n * @throws [NoSuchElementException] if no such element is found.\n */\npublic inline fun DoubleArray.first(predicate: (Double) -> Boolean): Double {\n for (element in this) if (predicate(element)) return element\n throw NoSuchElementException(\"Array contains no element matching the predicate.\")\n}\n\n/**\n * Returns the first element matching the given [predicate].\n * @throws [NoSuchElementException] if no such element is found.\n */\npublic inline fun BooleanArray.first(predicate: (Boolean) -> Boolean): Boolean {\n for (element in this) if (predicate(element)) return element\n throw NoSuchElementException(\"Array contains no element matching the predicate.\")\n}\n\n/**\n * Returns the first element matching the given [predicate].\n * @throws [NoSuchElementException] if no such element is found.\n */\npublic inline fun CharArray.first(predicate: (Char) -> Boolean): Char {\n for (element in this) if (predicate(element)) return element\n throw NoSuchElementException(\"Array contains no element matching the predicate.\")\n}\n\n/**\n * Returns the first element, or `null` if the array is empty.\n */\npublic fun <T> Array<out T>.firstOrNull(): T? {\n return if (isEmpty()) null else this[0]\n}\n\n/**\n * Returns the first element, or `null` if the array is empty.\n */\npublic fun ByteArray.firstOrNull(): Byte? {\n return if (isEmpty()) null else this[0]\n}\n\n/**\n * Returns the first element, or `null` if the array is empty.\n */\npublic fun ShortArray.firstOrNull(): Short? {\n return if (isEmpty()) null else this[0]\n}\n\n/**\n * Returns the first element, or `null` if the array is empty.\n */\npublic fun IntArray.firstOrNull(): Int? {\n return if (isEmpty()) null else this[0]\n}\n\n/**\n * Returns the first element, or `null` if the array is empty.\n */\npublic fun LongArray.firstOrNull(): Long? {\n return if (isEmpty()) null else this[0]\n}\n\n/**\n * Returns the first element, or `null` if the array is empty.\n */\npublic fun FloatArray.firstOrNull(): Float? {\n return if (isEmpty()) null else this[0]\n}\n\n/**\n * Returns the first element, or `null` if the array is empty.\n */\npublic fun DoubleArray.firstOrNull(): Double? {\n return if (isEmpty()) null else this[0]\n}\n\n/**\n * Returns the first element, or `null` if the array is empty.\n */\npublic fun BooleanArray.firstOrNull(): Boolean? {\n return if (isEmpty()) null else this[0]\n}\n\n/**\n * Returns the first element, or `null` if the array is empty.\n */\npublic fun CharArray.firstOrNull(): Char? {\n return if (isEmpty()) null else this[0]\n}\n\n/**\n * Returns the first element matching the given [predicate], or `null` if element was not found.\n */\npublic inline fun <T> Array<out T>.firstOrNull(predicate: (T) -> Boolean): T? {\n for (element in this) if (predicate(element)) return element\n return null\n}\n\n/**\n * Returns the first element matching the given [predicate], or `null` if element was not found.\n */\npublic inline fun ByteArray.firstOrNull(predicate: (Byte) -> Boolean): Byte? {\n for (element in this) if (predicate(element)) return element\n return null\n}\n\n/**\n * Returns the first element matching the given [predicate], or `null` if element was not found.\n */\npublic inline fun ShortArray.firstOrNull(predicate: (Short) -> Boolean): Short? {\n for (element in this) if (predicate(element)) return element\n return null\n}\n\n/**\n * Returns the first element matching the given [predicate], or `null` if element was not found.\n */\npublic inline fun IntArray.firstOrNull(predicate: (Int) -> Boolean): Int? {\n for (element in this) if (predicate(element)) return element\n return null\n}\n\n/**\n * Returns the first element matching the given [predicate], or `null` if element was not found.\n */\npublic inline fun LongArray.firstOrNull(predicate: (Long) -> Boolean): Long? {\n for (element in this) if (predicate(element)) return element\n return null\n}\n\n/**\n * Returns the first element matching the given [predicate], or `null` if element was not found.\n */\npublic inline fun FloatArray.firstOrNull(predicate: (Float) -> Boolean): Float? {\n for (element in this) if (predicate(element)) return element\n return null\n}\n\n/**\n * Returns the first element matching the given [predicate], or `null` if element was not found.\n */\npublic inline fun DoubleArray.firstOrNull(predicate: (Double) -> Boolean): Double? {\n for (element in this) if (predicate(element)) return element\n return null\n}\n\n/**\n * Returns the first element matching the given [predicate], or `null` if element was not found.\n */\npublic inline fun BooleanArray.firstOrNull(predicate: (Boolean) -> Boolean): Boolean? {\n for (element in this) if (predicate(element)) return element\n return null\n}\n\n/**\n * Returns the first element matching the given [predicate], or `null` if element was not found.\n */\npublic inline fun CharArray.firstOrNull(predicate: (Char) -> Boolean): Char? {\n for (element in this) if (predicate(element)) return element\n return null\n}\n\n/**\n * Returns an element at the given [index] or the result of calling the [defaultValue] function if the [index] is out of bounds of this array.\n */\[email protected]\npublic inline fun <T> Array<out T>.getOrElse(index: Int, defaultValue: (Int) -> T): T {\n return if (index >= 0 && index <= lastIndex) get(index) else defaultValue(index)\n}\n\n/**\n * Returns an element at the given [index] or the result of calling the [defaultValue] function if the [index] is out of bounds of this array.\n */\[email protected]\npublic inline fun ByteArray.getOrElse(index: Int, defaultValue: (Int) -> Byte): Byte {\n return if (index >= 0 && index <= lastIndex) get(index) else defaultValue(index)\n}\n\n/**\n * Returns an element at the given [index] or the result of calling the [defaultValue] function if the [index] is out of bounds of this array.\n */\[email protected]\npublic inline fun ShortArray.getOrElse(index: Int, defaultValue: (Int) -> Short): Short {\n return if (index >= 0 && index <= lastIndex) get(index) else defaultValue(index)\n}\n\n/**\n * Returns an element at the given [index] or the result of calling the [defaultValue] function if the [index] is out of bounds of this array.\n */\[email protected]\npublic inline fun IntArray.getOrElse(index: Int, defaultValue: (Int) -> Int): Int {\n return if (index >= 0 && index <= lastIndex) get(index) else defaultValue(index)\n}\n\n/**\n * Returns an element at the given [index] or the result of calling the [defaultValue] function if the [index] is out of bounds of this array.\n */\[email protected]\npublic inline fun LongArray.getOrElse(index: Int, defaultValue: (Int) -> Long): Long {\n return if (index >= 0 && index <= lastIndex) get(index) else defaultValue(index)\n}\n\n/**\n * Returns an element at the given [index] or the result of calling the [defaultValue] function if the [index] is out of bounds of this array.\n */\[email protected]\npublic inline fun FloatArray.getOrElse(index: Int, defaultValue: (Int) -> Float): Float {\n return if (index >= 0 && index <= lastIndex) get(index) else defaultValue(index)\n}\n\n/**\n * Returns an element at the given [index] or the result of calling the [defaultValue] function if the [index] is out of bounds of this array.\n */\[email protected]\npublic inline fun DoubleArray.getOrElse(index: Int, defaultValue: (Int) -> Double): Double {\n return if (index >= 0 && index <= lastIndex) get(index) else defaultValue(index)\n}\n\n/**\n * Returns an element at the given [index] or the result of calling the [defaultValue] function if the [index] is out of bounds of this array.\n */\[email protected]\npublic inline fun BooleanArray.getOrElse(index: Int, defaultValue: (Int) -> Boolean): Boolean {\n return if (index >= 0 && index <= lastIndex) get(index) else defaultValue(index)\n}\n\n/**\n * Returns an element at the given [index] or the result of calling the [defaultValue] function if the [index] is out of bounds of this array.\n */\[email protected]\npublic inline fun CharArray.getOrElse(index: Int, defaultValue: (Int) -> Char): Char {\n return if (index >= 0 && index <= lastIndex) get(index) else defaultValue(index)\n}\n\n/**\n * Returns an element at the given [index] or `null` if the [index] is out of bounds of this array.\n */\npublic fun <T> Array<out T>.getOrNull(index: Int): T? {\n return if (index >= 0 && index <= lastIndex) get(index) else null\n}\n\n/**\n * Returns an element at the given [index] or `null` if the [index] is out of bounds of this array.\n */\npublic fun ByteArray.getOrNull(index: Int): Byte? {\n return if (index >= 0 && index <= lastIndex) get(index) else null\n}\n\n/**\n * Returns an element at the given [index] or `null` if the [index] is out of bounds of this array.\n */\npublic fun ShortArray.getOrNull(index: Int): Short? {\n return if (index >= 0 && index <= lastIndex) get(index) else null\n}\n\n/**\n * Returns an element at the given [index] or `null` if the [index] is out of bounds of this array.\n */\npublic fun IntArray.getOrNull(index: Int): Int? {\n return if (index >= 0 && index <= lastIndex) get(index) else null\n}\n\n/**\n * Returns an element at the given [index] or `null` if the [index] is out of bounds of this array.\n */\npublic fun LongArray.getOrNull(index: Int): Long? {\n return if (index >= 0 && index <= lastIndex) get(index) else null\n}\n\n/**\n * Returns an element at the given [index] or `null` if the [index] is out of bounds of this array.\n */\npublic fun FloatArray.getOrNull(index: Int): Float? {\n return if (index >= 0 && index <= lastIndex) get(index) else null\n}\n\n/**\n * Returns an element at the given [index] or `null` if the [index] is out of bounds of this array.\n */\npublic fun DoubleArray.getOrNull(index: Int): Double? {\n return if (index >= 0 && index <= lastIndex) get(index) else null\n}\n\n/**\n * Returns an element at the given [index] or `null` if the [index] is out of bounds of this array.\n */\npublic fun BooleanArray.getOrNull(index: Int): Boolean? {\n return if (index >= 0 && index <= lastIndex) get(index) else null\n}\n\n/**\n * Returns an element at the given [index] or `null` if the [index] is out of bounds of this array.\n */\npublic fun CharArray.getOrNull(index: Int): Char? {\n return if (index >= 0 && index <= lastIndex) get(index) else null\n}\n\n/**\n * Returns first index of [element], or -1 if the array does not contain element.\n */\npublic fun <@kotlin.internal.OnlyInputTypes T> Array<out T>.indexOf(element: T): Int {\n if (element == null) {\n for (index in indices) {\n if (this[index] == null) {\n return index\n }\n }\n } else {\n for (index in indices) {\n if (element == this[index]) {\n return index\n }\n }\n }\n return -1\n}\n\n/**\n * Returns first index of [element], or -1 if the array does not contain element.\n */\npublic fun ByteArray.indexOf(element: Byte): Int {\n for (index in indices) {\n if (element == this[index]) {\n return index\n }\n }\n return -1\n}\n\n/**\n * Returns first index of [element], or -1 if the array does not contain element.\n */\npublic fun ShortArray.indexOf(element: Short): Int {\n for (index in indices) {\n if (element == this[index]) {\n return index\n }\n }\n return -1\n}\n\n/**\n * Returns first index of [element], or -1 if the array does not contain element.\n */\npublic fun IntArray.indexOf(element: Int): Int {\n for (index in indices) {\n if (element == this[index]) {\n return index\n }\n }\n return -1\n}\n\n/**\n * Returns first index of [element], or -1 if the array does not contain element.\n */\npublic fun LongArray.indexOf(element: Long): Int {\n for (index in indices) {\n if (element == this[index]) {\n return index\n }\n }\n return -1\n}\n\n/**\n * Returns first index of [element], or -1 if the array does not contain element.\n */\npublic fun FloatArray.indexOf(element: Float): Int {\n for (index in indices) {\n if (element == this[index]) {\n return index\n }\n }\n return -1\n}\n\n/**\n * Returns first index of [element], or -1 if the array does not contain element.\n */\npublic fun DoubleArray.indexOf(element: Double): Int {\n for (index in indices) {\n if (element == this[index]) {\n return index\n }\n }\n return -1\n}\n\n/**\n * Returns first index of [element], or -1 if the array does not contain element.\n */\npublic fun BooleanArray.indexOf(element: Boolean): Int {\n for (index in indices) {\n if (element == this[index]) {\n return index\n }\n }\n return -1\n}\n\n/**\n * Returns first index of [element], or -1 if the array does not contain element.\n */\npublic fun CharArray.indexOf(element: Char): Int {\n for (index in indices) {\n if (element == this[index]) {\n return index\n }\n }\n return -1\n}\n\n/**\n * Returns index of the first element matching the given [predicate], or -1 if the array does not contain such element.\n */\npublic inline fun <T> Array<out T>.indexOfFirst(predicate: (T) -> Boolean): Int {\n for (index in indices) {\n if (predicate(this[index])) {\n return index\n }\n }\n return -1\n}\n\n/**\n * Returns index of the first element matching the given [predicate], or -1 if the array does not contain such element.\n */\npublic inline fun ByteArray.indexOfFirst(predicate: (Byte) -> Boolean): Int {\n for (index in indices) {\n if (predicate(this[index])) {\n return index\n }\n }\n return -1\n}\n\n/**\n * Returns index of the first element matching the given [predicate], or -1 if the array does not contain such element.\n */\npublic inline fun ShortArray.indexOfFirst(predicate: (Short) -> Boolean): Int {\n for (index in indices) {\n if (predicate(this[index])) {\n return index\n }\n }\n return -1\n}\n\n/**\n * Returns index of the first element matching the given [predicate], or -1 if the array does not contain such element.\n */\npublic inline fun IntArray.indexOfFirst(predicate: (Int) -> Boolean): Int {\n for (index in indices) {\n if (predicate(this[index])) {\n return index\n }\n }\n return -1\n}\n\n/**\n * Returns index of the first element matching the given [predicate], or -1 if the array does not contain such element.\n */\npublic inline fun LongArray.indexOfFirst(predicate: (Long) -> Boolean): Int {\n for (index in indices) {\n if (predicate(this[index])) {\n return index\n }\n }\n return -1\n}\n\n/**\n * Returns index of the first element matching the given [predicate], or -1 if the array does not contain such element.\n */\npublic inline fun FloatArray.indexOfFirst(predicate: (Float) -> Boolean): Int {\n for (index in indices) {\n if (predicate(this[index])) {\n return index\n }\n }\n return -1\n}\n\n/**\n * Returns index of the first element matching the given [predicate], or -1 if the array does not contain such element.\n */\npublic inline fun DoubleArray.indexOfFirst(predicate: (Double) -> Boolean): Int {\n for (index in indices) {\n if (predicate(this[index])) {\n return index\n }\n }\n return -1\n}\n\n/**\n * Returns index of the first element matching the given [predicate], or -1 if the array does not contain such element.\n */\npublic inline fun BooleanArray.indexOfFirst(predicate: (Boolean) -> Boolean): Int {\n for (index in indices) {\n if (predicate(this[index])) {\n return index\n }\n }\n return -1\n}\n\n/**\n * Returns index of the first element matching the given [predicate], or -1 if the array does not contain such element.\n */\npublic inline fun CharArray.indexOfFirst(predicate: (Char) -> Boolean): Int {\n for (index in indices) {\n if (predicate(this[index])) {\n return index\n }\n }\n return -1\n}\n\n/**\n * Returns index of the last element matching the given [predicate], or -1 if the array does not contain such element.\n */\npublic inline fun <T> Array<out T>.indexOfLast(predicate: (T) -> Boolean): Int {\n for (index in indices.reversed()) {\n if (predicate(this[index])) {\n return index\n }\n }\n return -1\n}\n\n/**\n * Returns index of the last element matching the given [predicate], or -1 if the array does not contain such element.\n */\npublic inline fun ByteArray.indexOfLast(predicate: (Byte) -> Boolean): Int {\n for (index in indices.reversed()) {\n if (predicate(this[index])) {\n return index\n }\n }\n return -1\n}\n\n/**\n * Returns index of the last element matching the given [predicate], or -1 if the array does not contain such element.\n */\npublic inline fun ShortArray.indexOfLast(predicate: (Short) -> Boolean): Int {\n for (index in indices.reversed()) {\n if (predicate(this[index])) {\n return index\n }\n }\n return -1\n}\n\n/**\n * Returns index of the last element matching the given [predicate], or -1 if the array does not contain such element.\n */\npublic inline fun IntArray.indexOfLast(predicate: (Int) -> Boolean): Int {\n for (index in indices.reversed()) {\n if (predicate(this[index])) {\n return index\n }\n }\n return -1\n}\n\n/**\n * Returns index of the last element matching the given [predicate], or -1 if the array does not contain such element.\n */\npublic inline fun LongArray.indexOfLast(predicate: (Long) -> Boolean): Int {\n for (index in indices.reversed()) {\n if (predicate(this[index])) {\n return index\n }\n }\n return -1\n}\n\n/**\n * Returns index of the last element matching the given [predicate], or -1 if the array does not contain such element.\n */\npublic inline fun FloatArray.indexOfLast(predicate: (Float) -> Boolean): Int {\n for (index in indices.reversed()) {\n if (predicate(this[index])) {\n return index\n }\n }\n return -1\n}\n\n/**\n * Returns index of the last element matching the given [predicate], or -1 if the array does not contain such element.\n */\npublic inline fun DoubleArray.indexOfLast(predicate: (Double) -> Boolean): Int {\n for (index in indices.reversed()) {\n if (predicate(this[index])) {\n return index\n }\n }\n return -1\n}\n\n/**\n * Returns index of the last element matching the given [predicate], or -1 if the array does not contain such element.\n */\npublic inline fun BooleanArray.indexOfLast(predicate: (Boolean) -> Boolean): Int {\n for (index in indices.reversed()) {\n if (predicate(this[index])) {\n return index\n }\n }\n return -1\n}\n\n/**\n * Returns index of the last element matching the given [predicate], or -1 if the array does not contain such element.\n */\npublic inline fun CharArray.indexOfLast(predicate: (Char) -> Boolean): Int {\n for (index in indices.reversed()) {\n if (predicate(this[index])) {\n return index\n }\n }\n return -1\n}\n\n/**\n * Returns the last element.\n * @throws [NoSuchElementException] if the array is empty.\n */\npublic fun <T> Array<out T>.last(): T {\n if (isEmpty())\n throw NoSuchElementException(\"Array is empty.\")\n return this[lastIndex]\n}\n\n/**\n * Returns the last element.\n * @throws [NoSuchElementException] if the array is empty.\n */\npublic fun ByteArray.last(): Byte {\n if (isEmpty())\n throw NoSuchElementException(\"Array is empty.\")\n return this[lastIndex]\n}\n\n/**\n * Returns the last element.\n * @throws [NoSuchElementException] if the array is empty.\n */\npublic fun ShortArray.last(): Short {\n if (isEmpty())\n throw NoSuchElementException(\"Array is empty.\")\n return this[lastIndex]\n}\n\n/**\n * Returns the last element.\n * @throws [NoSuchElementException] if the array is empty.\n */\npublic fun IntArray.last(): Int {\n if (isEmpty())\n throw NoSuchElementException(\"Array is empty.\")\n return this[lastIndex]\n}\n\n/**\n * Returns the last element.\n * @throws [NoSuchElementException] if the array is empty.\n */\npublic fun LongArray.last(): Long {\n if (isEmpty())\n throw NoSuchElementException(\"Array is empty.\")\n return this[lastIndex]\n}\n\n/**\n * Returns the last element.\n * @throws [NoSuchElementException] if the array is empty.\n */\npublic fun FloatArray.last(): Float {\n if (isEmpty())\n throw NoSuchElementException(\"Array is empty.\")\n return this[lastIndex]\n}\n\n/**\n * Returns the last element.\n * @throws [NoSuchElementException] if the array is empty.\n */\npublic fun DoubleArray.last(): Double {\n if (isEmpty())\n throw NoSuchElementException(\"Array is empty.\")\n return this[lastIndex]\n}\n\n/**\n * Returns the last element.\n * @throws [NoSuchElementException] if the array is empty.\n */\npublic fun BooleanArray.last(): Boolean {\n if (isEmpty())\n throw NoSuchElementException(\"Array is empty.\")\n return this[lastIndex]\n}\n\n/**\n * Returns the last element.\n * @throws [NoSuchElementException] if the array is empty.\n */\npublic fun CharArray.last(): Char {\n if (isEmpty())\n throw NoSuchElementException(\"Array is empty.\")\n return this[lastIndex]\n}\n\n/**\n * Returns the last element matching the given [predicate].\n * @throws [NoSuchElementException] if no such element is found.\n */\npublic inline fun <T> Array<out T>.last(predicate: (T) -> Boolean): T {\n for (index in this.indices.reversed()) {\n val element = this[index]\n if (predicate(element)) return element\n }\n throw NoSuchElementException(\"Array contains no element matching the predicate.\")\n}\n\n/**\n * Returns the last element matching the given [predicate].\n * @throws [NoSuchElementException] if no such element is found.\n */\npublic inline fun ByteArray.last(predicate: (Byte) -> Boolean): Byte {\n for (index in this.indices.reversed()) {\n val element = this[index]\n if (predicate(element)) return element\n }\n throw NoSuchElementException(\"Array contains no element matching the predicate.\")\n}\n\n/**\n * Returns the last element matching the given [predicate].\n * @throws [NoSuchElementException] if no such element is found.\n */\npublic inline fun ShortArray.last(predicate: (Short) -> Boolean): Short {\n for (index in this.indices.reversed()) {\n val element = this[index]\n if (predicate(element)) return element\n }\n throw NoSuchElementException(\"Array contains no element matching the predicate.\")\n}\n\n/**\n * Returns the last element matching the given [predicate].\n * @throws [NoSuchElementException] if no such element is found.\n */\npublic inline fun IntArray.last(predicate: (Int) -> Boolean): Int {\n for (index in this.indices.reversed()) {\n val element = this[index]\n if (predicate(element)) return element\n }\n throw NoSuchElementException(\"Array contains no element matching the predicate.\")\n}\n\n/**\n * Returns the last element matching the given [predicate].\n * @throws [NoSuchElementException] if no such element is found.\n */\npublic inline fun LongArray.last(predicate: (Long) -> Boolean): Long {\n for (index in this.indices.reversed()) {\n val element = this[index]\n if (predicate(element)) return element\n }\n throw NoSuchElementException(\"Array contains no element matching the predicate.\")\n}\n\n/**\n * Returns the last element matching the given [predicate].\n * @throws [NoSuchElementException] if no such element is found.\n */\npublic inline fun FloatArray.last(predicate: (Float) -> Boolean): Float {\n for (index in this.indices.reversed()) {\n val element = this[index]\n if (predicate(element)) return element\n }\n throw NoSuchElementException(\"Array contains no element matching the predicate.\")\n}\n\n/**\n * Returns the last element matching the given [predicate].\n * @throws [NoSuchElementException] if no such element is found.\n */\npublic inline fun DoubleArray.last(predicate: (Double) -> Boolean): Double {\n for (index in this.indices.reversed()) {\n val element = this[index]\n if (predicate(element)) return element\n }\n throw NoSuchElementException(\"Array contains no element matching the predicate.\")\n}\n\n/**\n * Returns the last element matching the given [predicate].\n * @throws [NoSuchElementException] if no such element is found.\n */\npublic inline fun BooleanArray.last(predicate: (Boolean) -> Boolean): Boolean {\n for (index in this.indices.reversed()) {\n val element = this[index]\n if (predicate(element)) return element\n }\n throw NoSuchElementException(\"Array contains no element matching the predicate.\")\n}\n\n/**\n * Returns the last element matching the given [predicate].\n * @throws [NoSuchElementException] if no such element is found.\n */\npublic inline fun CharArray.last(predicate: (Char) -> Boolean): Char {\n for (index in this.indices.reversed()) {\n val element = this[index]\n if (predicate(element)) return element\n }\n throw NoSuchElementException(\"Array contains no element matching the predicate.\")\n}\n\n/**\n * Returns last index of [element], or -1 if the array does not contain element.\n */\npublic fun <@kotlin.internal.OnlyInputTypes T> Array<out T>.lastIndexOf(element: T): Int {\n if (element == null) {\n for (index in indices.reversed()) {\n if (this[index] == null) {\n return index\n }\n }\n } else {\n for (index in indices.reversed()) {\n if (element == this[index]) {\n return index\n }\n }\n }\n return -1\n}\n\n/**\n * Returns last index of [element], or -1 if the array does not contain element.\n */\npublic fun ByteArray.lastIndexOf(element: Byte): Int {\n for (index in indices.reversed()) {\n if (element == this[index]) {\n return index\n }\n }\n return -1\n}\n\n/**\n * Returns last index of [element], or -1 if the array does not contain element.\n */\npublic fun ShortArray.lastIndexOf(element: Short): Int {\n for (index in indices.reversed()) {\n if (element == this[index]) {\n return index\n }\n }\n return -1\n}\n\n/**\n * Returns last index of [element], or -1 if the array does not contain element.\n */\npublic fun IntArray.lastIndexOf(element: Int): Int {\n for (index in indices.reversed()) {\n if (element == this[index]) {\n return index\n }\n }\n return -1\n}\n\n/**\n * Returns last index of [element], or -1 if the array does not contain element.\n */\npublic fun LongArray.lastIndexOf(element: Long): Int {\n for (index in indices.reversed()) {\n if (element == this[index]) {\n return index\n }\n }\n return -1\n}\n\n/**\n * Returns last index of [element], or -1 if the array does not contain element.\n */\npublic fun FloatArray.lastIndexOf(element: Float): Int {\n for (index in indices.reversed()) {\n if (element == this[index]) {\n return index\n }\n }\n return -1\n}\n\n/**\n * Returns last index of [element], or -1 if the array does not contain element.\n */\npublic fun DoubleArray.lastIndexOf(element: Double): Int {\n for (index in indices.reversed()) {\n if (element == this[index]) {\n return index\n }\n }\n return -1\n}\n\n/**\n * Returns last index of [element], or -1 if the array does not contain element.\n */\npublic fun BooleanArray.lastIndexOf(element: Boolean): Int {\n for (index in indices.reversed()) {\n if (element == this[index]) {\n return index\n }\n }\n return -1\n}\n\n/**\n * Returns last index of [element], or -1 if the array does not contain element.\n */\npublic fun CharArray.lastIndexOf(element: Char): Int {\n for (index in indices.reversed()) {\n if (element == this[index]) {\n return index\n }\n }\n return -1\n}\n\n/**\n * Returns the last element, or `null` if the array is empty.\n */\npublic fun <T> Array<out T>.lastOrNull(): T? {\n return if (isEmpty()) null else this[size - 1]\n}\n\n/**\n * Returns the last element, or `null` if the array is empty.\n */\npublic fun ByteArray.lastOrNull(): Byte? {\n return if (isEmpty()) null else this[size - 1]\n}\n\n/**\n * Returns the last element, or `null` if the array is empty.\n */\npublic fun ShortArray.lastOrNull(): Short? {\n return if (isEmpty()) null else this[size - 1]\n}\n\n/**\n * Returns the last element, or `null` if the array is empty.\n */\npublic fun IntArray.lastOrNull(): Int? {\n return if (isEmpty()) null else this[size - 1]\n}\n\n/**\n * Returns the last element, or `null` if the array is empty.\n */\npublic fun LongArray.lastOrNull(): Long? {\n return if (isEmpty()) null else this[size - 1]\n}\n\n/**\n * Returns the last element, or `null` if the array is empty.\n */\npublic fun FloatArray.lastOrNull(): Float? {\n return if (isEmpty()) null else this[size - 1]\n}\n\n/**\n * Returns the last element, or `null` if the array is empty.\n */\npublic fun DoubleArray.lastOrNull(): Double? {\n return if (isEmpty()) null else this[size - 1]\n}\n\n/**\n * Returns the last element, or `null` if the array is empty.\n */\npublic fun BooleanArray.lastOrNull(): Boolean? {\n return if (isEmpty()) null else this[size - 1]\n}\n\n/**\n * Returns the last element, or `null` if the array is empty.\n */\npublic fun CharArray.lastOrNull(): Char? {\n return if (isEmpty()) null else this[size - 1]\n}\n\n/**\n * Returns the last element matching the given [predicate], or `null` if no such element was found.\n */\npublic inline fun <T> Array<out T>.lastOrNull(predicate: (T) -> Boolean): T? {\n for (index in this.indices.reversed()) {\n val element = this[index]\n if (predicate(element)) return element\n }\n return null\n}\n\n/**\n * Returns the last element matching the given [predicate], or `null` if no such element was found.\n */\npublic inline fun ByteArray.lastOrNull(predicate: (Byte) -> Boolean): Byte? {\n for (index in this.indices.reversed()) {\n val element = this[index]\n if (predicate(element)) return element\n }\n return null\n}\n\n/**\n * Returns the last element matching the given [predicate], or `null` if no such element was found.\n */\npublic inline fun ShortArray.lastOrNull(predicate: (Short) -> Boolean): Short? {\n for (index in this.indices.reversed()) {\n val element = this[index]\n if (predicate(element)) return element\n }\n return null\n}\n\n/**\n * Returns the last element matching the given [predicate], or `null` if no such element was found.\n */\npublic inline fun IntArray.lastOrNull(predicate: (Int) -> Boolean): Int? {\n for (index in this.indices.reversed()) {\n val element = this[index]\n if (predicate(element)) return element\n }\n return null\n}\n\n/**\n * Returns the last element matching the given [predicate], or `null` if no such element was found.\n */\npublic inline fun LongArray.lastOrNull(predicate: (Long) -> Boolean): Long? {\n for (index in this.indices.reversed()) {\n val element = this[index]\n if (predicate(element)) return element\n }\n return null\n}\n\n/**\n * Returns the last element matching the given [predicate], or `null` if no such element was found.\n */\npublic inline fun FloatArray.lastOrNull(predicate: (Float) -> Boolean): Float? {\n for (index in this.indices.reversed()) {\n val element = this[index]\n if (predicate(element)) return element\n }\n return null\n}\n\n/**\n * Returns the last element matching the given [predicate], or `null` if no such element was found.\n */\npublic inline fun DoubleArray.lastOrNull(predicate: (Double) -> Boolean): Double? {\n for (index in this.indices.reversed()) {\n val element = this[index]\n if (predicate(element)) return element\n }\n return null\n}\n\n/**\n * Returns the last element matching the given [predicate], or `null` if no such element was found.\n */\npublic inline fun BooleanArray.lastOrNull(predicate: (Boolean) -> Boolean): Boolean? {\n for (index in this.indices.reversed()) {\n val element = this[index]\n if (predicate(element)) return element\n }\n return null\n}\n\n/**\n * Returns the last element matching the given [predicate], or `null` if no such element was found.\n */\npublic inline fun CharArray.lastOrNull(predicate: (Char) -> Boolean): Char? {\n for (index in this.indices.reversed()) {\n val element = this[index]\n if (predicate(element)) return element\n }\n return null\n}\n\n/**\n * Returns a random element from this array.\n * \n * @throws NoSuchElementException if this array is empty.\n */\n@SinceKotlin(\"1.3\")\[email protected]\npublic inline fun <T> Array<out T>.random(): T {\n return random(Random)\n}\n\n/**\n * Returns a random element from this array.\n * \n * @throws NoSuchElementException if this array is empty.\n */\n@SinceKotlin(\"1.3\")\[email protected]\npublic inline fun ByteArray.random(): Byte {\n return random(Random)\n}\n\n/**\n * Returns a random element from this array.\n * \n * @throws NoSuchElementException if this array is empty.\n */\n@SinceKotlin(\"1.3\")\[email protected]\npublic inline fun ShortArray.random(): Short {\n return random(Random)\n}\n\n/**\n * Returns a random element from this array.\n * \n * @throws NoSuchElementException if this array is empty.\n */\n@SinceKotlin(\"1.3\")\[email protected]\npublic inline fun IntArray.random(): Int {\n return random(Random)\n}\n\n/**\n * Returns a random element from this array.\n * \n * @throws NoSuchElementException if this array is empty.\n */\n@SinceKotlin(\"1.3\")\[email protected]\npublic inline fun LongArray.random(): Long {\n return random(Random)\n}\n\n/**\n * Returns a random element from this array.\n * \n * @throws NoSuchElementException if this array is empty.\n */\n@SinceKotlin(\"1.3\")\[email protected]\npublic inline fun FloatArray.random(): Float {\n return random(Random)\n}\n\n/**\n * Returns a random element from this array.\n * \n * @throws NoSuchElementException if this array is empty.\n */\n@SinceKotlin(\"1.3\")\[email protected]\npublic inline fun DoubleArray.random(): Double {\n return random(Random)\n}\n\n/**\n * Returns a random element from this array.\n * \n * @throws NoSuchElementException if this array is empty.\n */\n@SinceKotlin(\"1.3\")\[email protected]\npublic inline fun BooleanArray.random(): Boolean {\n return random(Random)\n}\n\n/**\n * Returns a random element from this array.\n * \n * @throws NoSuchElementException if this array is empty.\n */\n@SinceKotlin(\"1.3\")\[email protected]\npublic inline fun CharArray.random(): Char {\n return random(Random)\n}\n\n/**\n * Returns a random element from this array using the specified source of randomness.\n * \n * @throws NoSuchElementException if this array is empty.\n */\n@SinceKotlin(\"1.3\")\npublic fun <T> Array<out T>.random(random: Random): T {\n if (isEmpty())\n throw NoSuchElementException(\"Array is empty.\")\n return get(random.nextInt(size))\n}\n\n/**\n * Returns a random element from this array using the specified source of randomness.\n * \n * @throws NoSuchElementException if this array is empty.\n */\n@SinceKotlin(\"1.3\")\npublic fun ByteArray.random(random: Random): Byte {\n if (isEmpty())\n throw NoSuchElementException(\"Array is empty.\")\n return get(random.nextInt(size))\n}\n\n/**\n * Returns a random element from this array using the specified source of randomness.\n * \n * @throws NoSuchElementException if this array is empty.\n */\n@SinceKotlin(\"1.3\")\npublic fun ShortArray.random(random: Random): Short {\n if (isEmpty())\n throw NoSuchElementException(\"Array is empty.\")\n return get(random.nextInt(size))\n}\n\n/**\n * Returns a random element from this array using the specified source of randomness.\n * \n * @throws NoSuchElementException if this array is empty.\n */\n@SinceKotlin(\"1.3\")\npublic fun IntArray.random(random: Random): Int {\n if (isEmpty())\n throw NoSuchElementException(\"Array is empty.\")\n return get(random.nextInt(size))\n}\n\n/**\n * Returns a random element from this array using the specified source of randomness.\n * \n * @throws NoSuchElementException if this array is empty.\n */\n@SinceKotlin(\"1.3\")\npublic fun LongArray.random(random: Random): Long {\n if (isEmpty())\n throw NoSuchElementException(\"Array is empty.\")\n return get(random.nextInt(size))\n}\n\n/**\n * Returns a random element from this array using the specified source of randomness.\n * \n * @throws NoSuchElementException if this array is empty.\n */\n@SinceKotlin(\"1.3\")\npublic fun FloatArray.random(random: Random): Float {\n if (isEmpty())\n throw NoSuchElementException(\"Array is empty.\")\n return get(random.nextInt(size))\n}\n\n/**\n * Returns a random element from this array using the specified source of randomness.\n * \n * @throws NoSuchElementException if this array is empty.\n */\n@SinceKotlin(\"1.3\")\npublic fun DoubleArray.random(random: Random): Double {\n if (isEmpty())\n throw NoSuchElementException(\"Array is empty.\")\n return get(random.nextInt(size))\n}\n\n/**\n * Returns a random element from this array using the specified source of randomness.\n * \n * @throws NoSuchElementException if this array is empty.\n */\n@SinceKotlin(\"1.3\")\npublic fun BooleanArray.random(random: Random): Boolean {\n if (isEmpty())\n throw NoSuchElementException(\"Array is empty.\")\n return get(random.nextInt(size))\n}\n\n/**\n * Returns a random element from this array using the specified source of randomness.\n * \n * @throws NoSuchElementException if this array is empty.\n */\n@SinceKotlin(\"1.3\")\npublic fun CharArray.random(random: Random): Char {\n if (isEmpty())\n throw NoSuchElementException(\"Array is empty.\")\n return get(random.nextInt(size))\n}\n\n/**\n * Returns the single element, or throws an exception if the array is empty or has more than one element.\n */\npublic fun <T> Array<out T>.single(): T {\n return when (size) {\n 0 -> throw NoSuchElementException(\"Array is empty.\")\n 1 -> this[0]\n else -> throw IllegalArgumentException(\"Array has more than one element.\")\n }\n}\n\n/**\n * Returns the single element, or throws an exception if the array is empty or has more than one element.\n */\npublic fun ByteArray.single(): Byte {\n return when (size) {\n 0 -> throw NoSuchElementException(\"Array is empty.\")\n 1 -> this[0]\n else -> throw IllegalArgumentException(\"Array has more than one element.\")\n }\n}\n\n/**\n * Returns the single element, or throws an exception if the array is empty or has more than one element.\n */\npublic fun ShortArray.single(): Short {\n return when (size) {\n 0 -> throw NoSuchElementException(\"Array is empty.\")\n 1 -> this[0]\n else -> throw IllegalArgumentException(\"Array has more than one element.\")\n }\n}\n\n/**\n * Returns the single element, or throws an exception if the array is empty or has more than one element.\n */\npublic fun IntArray.single(): Int {\n return when (size) {\n 0 -> throw NoSuchElementException(\"Array is empty.\")\n 1 -> this[0]\n else -> throw IllegalArgumentException(\"Array has more than one element.\")\n }\n}\n\n/**\n * Returns the single element, or throws an exception if the array is empty or has more than one element.\n */\npublic fun LongArray.single(): Long {\n return when (size) {\n 0 -> throw NoSuchElementException(\"Array is empty.\")\n 1 -> this[0]\n else -> throw IllegalArgumentException(\"Array has more than one element.\")\n }\n}\n\n/**\n * Returns the single element, or throws an exception if the array is empty or has more than one element.\n */\npublic fun FloatArray.single(): Float {\n return when (size) {\n 0 -> throw NoSuchElementException(\"Array is empty.\")\n 1 -> this[0]\n else -> throw IllegalArgumentException(\"Array has more than one element.\")\n }\n}\n\n/**\n * Returns the single element, or throws an exception if the array is empty or has more than one element.\n */\npublic fun DoubleArray.single(): Double {\n return when (size) {\n 0 -> throw NoSuchElementException(\"Array is empty.\")\n 1 -> this[0]\n else -> throw IllegalArgumentException(\"Array has more than one element.\")\n }\n}\n\n/**\n * Returns the single element, or throws an exception if the array is empty or has more than one element.\n */\npublic fun BooleanArray.single(): Boolean {\n return when (size) {\n 0 -> throw NoSuchElementException(\"Array is empty.\")\n 1 -> this[0]\n else -> throw IllegalArgumentException(\"Array has more than one element.\")\n }\n}\n\n/**\n * Returns the single element, or throws an exception if the array is empty or has more than one element.\n */\npublic fun CharArray.single(): Char {\n return when (size) {\n 0 -> throw NoSuchElementException(\"Array is empty.\")\n 1 -> this[0]\n else -> throw IllegalArgumentException(\"Array has more than one element.\")\n }\n}\n\n/**\n * Returns the single element matching the given [predicate], or throws exception if there is no or more than one matching element.\n */\npublic inline fun <T> Array<out T>.single(predicate: (T) -> Boolean): T {\n var single: T? = null\n var found = false\n for (element in this) {\n if (predicate(element)) {\n if (found) throw IllegalArgumentException(\"Array contains more than one matching element.\")\n single = element\n found = true\n }\n }\n if (!found) throw NoSuchElementException(\"Array contains no element matching the predicate.\")\n @Suppress(\"UNCHECKED_CAST\")\n return single as T\n}\n\n/**\n * Returns the single element matching the given [predicate], or throws exception if there is no or more than one matching element.\n */\npublic inline fun ByteArray.single(predicate: (Byte) -> Boolean): Byte {\n var single: Byte? = null\n var found = false\n for (element in this) {\n if (predicate(element)) {\n if (found) throw IllegalArgumentException(\"Array contains more than one matching element.\")\n single = element\n found = true\n }\n }\n if (!found) throw NoSuchElementException(\"Array contains no element matching the predicate.\")\n @Suppress(\"UNCHECKED_CAST\")\n return single as Byte\n}\n\n/**\n * Returns the single element matching the given [predicate], or throws exception if there is no or more than one matching element.\n */\npublic inline fun ShortArray.single(predicate: (Short) -> Boolean): Short {\n var single: Short? = null\n var found = false\n for (element in this) {\n if (predicate(element)) {\n if (found) throw IllegalArgumentException(\"Array contains more than one matching element.\")\n single = element\n found = true\n }\n }\n if (!found) throw NoSuchElementException(\"Array contains no element matching the predicate.\")\n @Suppress(\"UNCHECKED_CAST\")\n return single as Short\n}\n\n/**\n * Returns the single element matching the given [predicate], or throws exception if there is no or more than one matching element.\n */\npublic inline fun IntArray.single(predicate: (Int) -> Boolean): Int {\n var single: Int? = null\n var found = false\n for (element in this) {\n if (predicate(element)) {\n if (found) throw IllegalArgumentException(\"Array contains more than one matching element.\")\n single = element\n found = true\n }\n }\n if (!found) throw NoSuchElementException(\"Array contains no element matching the predicate.\")\n @Suppress(\"UNCHECKED_CAST\")\n return single as Int\n}\n\n/**\n * Returns the single element matching the given [predicate], or throws exception if there is no or more than one matching element.\n */\npublic inline fun LongArray.single(predicate: (Long) -> Boolean): Long {\n var single: Long? = null\n var found = false\n for (element in this) {\n if (predicate(element)) {\n if (found) throw IllegalArgumentException(\"Array contains more than one matching element.\")\n single = element\n found = true\n }\n }\n if (!found) throw NoSuchElementException(\"Array contains no element matching the predicate.\")\n @Suppress(\"UNCHECKED_CAST\")\n return single as Long\n}\n\n/**\n * Returns the single element matching the given [predicate], or throws exception if there is no or more than one matching element.\n */\npublic inline fun FloatArray.single(predicate: (Float) -> Boolean): Float {\n var single: Float? = null\n var found = false\n for (element in this) {\n if (predicate(element)) {\n if (found) throw IllegalArgumentException(\"Array contains more than one matching element.\")\n single = element\n found = true\n }\n }\n if (!found) throw NoSuchElementException(\"Array contains no element matching the predicate.\")\n @Suppress(\"UNCHECKED_CAST\")\n return single as Float\n}\n\n/**\n * Returns the single element matching the given [predicate], or throws exception if there is no or more than one matching element.\n */\npublic inline fun DoubleArray.single(predicate: (Double) -> Boolean): Double {\n var single: Double? = null\n var found = false\n for (element in this) {\n if (predicate(element)) {\n if (found) throw IllegalArgumentException(\"Array contains more than one matching element.\")\n single = element\n found = true\n }\n }\n if (!found) throw NoSuchElementException(\"Array contains no element matching the predicate.\")\n @Suppress(\"UNCHECKED_CAST\")\n return single as Double\n}\n\n/**\n * Returns the single element matching the given [predicate], or throws exception if there is no or more than one matching element.\n */\npublic inline fun BooleanArray.single(predicate: (Boolean) -> Boolean): Boolean {\n var single: Boolean? = null\n var found = false\n for (element in this) {\n if (predicate(element)) {\n if (found) throw IllegalArgumentException(\"Array contains more than one matching element.\")\n single = element\n found = true\n }\n }\n if (!found) throw NoSuchElementException(\"Array contains no element matching the predicate.\")\n @Suppress(\"UNCHECKED_CAST\")\n return single as Boolean\n}\n\n/**\n * Returns the single element matching the given [predicate], or throws exception if there is no or more than one matching element.\n */\npublic inline fun CharArray.single(predicate: (Char) -> Boolean): Char {\n var single: Char? = null\n var found = false\n for (element in this) {\n if (predicate(element)) {\n if (found) throw IllegalArgumentException(\"Array contains more than one matching element.\")\n single = element\n found = true\n }\n }\n if (!found) throw NoSuchElementException(\"Array contains no element matching the predicate.\")\n @Suppress(\"UNCHECKED_CAST\")\n return single as Char\n}\n\n/**\n * Returns single element, or `null` if the array is empty or has more than one element.\n */\npublic fun <T> Array<out T>.singleOrNull(): T? {\n return if (size == 1) this[0] else null\n}\n\n/**\n * Returns single element, or `null` if the array is empty or has more than one element.\n */\npublic fun ByteArray.singleOrNull(): Byte? {\n return if (size == 1) this[0] else null\n}\n\n/**\n * Returns single element, or `null` if the array is empty or has more than one element.\n */\npublic fun ShortArray.singleOrNull(): Short? {\n return if (size == 1) this[0] else null\n}\n\n/**\n * Returns single element, or `null` if the array is empty or has more than one element.\n */\npublic fun IntArray.singleOrNull(): Int? {\n return if (size == 1) this[0] else null\n}\n\n/**\n * Returns single element, or `null` if the array is empty or has more than one element.\n */\npublic fun LongArray.singleOrNull(): Long? {\n return if (size == 1) this[0] else null\n}\n\n/**\n * Returns single element, or `null` if the array is empty or has more than one element.\n */\npublic fun FloatArray.singleOrNull(): Float? {\n return if (size == 1) this[0] else null\n}\n\n/**\n * Returns single element, or `null` if the array is empty or has more than one element.\n */\npublic fun DoubleArray.singleOrNull(): Double? {\n return if (size == 1) this[0] else null\n}\n\n/**\n * Returns single element, or `null` if the array is empty or has more than one element.\n */\npublic fun BooleanArray.singleOrNull(): Boolean? {\n return if (size == 1) this[0] else null\n}\n\n/**\n * Returns single element, or `null` if the array is empty or has more than one element.\n */\npublic fun CharArray.singleOrNull(): Char? {\n return if (size == 1) this[0] else null\n}\n\n/**\n * Returns the single element matching the given [predicate], or `null` if element was not found or more than one element was found.\n */\npublic inline fun <T> Array<out T>.singleOrNull(predicate: (T) -> Boolean): T? {\n var single: T? = null\n var found = false\n for (element in this) {\n if (predicate(element)) {\n if (found) return null\n single = element\n found = true\n }\n }\n if (!found) return null\n return single\n}\n\n/**\n * Returns the single element matching the given [predicate], or `null` if element was not found or more than one element was found.\n */\npublic inline fun ByteArray.singleOrNull(predicate: (Byte) -> Boolean): Byte? {\n var single: Byte? = null\n var found = false\n for (element in this) {\n if (predicate(element)) {\n if (found) return null\n single = element\n found = true\n }\n }\n if (!found) return null\n return single\n}\n\n/**\n * Returns the single element matching the given [predicate], or `null` if element was not found or more than one element was found.\n */\npublic inline fun ShortArray.singleOrNull(predicate: (Short) -> Boolean): Short? {\n var single: Short? = null\n var found = false\n for (element in this) {\n if (predicate(element)) {\n if (found) return null\n single = element\n found = true\n }\n }\n if (!found) return null\n return single\n}\n\n/**\n * Returns the single element matching the given [predicate], or `null` if element was not found or more than one element was found.\n */\npublic inline fun IntArray.singleOrNull(predicate: (Int) -> Boolean): Int? {\n var single: Int? = null\n var found = false\n for (element in this) {\n if (predicate(element)) {\n if (found) return null\n single = element\n found = true\n }\n }\n if (!found) return null\n return single\n}\n\n/**\n * Returns the single element matching the given [predicate], or `null` if element was not found or more than one element was found.\n */\npublic inline fun LongArray.singleOrNull(predicate: (Long) -> Boolean): Long? {\n var single: Long? = null\n var found = false\n for (element in this) {\n if (predicate(element)) {\n if (found) return null\n single = element\n found = true\n }\n }\n if (!found) return null\n return single\n}\n\n/**\n * Returns the single element matching the given [predicate], or `null` if element was not found or more than one element was found.\n */\npublic inline fun FloatArray.singleOrNull(predicate: (Float) -> Boolean): Float? {\n var single: Float? = null\n var found = false\n for (element in this) {\n if (predicate(element)) {\n if (found) return null\n single = element\n found = true\n }\n }\n if (!found) return null\n return single\n}\n\n/**\n * Returns the single element matching the given [predicate], or `null` if element was not found or more than one element was found.\n */\npublic inline fun DoubleArray.singleOrNull(predicate: (Double) -> Boolean): Double? {\n var single: Double? = null\n var found = false\n for (element in this) {\n if (predicate(element)) {\n if (found) return null\n single = element\n found = true\n }\n }\n if (!found) return null\n return single\n}\n\n/**\n * Returns the single element matching the given [predicate], or `null` if element was not found or more than one element was found.\n */\npublic inline fun BooleanArray.singleOrNull(predicate: (Boolean) -> Boolean): Boolean? {\n var single: Boolean? = null\n var found = false\n for (element in this) {\n if (predicate(element)) {\n if (found) return null\n single = element\n found = true\n }\n }\n if (!found) return null\n return single\n}\n\n/**\n * Returns the single element matching the given [predicate], or `null` if element was not found or more than one element was found.\n */\npublic inline fun CharArray.singleOrNull(predicate: (Char) -> Boolean): Char? {\n var single: Char? = null\n var found = false\n for (element in this) {\n if (predicate(element)) {\n if (found) return null\n single = element\n found = true\n }\n }\n if (!found) return null\n return single\n}\n\n/**\n * Returns a list containing all elements except first [n] elements.\n * \n * @sample samples.collections.Collections.Transformations.drop\n */\npublic fun <T> Array<out T>.drop(n: Int): List<T> {\n require(n >= 0) { \"Requested element count $n is less than zero.\" }\n return takeLast((size - n).coerceAtLeast(0))\n}\n\n/**\n * Returns a list containing all elements except first [n] elements.\n * \n * @sample samples.collections.Collections.Transformations.drop\n */\npublic fun ByteArray.drop(n: Int): List<Byte> {\n require(n >= 0) { \"Requested element count $n is less than zero.\" }\n return takeLast((size - n).coerceAtLeast(0))\n}\n\n/**\n * Returns a list containing all elements except first [n] elements.\n * \n * @sample samples.collections.Collections.Transformations.drop\n */\npublic fun ShortArray.drop(n: Int): List<Short> {\n require(n >= 0) { \"Requested element count $n is less than zero.\" }\n return takeLast((size - n).coerceAtLeast(0))\n}\n\n/**\n * Returns a list containing all elements except first [n] elements.\n * \n * @sample samples.collections.Collections.Transformations.drop\n */\npublic fun IntArray.drop(n: Int): List<Int> {\n require(n >= 0) { \"Requested element count $n is less than zero.\" }\n return takeLast((size - n).coerceAtLeast(0))\n}\n\n/**\n * Returns a list containing all elements except first [n] elements.\n * \n * @sample samples.collections.Collections.Transformations.drop\n */\npublic fun LongArray.drop(n: Int): List<Long> {\n require(n >= 0) { \"Requested element count $n is less than zero.\" }\n return takeLast((size - n).coerceAtLeast(0))\n}\n\n/**\n * Returns a list containing all elements except first [n] elements.\n * \n * @sample samples.collections.Collections.Transformations.drop\n */\npublic fun FloatArray.drop(n: Int): List<Float> {\n require(n >= 0) { \"Requested element count $n is less than zero.\" }\n return takeLast((size - n).coerceAtLeast(0))\n}\n\n/**\n * Returns a list containing all elements except first [n] elements.\n * \n * @sample samples.collections.Collections.Transformations.drop\n */\npublic fun DoubleArray.drop(n: Int): List<Double> {\n require(n >= 0) { \"Requested element count $n is less than zero.\" }\n return takeLast((size - n).coerceAtLeast(0))\n}\n\n/**\n * Returns a list containing all elements except first [n] elements.\n * \n * @sample samples.collections.Collections.Transformations.drop\n */\npublic fun BooleanArray.drop(n: Int): List<Boolean> {\n require(n >= 0) { \"Requested element count $n is less than zero.\" }\n return takeLast((size - n).coerceAtLeast(0))\n}\n\n/**\n * Returns a list containing all elements except first [n] elements.\n * \n * @sample samples.collections.Collections.Transformations.drop\n */\npublic fun CharArray.drop(n: Int): List<Char> {\n require(n >= 0) { \"Requested element count $n is less than zero.\" }\n return takeLast((size - n).coerceAtLeast(0))\n}\n\n/**\n * Returns a list containing all elements except last [n] elements.\n * \n * @sample samples.collections.Collections.Transformations.drop\n */\npublic fun <T> Array<out T>.dropLast(n: Int): List<T> {\n require(n >= 0) { \"Requested element count $n is less than zero.\" }\n return take((size - n).coerceAtLeast(0))\n}\n\n/**\n * Returns a list containing all elements except last [n] elements.\n * \n * @sample samples.collections.Collections.Transformations.drop\n */\npublic fun ByteArray.dropLast(n: Int): List<Byte> {\n require(n >= 0) { \"Requested element count $n is less than zero.\" }\n return take((size - n).coerceAtLeast(0))\n}\n\n/**\n * Returns a list containing all elements except last [n] elements.\n * \n * @sample samples.collections.Collections.Transformations.drop\n */\npublic fun ShortArray.dropLast(n: Int): List<Short> {\n require(n >= 0) { \"Requested element count $n is less than zero.\" }\n return take((size - n).coerceAtLeast(0))\n}\n\n/**\n * Returns a list containing all elements except last [n] elements.\n * \n * @sample samples.collections.Collections.Transformations.drop\n */\npublic fun IntArray.dropLast(n: Int): List<Int> {\n require(n >= 0) { \"Requested element count $n is less than zero.\" }\n return take((size - n).coerceAtLeast(0))\n}\n\n/**\n * Returns a list containing all elements except last [n] elements.\n * \n * @sample samples.collections.Collections.Transformations.drop\n */\npublic fun LongArray.dropLast(n: Int): List<Long> {\n require(n >= 0) { \"Requested element count $n is less than zero.\" }\n return take((size - n).coerceAtLeast(0))\n}\n\n/**\n * Returns a list containing all elements except last [n] elements.\n * \n * @sample samples.collections.Collections.Transformations.drop\n */\npublic fun FloatArray.dropLast(n: Int): List<Float> {\n require(n >= 0) { \"Requested element count $n is less than zero.\" }\n return take((size - n).coerceAtLeast(0))\n}\n\n/**\n * Returns a list containing all elements except last [n] elements.\n * \n * @sample samples.collections.Collections.Transformations.drop\n */\npublic fun DoubleArray.dropLast(n: Int): List<Double> {\n require(n >= 0) { \"Requested element count $n is less than zero.\" }\n return take((size - n).coerceAtLeast(0))\n}\n\n/**\n * Returns a list containing all elements except last [n] elements.\n * \n * @sample samples.collections.Collections.Transformations.drop\n */\npublic fun BooleanArray.dropLast(n: Int): List<Boolean> {\n require(n >= 0) { \"Requested element count $n is less than zero.\" }\n return take((size - n).coerceAtLeast(0))\n}\n\n/**\n * Returns a list containing all elements except last [n] elements.\n * \n * @sample samples.collections.Collections.Transformations.drop\n */\npublic fun CharArray.dropLast(n: Int): List<Char> {\n require(n >= 0) { \"Requested element count $n is less than zero.\" }\n return take((size - n).coerceAtLeast(0))\n}\n\n/**\n * Returns a list containing all elements except last elements that satisfy the given [predicate].\n * \n * @sample samples.collections.Collections.Transformations.drop\n */\npublic inline fun <T> Array<out T>.dropLastWhile(predicate: (T) -> Boolean): List<T> {\n for (index in lastIndex downTo 0) {\n if (!predicate(this[index])) {\n return take(index + 1)\n }\n }\n return emptyList()\n}\n\n/**\n * Returns a list containing all elements except last elements that satisfy the given [predicate].\n * \n * @sample samples.collections.Collections.Transformations.drop\n */\npublic inline fun ByteArray.dropLastWhile(predicate: (Byte) -> Boolean): List<Byte> {\n for (index in lastIndex downTo 0) {\n if (!predicate(this[index])) {\n return take(index + 1)\n }\n }\n return emptyList()\n}\n\n/**\n * Returns a list containing all elements except last elements that satisfy the given [predicate].\n * \n * @sample samples.collections.Collections.Transformations.drop\n */\npublic inline fun ShortArray.dropLastWhile(predicate: (Short) -> Boolean): List<Short> {\n for (index in lastIndex downTo 0) {\n if (!predicate(this[index])) {\n return take(index + 1)\n }\n }\n return emptyList()\n}\n\n/**\n * Returns a list containing all elements except last elements that satisfy the given [predicate].\n * \n * @sample samples.collections.Collections.Transformations.drop\n */\npublic inline fun IntArray.dropLastWhile(predicate: (Int) -> Boolean): List<Int> {\n for (index in lastIndex downTo 0) {\n if (!predicate(this[index])) {\n return take(index + 1)\n }\n }\n return emptyList()\n}\n\n/**\n * Returns a list containing all elements except last elements that satisfy the given [predicate].\n * \n * @sample samples.collections.Collections.Transformations.drop\n */\npublic inline fun LongArray.dropLastWhile(predicate: (Long) -> Boolean): List<Long> {\n for (index in lastIndex downTo 0) {\n if (!predicate(this[index])) {\n return take(index + 1)\n }\n }\n return emptyList()\n}\n\n/**\n * Returns a list containing all elements except last elements that satisfy the given [predicate].\n * \n * @sample samples.collections.Collections.Transformations.drop\n */\npublic inline fun FloatArray.dropLastWhile(predicate: (Float) -> Boolean): List<Float> {\n for (index in lastIndex downTo 0) {\n if (!predicate(this[index])) {\n return take(index + 1)\n }\n }\n return emptyList()\n}\n\n/**\n * Returns a list containing all elements except last elements that satisfy the given [predicate].\n * \n * @sample samples.collections.Collections.Transformations.drop\n */\npublic inline fun DoubleArray.dropLastWhile(predicate: (Double) -> Boolean): List<Double> {\n for (index in lastIndex downTo 0) {\n if (!predicate(this[index])) {\n return take(index + 1)\n }\n }\n return emptyList()\n}\n\n/**\n * Returns a list containing all elements except last elements that satisfy the given [predicate].\n * \n * @sample samples.collections.Collections.Transformations.drop\n */\npublic inline fun BooleanArray.dropLastWhile(predicate: (Boolean) -> Boolean): List<Boolean> {\n for (index in lastIndex downTo 0) {\n if (!predicate(this[index])) {\n return take(index + 1)\n }\n }\n return emptyList()\n}\n\n/**\n * Returns a list containing all elements except last elements that satisfy the given [predicate].\n * \n * @sample samples.collections.Collections.Transformations.drop\n */\npublic inline fun CharArray.dropLastWhile(predicate: (Char) -> Boolean): List<Char> {\n for (index in lastIndex downTo 0) {\n if (!predicate(this[index])) {\n return take(index + 1)\n }\n }\n return emptyList()\n}\n\n/**\n * Returns a list containing all elements except first elements that satisfy the given [predicate].\n * \n * @sample samples.collections.Collections.Transformations.drop\n */\npublic inline fun <T> Array<out T>.dropWhile(predicate: (T) -> Boolean): List<T> {\n var yielding = false\n val list = ArrayList<T>()\n for (item in this)\n if (yielding)\n list.add(item)\n else if (!predicate(item)) {\n list.add(item)\n yielding = true\n }\n return list\n}\n\n/**\n * Returns a list containing all elements except first elements that satisfy the given [predicate].\n * \n * @sample samples.collections.Collections.Transformations.drop\n */\npublic inline fun ByteArray.dropWhile(predicate: (Byte) -> Boolean): List<Byte> {\n var yielding = false\n val list = ArrayList<Byte>()\n for (item in this)\n if (yielding)\n list.add(item)\n else if (!predicate(item)) {\n list.add(item)\n yielding = true\n }\n return list\n}\n\n/**\n * Returns a list containing all elements except first elements that satisfy the given [predicate].\n * \n * @sample samples.collections.Collections.Transformations.drop\n */\npublic inline fun ShortArray.dropWhile(predicate: (Short) -> Boolean): List<Short> {\n var yielding = false\n val list = ArrayList<Short>()\n for (item in this)\n if (yielding)\n list.add(item)\n else if (!predicate(item)) {\n list.add(item)\n yielding = true\n }\n return list\n}\n\n/**\n * Returns a list containing all elements except first elements that satisfy the given [predicate].\n * \n * @sample samples.collections.Collections.Transformations.drop\n */\npublic inline fun IntArray.dropWhile(predicate: (Int) -> Boolean): List<Int> {\n var yielding = false\n val list = ArrayList<Int>()\n for (item in this)\n if (yielding)\n list.add(item)\n else if (!predicate(item)) {\n list.add(item)\n yielding = true\n }\n return list\n}\n\n/**\n * Returns a list containing all elements except first elements that satisfy the given [predicate].\n * \n * @sample samples.collections.Collections.Transformations.drop\n */\npublic inline fun LongArray.dropWhile(predicate: (Long) -> Boolean): List<Long> {\n var yielding = false\n val list = ArrayList<Long>()\n for (item in this)\n if (yielding)\n list.add(item)\n else if (!predicate(item)) {\n list.add(item)\n yielding = true\n }\n return list\n}\n\n/**\n * Returns a list containing all elements except first elements that satisfy the given [predicate].\n * \n * @sample samples.collections.Collections.Transformations.drop\n */\npublic inline fun FloatArray.dropWhile(predicate: (Float) -> Boolean): List<Float> {\n var yielding = false\n val list = ArrayList<Float>()\n for (item in this)\n if (yielding)\n list.add(item)\n else if (!predicate(item)) {\n list.add(item)\n yielding = true\n }\n return list\n}\n\n/**\n * Returns a list containing all elements except first elements that satisfy the given [predicate].\n * \n * @sample samples.collections.Collections.Transformations.drop\n */\npublic inline fun DoubleArray.dropWhile(predicate: (Double) -> Boolean): List<Double> {\n var yielding = false\n val list = ArrayList<Double>()\n for (item in this)\n if (yielding)\n list.add(item)\n else if (!predicate(item)) {\n list.add(item)\n yielding = true\n }\n return list\n}\n\n/**\n * Returns a list containing all elements except first elements that satisfy the given [predicate].\n * \n * @sample samples.collections.Collections.Transformations.drop\n */\npublic inline fun BooleanArray.dropWhile(predicate: (Boolean) -> Boolean): List<Boolean> {\n var yielding = false\n val list = ArrayList<Boolean>()\n for (item in this)\n if (yielding)\n list.add(item)\n else if (!predicate(item)) {\n list.add(item)\n yielding = true\n }\n return list\n}\n\n/**\n * Returns a list containing all elements except first elements that satisfy the given [predicate].\n * \n * @sample samples.collections.Collections.Transformations.drop\n */\npublic inline fun CharArray.dropWhile(predicate: (Char) -> Boolean): List<Char> {\n var yielding = false\n val list = ArrayList<Char>()\n for (item in this)\n if (yielding)\n list.add(item)\n else if (!predicate(item)) {\n list.add(item)\n yielding = true\n }\n return list\n}\n\n/**\n * Returns a list containing only elements matching the given [predicate].\n */\npublic inline fun <T> Array<out T>.filter(predicate: (T) -> Boolean): List<T> {\n return filterTo(ArrayList<T>(), predicate)\n}\n\n/**\n * Returns a list containing only elements matching the given [predicate].\n */\npublic inline fun ByteArray.filter(predicate: (Byte) -> Boolean): List<Byte> {\n return filterTo(ArrayList<Byte>(), predicate)\n}\n\n/**\n * Returns a list containing only elements matching the given [predicate].\n */\npublic inline fun ShortArray.filter(predicate: (Short) -> Boolean): List<Short> {\n return filterTo(ArrayList<Short>(), predicate)\n}\n\n/**\n * Returns a list containing only elements matching the given [predicate].\n */\npublic inline fun IntArray.filter(predicate: (Int) -> Boolean): List<Int> {\n return filterTo(ArrayList<Int>(), predicate)\n}\n\n/**\n * Returns a list containing only elements matching the given [predicate].\n */\npublic inline fun LongArray.filter(predicate: (Long) -> Boolean): List<Long> {\n return filterTo(ArrayList<Long>(), predicate)\n}\n\n/**\n * Returns a list containing only elements matching the given [predicate].\n */\npublic inline fun FloatArray.filter(predicate: (Float) -> Boolean): List<Float> {\n return filterTo(ArrayList<Float>(), predicate)\n}\n\n/**\n * Returns a list containing only elements matching the given [predicate].\n */\npublic inline fun DoubleArray.filter(predicate: (Double) -> Boolean): List<Double> {\n return filterTo(ArrayList<Double>(), predicate)\n}\n\n/**\n * Returns a list containing only elements matching the given [predicate].\n */\npublic inline fun BooleanArray.filter(predicate: (Boolean) -> Boolean): List<Boolean> {\n return filterTo(ArrayList<Boolean>(), predicate)\n}\n\n/**\n * Returns a list containing only elements matching the given [predicate].\n */\npublic inline fun CharArray.filter(predicate: (Char) -> Boolean): List<Char> {\n return filterTo(ArrayList<Char>(), predicate)\n}\n\n/**\n * Returns a list containing only elements matching the given [predicate].\n * @param [predicate] function that takes the index of an element and the element itself\n * and returns the result of predicate evaluation on the element.\n */\npublic inline fun <T> Array<out T>.filterIndexed(predicate: (index: Int, T) -> Boolean): List<T> {\n return filterIndexedTo(ArrayList<T>(), predicate)\n}\n\n/**\n * Returns a list containing only elements matching the given [predicate].\n * @param [predicate] function that takes the index of an element and the element itself\n * and returns the result of predicate evaluation on the element.\n */\npublic inline fun ByteArray.filterIndexed(predicate: (index: Int, Byte) -> Boolean): List<Byte> {\n return filterIndexedTo(ArrayList<Byte>(), predicate)\n}\n\n/**\n * Returns a list containing only elements matching the given [predicate].\n * @param [predicate] function that takes the index of an element and the element itself\n * and returns the result of predicate evaluation on the element.\n */\npublic inline fun ShortArray.filterIndexed(predicate: (index: Int, Short) -> Boolean): List<Short> {\n return filterIndexedTo(ArrayList<Short>(), predicate)\n}\n\n/**\n * Returns a list containing only elements matching the given [predicate].\n * @param [predicate] function that takes the index of an element and the element itself\n * and returns the result of predicate evaluation on the element.\n */\npublic inline fun IntArray.filterIndexed(predicate: (index: Int, Int) -> Boolean): List<Int> {\n return filterIndexedTo(ArrayList<Int>(), predicate)\n}\n\n/**\n * Returns a list containing only elements matching the given [predicate].\n * @param [predicate] function that takes the index of an element and the element itself\n * and returns the result of predicate evaluation on the element.\n */\npublic inline fun LongArray.filterIndexed(predicate: (index: Int, Long) -> Boolean): List<Long> {\n return filterIndexedTo(ArrayList<Long>(), predicate)\n}\n\n/**\n * Returns a list containing only elements matching the given [predicate].\n * @param [predicate] function that takes the index of an element and the element itself\n * and returns the result of predicate evaluation on the element.\n */\npublic inline fun FloatArray.filterIndexed(predicate: (index: Int, Float) -> Boolean): List<Float> {\n return filterIndexedTo(ArrayList<Float>(), predicate)\n}\n\n/**\n * Returns a list containing only elements matching the given [predicate].\n * @param [predicate] function that takes the index of an element and the element itself\n * and returns the result of predicate evaluation on the element.\n */\npublic inline fun DoubleArray.filterIndexed(predicate: (index: Int, Double) -> Boolean): List<Double> {\n return filterIndexedTo(ArrayList<Double>(), predicate)\n}\n\n/**\n * Returns a list containing only elements matching the given [predicate].\n * @param [predicate] function that takes the index of an element and the element itself\n * and returns the result of predicate evaluation on the element.\n */\npublic inline fun BooleanArray.filterIndexed(predicate: (index: Int, Boolean) -> Boolean): List<Boolean> {\n return filterIndexedTo(ArrayList<Boolean>(), predicate)\n}\n\n/**\n * Returns a list containing only elements matching the given [predicate].\n * @param [predicate] function that takes the index of an element and the element itself\n * and returns the result of predicate evaluation on the element.\n */\npublic inline fun CharArray.filterIndexed(predicate: (index: Int, Char) -> Boolean): List<Char> {\n return filterIndexedTo(ArrayList<Char>(), predicate)\n}\n\n/**\n * Appends all elements matching the given [predicate] to the given [destination].\n * @param [predicate] function that takes the index of an element and the element itself\n * and returns the result of predicate evaluation on the element.\n */\npublic inline fun <T, C : MutableCollection<in T>> Array<out T>.filterIndexedTo(destination: C, predicate: (index: Int, T) -> Boolean): C {\n forEachIndexed { index, element ->\n if (predicate(index, element)) destination.add(element)\n }\n return destination\n}\n\n/**\n * Appends all elements matching the given [predicate] to the given [destination].\n * @param [predicate] function that takes the index of an element and the element itself\n * and returns the result of predicate evaluation on the element.\n */\npublic inline fun <C : MutableCollection<in Byte>> ByteArray.filterIndexedTo(destination: C, predicate: (index: Int, Byte) -> Boolean): C {\n forEachIndexed { index, element ->\n if (predicate(index, element)) destination.add(element)\n }\n return destination\n}\n\n/**\n * Appends all elements matching the given [predicate] to the given [destination].\n * @param [predicate] function that takes the index of an element and the element itself\n * and returns the result of predicate evaluation on the element.\n */\npublic inline fun <C : MutableCollection<in Short>> ShortArray.filterIndexedTo(destination: C, predicate: (index: Int, Short) -> Boolean): C {\n forEachIndexed { index, element ->\n if (predicate(index, element)) destination.add(element)\n }\n return destination\n}\n\n/**\n * Appends all elements matching the given [predicate] to the given [destination].\n * @param [predicate] function that takes the index of an element and the element itself\n * and returns the result of predicate evaluation on the element.\n */\npublic inline fun <C : MutableCollection<in Int>> IntArray.filterIndexedTo(destination: C, predicate: (index: Int, Int) -> Boolean): C {\n forEachIndexed { index, element ->\n if (predicate(index, element)) destination.add(element)\n }\n return destination\n}\n\n/**\n * Appends all elements matching the given [predicate] to the given [destination].\n * @param [predicate] function that takes the index of an element and the element itself\n * and returns the result of predicate evaluation on the element.\n */\npublic inline fun <C : MutableCollection<in Long>> LongArray.filterIndexedTo(destination: C, predicate: (index: Int, Long) -> Boolean): C {\n forEachIndexed { index, element ->\n if (predicate(index, element)) destination.add(element)\n }\n return destination\n}\n\n/**\n * Appends all elements matching the given [predicate] to the given [destination].\n * @param [predicate] function that takes the index of an element and the element itself\n * and returns the result of predicate evaluation on the element.\n */\npublic inline fun <C : MutableCollection<in Float>> FloatArray.filterIndexedTo(destination: C, predicate: (index: Int, Float) -> Boolean): C {\n forEachIndexed { index, element ->\n if (predicate(index, element)) destination.add(element)\n }\n return destination\n}\n\n/**\n * Appends all elements matching the given [predicate] to the given [destination].\n * @param [predicate] function that takes the index of an element and the element itself\n * and returns the result of predicate evaluation on the element.\n */\npublic inline fun <C : MutableCollection<in Double>> DoubleArray.filterIndexedTo(destination: C, predicate: (index: Int, Double) -> Boolean): C {\n forEachIndexed { index, element ->\n if (predicate(index, element)) destination.add(element)\n }\n return destination\n}\n\n/**\n * Appends all elements matching the given [predicate] to the given [destination].\n * @param [predicate] function that takes the index of an element and the element itself\n * and returns the result of predicate evaluation on the element.\n */\npublic inline fun <C : MutableCollection<in Boolean>> BooleanArray.filterIndexedTo(destination: C, predicate: (index: Int, Boolean) -> Boolean): C {\n forEachIndexed { index, element ->\n if (predicate(index, element)) destination.add(element)\n }\n return destination\n}\n\n/**\n * Appends all elements matching the given [predicate] to the given [destination].\n * @param [predicate] function that takes the index of an element and the element itself\n * and returns the result of predicate evaluation on the element.\n */\npublic inline fun <C : MutableCollection<in Char>> CharArray.filterIndexedTo(destination: C, predicate: (index: Int, Char) -> Boolean): C {\n forEachIndexed { index, element ->\n if (predicate(index, element)) destination.add(element)\n }\n return destination\n}\n\n/**\n * Returns a list containing all elements that are instances of specified type parameter R.\n */\npublic inline fun <reified R> Array<*>.filterIsInstance(): List<@kotlin.internal.NoInfer R> {\n return filterIsInstanceTo(ArrayList<R>())\n}\n\n/**\n * Appends all elements that are instances of specified type parameter R to the given [destination].\n */\npublic inline fun <reified R, C : MutableCollection<in R>> Array<*>.filterIsInstanceTo(destination: C): C {\n for (element in this) if (element is R) destination.add(element)\n return destination\n}\n\n/**\n * Returns a list containing all elements not matching the given [predicate].\n */\npublic inline fun <T> Array<out T>.filterNot(predicate: (T) -> Boolean): List<T> {\n return filterNotTo(ArrayList<T>(), predicate)\n}\n\n/**\n * Returns a list containing all elements not matching the given [predicate].\n */\npublic inline fun ByteArray.filterNot(predicate: (Byte) -> Boolean): List<Byte> {\n return filterNotTo(ArrayList<Byte>(), predicate)\n}\n\n/**\n * Returns a list containing all elements not matching the given [predicate].\n */\npublic inline fun ShortArray.filterNot(predicate: (Short) -> Boolean): List<Short> {\n return filterNotTo(ArrayList<Short>(), predicate)\n}\n\n/**\n * Returns a list containing all elements not matching the given [predicate].\n */\npublic inline fun IntArray.filterNot(predicate: (Int) -> Boolean): List<Int> {\n return filterNotTo(ArrayList<Int>(), predicate)\n}\n\n/**\n * Returns a list containing all elements not matching the given [predicate].\n */\npublic inline fun LongArray.filterNot(predicate: (Long) -> Boolean): List<Long> {\n return filterNotTo(ArrayList<Long>(), predicate)\n}\n\n/**\n * Returns a list containing all elements not matching the given [predicate].\n */\npublic inline fun FloatArray.filterNot(predicate: (Float) -> Boolean): List<Float> {\n return filterNotTo(ArrayList<Float>(), predicate)\n}\n\n/**\n * Returns a list containing all elements not matching the given [predicate].\n */\npublic inline fun DoubleArray.filterNot(predicate: (Double) -> Boolean): List<Double> {\n return filterNotTo(ArrayList<Double>(), predicate)\n}\n\n/**\n * Returns a list containing all elements not matching the given [predicate].\n */\npublic inline fun BooleanArray.filterNot(predicate: (Boolean) -> Boolean): List<Boolean> {\n return filterNotTo(ArrayList<Boolean>(), predicate)\n}\n\n/**\n * Returns a list containing all elements not matching the given [predicate].\n */\npublic inline fun CharArray.filterNot(predicate: (Char) -> Boolean): List<Char> {\n return filterNotTo(ArrayList<Char>(), predicate)\n}\n\n/**\n * Returns a list containing all elements that are not `null`.\n */\npublic fun <T : Any> Array<out T?>.filterNotNull(): List<T> {\n return filterNotNullTo(ArrayList<T>())\n}\n\n/**\n * Appends all elements that are not `null` to the given [destination].\n */\npublic fun <C : MutableCollection<in T>, T : Any> Array<out T?>.filterNotNullTo(destination: C): C {\n for (element in this) if (element != null) destination.add(element)\n return destination\n}\n\n/**\n * Appends all elements not matching the given [predicate] to the given [destination].\n */\npublic inline fun <T, C : MutableCollection<in T>> Array<out T>.filterNotTo(destination: C, predicate: (T) -> Boolean): C {\n for (element in this) if (!predicate(element)) destination.add(element)\n return destination\n}\n\n/**\n * Appends all elements not matching the given [predicate] to the given [destination].\n */\npublic inline fun <C : MutableCollection<in Byte>> ByteArray.filterNotTo(destination: C, predicate: (Byte) -> Boolean): C {\n for (element in this) if (!predicate(element)) destination.add(element)\n return destination\n}\n\n/**\n * Appends all elements not matching the given [predicate] to the given [destination].\n */\npublic inline fun <C : MutableCollection<in Short>> ShortArray.filterNotTo(destination: C, predicate: (Short) -> Boolean): C {\n for (element in this) if (!predicate(element)) destination.add(element)\n return destination\n}\n\n/**\n * Appends all elements not matching the given [predicate] to the given [destination].\n */\npublic inline fun <C : MutableCollection<in Int>> IntArray.filterNotTo(destination: C, predicate: (Int) -> Boolean): C {\n for (element in this) if (!predicate(element)) destination.add(element)\n return destination\n}\n\n/**\n * Appends all elements not matching the given [predicate] to the given [destination].\n */\npublic inline fun <C : MutableCollection<in Long>> LongArray.filterNotTo(destination: C, predicate: (Long) -> Boolean): C {\n for (element in this) if (!predicate(element)) destination.add(element)\n return destination\n}\n\n/**\n * Appends all elements not matching the given [predicate] to the given [destination].\n */\npublic inline fun <C : MutableCollection<in Float>> FloatArray.filterNotTo(destination: C, predicate: (Float) -> Boolean): C {\n for (element in this) if (!predicate(element)) destination.add(element)\n return destination\n}\n\n/**\n * Appends all elements not matching the given [predicate] to the given [destination].\n */\npublic inline fun <C : MutableCollection<in Double>> DoubleArray.filterNotTo(destination: C, predicate: (Double) -> Boolean): C {\n for (element in this) if (!predicate(element)) destination.add(element)\n return destination\n}\n\n/**\n * Appends all elements not matching the given [predicate] to the given [destination].\n */\npublic inline fun <C : MutableCollection<in Boolean>> BooleanArray.filterNotTo(destination: C, predicate: (Boolean) -> Boolean): C {\n for (element in this) if (!predicate(element)) destination.add(element)\n return destination\n}\n\n/**\n * Appends all elements not matching the given [predicate] to the given [destination].\n */\npublic inline fun <C : MutableCollection<in Char>> CharArray.filterNotTo(destination: C, predicate: (Char) -> Boolean): C {\n for (element in this) if (!predicate(element)) destination.add(element)\n return destination\n}\n\n/**\n * Appends all elements matching the given [predicate] to the given [destination].\n */\npublic inline fun <T, C : MutableCollection<in T>> Array<out T>.filterTo(destination: C, predicate: (T) -> Boolean): C {\n for (element in this) if (predicate(element)) destination.add(element)\n return destination\n}\n\n/**\n * Appends all elements matching the given [predicate] to the given [destination].\n */\npublic inline fun <C : MutableCollection<in Byte>> ByteArray.filterTo(destination: C, predicate: (Byte) -> Boolean): C {\n for (element in this) if (predicate(element)) destination.add(element)\n return destination\n}\n\n/**\n * Appends all elements matching the given [predicate] to the given [destination].\n */\npublic inline fun <C : MutableCollection<in Short>> ShortArray.filterTo(destination: C, predicate: (Short) -> Boolean): C {\n for (element in this) if (predicate(element)) destination.add(element)\n return destination\n}\n\n/**\n * Appends all elements matching the given [predicate] to the given [destination].\n */\npublic inline fun <C : MutableCollection<in Int>> IntArray.filterTo(destination: C, predicate: (Int) -> Boolean): C {\n for (element in this) if (predicate(element)) destination.add(element)\n return destination\n}\n\n/**\n * Appends all elements matching the given [predicate] to the given [destination].\n */\npublic inline fun <C : MutableCollection<in Long>> LongArray.filterTo(destination: C, predicate: (Long) -> Boolean): C {\n for (element in this) if (predicate(element)) destination.add(element)\n return destination\n}\n\n/**\n * Appends all elements matching the given [predicate] to the given [destination].\n */\npublic inline fun <C : MutableCollection<in Float>> FloatArray.filterTo(destination: C, predicate: (Float) -> Boolean): C {\n for (element in this) if (predicate(element)) destination.add(element)\n return destination\n}\n\n/**\n * Appends all elements matching the given [predicate] to the given [destination].\n */\npublic inline fun <C : MutableCollection<in Double>> DoubleArray.filterTo(destination: C, predicate: (Double) -> Boolean): C {\n for (element in this) if (predicate(element)) destination.add(element)\n return destination\n}\n\n/**\n * Appends all elements matching the given [predicate] to the given [destination].\n */\npublic inline fun <C : MutableCollection<in Boolean>> BooleanArray.filterTo(destination: C, predicate: (Boolean) -> Boolean): C {\n for (element in this) if (predicate(element)) destination.add(element)\n return destination\n}\n\n/**\n * Appends all elements matching the given [predicate] to the given [destination].\n */\npublic inline fun <C : MutableCollection<in Char>> CharArray.filterTo(destination: C, predicate: (Char) -> Boolean): C {\n for (element in this) if (predicate(element)) destination.add(element)\n return destination\n}\n\n/**\n * Returns a list containing elements at indices in the specified [indices] range.\n */\npublic fun <T> Array<out T>.slice(indices: IntRange): List<T> {\n if (indices.isEmpty()) return listOf()\n return copyOfRange(indices.start, indices.endInclusive + 1).asList()\n}\n\n/**\n * Returns a list containing elements at indices in the specified [indices] range.\n */\npublic fun ByteArray.slice(indices: IntRange): List<Byte> {\n if (indices.isEmpty()) return listOf()\n return copyOfRange(indices.start, indices.endInclusive + 1).asList()\n}\n\n/**\n * Returns a list containing elements at indices in the specified [indices] range.\n */\npublic fun ShortArray.slice(indices: IntRange): List<Short> {\n if (indices.isEmpty()) return listOf()\n return copyOfRange(indices.start, indices.endInclusive + 1).asList()\n}\n\n/**\n * Returns a list containing elements at indices in the specified [indices] range.\n */\npublic fun IntArray.slice(indices: IntRange): List<Int> {\n if (indices.isEmpty()) return listOf()\n return copyOfRange(indices.start, indices.endInclusive + 1).asList()\n}\n\n/**\n * Returns a list containing elements at indices in the specified [indices] range.\n */\npublic fun LongArray.slice(indices: IntRange): List<Long> {\n if (indices.isEmpty()) return listOf()\n return copyOfRange(indices.start, indices.endInclusive + 1).asList()\n}\n\n/**\n * Returns a list containing elements at indices in the specified [indices] range.\n */\npublic fun FloatArray.slice(indices: IntRange): List<Float> {\n if (indices.isEmpty()) return listOf()\n return copyOfRange(indices.start, indices.endInclusive + 1).asList()\n}\n\n/**\n * Returns a list containing elements at indices in the specified [indices] range.\n */\npublic fun DoubleArray.slice(indices: IntRange): List<Double> {\n if (indices.isEmpty()) return listOf()\n return copyOfRange(indices.start, indices.endInclusive + 1).asList()\n}\n\n/**\n * Returns a list containing elements at indices in the specified [indices] range.\n */\npublic fun BooleanArray.slice(indices: IntRange): List<Boolean> {\n if (indices.isEmpty()) return listOf()\n return copyOfRange(indices.start, indices.endInclusive + 1).asList()\n}\n\n/**\n * Returns a list containing elements at indices in the specified [indices] range.\n */\npublic fun CharArray.slice(indices: IntRange): List<Char> {\n if (indices.isEmpty()) return listOf()\n return copyOfRange(indices.start, indices.endInclusive + 1).asList()\n}\n\n/**\n * Returns a list containing elements at specified [indices].\n */\npublic fun <T> Array<out T>.slice(indices: Iterable<Int>): List<T> {\n val size = indices.collectionSizeOrDefault(10)\n if (size == 0) return emptyList()\n val list = ArrayList<T>(size)\n for (index in indices) {\n list.add(get(index))\n }\n return list\n}\n\n/**\n * Returns a list containing elements at specified [indices].\n */\npublic fun ByteArray.slice(indices: Iterable<Int>): List<Byte> {\n val size = indices.collectionSizeOrDefault(10)\n if (size == 0) return emptyList()\n val list = ArrayList<Byte>(size)\n for (index in indices) {\n list.add(get(index))\n }\n return list\n}\n\n/**\n * Returns a list containing elements at specified [indices].\n */\npublic fun ShortArray.slice(indices: Iterable<Int>): List<Short> {\n val size = indices.collectionSizeOrDefault(10)\n if (size == 0) return emptyList()\n val list = ArrayList<Short>(size)\n for (index in indices) {\n list.add(get(index))\n }\n return list\n}\n\n/**\n * Returns a list containing elements at specified [indices].\n */\npublic fun IntArray.slice(indices: Iterable<Int>): List<Int> {\n val size = indices.collectionSizeOrDefault(10)\n if (size == 0) return emptyList()\n val list = ArrayList<Int>(size)\n for (index in indices) {\n list.add(get(index))\n }\n return list\n}\n\n/**\n * Returns a list containing elements at specified [indices].\n */\npublic fun LongArray.slice(indices: Iterable<Int>): List<Long> {\n val size = indices.collectionSizeOrDefault(10)\n if (size == 0) return emptyList()\n val list = ArrayList<Long>(size)\n for (index in indices) {\n list.add(get(index))\n }\n return list\n}\n\n/**\n * Returns a list containing elements at specified [indices].\n */\npublic fun FloatArray.slice(indices: Iterable<Int>): List<Float> {\n val size = indices.collectionSizeOrDefault(10)\n if (size == 0) return emptyList()\n val list = ArrayList<Float>(size)\n for (index in indices) {\n list.add(get(index))\n }\n return list\n}\n\n/**\n * Returns a list containing elements at specified [indices].\n */\npublic fun DoubleArray.slice(indices: Iterable<Int>): List<Double> {\n val size = indices.collectionSizeOrDefault(10)\n if (size == 0) return emptyList()\n val list = ArrayList<Double>(size)\n for (index in indices) {\n list.add(get(index))\n }\n return list\n}\n\n/**\n * Returns a list containing elements at specified [indices].\n */\npublic fun BooleanArray.slice(indices: Iterable<Int>): List<Boolean> {\n val size = indices.collectionSizeOrDefault(10)\n if (size == 0) return emptyList()\n val list = ArrayList<Boolean>(size)\n for (index in indices) {\n list.add(get(index))\n }\n return list\n}\n\n/**\n * Returns a list containing elements at specified [indices].\n */\npublic fun CharArray.slice(indices: Iterable<Int>): List<Char> {\n val size = indices.collectionSizeOrDefault(10)\n if (size == 0) return emptyList()\n val list = ArrayList<Char>(size)\n for (index in indices) {\n list.add(get(index))\n }\n return list\n}\n\n/**\n * Returns an array containing elements of this array at specified [indices].\n */\npublic fun <T> Array<T>.sliceArray(indices: Collection<Int>): Array<T> {\n val result = arrayOfNulls(this, indices.size)\n var targetIndex = 0\n for (sourceIndex in indices) {\n result[targetIndex++] = this[sourceIndex]\n }\n return result\n}\n\n/**\n * Returns an array containing elements of this array at specified [indices].\n */\npublic fun ByteArray.sliceArray(indices: Collection<Int>): ByteArray {\n val result = ByteArray(indices.size)\n var targetIndex = 0\n for (sourceIndex in indices) {\n result[targetIndex++] = this[sourceIndex]\n }\n return result\n}\n\n/**\n * Returns an array containing elements of this array at specified [indices].\n */\npublic fun ShortArray.sliceArray(indices: Collection<Int>): ShortArray {\n val result = ShortArray(indices.size)\n var targetIndex = 0\n for (sourceIndex in indices) {\n result[targetIndex++] = this[sourceIndex]\n }\n return result\n}\n\n/**\n * Returns an array containing elements of this array at specified [indices].\n */\npublic fun IntArray.sliceArray(indices: Collection<Int>): IntArray {\n val result = IntArray(indices.size)\n var targetIndex = 0\n for (sourceIndex in indices) {\n result[targetIndex++] = this[sourceIndex]\n }\n return result\n}\n\n/**\n * Returns an array containing elements of this array at specified [indices].\n */\npublic fun LongArray.sliceArray(indices: Collection<Int>): LongArray {\n val result = LongArray(indices.size)\n var targetIndex = 0\n for (sourceIndex in indices) {\n result[targetIndex++] = this[sourceIndex]\n }\n return result\n}\n\n/**\n * Returns an array containing elements of this array at specified [indices].\n */\npublic fun FloatArray.sliceArray(indices: Collection<Int>): FloatArray {\n val result = FloatArray(indices.size)\n var targetIndex = 0\n for (sourceIndex in indices) {\n result[targetIndex++] = this[sourceIndex]\n }\n return result\n}\n\n/**\n * Returns an array containing elements of this array at specified [indices].\n */\npublic fun DoubleArray.sliceArray(indices: Collection<Int>): DoubleArray {\n val result = DoubleArray(indices.size)\n var targetIndex = 0\n for (sourceIndex in indices) {\n result[targetIndex++] = this[sourceIndex]\n }\n return result\n}\n\n/**\n * Returns an array containing elements of this array at specified [indices].\n */\npublic fun BooleanArray.sliceArray(indices: Collection<Int>): BooleanArray {\n val result = BooleanArray(indices.size)\n var targetIndex = 0\n for (sourceIndex in indices) {\n result[targetIndex++] = this[sourceIndex]\n }\n return result\n}\n\n/**\n * Returns an array containing elements of this array at specified [indices].\n */\npublic fun CharArray.sliceArray(indices: Collection<Int>): CharArray {\n val result = CharArray(indices.size)\n var targetIndex = 0\n for (sourceIndex in indices) {\n result[targetIndex++] = this[sourceIndex]\n }\n return result\n}\n\n/**\n * Returns a list containing elements at indices in the specified [indices] range.\n */\npublic fun <T> Array<T>.sliceArray(indices: IntRange): Array<T> {\n if (indices.isEmpty()) return copyOfRange(0, 0)\n return copyOfRange(indices.start, indices.endInclusive + 1)\n}\n\n/**\n * Returns a list containing elements at indices in the specified [indices] range.\n */\npublic fun ByteArray.sliceArray(indices: IntRange): ByteArray {\n if (indices.isEmpty()) return ByteArray(0)\n return copyOfRange(indices.start, indices.endInclusive + 1)\n}\n\n/**\n * Returns a list containing elements at indices in the specified [indices] range.\n */\npublic fun ShortArray.sliceArray(indices: IntRange): ShortArray {\n if (indices.isEmpty()) return ShortArray(0)\n return copyOfRange(indices.start, indices.endInclusive + 1)\n}\n\n/**\n * Returns a list containing elements at indices in the specified [indices] range.\n */\npublic fun IntArray.sliceArray(indices: IntRange): IntArray {\n if (indices.isEmpty()) return IntArray(0)\n return copyOfRange(indices.start, indices.endInclusive + 1)\n}\n\n/**\n * Returns a list containing elements at indices in the specified [indices] range.\n */\npublic fun LongArray.sliceArray(indices: IntRange): LongArray {\n if (indices.isEmpty()) return LongArray(0)\n return copyOfRange(indices.start, indices.endInclusive + 1)\n}\n\n/**\n * Returns a list containing elements at indices in the specified [indices] range.\n */\npublic fun FloatArray.sliceArray(indices: IntRange): FloatArray {\n if (indices.isEmpty()) return FloatArray(0)\n return copyOfRange(indices.start, indices.endInclusive + 1)\n}\n\n/**\n * Returns a list containing elements at indices in the specified [indices] range.\n */\npublic fun DoubleArray.sliceArray(indices: IntRange): DoubleArray {\n if (indices.isEmpty()) return DoubleArray(0)\n return copyOfRange(indices.start, indices.endInclusive + 1)\n}\n\n/**\n * Returns a list containing elements at indices in the specified [indices] range.\n */\npublic fun BooleanArray.sliceArray(indices: IntRange): BooleanArray {\n if (indices.isEmpty()) return BooleanArray(0)\n return copyOfRange(indices.start, indices.endInclusive + 1)\n}\n\n/**\n * Returns a list containing elements at indices in the specified [indices] range.\n */\npublic fun CharArray.sliceArray(indices: IntRange): CharArray {\n if (indices.isEmpty()) return CharArray(0)\n return copyOfRange(indices.start, indices.endInclusive + 1)\n}\n\n/**\n * Returns a list containing first [n] elements.\n * \n * @sample samples.collections.Collections.Transformations.take\n */\npublic fun <T> Array<out T>.take(n: Int): List<T> {\n require(n >= 0) { \"Requested element count $n is less than zero.\" }\n if (n == 0) return emptyList()\n if (n >= size) return toList()\n if (n == 1) return listOf(this[0])\n var count = 0\n val list = ArrayList<T>(n)\n for (item in this) {\n if (count++ == n)\n break\n list.add(item)\n }\n return list\n}\n\n/**\n * Returns a list containing first [n] elements.\n * \n * @sample samples.collections.Collections.Transformations.take\n */\npublic fun ByteArray.take(n: Int): List<Byte> {\n require(n >= 0) { \"Requested element count $n is less than zero.\" }\n if (n == 0) return emptyList()\n if (n >= size) return toList()\n if (n == 1) return listOf(this[0])\n var count = 0\n val list = ArrayList<Byte>(n)\n for (item in this) {\n if (count++ == n)\n break\n list.add(item)\n }\n return list\n}\n\n/**\n * Returns a list containing first [n] elements.\n * \n * @sample samples.collections.Collections.Transformations.take\n */\npublic fun ShortArray.take(n: Int): List<Short> {\n require(n >= 0) { \"Requested element count $n is less than zero.\" }\n if (n == 0) return emptyList()\n if (n >= size) return toList()\n if (n == 1) return listOf(this[0])\n var count = 0\n val list = ArrayList<Short>(n)\n for (item in this) {\n if (count++ == n)\n break\n list.add(item)\n }\n return list\n}\n\n/**\n * Returns a list containing first [n] elements.\n * \n * @sample samples.collections.Collections.Transformations.take\n */\npublic fun IntArray.take(n: Int): List<Int> {\n require(n >= 0) { \"Requested element count $n is less than zero.\" }\n if (n == 0) return emptyList()\n if (n >= size) return toList()\n if (n == 1) return listOf(this[0])\n var count = 0\n val list = ArrayList<Int>(n)\n for (item in this) {\n if (count++ == n)\n break\n list.add(item)\n }\n return list\n}\n\n/**\n * Returns a list containing first [n] elements.\n * \n * @sample samples.collections.Collections.Transformations.take\n */\npublic fun LongArray.take(n: Int): List<Long> {\n require(n >= 0) { \"Requested element count $n is less than zero.\" }\n if (n == 0) return emptyList()\n if (n >= size) return toList()\n if (n == 1) return listOf(this[0])\n var count = 0\n val list = ArrayList<Long>(n)\n for (item in this) {\n if (count++ == n)\n break\n list.add(item)\n }\n return list\n}\n\n/**\n * Returns a list containing first [n] elements.\n * \n * @sample samples.collections.Collections.Transformations.take\n */\npublic fun FloatArray.take(n: Int): List<Float> {\n require(n >= 0) { \"Requested element count $n is less than zero.\" }\n if (n == 0) return emptyList()\n if (n >= size) return toList()\n if (n == 1) return listOf(this[0])\n var count = 0\n val list = ArrayList<Float>(n)\n for (item in this) {\n if (count++ == n)\n break\n list.add(item)\n }\n return list\n}\n\n/**\n * Returns a list containing first [n] elements.\n * \n * @sample samples.collections.Collections.Transformations.take\n */\npublic fun DoubleArray.take(n: Int): List<Double> {\n require(n >= 0) { \"Requested element count $n is less than zero.\" }\n if (n == 0) return emptyList()\n if (n >= size) return toList()\n if (n == 1) return listOf(this[0])\n var count = 0\n val list = ArrayList<Double>(n)\n for (item in this) {\n if (count++ == n)\n break\n list.add(item)\n }\n return list\n}\n\n/**\n * Returns a list containing first [n] elements.\n * \n * @sample samples.collections.Collections.Transformations.take\n */\npublic fun BooleanArray.take(n: Int): List<Boolean> {\n require(n >= 0) { \"Requested element count $n is less than zero.\" }\n if (n == 0) return emptyList()\n if (n >= size) return toList()\n if (n == 1) return listOf(this[0])\n var count = 0\n val list = ArrayList<Boolean>(n)\n for (item in this) {\n if (count++ == n)\n break\n list.add(item)\n }\n return list\n}\n\n/**\n * Returns a list containing first [n] elements.\n * \n * @sample samples.collections.Collections.Transformations.take\n */\npublic fun CharArray.take(n: Int): List<Char> {\n require(n >= 0) { \"Requested element count $n is less than zero.\" }\n if (n == 0) return emptyList()\n if (n >= size) return toList()\n if (n == 1) return listOf(this[0])\n var count = 0\n val list = ArrayList<Char>(n)\n for (item in this) {\n if (count++ == n)\n break\n list.add(item)\n }\n return list\n}\n\n/**\n * Returns a list containing last [n] elements.\n * \n * @sample samples.collections.Collections.Transformations.take\n */\npublic fun <T> Array<out T>.takeLast(n: Int): List<T> {\n require(n >= 0) { \"Requested element count $n is less than zero.\" }\n if (n == 0) return emptyList()\n val size = size\n if (n >= size) return toList()\n if (n == 1) return listOf(this[size - 1])\n val list = ArrayList<T>(n)\n for (index in size - n until size)\n list.add(this[index])\n return list\n}\n\n/**\n * Returns a list containing last [n] elements.\n * \n * @sample samples.collections.Collections.Transformations.take\n */\npublic fun ByteArray.takeLast(n: Int): List<Byte> {\n require(n >= 0) { \"Requested element count $n is less than zero.\" }\n if (n == 0) return emptyList()\n val size = size\n if (n >= size) return toList()\n if (n == 1) return listOf(this[size - 1])\n val list = ArrayList<Byte>(n)\n for (index in size - n until size)\n list.add(this[index])\n return list\n}\n\n/**\n * Returns a list containing last [n] elements.\n * \n * @sample samples.collections.Collections.Transformations.take\n */\npublic fun ShortArray.takeLast(n: Int): List<Short> {\n require(n >= 0) { \"Requested element count $n is less than zero.\" }\n if (n == 0) return emptyList()\n val size = size\n if (n >= size) return toList()\n if (n == 1) return listOf(this[size - 1])\n val list = ArrayList<Short>(n)\n for (index in size - n until size)\n list.add(this[index])\n return list\n}\n\n/**\n * Returns a list containing last [n] elements.\n * \n * @sample samples.collections.Collections.Transformations.take\n */\npublic fun IntArray.takeLast(n: Int): List<Int> {\n require(n >= 0) { \"Requested element count $n is less than zero.\" }\n if (n == 0) return emptyList()\n val size = size\n if (n >= size) return toList()\n if (n == 1) return listOf(this[size - 1])\n val list = ArrayList<Int>(n)\n for (index in size - n until size)\n list.add(this[index])\n return list\n}\n\n/**\n * Returns a list containing last [n] elements.\n * \n * @sample samples.collections.Collections.Transformations.take\n */\npublic fun LongArray.takeLast(n: Int): List<Long> {\n require(n >= 0) { \"Requested element count $n is less than zero.\" }\n if (n == 0) return emptyList()\n val size = size\n if (n >= size) return toList()\n if (n == 1) return listOf(this[size - 1])\n val list = ArrayList<Long>(n)\n for (index in size - n until size)\n list.add(this[index])\n return list\n}\n\n/**\n * Returns a list containing last [n] elements.\n * \n * @sample samples.collections.Collections.Transformations.take\n */\npublic fun FloatArray.takeLast(n: Int): List<Float> {\n require(n >= 0) { \"Requested element count $n is less than zero.\" }\n if (n == 0) return emptyList()\n val size = size\n if (n >= size) return toList()\n if (n == 1) return listOf(this[size - 1])\n val list = ArrayList<Float>(n)\n for (index in size - n until size)\n list.add(this[index])\n return list\n}\n\n/**\n * Returns a list containing last [n] elements.\n * \n * @sample samples.collections.Collections.Transformations.take\n */\npublic fun DoubleArray.takeLast(n: Int): List<Double> {\n require(n >= 0) { \"Requested element count $n is less than zero.\" }\n if (n == 0) return emptyList()\n val size = size\n if (n >= size) return toList()\n if (n == 1) return listOf(this[size - 1])\n val list = ArrayList<Double>(n)\n for (index in size - n until size)\n list.add(this[index])\n return list\n}\n\n/**\n * Returns a list containing last [n] elements.\n * \n * @sample samples.collections.Collections.Transformations.take\n */\npublic fun BooleanArray.takeLast(n: Int): List<Boolean> {\n require(n >= 0) { \"Requested element count $n is less than zero.\" }\n if (n == 0) return emptyList()\n val size = size\n if (n >= size) return toList()\n if (n == 1) return listOf(this[size - 1])\n val list = ArrayList<Boolean>(n)\n for (index in size - n until size)\n list.add(this[index])\n return list\n}\n\n/**\n * Returns a list containing last [n] elements.\n * \n * @sample samples.collections.Collections.Transformations.take\n */\npublic fun CharArray.takeLast(n: Int): List<Char> {\n require(n >= 0) { \"Requested element count $n is less than zero.\" }\n if (n == 0) return emptyList()\n val size = size\n if (n >= size) return toList()\n if (n == 1) return listOf(this[size - 1])\n val list = ArrayList<Char>(n)\n for (index in size - n until size)\n list.add(this[index])\n return list\n}\n\n/**\n * Returns a list containing last elements satisfying the given [predicate].\n * \n * @sample samples.collections.Collections.Transformations.take\n */\npublic inline fun <T> Array<out T>.takeLastWhile(predicate: (T) -> Boolean): List<T> {\n for (index in lastIndex downTo 0) {\n if (!predicate(this[index])) {\n return drop(index + 1)\n }\n }\n return toList()\n}\n\n/**\n * Returns a list containing last elements satisfying the given [predicate].\n * \n * @sample samples.collections.Collections.Transformations.take\n */\npublic inline fun ByteArray.takeLastWhile(predicate: (Byte) -> Boolean): List<Byte> {\n for (index in lastIndex downTo 0) {\n if (!predicate(this[index])) {\n return drop(index + 1)\n }\n }\n return toList()\n}\n\n/**\n * Returns a list containing last elements satisfying the given [predicate].\n * \n * @sample samples.collections.Collections.Transformations.take\n */\npublic inline fun ShortArray.takeLastWhile(predicate: (Short) -> Boolean): List<Short> {\n for (index in lastIndex downTo 0) {\n if (!predicate(this[index])) {\n return drop(index + 1)\n }\n }\n return toList()\n}\n\n/**\n * Returns a list containing last elements satisfying the given [predicate].\n * \n * @sample samples.collections.Collections.Transformations.take\n */\npublic inline fun IntArray.takeLastWhile(predicate: (Int) -> Boolean): List<Int> {\n for (index in lastIndex downTo 0) {\n if (!predicate(this[index])) {\n return drop(index + 1)\n }\n }\n return toList()\n}\n\n/**\n * Returns a list containing last elements satisfying the given [predicate].\n * \n * @sample samples.collections.Collections.Transformations.take\n */\npublic inline fun LongArray.takeLastWhile(predicate: (Long) -> Boolean): List<Long> {\n for (index in lastIndex downTo 0) {\n if (!predicate(this[index])) {\n return drop(index + 1)\n }\n }\n return toList()\n}\n\n/**\n * Returns a list containing last elements satisfying the given [predicate].\n * \n * @sample samples.collections.Collections.Transformations.take\n */\npublic inline fun FloatArray.takeLastWhile(predicate: (Float) -> Boolean): List<Float> {\n for (index in lastIndex downTo 0) {\n if (!predicate(this[index])) {\n return drop(index + 1)\n }\n }\n return toList()\n}\n\n/**\n * Returns a list containing last elements satisfying the given [predicate].\n * \n * @sample samples.collections.Collections.Transformations.take\n */\npublic inline fun DoubleArray.takeLastWhile(predicate: (Double) -> Boolean): List<Double> {\n for (index in lastIndex downTo 0) {\n if (!predicate(this[index])) {\n return drop(index + 1)\n }\n }\n return toList()\n}\n\n/**\n * Returns a list containing last elements satisfying the given [predicate].\n * \n * @sample samples.collections.Collections.Transformations.take\n */\npublic inline fun BooleanArray.takeLastWhile(predicate: (Boolean) -> Boolean): List<Boolean> {\n for (index in lastIndex downTo 0) {\n if (!predicate(this[index])) {\n return drop(index + 1)\n }\n }\n return toList()\n}\n\n/**\n * Returns a list containing last elements satisfying the given [predicate].\n * \n * @sample samples.collections.Collections.Transformations.take\n */\npublic inline fun CharArray.takeLastWhile(predicate: (Char) -> Boolean): List<Char> {\n for (index in lastIndex downTo 0) {\n if (!predicate(this[index])) {\n return drop(index + 1)\n }\n }\n return toList()\n}\n\n/**\n * Returns a list containing first elements satisfying the given [predicate].\n * \n * @sample samples.collections.Collections.Transformations.take\n */\npublic inline fun <T> Array<out T>.takeWhile(predicate: (T) -> Boolean): List<T> {\n val list = ArrayList<T>()\n for (item in this) {\n if (!predicate(item))\n break\n list.add(item)\n }\n return list\n}\n\n/**\n * Returns a list containing first elements satisfying the given [predicate].\n * \n * @sample samples.collections.Collections.Transformations.take\n */\npublic inline fun ByteArray.takeWhile(predicate: (Byte) -> Boolean): List<Byte> {\n val list = ArrayList<Byte>()\n for (item in this) {\n if (!predicate(item))\n break\n list.add(item)\n }\n return list\n}\n\n/**\n * Returns a list containing first elements satisfying the given [predicate].\n * \n * @sample samples.collections.Collections.Transformations.take\n */\npublic inline fun ShortArray.takeWhile(predicate: (Short) -> Boolean): List<Short> {\n val list = ArrayList<Short>()\n for (item in this) {\n if (!predicate(item))\n break\n list.add(item)\n }\n return list\n}\n\n/**\n * Returns a list containing first elements satisfying the given [predicate].\n * \n * @sample samples.collections.Collections.Transformations.take\n */\npublic inline fun IntArray.takeWhile(predicate: (Int) -> Boolean): List<Int> {\n val list = ArrayList<Int>()\n for (item in this) {\n if (!predicate(item))\n break\n list.add(item)\n }\n return list\n}\n\n/**\n * Returns a list containing first elements satisfying the given [predicate].\n * \n * @sample samples.collections.Collections.Transformations.take\n */\npublic inline fun LongArray.takeWhile(predicate: (Long) -> Boolean): List<Long> {\n val list = ArrayList<Long>()\n for (item in this) {\n if (!predicate(item))\n break\n list.add(item)\n }\n return list\n}\n\n/**\n * Returns a list containing first elements satisfying the given [predicate].\n * \n * @sample samples.collections.Collections.Transformations.take\n */\npublic inline fun FloatArray.takeWhile(predicate: (Float) -> Boolean): List<Float> {\n val list = ArrayList<Float>()\n for (item in this) {\n if (!predicate(item))\n break\n list.add(item)\n }\n return list\n}\n\n/**\n * Returns a list containing first elements satisfying the given [predicate].\n * \n * @sample samples.collections.Collections.Transformations.take\n */\npublic inline fun DoubleArray.takeWhile(predicate: (Double) -> Boolean): List<Double> {\n val list = ArrayList<Double>()\n for (item in this) {\n if (!predicate(item))\n break\n list.add(item)\n }\n return list\n}\n\n/**\n * Returns a list containing first elements satisfying the given [predicate].\n * \n * @sample samples.collections.Collections.Transformations.take\n */\npublic inline fun BooleanArray.takeWhile(predicate: (Boolean) -> Boolean): List<Boolean> {\n val list = ArrayList<Boolean>()\n for (item in this) {\n if (!predicate(item))\n break\n list.add(item)\n }\n return list\n}\n\n/**\n * Returns a list containing first elements satisfying the given [predicate].\n * \n * @sample samples.collections.Collections.Transformations.take\n */\npublic inline fun CharArray.takeWhile(predicate: (Char) -> Boolean): List<Char> {\n val list = ArrayList<Char>()\n for (item in this) {\n if (!predicate(item))\n break\n list.add(item)\n }\n return list\n}\n\n/**\n * Reverses elements in the array in-place.\n */\npublic fun <T> Array<T>.reverse(): Unit {\n val midPoint = (size / 2) - 1\n if (midPoint < 0) return\n var reverseIndex = lastIndex\n for (index in 0..midPoint) {\n val tmp = this[index]\n this[index] = this[reverseIndex]\n this[reverseIndex] = tmp\n reverseIndex--\n }\n}\n\n/**\n * Reverses elements in the array in-place.\n */\npublic fun ByteArray.reverse(): Unit {\n val midPoint = (size / 2) - 1\n if (midPoint < 0) return\n var reverseIndex = lastIndex\n for (index in 0..midPoint) {\n val tmp = this[index]\n this[index] = this[reverseIndex]\n this[reverseIndex] = tmp\n reverseIndex--\n }\n}\n\n/**\n * Reverses elements in the array in-place.\n */\npublic fun ShortArray.reverse(): Unit {\n val midPoint = (size / 2) - 1\n if (midPoint < 0) return\n var reverseIndex = lastIndex\n for (index in 0..midPoint) {\n val tmp = this[index]\n this[index] = this[reverseIndex]\n this[reverseIndex] = tmp\n reverseIndex--\n }\n}\n\n/**\n * Reverses elements in the array in-place.\n */\npublic fun IntArray.reverse(): Unit {\n val midPoint = (size / 2) - 1\n if (midPoint < 0) return\n var reverseIndex = lastIndex\n for (index in 0..midPoint) {\n val tmp = this[index]\n this[index] = this[reverseIndex]\n this[reverseIndex] = tmp\n reverseIndex--\n }\n}\n\n/**\n * Reverses elements in the array in-place.\n */\npublic fun LongArray.reverse(): Unit {\n val midPoint = (size / 2) - 1\n if (midPoint < 0) return\n var reverseIndex = lastIndex\n for (index in 0..midPoint) {\n val tmp = this[index]\n this[index] = this[reverseIndex]\n this[reverseIndex] = tmp\n reverseIndex--\n }\n}\n\n/**\n * Reverses elements in the array in-place.\n */\npublic fun FloatArray.reverse(): Unit {\n val midPoint = (size / 2) - 1\n if (midPoint < 0) return\n var reverseIndex = lastIndex\n for (index in 0..midPoint) {\n val tmp = this[index]\n this[index] = this[reverseIndex]\n this[reverseIndex] = tmp\n reverseIndex--\n }\n}\n\n/**\n * Reverses elements in the array in-place.\n */\npublic fun DoubleArray.reverse(): Unit {\n val midPoint = (size / 2) - 1\n if (midPoint < 0) return\n var reverseIndex = lastIndex\n for (index in 0..midPoint) {\n val tmp = this[index]\n this[index] = this[reverseIndex]\n this[reverseIndex] = tmp\n reverseIndex--\n }\n}\n\n/**\n * Reverses elements in the array in-place.\n */\npublic fun BooleanArray.reverse(): Unit {\n val midPoint = (size / 2) - 1\n if (midPoint < 0) return\n var reverseIndex = lastIndex\n for (index in 0..midPoint) {\n val tmp = this[index]\n this[index] = this[reverseIndex]\n this[reverseIndex] = tmp\n reverseIndex--\n }\n}\n\n/**\n * Reverses elements in the array in-place.\n */\npublic fun CharArray.reverse(): Unit {\n val midPoint = (size / 2) - 1\n if (midPoint < 0) return\n var reverseIndex = lastIndex\n for (index in 0..midPoint) {\n val tmp = this[index]\n this[index] = this[reverseIndex]\n this[reverseIndex] = tmp\n reverseIndex--\n }\n}\n\n/**\n * Returns a list with elements in reversed order.\n */\npublic fun <T> Array<out T>.reversed(): List<T> {\n if (isEmpty()) return emptyList()\n val list = toMutableList()\n list.reverse()\n return list\n}\n\n/**\n * Returns a list with elements in reversed order.\n */\npublic fun ByteArray.reversed(): List<Byte> {\n if (isEmpty()) return emptyList()\n val list = toMutableList()\n list.reverse()\n return list\n}\n\n/**\n * Returns a list with elements in reversed order.\n */\npublic fun ShortArray.reversed(): List<Short> {\n if (isEmpty()) return emptyList()\n val list = toMutableList()\n list.reverse()\n return list\n}\n\n/**\n * Returns a list with elements in reversed order.\n */\npublic fun IntArray.reversed(): List<Int> {\n if (isEmpty()) return emptyList()\n val list = toMutableList()\n list.reverse()\n return list\n}\n\n/**\n * Returns a list with elements in reversed order.\n */\npublic fun LongArray.reversed(): List<Long> {\n if (isEmpty()) return emptyList()\n val list = toMutableList()\n list.reverse()\n return list\n}\n\n/**\n * Returns a list with elements in reversed order.\n */\npublic fun FloatArray.reversed(): List<Float> {\n if (isEmpty()) return emptyList()\n val list = toMutableList()\n list.reverse()\n return list\n}\n\n/**\n * Returns a list with elements in reversed order.\n */\npublic fun DoubleArray.reversed(): List<Double> {\n if (isEmpty()) return emptyList()\n val list = toMutableList()\n list.reverse()\n return list\n}\n\n/**\n * Returns a list with elements in reversed order.\n */\npublic fun BooleanArray.reversed(): List<Boolean> {\n if (isEmpty()) return emptyList()\n val list = toMutableList()\n list.reverse()\n return list\n}\n\n/**\n * Returns a list with elements in reversed order.\n */\npublic fun CharArray.reversed(): List<Char> {\n if (isEmpty()) return emptyList()\n val list = toMutableList()\n list.reverse()\n return list\n}\n\n/**\n * Returns an array with elements of this array in reversed order.\n */\npublic fun <T> Array<T>.reversedArray(): Array<T> {\n if (isEmpty()) return this\n val result = arrayOfNulls(this, size)\n val lastIndex = lastIndex\n for (i in 0..lastIndex)\n result[lastIndex - i] = this[i]\n return result\n}\n\n/**\n * Returns an array with elements of this array in reversed order.\n */\npublic fun ByteArray.reversedArray(): ByteArray {\n if (isEmpty()) return this\n val result = ByteArray(size)\n val lastIndex = lastIndex\n for (i in 0..lastIndex)\n result[lastIndex - i] = this[i]\n return result\n}\n\n/**\n * Returns an array with elements of this array in reversed order.\n */\npublic fun ShortArray.reversedArray(): ShortArray {\n if (isEmpty()) return this\n val result = ShortArray(size)\n val lastIndex = lastIndex\n for (i in 0..lastIndex)\n result[lastIndex - i] = this[i]\n return result\n}\n\n/**\n * Returns an array with elements of this array in reversed order.\n */\npublic fun IntArray.reversedArray(): IntArray {\n if (isEmpty()) return this\n val result = IntArray(size)\n val lastIndex = lastIndex\n for (i in 0..lastIndex)\n result[lastIndex - i] = this[i]\n return result\n}\n\n/**\n * Returns an array with elements of this array in reversed order.\n */\npublic fun LongArray.reversedArray(): LongArray {\n if (isEmpty()) return this\n val result = LongArray(size)\n val lastIndex = lastIndex\n for (i in 0..lastIndex)\n result[lastIndex - i] = this[i]\n return result\n}\n\n/**\n * Returns an array with elements of this array in reversed order.\n */\npublic fun FloatArray.reversedArray(): FloatArray {\n if (isEmpty()) return this\n val result = FloatArray(size)\n val lastIndex = lastIndex\n for (i in 0..lastIndex)\n result[lastIndex - i] = this[i]\n return result\n}\n\n/**\n * Returns an array with elements of this array in reversed order.\n */\npublic fun DoubleArray.reversedArray(): DoubleArray {\n if (isEmpty()) return this\n val result = DoubleArray(size)\n val lastIndex = lastIndex\n for (i in 0..lastIndex)\n result[lastIndex - i] = this[i]\n return result\n}\n\n/**\n * Returns an array with elements of this array in reversed order.\n */\npublic fun BooleanArray.reversedArray(): BooleanArray {\n if (isEmpty()) return this\n val result = BooleanArray(size)\n val lastIndex = lastIndex\n for (i in 0..lastIndex)\n result[lastIndex - i] = this[i]\n return result\n}\n\n/**\n * Returns an array with elements of this array in reversed order.\n */\npublic fun CharArray.reversedArray(): CharArray {\n if (isEmpty()) return this\n val result = CharArray(size)\n val lastIndex = lastIndex\n for (i in 0..lastIndex)\n result[lastIndex - i] = this[i]\n return result\n}\n\n/**\n * Sorts elements in the array in-place according to natural sort order of the value returned by specified [selector] function.\n * \n * The sort is _stable_. It means that equal elements preserve their order relative to each other after sorting.\n */\npublic inline fun <T, R : Comparable<R>> Array<out T>.sortBy(crossinline selector: (T) -> R?): Unit {\n if (size > 1) sortWith(compareBy(selector))\n}\n\n/**\n * Sorts elements in the array in-place descending according to natural sort order of the value returned by specified [selector] function.\n * \n * The sort is _stable_. It means that equal elements preserve their order relative to each other after sorting.\n */\npublic inline fun <T, R : Comparable<R>> Array<out T>.sortByDescending(crossinline selector: (T) -> R?): Unit {\n if (size > 1) sortWith(compareByDescending(selector))\n}\n\n/**\n * Sorts elements in the array in-place descending according to their natural sort order.\n * \n * The sort is _stable_. It means that equal elements preserve their order relative to each other after sorting.\n */\npublic fun <T : Comparable<T>> Array<out T>.sortDescending(): Unit {\n sortWith(reverseOrder())\n}\n\n/**\n * Sorts elements in the array in-place descending according to their natural sort order.\n */\npublic fun ByteArray.sortDescending(): Unit {\n if (size > 1) {\n sort()\n reverse()\n }\n}\n\n/**\n * Sorts elements in the array in-place descending according to their natural sort order.\n */\npublic fun ShortArray.sortDescending(): Unit {\n if (size > 1) {\n sort()\n reverse()\n }\n}\n\n/**\n * Sorts elements in the array in-place descending according to their natural sort order.\n */\npublic fun IntArray.sortDescending(): Unit {\n if (size > 1) {\n sort()\n reverse()\n }\n}\n\n/**\n * Sorts elements in the array in-place descending according to their natural sort order.\n */\npublic fun LongArray.sortDescending(): Unit {\n if (size > 1) {\n sort()\n reverse()\n }\n}\n\n/**\n * Sorts elements in the array in-place descending according to their natural sort order.\n */\npublic fun FloatArray.sortDescending(): Unit {\n if (size > 1) {\n sort()\n reverse()\n }\n}\n\n/**\n * Sorts elements in the array in-place descending according to their natural sort order.\n */\npublic fun DoubleArray.sortDescending(): Unit {\n if (size > 1) {\n sort()\n reverse()\n }\n}\n\n/**\n * Sorts elements in the array in-place descending according to their natural sort order.\n */\npublic fun CharArray.sortDescending(): Unit {\n if (size > 1) {\n sort()\n reverse()\n }\n}\n\n/**\n * Returns a list of all elements sorted according to their natural sort order.\n * \n * The sort is _stable_. It means that equal elements preserve their order relative to each other after sorting.\n */\npublic fun <T : Comparable<T>> Array<out T>.sorted(): List<T> {\n return sortedArray().asList()\n}\n\n/**\n * Returns a list of all elements sorted according to their natural sort order.\n */\npublic fun ByteArray.sorted(): List<Byte> {\n return toTypedArray().apply { sort() }.asList()\n}\n\n/**\n * Returns a list of all elements sorted according to their natural sort order.\n */\npublic fun ShortArray.sorted(): List<Short> {\n return toTypedArray().apply { sort() }.asList()\n}\n\n/**\n * Returns a list of all elements sorted according to their natural sort order.\n */\npublic fun IntArray.sorted(): List<Int> {\n return toTypedArray().apply { sort() }.asList()\n}\n\n/**\n * Returns a list of all elements sorted according to their natural sort order.\n */\npublic fun LongArray.sorted(): List<Long> {\n return toTypedArray().apply { sort() }.asList()\n}\n\n/**\n * Returns a list of all elements sorted according to their natural sort order.\n */\npublic fun FloatArray.sorted(): List<Float> {\n return toTypedArray().apply { sort() }.asList()\n}\n\n/**\n * Returns a list of all elements sorted according to their natural sort order.\n */\npublic fun DoubleArray.sorted(): List<Double> {\n return toTypedArray().apply { sort() }.asList()\n}\n\n/**\n * Returns a list of all elements sorted according to their natural sort order.\n */\npublic fun CharArray.sorted(): List<Char> {\n return toTypedArray().apply { sort() }.asList()\n}\n\n/**\n * Returns an array with all elements of this array sorted according to their natural sort order.\n * \n * The sort is _stable_. It means that equal elements preserve their order relative to each other after sorting.\n */\npublic fun <T : Comparable<T>> Array<T>.sortedArray(): Array<T> {\n if (isEmpty()) return this\n return this.copyOf().apply { sort() }\n}\n\n/**\n * Returns an array with all elements of this array sorted according to their natural sort order.\n */\npublic fun ByteArray.sortedArray(): ByteArray {\n if (isEmpty()) return this\n return this.copyOf().apply { sort() }\n}\n\n/**\n * Returns an array with all elements of this array sorted according to their natural sort order.\n */\npublic fun ShortArray.sortedArray(): ShortArray {\n if (isEmpty()) return this\n return this.copyOf().apply { sort() }\n}\n\n/**\n * Returns an array with all elements of this array sorted according to their natural sort order.\n */\npublic fun IntArray.sortedArray(): IntArray {\n if (isEmpty()) return this\n return this.copyOf().apply { sort() }\n}\n\n/**\n * Returns an array with all elements of this array sorted according to their natural sort order.\n */\npublic fun LongArray.sortedArray(): LongArray {\n if (isEmpty()) return this\n return this.copyOf().apply { sort() }\n}\n\n/**\n * Returns an array with all elements of this array sorted according to their natural sort order.\n */\npublic fun FloatArray.sortedArray(): FloatArray {\n if (isEmpty()) return this\n return this.copyOf().apply { sort() }\n}\n\n/**\n * Returns an array with all elements of this array sorted according to their natural sort order.\n */\npublic fun DoubleArray.sortedArray(): DoubleArray {\n if (isEmpty()) return this\n return this.copyOf().apply { sort() }\n}\n\n/**\n * Returns an array with all elements of this array sorted according to their natural sort order.\n */\npublic fun CharArray.sortedArray(): CharArray {\n if (isEmpty()) return this\n return this.copyOf().apply { sort() }\n}\n\n/**\n * Returns an array with all elements of this array sorted descending according to their natural sort order.\n * \n * The sort is _stable_. It means that equal elements preserve their order relative to each other after sorting.\n */\npublic fun <T : Comparable<T>> Array<T>.sortedArrayDescending(): Array<T> {\n if (isEmpty()) return this\n return this.copyOf().apply { sortWith(reverseOrder()) }\n}\n\n/**\n * Returns an array with all elements of this array sorted descending according to their natural sort order.\n */\npublic fun ByteArray.sortedArrayDescending(): ByteArray {\n if (isEmpty()) return this\n return this.copyOf().apply { sortDescending() }\n}\n\n/**\n * Returns an array with all elements of this array sorted descending according to their natural sort order.\n */\npublic fun ShortArray.sortedArrayDescending(): ShortArray {\n if (isEmpty()) return this\n return this.copyOf().apply { sortDescending() }\n}\n\n/**\n * Returns an array with all elements of this array sorted descending according to their natural sort order.\n */\npublic fun IntArray.sortedArrayDescending(): IntArray {\n if (isEmpty()) return this\n return this.copyOf().apply { sortDescending() }\n}\n\n/**\n * Returns an array with all elements of this array sorted descending according to their natural sort order.\n */\npublic fun LongArray.sortedArrayDescending(): LongArray {\n if (isEmpty()) return this\n return this.copyOf().apply { sortDescending() }\n}\n\n/**\n * Returns an array with all elements of this array sorted descending according to their natural sort order.\n */\npublic fun FloatArray.sortedArrayDescending(): FloatArray {\n if (isEmpty()) return this\n return this.copyOf().apply { sortDescending() }\n}\n\n/**\n * Returns an array with all elements of this array sorted descending according to their natural sort order.\n */\npublic fun DoubleArray.sortedArrayDescending(): DoubleArray {\n if (isEmpty()) return this\n return this.copyOf().apply { sortDescending() }\n}\n\n/**\n * Returns an array with all elements of this array sorted descending according to their natural sort order.\n */\npublic fun CharArray.sortedArrayDescending(): CharArray {\n if (isEmpty()) return this\n return this.copyOf().apply { sortDescending() }\n}\n\n/**\n * Returns an array with all elements of this array sorted according the specified [comparator].\n * \n * The sort is _stable_. It means that equal elements preserve their order relative to each other after sorting.\n */\npublic fun <T> Array<out T>.sortedArrayWith(comparator: Comparator<in T>): Array<out T> {\n if (isEmpty()) return this\n return this.copyOf().apply { sortWith(comparator) }\n}\n\n/**\n * Returns a list of all elements sorted according to natural sort order of the value returned by specified [selector] function.\n * \n * The sort is _stable_. It means that equal elements preserve their order relative to each other after sorting.\n */\npublic inline fun <T, R : Comparable<R>> Array<out T>.sortedBy(crossinline selector: (T) -> R?): List<T> {\n return sortedWith(compareBy(selector))\n}\n\n/**\n * Returns a list of all elements sorted according to natural sort order of the value returned by specified [selector] function.\n */\npublic inline fun <R : Comparable<R>> ByteArray.sortedBy(crossinline selector: (Byte) -> R?): List<Byte> {\n return sortedWith(compareBy(selector))\n}\n\n/**\n * Returns a list of all elements sorted according to natural sort order of the value returned by specified [selector] function.\n */\npublic inline fun <R : Comparable<R>> ShortArray.sortedBy(crossinline selector: (Short) -> R?): List<Short> {\n return sortedWith(compareBy(selector))\n}\n\n/**\n * Returns a list of all elements sorted according to natural sort order of the value returned by specified [selector] function.\n */\npublic inline fun <R : Comparable<R>> IntArray.sortedBy(crossinline selector: (Int) -> R?): List<Int> {\n return sortedWith(compareBy(selector))\n}\n\n/**\n * Returns a list of all elements sorted according to natural sort order of the value returned by specified [selector] function.\n */\npublic inline fun <R : Comparable<R>> LongArray.sortedBy(crossinline selector: (Long) -> R?): List<Long> {\n return sortedWith(compareBy(selector))\n}\n\n/**\n * Returns a list of all elements sorted according to natural sort order of the value returned by specified [selector] function.\n */\npublic inline fun <R : Comparable<R>> FloatArray.sortedBy(crossinline selector: (Float) -> R?): List<Float> {\n return sortedWith(compareBy(selector))\n}\n\n/**\n * Returns a list of all elements sorted according to natural sort order of the value returned by specified [selector] function.\n */\npublic inline fun <R : Comparable<R>> DoubleArray.sortedBy(crossinline selector: (Double) -> R?): List<Double> {\n return sortedWith(compareBy(selector))\n}\n\n/**\n * Returns a list of all elements sorted according to natural sort order of the value returned by specified [selector] function.\n */\npublic inline fun <R : Comparable<R>> BooleanArray.sortedBy(crossinline selector: (Boolean) -> R?): List<Boolean> {\n return sortedWith(compareBy(selector))\n}\n\n/**\n * Returns a list of all elements sorted according to natural sort order of the value returned by specified [selector] function.\n */\npublic inline fun <R : Comparable<R>> CharArray.sortedBy(crossinline selector: (Char) -> R?): List<Char> {\n return sortedWith(compareBy(selector))\n}\n\n/**\n * Returns a list of all elements sorted descending according to natural sort order of the value returned by specified [selector] function.\n * \n * The sort is _stable_. It means that equal elements preserve their order relative to each other after sorting.\n */\npublic inline fun <T, R : Comparable<R>> Array<out T>.sortedByDescending(crossinline selector: (T) -> R?): List<T> {\n return sortedWith(compareByDescending(selector))\n}\n\n/**\n * Returns a list of all elements sorted descending according to natural sort order of the value returned by specified [selector] function.\n */\npublic inline fun <R : Comparable<R>> ByteArray.sortedByDescending(crossinline selector: (Byte) -> R?): List<Byte> {\n return sortedWith(compareByDescending(selector))\n}\n\n/**\n * Returns a list of all elements sorted descending according to natural sort order of the value returned by specified [selector] function.\n */\npublic inline fun <R : Comparable<R>> ShortArray.sortedByDescending(crossinline selector: (Short) -> R?): List<Short> {\n return sortedWith(compareByDescending(selector))\n}\n\n/**\n * Returns a list of all elements sorted descending according to natural sort order of the value returned by specified [selector] function.\n */\npublic inline fun <R : Comparable<R>> IntArray.sortedByDescending(crossinline selector: (Int) -> R?): List<Int> {\n return sortedWith(compareByDescending(selector))\n}\n\n/**\n * Returns a list of all elements sorted descending according to natural sort order of the value returned by specified [selector] function.\n */\npublic inline fun <R : Comparable<R>> LongArray.sortedByDescending(crossinline selector: (Long) -> R?): List<Long> {\n return sortedWith(compareByDescending(selector))\n}\n\n/**\n * Returns a list of all elements sorted descending according to natural sort order of the value returned by specified [selector] function.\n */\npublic inline fun <R : Comparable<R>> FloatArray.sortedByDescending(crossinline selector: (Float) -> R?): List<Float> {\n return sortedWith(compareByDescending(selector))\n}\n\n/**\n * Returns a list of all elements sorted descending according to natural sort order of the value returned by specified [selector] function.\n */\npublic inline fun <R : Comparable<R>> DoubleArray.sortedByDescending(crossinline selector: (Double) -> R?): List<Double> {\n return sortedWith(compareByDescending(selector))\n}\n\n/**\n * Returns a list of all elements sorted descending according to natural sort order of the value returned by specified [selector] function.\n */\npublic inline fun <R : Comparable<R>> BooleanArray.sortedByDescending(crossinline selector: (Boolean) -> R?): List<Boolean> {\n return sortedWith(compareByDescending(selector))\n}\n\n/**\n * Returns a list of all elements sorted descending according to natural sort order of the value returned by specified [selector] function.\n */\npublic inline fun <R : Comparable<R>> CharArray.sortedByDescending(crossinline selector: (Char) -> R?): List<Char> {\n return sortedWith(compareByDescending(selector))\n}\n\n/**\n * Returns a list of all elements sorted descending according to their natural sort order.\n * \n * The sort is _stable_. It means that equal elements preserve their order relative to each other after sorting.\n */\npublic fun <T : Comparable<T>> Array<out T>.sortedDescending(): List<T> {\n return sortedWith(reverseOrder())\n}\n\n/**\n * Returns a list of all elements sorted descending according to their natural sort order.\n */\npublic fun ByteArray.sortedDescending(): List<Byte> {\n return copyOf().apply { sort() }.reversed()\n}\n\n/**\n * Returns a list of all elements sorted descending according to their natural sort order.\n */\npublic fun ShortArray.sortedDescending(): List<Short> {\n return copyOf().apply { sort() }.reversed()\n}\n\n/**\n * Returns a list of all elements sorted descending according to their natural sort order.\n */\npublic fun IntArray.sortedDescending(): List<Int> {\n return copyOf().apply { sort() }.reversed()\n}\n\n/**\n * Returns a list of all elements sorted descending according to their natural sort order.\n */\npublic fun LongArray.sortedDescending(): List<Long> {\n return copyOf().apply { sort() }.reversed()\n}\n\n/**\n * Returns a list of all elements sorted descending according to their natural sort order.\n */\npublic fun FloatArray.sortedDescending(): List<Float> {\n return copyOf().apply { sort() }.reversed()\n}\n\n/**\n * Returns a list of all elements sorted descending according to their natural sort order.\n */\npublic fun DoubleArray.sortedDescending(): List<Double> {\n return copyOf().apply { sort() }.reversed()\n}\n\n/**\n * Returns a list of all elements sorted descending according to their natural sort order.\n */\npublic fun CharArray.sortedDescending(): List<Char> {\n return copyOf().apply { sort() }.reversed()\n}\n\n/**\n * Returns a list of all elements sorted according to the specified [comparator].\n * \n * The sort is _stable_. It means that equal elements preserve their order relative to each other after sorting.\n */\npublic fun <T> Array<out T>.sortedWith(comparator: Comparator<in T>): List<T> {\n return sortedArrayWith(comparator).asList()\n}\n\n/**\n * Returns a list of all elements sorted according to the specified [comparator].\n */\npublic fun ByteArray.sortedWith(comparator: Comparator<in Byte>): List<Byte> {\n return toTypedArray().apply { sortWith(comparator) }.asList()\n}\n\n/**\n * Returns a list of all elements sorted according to the specified [comparator].\n */\npublic fun ShortArray.sortedWith(comparator: Comparator<in Short>): List<Short> {\n return toTypedArray().apply { sortWith(comparator) }.asList()\n}\n\n/**\n * Returns a list of all elements sorted according to the specified [comparator].\n */\npublic fun IntArray.sortedWith(comparator: Comparator<in Int>): List<Int> {\n return toTypedArray().apply { sortWith(comparator) }.asList()\n}\n\n/**\n * Returns a list of all elements sorted according to the specified [comparator].\n */\npublic fun LongArray.sortedWith(comparator: Comparator<in Long>): List<Long> {\n return toTypedArray().apply { sortWith(comparator) }.asList()\n}\n\n/**\n * Returns a list of all elements sorted according to the specified [comparator].\n */\npublic fun FloatArray.sortedWith(comparator: Comparator<in Float>): List<Float> {\n return toTypedArray().apply { sortWith(comparator) }.asList()\n}\n\n/**\n * Returns a list of all elements sorted according to the specified [comparator].\n */\npublic fun DoubleArray.sortedWith(comparator: Comparator<in Double>): List<Double> {\n return toTypedArray().apply { sortWith(comparator) }.asList()\n}\n\n/**\n * Returns a list of all elements sorted according to the specified [comparator].\n */\npublic fun BooleanArray.sortedWith(comparator: Comparator<in Boolean>): List<Boolean> {\n return toTypedArray().apply { sortWith(comparator) }.asList()\n}\n\n/**\n * Returns a list of all elements sorted according to the specified [comparator].\n */\npublic fun CharArray.sortedWith(comparator: Comparator<in Char>): List<Char> {\n return toTypedArray().apply { sortWith(comparator) }.asList()\n}\n\n/**\n * Returns a [List] that wraps the original array.\n */\npublic expect fun <T> Array<out T>.asList(): List<T>\n\n/**\n * Returns a [List] that wraps the original array.\n */\npublic expect fun ByteArray.asList(): List<Byte>\n\n/**\n * Returns a [List] that wraps the original array.\n */\npublic expect fun ShortArray.asList(): List<Short>\n\n/**\n * Returns a [List] that wraps the original array.\n */\npublic expect fun IntArray.asList(): List<Int>\n\n/**\n * Returns a [List] that wraps the original array.\n */\npublic expect fun LongArray.asList(): List<Long>\n\n/**\n * Returns a [List] that wraps the original array.\n */\npublic expect fun FloatArray.asList(): List<Float>\n\n/**\n * Returns a [List] that wraps the original array.\n */\npublic expect fun DoubleArray.asList(): List<Double>\n\n/**\n * Returns a [List] that wraps the original array.\n */\npublic expect fun BooleanArray.asList(): List<Boolean>\n\n/**\n * Returns a [List] that wraps the original array.\n */\npublic expect fun CharArray.asList(): List<Char>\n\n/**\n * Returns `true` if the two specified arrays are *deeply* equal to one another,\n * i.e. contain the same number of the same elements in the same order.\n * \n * If two corresponding elements are nested arrays, they are also compared deeply.\n * If any of arrays contains itself on any nesting level the behavior is undefined.\n * \n * The elements of other types are compared for equality with the [equals][Any.equals] function.\n * For floating point numbers it means that `NaN` is equal to itself and `-0.0` is not equal to `0.0`.\n */\n@SinceKotlin(\"1.1\")\npublic expect infix fun <T> Array<out T>.contentDeepEquals(other: Array<out T>): Boolean\n\n/**\n * Returns a hash code based on the contents of this array as if it is [List].\n * Nested arrays are treated as lists too.\n * \n * If any of arrays contains itself on any nesting level the behavior is undefined.\n */\n@SinceKotlin(\"1.1\")\npublic expect fun <T> Array<out T>.contentDeepHashCode(): Int\n\n/**\n * Returns a string representation of the contents of this array as if it is a [List].\n * Nested arrays are treated as lists too.\n * \n * If any of arrays contains itself on any nesting level that reference\n * is rendered as `\"[...]\"` to prevent recursion.\n * \n * @sample samples.collections.Arrays.ContentOperations.contentDeepToString\n */\n@SinceKotlin(\"1.1\")\npublic expect fun <T> Array<out T>.contentDeepToString(): String\n\n/**\n * Returns `true` if the two specified arrays are *structurally* equal to one another,\n * i.e. contain the same number of the same elements in the same order.\n * \n * The elements are compared for equality with the [equals][Any.equals] function.\n * For floating point numbers it means that `NaN` is equal to itself and `-0.0` is not equal to `0.0`.\n */\n@SinceKotlin(\"1.1\")\npublic expect infix fun <T> Array<out T>.contentEquals(other: Array<out T>): Boolean\n\n/**\n * Returns `true` if the two specified arrays are *structurally* equal to one another,\n * i.e. contain the same number of the same elements in the same order.\n * \n * The elements are compared for equality with the [equals][Any.equals] function.\n * For floating point numbers it means that `NaN` is equal to itself and `-0.0` is not equal to `0.0`.\n */\n@SinceKotlin(\"1.1\")\npublic expect infix fun ByteArray.contentEquals(other: ByteArray): Boolean\n\n/**\n * Returns `true` if the two specified arrays are *structurally* equal to one another,\n * i.e. contain the same number of the same elements in the same order.\n * \n * The elements are compared for equality with the [equals][Any.equals] function.\n * For floating point numbers it means that `NaN` is equal to itself and `-0.0` is not equal to `0.0`.\n */\n@SinceKotlin(\"1.1\")\npublic expect infix fun ShortArray.contentEquals(other: ShortArray): Boolean\n\n/**\n * Returns `true` if the two specified arrays are *structurally* equal to one another,\n * i.e. contain the same number of the same elements in the same order.\n * \n * The elements are compared for equality with the [equals][Any.equals] function.\n * For floating point numbers it means that `NaN` is equal to itself and `-0.0` is not equal to `0.0`.\n */\n@SinceKotlin(\"1.1\")\npublic expect infix fun IntArray.contentEquals(other: IntArray): Boolean\n\n/**\n * Returns `true` if the two specified arrays are *structurally* equal to one another,\n * i.e. contain the same number of the same elements in the same order.\n * \n * The elements are compared for equality with the [equals][Any.equals] function.\n * For floating point numbers it means that `NaN` is equal to itself and `-0.0` is not equal to `0.0`.\n */\n@SinceKotlin(\"1.1\")\npublic expect infix fun LongArray.contentEquals(other: LongArray): Boolean\n\n/**\n * Returns `true` if the two specified arrays are *structurally* equal to one another,\n * i.e. contain the same number of the same elements in the same order.\n * \n * The elements are compared for equality with the [equals][Any.equals] function.\n * For floating point numbers it means that `NaN` is equal to itself and `-0.0` is not equal to `0.0`.\n */\n@SinceKotlin(\"1.1\")\npublic expect infix fun FloatArray.contentEquals(other: FloatArray): Boolean\n\n/**\n * Returns `true` if the two specified arrays are *structurally* equal to one another,\n * i.e. contain the same number of the same elements in the same order.\n * \n * The elements are compared for equality with the [equals][Any.equals] function.\n * For floating point numbers it means that `NaN` is equal to itself and `-0.0` is not equal to `0.0`.\n */\n@SinceKotlin(\"1.1\")\npublic expect infix fun DoubleArray.contentEquals(other: DoubleArray): Boolean\n\n/**\n * Returns `true` if the two specified arrays are *structurally* equal to one another,\n * i.e. contain the same number of the same elements in the same order.\n * \n * The elements are compared for equality with the [equals][Any.equals] function.\n * For floating point numbers it means that `NaN` is equal to itself and `-0.0` is not equal to `0.0`.\n */\n@SinceKotlin(\"1.1\")\npublic expect infix fun BooleanArray.contentEquals(other: BooleanArray): Boolean\n\n/**\n * Returns `true` if the two specified arrays are *structurally* equal to one another,\n * i.e. contain the same number of the same elements in the same order.\n * \n * The elements are compared for equality with the [equals][Any.equals] function.\n * For floating point numbers it means that `NaN` is equal to itself and `-0.0` is not equal to `0.0`.\n */\n@SinceKotlin(\"1.1\")\npublic expect infix fun CharArray.contentEquals(other: CharArray): Boolean\n\n/**\n * Returns a hash code based on the contents of this array as if it is [List].\n */\n@SinceKotlin(\"1.1\")\npublic expect fun <T> Array<out T>.contentHashCode(): Int\n\n/**\n * Returns a hash code based on the contents of this array as if it is [List].\n */\n@SinceKotlin(\"1.1\")\npublic expect fun ByteArray.contentHashCode(): Int\n\n/**\n * Returns a hash code based on the contents of this array as if it is [List].\n */\n@SinceKotlin(\"1.1\")\npublic expect fun ShortArray.contentHashCode(): Int\n\n/**\n * Returns a hash code based on the contents of this array as if it is [List].\n */\n@SinceKotlin(\"1.1\")\npublic expect fun IntArray.contentHashCode(): Int\n\n/**\n * Returns a hash code based on the contents of this array as if it is [List].\n */\n@SinceKotlin(\"1.1\")\npublic expect fun LongArray.contentHashCode(): Int\n\n/**\n * Returns a hash code based on the contents of this array as if it is [List].\n */\n@SinceKotlin(\"1.1\")\npublic expect fun FloatArray.contentHashCode(): Int\n\n/**\n * Returns a hash code based on the contents of this array as if it is [List].\n */\n@SinceKotlin(\"1.1\")\npublic expect fun DoubleArray.contentHashCode(): Int\n\n/**\n * Returns a hash code based on the contents of this array as if it is [List].\n */\n@SinceKotlin(\"1.1\")\npublic expect fun BooleanArray.contentHashCode(): Int\n\n/**\n * Returns a hash code based on the contents of this array as if it is [List].\n */\n@SinceKotlin(\"1.1\")\npublic expect fun CharArray.contentHashCode(): Int\n\n/**\n * Returns a string representation of the contents of the specified array as if it is [List].\n * \n * @sample samples.collections.Arrays.ContentOperations.contentToString\n */\n@SinceKotlin(\"1.1\")\npublic expect fun <T> Array<out T>.contentToString(): String\n\n/**\n * Returns a string representation of the contents of the specified array as if it is [List].\n * \n * @sample samples.collections.Arrays.ContentOperations.contentToString\n */\n@SinceKotlin(\"1.1\")\npublic expect fun ByteArray.contentToString(): String\n\n/**\n * Returns a string representation of the contents of the specified array as if it is [List].\n * \n * @sample samples.collections.Arrays.ContentOperations.contentToString\n */\n@SinceKotlin(\"1.1\")\npublic expect fun ShortArray.contentToString(): String\n\n/**\n * Returns a string representation of the contents of the specified array as if it is [List].\n * \n * @sample samples.collections.Arrays.ContentOperations.contentToString\n */\n@SinceKotlin(\"1.1\")\npublic expect fun IntArray.contentToString(): String\n\n/**\n * Returns a string representation of the contents of the specified array as if it is [List].\n * \n * @sample samples.collections.Arrays.ContentOperations.contentToString\n */\n@SinceKotlin(\"1.1\")\npublic expect fun LongArray.contentToString(): String\n\n/**\n * Returns a string representation of the contents of the specified array as if it is [List].\n * \n * @sample samples.collections.Arrays.ContentOperations.contentToString\n */\n@SinceKotlin(\"1.1\")\npublic expect fun FloatArray.contentToString(): String\n\n/**\n * Returns a string representation of the contents of the specified array as if it is [List].\n * \n * @sample samples.collections.Arrays.ContentOperations.contentToString\n */\n@SinceKotlin(\"1.1\")\npublic expect fun DoubleArray.contentToString(): String\n\n/**\n * Returns a string representation of the contents of the specified array as if it is [List].\n * \n * @sample samples.collections.Arrays.ContentOperations.contentToString\n */\n@SinceKotlin(\"1.1\")\npublic expect fun BooleanArray.contentToString(): String\n\n/**\n * Returns a string representation of the contents of the specified array as if it is [List].\n * \n * @sample samples.collections.Arrays.ContentOperations.contentToString\n */\n@SinceKotlin(\"1.1\")\npublic expect fun CharArray.contentToString(): String\n\n/**\n * Copies this array or its subrange into the [destination] array and returns that array.\n * \n * It's allowed to pass the same array in the [destination] and even specify the subrange so that it overlaps with the destination range.\n * \n * @param destination the array to copy to.\n * @param destinationOffset the position in the [destination] array to copy to, 0 by default.\n * @param startIndex the beginning (inclusive) of the subrange to copy, 0 by default.\n * @param endIndex the end (exclusive) of the subrange to copy, size of this array by default.\n * \n * @throws IndexOutOfBoundsException or [IllegalArgumentException] when [startIndex] or [endIndex] is out of range of this array indices or when `startIndex > endIndex`.\n * @throws IndexOutOfBoundsException when the subrange doesn't fit into the [destination] array starting at the specified [destinationOffset],\n * or when that index is out of the [destination] array indices range.\n * \n * @return the [destination] array.\n */\n@SinceKotlin(\"1.3\")\npublic expect fun <T> Array<out T>.copyInto(destination: Array<T>, destinationOffset: Int = 0, startIndex: Int = 0, endIndex: Int = size): Array<T>\n\n/**\n * Copies this array or its subrange into the [destination] array and returns that array.\n * \n * It's allowed to pass the same array in the [destination] and even specify the subrange so that it overlaps with the destination range.\n * \n * @param destination the array to copy to.\n * @param destinationOffset the position in the [destination] array to copy to, 0 by default.\n * @param startIndex the beginning (inclusive) of the subrange to copy, 0 by default.\n * @param endIndex the end (exclusive) of the subrange to copy, size of this array by default.\n * \n * @throws IndexOutOfBoundsException or [IllegalArgumentException] when [startIndex] or [endIndex] is out of range of this array indices or when `startIndex > endIndex`.\n * @throws IndexOutOfBoundsException when the subrange doesn't fit into the [destination] array starting at the specified [destinationOffset],\n * or when that index is out of the [destination] array indices range.\n * \n * @return the [destination] array.\n */\n@SinceKotlin(\"1.3\")\npublic expect fun ByteArray.copyInto(destination: ByteArray, destinationOffset: Int = 0, startIndex: Int = 0, endIndex: Int = size): ByteArray\n\n/**\n * Copies this array or its subrange into the [destination] array and returns that array.\n * \n * It's allowed to pass the same array in the [destination] and even specify the subrange so that it overlaps with the destination range.\n * \n * @param destination the array to copy to.\n * @param destinationOffset the position in the [destination] array to copy to, 0 by default.\n * @param startIndex the beginning (inclusive) of the subrange to copy, 0 by default.\n * @param endIndex the end (exclusive) of the subrange to copy, size of this array by default.\n * \n * @throws IndexOutOfBoundsException or [IllegalArgumentException] when [startIndex] or [endIndex] is out of range of this array indices or when `startIndex > endIndex`.\n * @throws IndexOutOfBoundsException when the subrange doesn't fit into the [destination] array starting at the specified [destinationOffset],\n * or when that index is out of the [destination] array indices range.\n * \n * @return the [destination] array.\n */\n@SinceKotlin(\"1.3\")\npublic expect fun ShortArray.copyInto(destination: ShortArray, destinationOffset: Int = 0, startIndex: Int = 0, endIndex: Int = size): ShortArray\n\n/**\n * Copies this array or its subrange into the [destination] array and returns that array.\n * \n * It's allowed to pass the same array in the [destination] and even specify the subrange so that it overlaps with the destination range.\n * \n * @param destination the array to copy to.\n * @param destinationOffset the position in the [destination] array to copy to, 0 by default.\n * @param startIndex the beginning (inclusive) of the subrange to copy, 0 by default.\n * @param endIndex the end (exclusive) of the subrange to copy, size of this array by default.\n * \n * @throws IndexOutOfBoundsException or [IllegalArgumentException] when [startIndex] or [endIndex] is out of range of this array indices or when `startIndex > endIndex`.\n * @throws IndexOutOfBoundsException when the subrange doesn't fit into the [destination] array starting at the specified [destinationOffset],\n * or when that index is out of the [destination] array indices range.\n * \n * @return the [destination] array.\n */\n@SinceKotlin(\"1.3\")\npublic expect fun IntArray.copyInto(destination: IntArray, destinationOffset: Int = 0, startIndex: Int = 0, endIndex: Int = size): IntArray\n\n/**\n * Copies this array or its subrange into the [destination] array and returns that array.\n * \n * It's allowed to pass the same array in the [destination] and even specify the subrange so that it overlaps with the destination range.\n * \n * @param destination the array to copy to.\n * @param destinationOffset the position in the [destination] array to copy to, 0 by default.\n * @param startIndex the beginning (inclusive) of the subrange to copy, 0 by default.\n * @param endIndex the end (exclusive) of the subrange to copy, size of this array by default.\n * \n * @throws IndexOutOfBoundsException or [IllegalArgumentException] when [startIndex] or [endIndex] is out of range of this array indices or when `startIndex > endIndex`.\n * @throws IndexOutOfBoundsException when the subrange doesn't fit into the [destination] array starting at the specified [destinationOffset],\n * or when that index is out of the [destination] array indices range.\n * \n * @return the [destination] array.\n */\n@SinceKotlin(\"1.3\")\npublic expect fun LongArray.copyInto(destination: LongArray, destinationOffset: Int = 0, startIndex: Int = 0, endIndex: Int = size): LongArray\n\n/**\n * Copies this array or its subrange into the [destination] array and returns that array.\n * \n * It's allowed to pass the same array in the [destination] and even specify the subrange so that it overlaps with the destination range.\n * \n * @param destination the array to copy to.\n * @param destinationOffset the position in the [destination] array to copy to, 0 by default.\n * @param startIndex the beginning (inclusive) of the subrange to copy, 0 by default.\n * @param endIndex the end (exclusive) of the subrange to copy, size of this array by default.\n * \n * @throws IndexOutOfBoundsException or [IllegalArgumentException] when [startIndex] or [endIndex] is out of range of this array indices or when `startIndex > endIndex`.\n * @throws IndexOutOfBoundsException when the subrange doesn't fit into the [destination] array starting at the specified [destinationOffset],\n * or when that index is out of the [destination] array indices range.\n * \n * @return the [destination] array.\n */\n@SinceKotlin(\"1.3\")\npublic expect fun FloatArray.copyInto(destination: FloatArray, destinationOffset: Int = 0, startIndex: Int = 0, endIndex: Int = size): FloatArray\n\n/**\n * Copies this array or its subrange into the [destination] array and returns that array.\n * \n * It's allowed to pass the same array in the [destination] and even specify the subrange so that it overlaps with the destination range.\n * \n * @param destination the array to copy to.\n * @param destinationOffset the position in the [destination] array to copy to, 0 by default.\n * @param startIndex the beginning (inclusive) of the subrange to copy, 0 by default.\n * @param endIndex the end (exclusive) of the subrange to copy, size of this array by default.\n * \n * @throws IndexOutOfBoundsException or [IllegalArgumentException] when [startIndex] or [endIndex] is out of range of this array indices or when `startIndex > endIndex`.\n * @throws IndexOutOfBoundsException when the subrange doesn't fit into the [destination] array starting at the specified [destinationOffset],\n * or when that index is out of the [destination] array indices range.\n * \n * @return the [destination] array.\n */\n@SinceKotlin(\"1.3\")\npublic expect fun DoubleArray.copyInto(destination: DoubleArray, destinationOffset: Int = 0, startIndex: Int = 0, endIndex: Int = size): DoubleArray\n\n/**\n * Copies this array or its subrange into the [destination] array and returns that array.\n * \n * It's allowed to pass the same array in the [destination] and even specify the subrange so that it overlaps with the destination range.\n * \n * @param destination the array to copy to.\n * @param destinationOffset the position in the [destination] array to copy to, 0 by default.\n * @param startIndex the beginning (inclusive) of the subrange to copy, 0 by default.\n * @param endIndex the end (exclusive) of the subrange to copy, size of this array by default.\n * \n * @throws IndexOutOfBoundsException or [IllegalArgumentException] when [startIndex] or [endIndex] is out of range of this array indices or when `startIndex > endIndex`.\n * @throws IndexOutOfBoundsException when the subrange doesn't fit into the [destination] array starting at the specified [destinationOffset],\n * or when that index is out of the [destination] array indices range.\n * \n * @return the [destination] array.\n */\n@SinceKotlin(\"1.3\")\npublic expect fun BooleanArray.copyInto(destination: BooleanArray, destinationOffset: Int = 0, startIndex: Int = 0, endIndex: Int = size): BooleanArray\n\n/**\n * Copies this array or its subrange into the [destination] array and returns that array.\n * \n * It's allowed to pass the same array in the [destination] and even specify the subrange so that it overlaps with the destination range.\n * \n * @param destination the array to copy to.\n * @param destinationOffset the position in the [destination] array to copy to, 0 by default.\n * @param startIndex the beginning (inclusive) of the subrange to copy, 0 by default.\n * @param endIndex the end (exclusive) of the subrange to copy, size of this array by default.\n * \n * @throws IndexOutOfBoundsException or [IllegalArgumentException] when [startIndex] or [endIndex] is out of range of this array indices or when `startIndex > endIndex`.\n * @throws IndexOutOfBoundsException when the subrange doesn't fit into the [destination] array starting at the specified [destinationOffset],\n * or when that index is out of the [destination] array indices range.\n * \n * @return the [destination] array.\n */\n@SinceKotlin(\"1.3\")\npublic expect fun CharArray.copyInto(destination: CharArray, destinationOffset: Int = 0, startIndex: Int = 0, endIndex: Int = size): CharArray\n\n/**\n * Returns new array which is a copy of the original array.\n * \n * @sample samples.collections.Arrays.CopyOfOperations.copyOf\n */\n@Suppress(\"NO_ACTUAL_FOR_EXPECT\")\npublic expect fun <T> Array<T>.copyOf(): Array<T>\n\n/**\n * Returns new array which is a copy of the original array.\n * \n * @sample samples.collections.Arrays.CopyOfOperations.copyOf\n */\npublic expect fun ByteArray.copyOf(): ByteArray\n\n/**\n * Returns new array which is a copy of the original array.\n * \n * @sample samples.collections.Arrays.CopyOfOperations.copyOf\n */\npublic expect fun ShortArray.copyOf(): ShortArray\n\n/**\n * Returns new array which is a copy of the original array.\n * \n * @sample samples.collections.Arrays.CopyOfOperations.copyOf\n */\npublic expect fun IntArray.copyOf(): IntArray\n\n/**\n * Returns new array which is a copy of the original array.\n * \n * @sample samples.collections.Arrays.CopyOfOperations.copyOf\n */\npublic expect fun LongArray.copyOf(): LongArray\n\n/**\n * Returns new array which is a copy of the original array.\n * \n * @sample samples.collections.Arrays.CopyOfOperations.copyOf\n */\npublic expect fun FloatArray.copyOf(): FloatArray\n\n/**\n * Returns new array which is a copy of the original array.\n * \n * @sample samples.collections.Arrays.CopyOfOperations.copyOf\n */\npublic expect fun DoubleArray.copyOf(): DoubleArray\n\n/**\n * Returns new array which is a copy of the original array.\n * \n * @sample samples.collections.Arrays.CopyOfOperations.copyOf\n */\npublic expect fun BooleanArray.copyOf(): BooleanArray\n\n/**\n * Returns new array which is a copy of the original array.\n * \n * @sample samples.collections.Arrays.CopyOfOperations.copyOf\n */\npublic expect fun CharArray.copyOf(): CharArray\n\n/**\n * Returns new array which is a copy of the original array, resized to the given [newSize].\n * The copy is either truncated or padded at the end with zero values if necessary.\n * \n * - If [newSize] is less than the size of the original array, the copy array is truncated to the [newSize].\n * - If [newSize] is greater than the size of the original array, the extra elements in the copy array are filled with zero values.\n * \n * @sample samples.collections.Arrays.CopyOfOperations.resizedPrimitiveCopyOf\n */\npublic expect fun ByteArray.copyOf(newSize: Int): ByteArray\n\n/**\n * Returns new array which is a copy of the original array, resized to the given [newSize].\n * The copy is either truncated or padded at the end with zero values if necessary.\n * \n * - If [newSize] is less than the size of the original array, the copy array is truncated to the [newSize].\n * - If [newSize] is greater than the size of the original array, the extra elements in the copy array are filled with zero values.\n * \n * @sample samples.collections.Arrays.CopyOfOperations.resizedPrimitiveCopyOf\n */\npublic expect fun ShortArray.copyOf(newSize: Int): ShortArray\n\n/**\n * Returns new array which is a copy of the original array, resized to the given [newSize].\n * The copy is either truncated or padded at the end with zero values if necessary.\n * \n * - If [newSize] is less than the size of the original array, the copy array is truncated to the [newSize].\n * - If [newSize] is greater than the size of the original array, the extra elements in the copy array are filled with zero values.\n * \n * @sample samples.collections.Arrays.CopyOfOperations.resizedPrimitiveCopyOf\n */\npublic expect fun IntArray.copyOf(newSize: Int): IntArray\n\n/**\n * Returns new array which is a copy of the original array, resized to the given [newSize].\n * The copy is either truncated or padded at the end with zero values if necessary.\n * \n * - If [newSize] is less than the size of the original array, the copy array is truncated to the [newSize].\n * - If [newSize] is greater than the size of the original array, the extra elements in the copy array are filled with zero values.\n * \n * @sample samples.collections.Arrays.CopyOfOperations.resizedPrimitiveCopyOf\n */\npublic expect fun LongArray.copyOf(newSize: Int): LongArray\n\n/**\n * Returns new array which is a copy of the original array, resized to the given [newSize].\n * The copy is either truncated or padded at the end with zero values if necessary.\n * \n * - If [newSize] is less than the size of the original array, the copy array is truncated to the [newSize].\n * - If [newSize] is greater than the size of the original array, the extra elements in the copy array are filled with zero values.\n * \n * @sample samples.collections.Arrays.CopyOfOperations.resizedPrimitiveCopyOf\n */\npublic expect fun FloatArray.copyOf(newSize: Int): FloatArray\n\n/**\n * Returns new array which is a copy of the original array, resized to the given [newSize].\n * The copy is either truncated or padded at the end with zero values if necessary.\n * \n * - If [newSize] is less than the size of the original array, the copy array is truncated to the [newSize].\n * - If [newSize] is greater than the size of the original array, the extra elements in the copy array are filled with zero values.\n * \n * @sample samples.collections.Arrays.CopyOfOperations.resizedPrimitiveCopyOf\n */\npublic expect fun DoubleArray.copyOf(newSize: Int): DoubleArray\n\n/**\n * Returns new array which is a copy of the original array, resized to the given [newSize].\n * The copy is either truncated or padded at the end with `false` values if necessary.\n * \n * - If [newSize] is less than the size of the original array, the copy array is truncated to the [newSize].\n * - If [newSize] is greater than the size of the original array, the extra elements in the copy array are filled with `false` values.\n * \n * @sample samples.collections.Arrays.CopyOfOperations.resizedPrimitiveCopyOf\n */\npublic expect fun BooleanArray.copyOf(newSize: Int): BooleanArray\n\n/**\n * Returns new array which is a copy of the original array, resized to the given [newSize].\n * The copy is either truncated or padded at the end with null char (`\\u0000`) values if necessary.\n * \n * - If [newSize] is less than the size of the original array, the copy array is truncated to the [newSize].\n * - If [newSize] is greater than the size of the original array, the extra elements in the copy array are filled with null char (`\\u0000`) values.\n * \n * @sample samples.collections.Arrays.CopyOfOperations.resizedPrimitiveCopyOf\n */\npublic expect fun CharArray.copyOf(newSize: Int): CharArray\n\n/**\n * Returns new array which is a copy of the original array, resized to the given [newSize].\n * The copy is either truncated or padded at the end with `null` values if necessary.\n * \n * - If [newSize] is less than the size of the original array, the copy array is truncated to the [newSize].\n * - If [newSize] is greater than the size of the original array, the extra elements in the copy array are filled with `null` values.\n * \n * @sample samples.collections.Arrays.CopyOfOperations.resizingCopyOf\n */\n@Suppress(\"NO_ACTUAL_FOR_EXPECT\")\npublic expect fun <T> Array<T>.copyOf(newSize: Int): Array<T?>\n\n/**\n * Returns a new array which is a copy of the specified range of the original array.\n * \n * @param fromIndex the start of the range (inclusive), must be in `0..array.size`\n * @param toIndex the end of the range (exclusive), must be in `fromIndex..array.size`\n */\n@Suppress(\"NO_ACTUAL_FOR_EXPECT\")\npublic expect fun <T> Array<T>.copyOfRange(fromIndex: Int, toIndex: Int): Array<T>\n\n/**\n * Returns a new array which is a copy of the specified range of the original array.\n * \n * @param fromIndex the start of the range (inclusive), must be in `0..array.size`\n * @param toIndex the end of the range (exclusive), must be in `fromIndex..array.size`\n */\npublic expect fun ByteArray.copyOfRange(fromIndex: Int, toIndex: Int): ByteArray\n\n/**\n * Returns a new array which is a copy of the specified range of the original array.\n * \n * @param fromIndex the start of the range (inclusive), must be in `0..array.size`\n * @param toIndex the end of the range (exclusive), must be in `fromIndex..array.size`\n */\npublic expect fun ShortArray.copyOfRange(fromIndex: Int, toIndex: Int): ShortArray\n\n/**\n * Returns a new array which is a copy of the specified range of the original array.\n * \n * @param fromIndex the start of the range (inclusive), must be in `0..array.size`\n * @param toIndex the end of the range (exclusive), must be in `fromIndex..array.size`\n */\npublic expect fun IntArray.copyOfRange(fromIndex: Int, toIndex: Int): IntArray\n\n/**\n * Returns a new array which is a copy of the specified range of the original array.\n * \n * @param fromIndex the start of the range (inclusive), must be in `0..array.size`\n * @param toIndex the end of the range (exclusive), must be in `fromIndex..array.size`\n */\npublic expect fun LongArray.copyOfRange(fromIndex: Int, toIndex: Int): LongArray\n\n/**\n * Returns a new array which is a copy of the specified range of the original array.\n * \n * @param fromIndex the start of the range (inclusive), must be in `0..array.size`\n * @param toIndex the end of the range (exclusive), must be in `fromIndex..array.size`\n */\npublic expect fun FloatArray.copyOfRange(fromIndex: Int, toIndex: Int): FloatArray\n\n/**\n * Returns a new array which is a copy of the specified range of the original array.\n * \n * @param fromIndex the start of the range (inclusive), must be in `0..array.size`\n * @param toIndex the end of the range (exclusive), must be in `fromIndex..array.size`\n */\npublic expect fun DoubleArray.copyOfRange(fromIndex: Int, toIndex: Int): DoubleArray\n\n/**\n * Returns a new array which is a copy of the specified range of the original array.\n * \n * @param fromIndex the start of the range (inclusive), must be in `0..array.size`\n * @param toIndex the end of the range (exclusive), must be in `fromIndex..array.size`\n */\npublic expect fun BooleanArray.copyOfRange(fromIndex: Int, toIndex: Int): BooleanArray\n\n/**\n * Returns a new array which is a copy of the specified range of the original array.\n * \n * @param fromIndex the start of the range (inclusive), must be in `0..array.size`\n * @param toIndex the end of the range (exclusive), must be in `fromIndex..array.size`\n */\npublic expect fun CharArray.copyOfRange(fromIndex: Int, toIndex: Int): CharArray\n\n/**\n * Returns the range of valid indices for the array.\n */\npublic val <T> Array<out T>.indices: IntRange\n get() = IntRange(0, lastIndex)\n\n/**\n * Returns the range of valid indices for the array.\n */\npublic val ByteArray.indices: IntRange\n get() = IntRange(0, lastIndex)\n\n/**\n * Returns the range of valid indices for the array.\n */\npublic val ShortArray.indices: IntRange\n get() = IntRange(0, lastIndex)\n\n/**\n * Returns the range of valid indices for the array.\n */\npublic val IntArray.indices: IntRange\n get() = IntRange(0, lastIndex)\n\n/**\n * Returns the range of valid indices for the array.\n */\npublic val LongArray.indices: IntRange\n get() = IntRange(0, lastIndex)\n\n/**\n * Returns the range of valid indices for the array.\n */\npublic val FloatArray.indices: IntRange\n get() = IntRange(0, lastIndex)\n\n/**\n * Returns the range of valid indices for the array.\n */\npublic val DoubleArray.indices: IntRange\n get() = IntRange(0, lastIndex)\n\n/**\n * Returns the range of valid indices for the array.\n */\npublic val BooleanArray.indices: IntRange\n get() = IntRange(0, lastIndex)\n\n/**\n * Returns the range of valid indices for the array.\n */\npublic val CharArray.indices: IntRange\n get() = IntRange(0, lastIndex)\n\n/**\n * Returns `true` if the array is empty.\n */\[email protected]\npublic inline fun <T> Array<out T>.isEmpty(): Boolean {\n return size == 0\n}\n\n/**\n * Returns `true` if the array is empty.\n */\[email protected]\npublic inline fun ByteArray.isEmpty(): Boolean {\n return size == 0\n}\n\n/**\n * Returns `true` if the array is empty.\n */\[email protected]\npublic inline fun ShortArray.isEmpty(): Boolean {\n return size == 0\n}\n\n/**\n * Returns `true` if the array is empty.\n */\[email protected]\npublic inline fun IntArray.isEmpty(): Boolean {\n return size == 0\n}\n\n/**\n * Returns `true` if the array is empty.\n */\[email protected]\npublic inline fun LongArray.isEmpty(): Boolean {\n return size == 0\n}\n\n/**\n * Returns `true` if the array is empty.\n */\[email protected]\npublic inline fun FloatArray.isEmpty(): Boolean {\n return size == 0\n}\n\n/**\n * Returns `true` if the array is empty.\n */\[email protected]\npublic inline fun DoubleArray.isEmpty(): Boolean {\n return size == 0\n}\n\n/**\n * Returns `true` if the array is empty.\n */\[email protected]\npublic inline fun BooleanArray.isEmpty(): Boolean {\n return size == 0\n}\n\n/**\n * Returns `true` if the array is empty.\n */\[email protected]\npublic inline fun CharArray.isEmpty(): Boolean {\n return size == 0\n}\n\n/**\n * Returns `true` if the array is not empty.\n */\[email protected]\npublic inline fun <T> Array<out T>.isNotEmpty(): Boolean {\n return !isEmpty()\n}\n\n/**\n * Returns `true` if the array is not empty.\n */\[email protected]\npublic inline fun ByteArray.isNotEmpty(): Boolean {\n return !isEmpty()\n}\n\n/**\n * Returns `true` if the array is not empty.\n */\[email protected]\npublic inline fun ShortArray.isNotEmpty(): Boolean {\n return !isEmpty()\n}\n\n/**\n * Returns `true` if the array is not empty.\n */\[email protected]\npublic inline fun IntArray.isNotEmpty(): Boolean {\n return !isEmpty()\n}\n\n/**\n * Returns `true` if the array is not empty.\n */\[email protected]\npublic inline fun LongArray.isNotEmpty(): Boolean {\n return !isEmpty()\n}\n\n/**\n * Returns `true` if the array is not empty.\n */\[email protected]\npublic inline fun FloatArray.isNotEmpty(): Boolean {\n return !isEmpty()\n}\n\n/**\n * Returns `true` if the array is not empty.\n */\[email protected]\npublic inline fun DoubleArray.isNotEmpty(): Boolean {\n return !isEmpty()\n}\n\n/**\n * Returns `true` if the array is not empty.\n */\[email protected]\npublic inline fun BooleanArray.isNotEmpty(): Boolean {\n return !isEmpty()\n}\n\n/**\n * Returns `true` if the array is not empty.\n */\[email protected]\npublic inline fun CharArray.isNotEmpty(): Boolean {\n return !isEmpty()\n}\n\n/**\n * Returns the last valid index for the array.\n */\npublic val <T> Array<out T>.lastIndex: Int\n get() = size - 1\n\n/**\n * Returns the last valid index for the array.\n */\npublic val ByteArray.lastIndex: Int\n get() = size - 1\n\n/**\n * Returns the last valid index for the array.\n */\npublic val ShortArray.lastIndex: Int\n get() = size - 1\n\n/**\n * Returns the last valid index for the array.\n */\npublic val IntArray.lastIndex: Int\n get() = size - 1\n\n/**\n * Returns the last valid index for the array.\n */\npublic val LongArray.lastIndex: Int\n get() = size - 1\n\n/**\n * Returns the last valid index for the array.\n */\npublic val FloatArray.lastIndex: Int\n get() = size - 1\n\n/**\n * Returns the last valid index for the array.\n */\npublic val DoubleArray.lastIndex: Int\n get() = size - 1\n\n/**\n * Returns the last valid index for the array.\n */\npublic val BooleanArray.lastIndex: Int\n get() = size - 1\n\n/**\n * Returns the last valid index for the array.\n */\npublic val CharArray.lastIndex: Int\n get() = size - 1\n\n/**\n * Returns an array containing all elements of the original array and then the given [element].\n */\n@Suppress(\"NO_ACTUAL_FOR_EXPECT\")\npublic expect operator fun <T> Array<T>.plus(element: T): Array<T>\n\n/**\n * Returns an array containing all elements of the original array and then the given [element].\n */\npublic expect operator fun ByteArray.plus(element: Byte): ByteArray\n\n/**\n * Returns an array containing all elements of the original array and then the given [element].\n */\npublic expect operator fun ShortArray.plus(element: Short): ShortArray\n\n/**\n * Returns an array containing all elements of the original array and then the given [element].\n */\npublic expect operator fun IntArray.plus(element: Int): IntArray\n\n/**\n * Returns an array containing all elements of the original array and then the given [element].\n */\npublic expect operator fun LongArray.plus(element: Long): LongArray\n\n/**\n * Returns an array containing all elements of the original array and then the given [element].\n */\npublic expect operator fun FloatArray.plus(element: Float): FloatArray\n\n/**\n * Returns an array containing all elements of the original array and then the given [element].\n */\npublic expect operator fun DoubleArray.plus(element: Double): DoubleArray\n\n/**\n * Returns an array containing all elements of the original array and then the given [element].\n */\npublic expect operator fun BooleanArray.plus(element: Boolean): BooleanArray\n\n/**\n * Returns an array containing all elements of the original array and then the given [element].\n */\npublic expect operator fun CharArray.plus(element: Char): CharArray\n\n/**\n * Returns an array containing all elements of the original array and then all elements of the given [elements] collection.\n */\n@Suppress(\"NO_ACTUAL_FOR_EXPECT\")\npublic expect operator fun <T> Array<T>.plus(elements: Collection<T>): Array<T>\n\n/**\n * Returns an array containing all elements of the original array and then all elements of the given [elements] collection.\n */\npublic expect operator fun ByteArray.plus(elements: Collection<Byte>): ByteArray\n\n/**\n * Returns an array containing all elements of the original array and then all elements of the given [elements] collection.\n */\npublic expect operator fun ShortArray.plus(elements: Collection<Short>): ShortArray\n\n/**\n * Returns an array containing all elements of the original array and then all elements of the given [elements] collection.\n */\npublic expect operator fun IntArray.plus(elements: Collection<Int>): IntArray\n\n/**\n * Returns an array containing all elements of the original array and then all elements of the given [elements] collection.\n */\npublic expect operator fun LongArray.plus(elements: Collection<Long>): LongArray\n\n/**\n * Returns an array containing all elements of the original array and then all elements of the given [elements] collection.\n */\npublic expect operator fun FloatArray.plus(elements: Collection<Float>): FloatArray\n\n/**\n * Returns an array containing all elements of the original array and then all elements of the given [elements] collection.\n */\npublic expect operator fun DoubleArray.plus(elements: Collection<Double>): DoubleArray\n\n/**\n * Returns an array containing all elements of the original array and then all elements of the given [elements] collection.\n */\npublic expect operator fun BooleanArray.plus(elements: Collection<Boolean>): BooleanArray\n\n/**\n * Returns an array containing all elements of the original array and then all elements of the given [elements] collection.\n */\npublic expect operator fun CharArray.plus(elements: Collection<Char>): CharArray\n\n/**\n * Returns an array containing all elements of the original array and then all elements of the given [elements] array.\n */\n@Suppress(\"NO_ACTUAL_FOR_EXPECT\")\npublic expect operator fun <T> Array<T>.plus(elements: Array<out T>): Array<T>\n\n/**\n * Returns an array containing all elements of the original array and then all elements of the given [elements] array.\n */\npublic expect operator fun ByteArray.plus(elements: ByteArray): ByteArray\n\n/**\n * Returns an array containing all elements of the original array and then all elements of the given [elements] array.\n */\npublic expect operator fun ShortArray.plus(elements: ShortArray): ShortArray\n\n/**\n * Returns an array containing all elements of the original array and then all elements of the given [elements] array.\n */\npublic expect operator fun IntArray.plus(elements: IntArray): IntArray\n\n/**\n * Returns an array containing all elements of the original array and then all elements of the given [elements] array.\n */\npublic expect operator fun LongArray.plus(elements: LongArray): LongArray\n\n/**\n * Returns an array containing all elements of the original array and then all elements of the given [elements] array.\n */\npublic expect operator fun FloatArray.plus(elements: FloatArray): FloatArray\n\n/**\n * Returns an array containing all elements of the original array and then all elements of the given [elements] array.\n */\npublic expect operator fun DoubleArray.plus(elements: DoubleArray): DoubleArray\n\n/**\n * Returns an array containing all elements of the original array and then all elements of the given [elements] array.\n */\npublic expect operator fun BooleanArray.plus(elements: BooleanArray): BooleanArray\n\n/**\n * Returns an array containing all elements of the original array and then all elements of the given [elements] array.\n */\npublic expect operator fun CharArray.plus(elements: CharArray): CharArray\n\n/**\n * Returns an array containing all elements of the original array and then the given [element].\n */\n@Suppress(\"NO_ACTUAL_FOR_EXPECT\")\npublic expect fun <T> Array<T>.plusElement(element: T): Array<T>\n\n/**\n * Sorts the array in-place.\n */\npublic expect fun IntArray.sort(): Unit\n\n/**\n * Sorts the array in-place.\n */\npublic expect fun LongArray.sort(): Unit\n\n/**\n * Sorts the array in-place.\n */\npublic expect fun ByteArray.sort(): Unit\n\n/**\n * Sorts the array in-place.\n */\npublic expect fun ShortArray.sort(): Unit\n\n/**\n * Sorts the array in-place.\n */\npublic expect fun DoubleArray.sort(): Unit\n\n/**\n * Sorts the array in-place.\n */\npublic expect fun FloatArray.sort(): Unit\n\n/**\n * Sorts the array in-place.\n */\npublic expect fun CharArray.sort(): Unit\n\n/**\n * Sorts the array in-place according to the natural order of its elements.\n * \n * The sort is _stable_. It means that equal elements preserve their order relative to each other after sorting.\n */\npublic expect fun <T : Comparable<T>> Array<out T>.sort(): Unit\n\n/**\n * Sorts the array in-place according to the order specified by the given [comparator].\n * \n * The sort is _stable_. It means that equal elements preserve their order relative to each other after sorting.\n */\npublic expect fun <T> Array<out T>.sortWith(comparator: Comparator<in T>): Unit\n\n/**\n * Returns an array of Boolean containing all of the elements of this generic array.\n */\npublic fun Array<out Boolean>.toBooleanArray(): BooleanArray {\n val result = BooleanArray(size)\n for (index in indices)\n result[index] = this[index]\n return result\n}\n\n/**\n * Returns an array of Byte containing all of the elements of this generic array.\n */\npublic fun Array<out Byte>.toByteArray(): ByteArray {\n val result = ByteArray(size)\n for (index in indices)\n result[index] = this[index]\n return result\n}\n\n/**\n * Returns an array of Char containing all of the elements of this generic array.\n */\npublic fun Array<out Char>.toCharArray(): CharArray {\n val result = CharArray(size)\n for (index in indices)\n result[index] = this[index]\n return result\n}\n\n/**\n * Returns an array of Double containing all of the elements of this generic array.\n */\npublic fun Array<out Double>.toDoubleArray(): DoubleArray {\n val result = DoubleArray(size)\n for (index in indices)\n result[index] = this[index]\n return result\n}\n\n/**\n * Returns an array of Float containing all of the elements of this generic array.\n */\npublic fun Array<out Float>.toFloatArray(): FloatArray {\n val result = FloatArray(size)\n for (index in indices)\n result[index] = this[index]\n return result\n}\n\n/**\n * Returns an array of Int containing all of the elements of this generic array.\n */\npublic fun Array<out Int>.toIntArray(): IntArray {\n val result = IntArray(size)\n for (index in indices)\n result[index] = this[index]\n return result\n}\n\n/**\n * Returns an array of Long containing all of the elements of this generic array.\n */\npublic fun Array<out Long>.toLongArray(): LongArray {\n val result = LongArray(size)\n for (index in indices)\n result[index] = this[index]\n return result\n}\n\n/**\n * Returns an array of Short containing all of the elements of this generic array.\n */\npublic fun Array<out Short>.toShortArray(): ShortArray {\n val result = ShortArray(size)\n for (index in indices)\n result[index] = this[index]\n return result\n}\n\n/**\n * Returns a *typed* object array containing all of the elements of this primitive array.\n */\npublic expect fun ByteArray.toTypedArray(): Array<Byte>\n\n/**\n * Returns a *typed* object array containing all of the elements of this primitive array.\n */\npublic expect fun ShortArray.toTypedArray(): Array<Short>\n\n/**\n * Returns a *typed* object array containing all of the elements of this primitive array.\n */\npublic expect fun IntArray.toTypedArray(): Array<Int>\n\n/**\n * Returns a *typed* object array containing all of the elements of this primitive array.\n */\npublic expect fun LongArray.toTypedArray(): Array<Long>\n\n/**\n * Returns a *typed* object array containing all of the elements of this primitive array.\n */\npublic expect fun FloatArray.toTypedArray(): Array<Float>\n\n/**\n * Returns a *typed* object array containing all of the elements of this primitive array.\n */\npublic expect fun DoubleArray.toTypedArray(): Array<Double>\n\n/**\n * Returns a *typed* object array containing all of the elements of this primitive array.\n */\npublic expect fun BooleanArray.toTypedArray(): Array<Boolean>\n\n/**\n * Returns a *typed* object array containing all of the elements of this primitive array.\n */\npublic expect fun CharArray.toTypedArray(): Array<Char>\n\n/**\n * Returns a [Map] containing key-value pairs provided by [transform] function\n * applied to elements of the given array.\n * \n * If any of two pairs would have the same key the last one gets added to the map.\n * \n * The returned map preserves the entry iteration order of the original array.\n */\npublic inline fun <T, K, V> Array<out T>.associate(transform: (T) -> Pair<K, V>): Map<K, V> {\n val capacity = mapCapacity(size).coerceAtLeast(16)\n return associateTo(LinkedHashMap<K, V>(capacity), transform)\n}\n\n/**\n * Returns a [Map] containing key-value pairs provided by [transform] function\n * applied to elements of the given array.\n * \n * If any of two pairs would have the same key the last one gets added to the map.\n * \n * The returned map preserves the entry iteration order of the original array.\n */\npublic inline fun <K, V> ByteArray.associate(transform: (Byte) -> Pair<K, V>): Map<K, V> {\n val capacity = mapCapacity(size).coerceAtLeast(16)\n return associateTo(LinkedHashMap<K, V>(capacity), transform)\n}\n\n/**\n * Returns a [Map] containing key-value pairs provided by [transform] function\n * applied to elements of the given array.\n * \n * If any of two pairs would have the same key the last one gets added to the map.\n * \n * The returned map preserves the entry iteration order of the original array.\n */\npublic inline fun <K, V> ShortArray.associate(transform: (Short) -> Pair<K, V>): Map<K, V> {\n val capacity = mapCapacity(size).coerceAtLeast(16)\n return associateTo(LinkedHashMap<K, V>(capacity), transform)\n}\n\n/**\n * Returns a [Map] containing key-value pairs provided by [transform] function\n * applied to elements of the given array.\n * \n * If any of two pairs would have the same key the last one gets added to the map.\n * \n * The returned map preserves the entry iteration order of the original array.\n */\npublic inline fun <K, V> IntArray.associate(transform: (Int) -> Pair<K, V>): Map<K, V> {\n val capacity = mapCapacity(size).coerceAtLeast(16)\n return associateTo(LinkedHashMap<K, V>(capacity), transform)\n}\n\n/**\n * Returns a [Map] containing key-value pairs provided by [transform] function\n * applied to elements of the given array.\n * \n * If any of two pairs would have the same key the last one gets added to the map.\n * \n * The returned map preserves the entry iteration order of the original array.\n */\npublic inline fun <K, V> LongArray.associate(transform: (Long) -> Pair<K, V>): Map<K, V> {\n val capacity = mapCapacity(size).coerceAtLeast(16)\n return associateTo(LinkedHashMap<K, V>(capacity), transform)\n}\n\n/**\n * Returns a [Map] containing key-value pairs provided by [transform] function\n * applied to elements of the given array.\n * \n * If any of two pairs would have the same key the last one gets added to the map.\n * \n * The returned map preserves the entry iteration order of the original array.\n */\npublic inline fun <K, V> FloatArray.associate(transform: (Float) -> Pair<K, V>): Map<K, V> {\n val capacity = mapCapacity(size).coerceAtLeast(16)\n return associateTo(LinkedHashMap<K, V>(capacity), transform)\n}\n\n/**\n * Returns a [Map] containing key-value pairs provided by [transform] function\n * applied to elements of the given array.\n * \n * If any of two pairs would have the same key the last one gets added to the map.\n * \n * The returned map preserves the entry iteration order of the original array.\n */\npublic inline fun <K, V> DoubleArray.associate(transform: (Double) -> Pair<K, V>): Map<K, V> {\n val capacity = mapCapacity(size).coerceAtLeast(16)\n return associateTo(LinkedHashMap<K, V>(capacity), transform)\n}\n\n/**\n * Returns a [Map] containing key-value pairs provided by [transform] function\n * applied to elements of the given array.\n * \n * If any of two pairs would have the same key the last one gets added to the map.\n * \n * The returned map preserves the entry iteration order of the original array.\n */\npublic inline fun <K, V> BooleanArray.associate(transform: (Boolean) -> Pair<K, V>): Map<K, V> {\n val capacity = mapCapacity(size).coerceAtLeast(16)\n return associateTo(LinkedHashMap<K, V>(capacity), transform)\n}\n\n/**\n * Returns a [Map] containing key-value pairs provided by [transform] function\n * applied to elements of the given array.\n * \n * If any of two pairs would have the same key the last one gets added to the map.\n * \n * The returned map preserves the entry iteration order of the original array.\n */\npublic inline fun <K, V> CharArray.associate(transform: (Char) -> Pair<K, V>): Map<K, V> {\n val capacity = mapCapacity(size).coerceAtLeast(16)\n return associateTo(LinkedHashMap<K, V>(capacity), transform)\n}\n\n/**\n * Returns a [Map] containing the elements from the given array indexed by the key\n * returned from [keySelector] function applied to each element.\n * \n * If any two elements would have the same key returned by [keySelector] the last one gets added to the map.\n * \n * The returned map preserves the entry iteration order of the original array.\n */\npublic inline fun <T, K> Array<out T>.associateBy(keySelector: (T) -> K): Map<K, T> {\n val capacity = mapCapacity(size).coerceAtLeast(16)\n return associateByTo(LinkedHashMap<K, T>(capacity), keySelector)\n}\n\n/**\n * Returns a [Map] containing the elements from the given array indexed by the key\n * returned from [keySelector] function applied to each element.\n * \n * If any two elements would have the same key returned by [keySelector] the last one gets added to the map.\n * \n * The returned map preserves the entry iteration order of the original array.\n */\npublic inline fun <K> ByteArray.associateBy(keySelector: (Byte) -> K): Map<K, Byte> {\n val capacity = mapCapacity(size).coerceAtLeast(16)\n return associateByTo(LinkedHashMap<K, Byte>(capacity), keySelector)\n}\n\n/**\n * Returns a [Map] containing the elements from the given array indexed by the key\n * returned from [keySelector] function applied to each element.\n * \n * If any two elements would have the same key returned by [keySelector] the last one gets added to the map.\n * \n * The returned map preserves the entry iteration order of the original array.\n */\npublic inline fun <K> ShortArray.associateBy(keySelector: (Short) -> K): Map<K, Short> {\n val capacity = mapCapacity(size).coerceAtLeast(16)\n return associateByTo(LinkedHashMap<K, Short>(capacity), keySelector)\n}\n\n/**\n * Returns a [Map] containing the elements from the given array indexed by the key\n * returned from [keySelector] function applied to each element.\n * \n * If any two elements would have the same key returned by [keySelector] the last one gets added to the map.\n * \n * The returned map preserves the entry iteration order of the original array.\n */\npublic inline fun <K> IntArray.associateBy(keySelector: (Int) -> K): Map<K, Int> {\n val capacity = mapCapacity(size).coerceAtLeast(16)\n return associateByTo(LinkedHashMap<K, Int>(capacity), keySelector)\n}\n\n/**\n * Returns a [Map] containing the elements from the given array indexed by the key\n * returned from [keySelector] function applied to each element.\n * \n * If any two elements would have the same key returned by [keySelector] the last one gets added to the map.\n * \n * The returned map preserves the entry iteration order of the original array.\n */\npublic inline fun <K> LongArray.associateBy(keySelector: (Long) -> K): Map<K, Long> {\n val capacity = mapCapacity(size).coerceAtLeast(16)\n return associateByTo(LinkedHashMap<K, Long>(capacity), keySelector)\n}\n\n/**\n * Returns a [Map] containing the elements from the given array indexed by the key\n * returned from [keySelector] function applied to each element.\n * \n * If any two elements would have the same key returned by [keySelector] the last one gets added to the map.\n * \n * The returned map preserves the entry iteration order of the original array.\n */\npublic inline fun <K> FloatArray.associateBy(keySelector: (Float) -> K): Map<K, Float> {\n val capacity = mapCapacity(size).coerceAtLeast(16)\n return associateByTo(LinkedHashMap<K, Float>(capacity), keySelector)\n}\n\n/**\n * Returns a [Map] containing the elements from the given array indexed by the key\n * returned from [keySelector] function applied to each element.\n * \n * If any two elements would have the same key returned by [keySelector] the last one gets added to the map.\n * \n * The returned map preserves the entry iteration order of the original array.\n */\npublic inline fun <K> DoubleArray.associateBy(keySelector: (Double) -> K): Map<K, Double> {\n val capacity = mapCapacity(size).coerceAtLeast(16)\n return associateByTo(LinkedHashMap<K, Double>(capacity), keySelector)\n}\n\n/**\n * Returns a [Map] containing the elements from the given array indexed by the key\n * returned from [keySelector] function applied to each element.\n * \n * If any two elements would have the same key returned by [keySelector] the last one gets added to the map.\n * \n * The returned map preserves the entry iteration order of the original array.\n */\npublic inline fun <K> BooleanArray.associateBy(keySelector: (Boolean) -> K): Map<K, Boolean> {\n val capacity = mapCapacity(size).coerceAtLeast(16)\n return associateByTo(LinkedHashMap<K, Boolean>(capacity), keySelector)\n}\n\n/**\n * Returns a [Map] containing the elements from the given array indexed by the key\n * returned from [keySelector] function applied to each element.\n * \n * If any two elements would have the same key returned by [keySelector] the last one gets added to the map.\n * \n * The returned map preserves the entry iteration order of the original array.\n */\npublic inline fun <K> CharArray.associateBy(keySelector: (Char) -> K): Map<K, Char> {\n val capacity = mapCapacity(size).coerceAtLeast(16)\n return associateByTo(LinkedHashMap<K, Char>(capacity), keySelector)\n}\n\n/**\n * Returns a [Map] containing the values provided by [valueTransform] and indexed by [keySelector] functions applied to elements of the given array.\n * \n * If any two elements would have the same key returned by [keySelector] the last one gets added to the map.\n * \n * The returned map preserves the entry iteration order of the original array.\n */\npublic inline fun <T, K, V> Array<out T>.associateBy(keySelector: (T) -> K, valueTransform: (T) -> V): Map<K, V> {\n val capacity = mapCapacity(size).coerceAtLeast(16)\n return associateByTo(LinkedHashMap<K, V>(capacity), keySelector, valueTransform)\n}\n\n/**\n * Returns a [Map] containing the values provided by [valueTransform] and indexed by [keySelector] functions applied to elements of the given array.\n * \n * If any two elements would have the same key returned by [keySelector] the last one gets added to the map.\n * \n * The returned map preserves the entry iteration order of the original array.\n */\npublic inline fun <K, V> ByteArray.associateBy(keySelector: (Byte) -> K, valueTransform: (Byte) -> V): Map<K, V> {\n val capacity = mapCapacity(size).coerceAtLeast(16)\n return associateByTo(LinkedHashMap<K, V>(capacity), keySelector, valueTransform)\n}\n\n/**\n * Returns a [Map] containing the values provided by [valueTransform] and indexed by [keySelector] functions applied to elements of the given array.\n * \n * If any two elements would have the same key returned by [keySelector] the last one gets added to the map.\n * \n * The returned map preserves the entry iteration order of the original array.\n */\npublic inline fun <K, V> ShortArray.associateBy(keySelector: (Short) -> K, valueTransform: (Short) -> V): Map<K, V> {\n val capacity = mapCapacity(size).coerceAtLeast(16)\n return associateByTo(LinkedHashMap<K, V>(capacity), keySelector, valueTransform)\n}\n\n/**\n * Returns a [Map] containing the values provided by [valueTransform] and indexed by [keySelector] functions applied to elements of the given array.\n * \n * If any two elements would have the same key returned by [keySelector] the last one gets added to the map.\n * \n * The returned map preserves the entry iteration order of the original array.\n */\npublic inline fun <K, V> IntArray.associateBy(keySelector: (Int) -> K, valueTransform: (Int) -> V): Map<K, V> {\n val capacity = mapCapacity(size).coerceAtLeast(16)\n return associateByTo(LinkedHashMap<K, V>(capacity), keySelector, valueTransform)\n}\n\n/**\n * Returns a [Map] containing the values provided by [valueTransform] and indexed by [keySelector] functions applied to elements of the given array.\n * \n * If any two elements would have the same key returned by [keySelector] the last one gets added to the map.\n * \n * The returned map preserves the entry iteration order of the original array.\n */\npublic inline fun <K, V> LongArray.associateBy(keySelector: (Long) -> K, valueTransform: (Long) -> V): Map<K, V> {\n val capacity = mapCapacity(size).coerceAtLeast(16)\n return associateByTo(LinkedHashMap<K, V>(capacity), keySelector, valueTransform)\n}\n\n/**\n * Returns a [Map] containing the values provided by [valueTransform] and indexed by [keySelector] functions applied to elements of the given array.\n * \n * If any two elements would have the same key returned by [keySelector] the last one gets added to the map.\n * \n * The returned map preserves the entry iteration order of the original array.\n */\npublic inline fun <K, V> FloatArray.associateBy(keySelector: (Float) -> K, valueTransform: (Float) -> V): Map<K, V> {\n val capacity = mapCapacity(size).coerceAtLeast(16)\n return associateByTo(LinkedHashMap<K, V>(capacity), keySelector, valueTransform)\n}\n\n/**\n * Returns a [Map] containing the values provided by [valueTransform] and indexed by [keySelector] functions applied to elements of the given array.\n * \n * If any two elements would have the same key returned by [keySelector] the last one gets added to the map.\n * \n * The returned map preserves the entry iteration order of the original array.\n */\npublic inline fun <K, V> DoubleArray.associateBy(keySelector: (Double) -> K, valueTransform: (Double) -> V): Map<K, V> {\n val capacity = mapCapacity(size).coerceAtLeast(16)\n return associateByTo(LinkedHashMap<K, V>(capacity), keySelector, valueTransform)\n}\n\n/**\n * Returns a [Map] containing the values provided by [valueTransform] and indexed by [keySelector] functions applied to elements of the given array.\n * \n * If any two elements would have the same key returned by [keySelector] the last one gets added to the map.\n * \n * The returned map preserves the entry iteration order of the original array.\n */\npublic inline fun <K, V> BooleanArray.associateBy(keySelector: (Boolean) -> K, valueTransform: (Boolean) -> V): Map<K, V> {\n val capacity = mapCapacity(size).coerceAtLeast(16)\n return associateByTo(LinkedHashMap<K, V>(capacity), keySelector, valueTransform)\n}\n\n/**\n * Returns a [Map] containing the values provided by [valueTransform] and indexed by [keySelector] functions applied to elements of the given array.\n * \n * If any two elements would have the same key returned by [keySelector] the last one gets added to the map.\n * \n * The returned map preserves the entry iteration order of the original array.\n */\npublic inline fun <K, V> CharArray.associateBy(keySelector: (Char) -> K, valueTransform: (Char) -> V): Map<K, V> {\n val capacity = mapCapacity(size).coerceAtLeast(16)\n return associateByTo(LinkedHashMap<K, V>(capacity), keySelector, valueTransform)\n}\n\n/**\n * Populates and returns the [destination] mutable map with key-value pairs,\n * where key is provided by the [keySelector] function applied to each element of the given array\n * and value is the element itself.\n * \n * If any two elements would have the same key returned by [keySelector] the last one gets added to the map.\n */\npublic inline fun <T, K, M : MutableMap<in K, in T>> Array<out T>.associateByTo(destination: M, keySelector: (T) -> K): M {\n for (element in this) {\n destination.put(keySelector(element), element)\n }\n return destination\n}\n\n/**\n * Populates and returns the [destination] mutable map with key-value pairs,\n * where key is provided by the [keySelector] function applied to each element of the given array\n * and value is the element itself.\n * \n * If any two elements would have the same key returned by [keySelector] the last one gets added to the map.\n */\npublic inline fun <K, M : MutableMap<in K, in Byte>> ByteArray.associateByTo(destination: M, keySelector: (Byte) -> K): M {\n for (element in this) {\n destination.put(keySelector(element), element)\n }\n return destination\n}\n\n/**\n * Populates and returns the [destination] mutable map with key-value pairs,\n * where key is provided by the [keySelector] function applied to each element of the given array\n * and value is the element itself.\n * \n * If any two elements would have the same key returned by [keySelector] the last one gets added to the map.\n */\npublic inline fun <K, M : MutableMap<in K, in Short>> ShortArray.associateByTo(destination: M, keySelector: (Short) -> K): M {\n for (element in this) {\n destination.put(keySelector(element), element)\n }\n return destination\n}\n\n/**\n * Populates and returns the [destination] mutable map with key-value pairs,\n * where key is provided by the [keySelector] function applied to each element of the given array\n * and value is the element itself.\n * \n * If any two elements would have the same key returned by [keySelector] the last one gets added to the map.\n */\npublic inline fun <K, M : MutableMap<in K, in Int>> IntArray.associateByTo(destination: M, keySelector: (Int) -> K): M {\n for (element in this) {\n destination.put(keySelector(element), element)\n }\n return destination\n}\n\n/**\n * Populates and returns the [destination] mutable map with key-value pairs,\n * where key is provided by the [keySelector] function applied to each element of the given array\n * and value is the element itself.\n * \n * If any two elements would have the same key returned by [keySelector] the last one gets added to the map.\n */\npublic inline fun <K, M : MutableMap<in K, in Long>> LongArray.associateByTo(destination: M, keySelector: (Long) -> K): M {\n for (element in this) {\n destination.put(keySelector(element), element)\n }\n return destination\n}\n\n/**\n * Populates and returns the [destination] mutable map with key-value pairs,\n * where key is provided by the [keySelector] function applied to each element of the given array\n * and value is the element itself.\n * \n * If any two elements would have the same key returned by [keySelector] the last one gets added to the map.\n */\npublic inline fun <K, M : MutableMap<in K, in Float>> FloatArray.associateByTo(destination: M, keySelector: (Float) -> K): M {\n for (element in this) {\n destination.put(keySelector(element), element)\n }\n return destination\n}\n\n/**\n * Populates and returns the [destination] mutable map with key-value pairs,\n * where key is provided by the [keySelector] function applied to each element of the given array\n * and value is the element itself.\n * \n * If any two elements would have the same key returned by [keySelector] the last one gets added to the map.\n */\npublic inline fun <K, M : MutableMap<in K, in Double>> DoubleArray.associateByTo(destination: M, keySelector: (Double) -> K): M {\n for (element in this) {\n destination.put(keySelector(element), element)\n }\n return destination\n}\n\n/**\n * Populates and returns the [destination] mutable map with key-value pairs,\n * where key is provided by the [keySelector] function applied to each element of the given array\n * and value is the element itself.\n * \n * If any two elements would have the same key returned by [keySelector] the last one gets added to the map.\n */\npublic inline fun <K, M : MutableMap<in K, in Boolean>> BooleanArray.associateByTo(destination: M, keySelector: (Boolean) -> K): M {\n for (element in this) {\n destination.put(keySelector(element), element)\n }\n return destination\n}\n\n/**\n * Populates and returns the [destination] mutable map with key-value pairs,\n * where key is provided by the [keySelector] function applied to each element of the given array\n * and value is the element itself.\n * \n * If any two elements would have the same key returned by [keySelector] the last one gets added to the map.\n */\npublic inline fun <K, M : MutableMap<in K, in Char>> CharArray.associateByTo(destination: M, keySelector: (Char) -> K): M {\n for (element in this) {\n destination.put(keySelector(element), element)\n }\n return destination\n}\n\n/**\n * Populates and returns the [destination] mutable map with key-value pairs,\n * where key is provided by the [keySelector] function and\n * and value is provided by the [valueTransform] function applied to elements of the given array.\n * \n * If any two elements would have the same key returned by [keySelector] the last one gets added to the map.\n */\npublic inline fun <T, K, V, M : MutableMap<in K, in V>> Array<out T>.associateByTo(destination: M, keySelector: (T) -> K, valueTransform: (T) -> V): M {\n for (element in this) {\n destination.put(keySelector(element), valueTransform(element))\n }\n return destination\n}\n\n/**\n * Populates and returns the [destination] mutable map with key-value pairs,\n * where key is provided by the [keySelector] function and\n * and value is provided by the [valueTransform] function applied to elements of the given array.\n * \n * If any two elements would have the same key returned by [keySelector] the last one gets added to the map.\n */\npublic inline fun <K, V, M : MutableMap<in K, in V>> ByteArray.associateByTo(destination: M, keySelector: (Byte) -> K, valueTransform: (Byte) -> V): M {\n for (element in this) {\n destination.put(keySelector(element), valueTransform(element))\n }\n return destination\n}\n\n/**\n * Populates and returns the [destination] mutable map with key-value pairs,\n * where key is provided by the [keySelector] function and\n * and value is provided by the [valueTransform] function applied to elements of the given array.\n * \n * If any two elements would have the same key returned by [keySelector] the last one gets added to the map.\n */\npublic inline fun <K, V, M : MutableMap<in K, in V>> ShortArray.associateByTo(destination: M, keySelector: (Short) -> K, valueTransform: (Short) -> V): M {\n for (element in this) {\n destination.put(keySelector(element), valueTransform(element))\n }\n return destination\n}\n\n/**\n * Populates and returns the [destination] mutable map with key-value pairs,\n * where key is provided by the [keySelector] function and\n * and value is provided by the [valueTransform] function applied to elements of the given array.\n * \n * If any two elements would have the same key returned by [keySelector] the last one gets added to the map.\n */\npublic inline fun <K, V, M : MutableMap<in K, in V>> IntArray.associateByTo(destination: M, keySelector: (Int) -> K, valueTransform: (Int) -> V): M {\n for (element in this) {\n destination.put(keySelector(element), valueTransform(element))\n }\n return destination\n}\n\n/**\n * Populates and returns the [destination] mutable map with key-value pairs,\n * where key is provided by the [keySelector] function and\n * and value is provided by the [valueTransform] function applied to elements of the given array.\n * \n * If any two elements would have the same key returned by [keySelector] the last one gets added to the map.\n */\npublic inline fun <K, V, M : MutableMap<in K, in V>> LongArray.associateByTo(destination: M, keySelector: (Long) -> K, valueTransform: (Long) -> V): M {\n for (element in this) {\n destination.put(keySelector(element), valueTransform(element))\n }\n return destination\n}\n\n/**\n * Populates and returns the [destination] mutable map with key-value pairs,\n * where key is provided by the [keySelector] function and\n * and value is provided by the [valueTransform] function applied to elements of the given array.\n * \n * If any two elements would have the same key returned by [keySelector] the last one gets added to the map.\n */\npublic inline fun <K, V, M : MutableMap<in K, in V>> FloatArray.associateByTo(destination: M, keySelector: (Float) -> K, valueTransform: (Float) -> V): M {\n for (element in this) {\n destination.put(keySelector(element), valueTransform(element))\n }\n return destination\n}\n\n/**\n * Populates and returns the [destination] mutable map with key-value pairs,\n * where key is provided by the [keySelector] function and\n * and value is provided by the [valueTransform] function applied to elements of the given array.\n * \n * If any two elements would have the same key returned by [keySelector] the last one gets added to the map.\n */\npublic inline fun <K, V, M : MutableMap<in K, in V>> DoubleArray.associateByTo(destination: M, keySelector: (Double) -> K, valueTransform: (Double) -> V): M {\n for (element in this) {\n destination.put(keySelector(element), valueTransform(element))\n }\n return destination\n}\n\n/**\n * Populates and returns the [destination] mutable map with key-value pairs,\n * where key is provided by the [keySelector] function and\n * and value is provided by the [valueTransform] function applied to elements of the given array.\n * \n * If any two elements would have the same key returned by [keySelector] the last one gets added to the map.\n */\npublic inline fun <K, V, M : MutableMap<in K, in V>> BooleanArray.associateByTo(destination: M, keySelector: (Boolean) -> K, valueTransform: (Boolean) -> V): M {\n for (element in this) {\n destination.put(keySelector(element), valueTransform(element))\n }\n return destination\n}\n\n/**\n * Populates and returns the [destination] mutable map with key-value pairs,\n * where key is provided by the [keySelector] function and\n * and value is provided by the [valueTransform] function applied to elements of the given array.\n * \n * If any two elements would have the same key returned by [keySelector] the last one gets added to the map.\n */\npublic inline fun <K, V, M : MutableMap<in K, in V>> CharArray.associateByTo(destination: M, keySelector: (Char) -> K, valueTransform: (Char) -> V): M {\n for (element in this) {\n destination.put(keySelector(element), valueTransform(element))\n }\n return destination\n}\n\n/**\n * Populates and returns the [destination] mutable map with key-value pairs\n * provided by [transform] function applied to each element of the given array.\n * \n * If any of two pairs would have the same key the last one gets added to the map.\n */\npublic inline fun <T, K, V, M : MutableMap<in K, in V>> Array<out T>.associateTo(destination: M, transform: (T) -> Pair<K, V>): M {\n for (element in this) {\n destination += transform(element)\n }\n return destination\n}\n\n/**\n * Populates and returns the [destination] mutable map with key-value pairs\n * provided by [transform] function applied to each element of the given array.\n * \n * If any of two pairs would have the same key the last one gets added to the map.\n */\npublic inline fun <K, V, M : MutableMap<in K, in V>> ByteArray.associateTo(destination: M, transform: (Byte) -> Pair<K, V>): M {\n for (element in this) {\n destination += transform(element)\n }\n return destination\n}\n\n/**\n * Populates and returns the [destination] mutable map with key-value pairs\n * provided by [transform] function applied to each element of the given array.\n * \n * If any of two pairs would have the same key the last one gets added to the map.\n */\npublic inline fun <K, V, M : MutableMap<in K, in V>> ShortArray.associateTo(destination: M, transform: (Short) -> Pair<K, V>): M {\n for (element in this) {\n destination += transform(element)\n }\n return destination\n}\n\n/**\n * Populates and returns the [destination] mutable map with key-value pairs\n * provided by [transform] function applied to each element of the given array.\n * \n * If any of two pairs would have the same key the last one gets added to the map.\n */\npublic inline fun <K, V, M : MutableMap<in K, in V>> IntArray.associateTo(destination: M, transform: (Int) -> Pair<K, V>): M {\n for (element in this) {\n destination += transform(element)\n }\n return destination\n}\n\n/**\n * Populates and returns the [destination] mutable map with key-value pairs\n * provided by [transform] function applied to each element of the given array.\n * \n * If any of two pairs would have the same key the last one gets added to the map.\n */\npublic inline fun <K, V, M : MutableMap<in K, in V>> LongArray.associateTo(destination: M, transform: (Long) -> Pair<K, V>): M {\n for (element in this) {\n destination += transform(element)\n }\n return destination\n}\n\n/**\n * Populates and returns the [destination] mutable map with key-value pairs\n * provided by [transform] function applied to each element of the given array.\n * \n * If any of two pairs would have the same key the last one gets added to the map.\n */\npublic inline fun <K, V, M : MutableMap<in K, in V>> FloatArray.associateTo(destination: M, transform: (Float) -> Pair<K, V>): M {\n for (element in this) {\n destination += transform(element)\n }\n return destination\n}\n\n/**\n * Populates and returns the [destination] mutable map with key-value pairs\n * provided by [transform] function applied to each element of the given array.\n * \n * If any of two pairs would have the same key the last one gets added to the map.\n */\npublic inline fun <K, V, M : MutableMap<in K, in V>> DoubleArray.associateTo(destination: M, transform: (Double) -> Pair<K, V>): M {\n for (element in this) {\n destination += transform(element)\n }\n return destination\n}\n\n/**\n * Populates and returns the [destination] mutable map with key-value pairs\n * provided by [transform] function applied to each element of the given array.\n * \n * If any of two pairs would have the same key the last one gets added to the map.\n */\npublic inline fun <K, V, M : MutableMap<in K, in V>> BooleanArray.associateTo(destination: M, transform: (Boolean) -> Pair<K, V>): M {\n for (element in this) {\n destination += transform(element)\n }\n return destination\n}\n\n/**\n * Populates and returns the [destination] mutable map with key-value pairs\n * provided by [transform] function applied to each element of the given array.\n * \n * If any of two pairs would have the same key the last one gets added to the map.\n */\npublic inline fun <K, V, M : MutableMap<in K, in V>> CharArray.associateTo(destination: M, transform: (Char) -> Pair<K, V>): M {\n for (element in this) {\n destination += transform(element)\n }\n return destination\n}\n\n/**\n * Appends all elements to the given [destination] collection.\n */\npublic fun <T, C : MutableCollection<in T>> Array<out T>.toCollection(destination: C): C {\n for (item in this) {\n destination.add(item)\n }\n return destination\n}\n\n/**\n * Appends all elements to the given [destination] collection.\n */\npublic fun <C : MutableCollection<in Byte>> ByteArray.toCollection(destination: C): C {\n for (item in this) {\n destination.add(item)\n }\n return destination\n}\n\n/**\n * Appends all elements to the given [destination] collection.\n */\npublic fun <C : MutableCollection<in Short>> ShortArray.toCollection(destination: C): C {\n for (item in this) {\n destination.add(item)\n }\n return destination\n}\n\n/**\n * Appends all elements to the given [destination] collection.\n */\npublic fun <C : MutableCollection<in Int>> IntArray.toCollection(destination: C): C {\n for (item in this) {\n destination.add(item)\n }\n return destination\n}\n\n/**\n * Appends all elements to the given [destination] collection.\n */\npublic fun <C : MutableCollection<in Long>> LongArray.toCollection(destination: C): C {\n for (item in this) {\n destination.add(item)\n }\n return destination\n}\n\n/**\n * Appends all elements to the given [destination] collection.\n */\npublic fun <C : MutableCollection<in Float>> FloatArray.toCollection(destination: C): C {\n for (item in this) {\n destination.add(item)\n }\n return destination\n}\n\n/**\n * Appends all elements to the given [destination] collection.\n */\npublic fun <C : MutableCollection<in Double>> DoubleArray.toCollection(destination: C): C {\n for (item in this) {\n destination.add(item)\n }\n return destination\n}\n\n/**\n * Appends all elements to the given [destination] collection.\n */\npublic fun <C : MutableCollection<in Boolean>> BooleanArray.toCollection(destination: C): C {\n for (item in this) {\n destination.add(item)\n }\n return destination\n}\n\n/**\n * Appends all elements to the given [destination] collection.\n */\npublic fun <C : MutableCollection<in Char>> CharArray.toCollection(destination: C): C {\n for (item in this) {\n destination.add(item)\n }\n return destination\n}\n\n/**\n * Returns a [HashSet] of all elements.\n */\npublic fun <T> Array<out T>.toHashSet(): HashSet<T> {\n return toCollection(HashSet<T>(mapCapacity(size)))\n}\n\n/**\n * Returns a [HashSet] of all elements.\n */\npublic fun ByteArray.toHashSet(): HashSet<Byte> {\n return toCollection(HashSet<Byte>(mapCapacity(size)))\n}\n\n/**\n * Returns a [HashSet] of all elements.\n */\npublic fun ShortArray.toHashSet(): HashSet<Short> {\n return toCollection(HashSet<Short>(mapCapacity(size)))\n}\n\n/**\n * Returns a [HashSet] of all elements.\n */\npublic fun IntArray.toHashSet(): HashSet<Int> {\n return toCollection(HashSet<Int>(mapCapacity(size)))\n}\n\n/**\n * Returns a [HashSet] of all elements.\n */\npublic fun LongArray.toHashSet(): HashSet<Long> {\n return toCollection(HashSet<Long>(mapCapacity(size)))\n}\n\n/**\n * Returns a [HashSet] of all elements.\n */\npublic fun FloatArray.toHashSet(): HashSet<Float> {\n return toCollection(HashSet<Float>(mapCapacity(size)))\n}\n\n/**\n * Returns a [HashSet] of all elements.\n */\npublic fun DoubleArray.toHashSet(): HashSet<Double> {\n return toCollection(HashSet<Double>(mapCapacity(size)))\n}\n\n/**\n * Returns a [HashSet] of all elements.\n */\npublic fun BooleanArray.toHashSet(): HashSet<Boolean> {\n return toCollection(HashSet<Boolean>(mapCapacity(size)))\n}\n\n/**\n * Returns a [HashSet] of all elements.\n */\npublic fun CharArray.toHashSet(): HashSet<Char> {\n return toCollection(HashSet<Char>(mapCapacity(size)))\n}\n\n/**\n * Returns a [List] containing all elements.\n */\npublic fun <T> Array<out T>.toList(): List<T> {\n return when (size) {\n 0 -> emptyList()\n 1 -> listOf(this[0])\n else -> this.toMutableList()\n }\n}\n\n/**\n * Returns a [List] containing all elements.\n */\npublic fun ByteArray.toList(): List<Byte> {\n return when (size) {\n 0 -> emptyList()\n 1 -> listOf(this[0])\n else -> this.toMutableList()\n }\n}\n\n/**\n * Returns a [List] containing all elements.\n */\npublic fun ShortArray.toList(): List<Short> {\n return when (size) {\n 0 -> emptyList()\n 1 -> listOf(this[0])\n else -> this.toMutableList()\n }\n}\n\n/**\n * Returns a [List] containing all elements.\n */\npublic fun IntArray.toList(): List<Int> {\n return when (size) {\n 0 -> emptyList()\n 1 -> listOf(this[0])\n else -> this.toMutableList()\n }\n}\n\n/**\n * Returns a [List] containing all elements.\n */\npublic fun LongArray.toList(): List<Long> {\n return when (size) {\n 0 -> emptyList()\n 1 -> listOf(this[0])\n else -> this.toMutableList()\n }\n}\n\n/**\n * Returns a [List] containing all elements.\n */\npublic fun FloatArray.toList(): List<Float> {\n return when (size) {\n 0 -> emptyList()\n 1 -> listOf(this[0])\n else -> this.toMutableList()\n }\n}\n\n/**\n * Returns a [List] containing all elements.\n */\npublic fun DoubleArray.toList(): List<Double> {\n return when (size) {\n 0 -> emptyList()\n 1 -> listOf(this[0])\n else -> this.toMutableList()\n }\n}\n\n/**\n * Returns a [List] containing all elements.\n */\npublic fun BooleanArray.toList(): List<Boolean> {\n return when (size) {\n 0 -> emptyList()\n 1 -> listOf(this[0])\n else -> this.toMutableList()\n }\n}\n\n/**\n * Returns a [List] containing all elements.\n */\npublic fun CharArray.toList(): List<Char> {\n return when (size) {\n 0 -> emptyList()\n 1 -> listOf(this[0])\n else -> this.toMutableList()\n }\n}\n\n/**\n * Returns a [MutableList] filled with all elements of this array.\n */\npublic fun <T> Array<out T>.toMutableList(): MutableList<T> {\n return ArrayList(this.asCollection())\n}\n\n/**\n * Returns a [MutableList] filled with all elements of this array.\n */\npublic fun ByteArray.toMutableList(): MutableList<Byte> {\n val list = ArrayList<Byte>(size)\n for (item in this) list.add(item)\n return list\n}\n\n/**\n * Returns a [MutableList] filled with all elements of this array.\n */\npublic fun ShortArray.toMutableList(): MutableList<Short> {\n val list = ArrayList<Short>(size)\n for (item in this) list.add(item)\n return list\n}\n\n/**\n * Returns a [MutableList] filled with all elements of this array.\n */\npublic fun IntArray.toMutableList(): MutableList<Int> {\n val list = ArrayList<Int>(size)\n for (item in this) list.add(item)\n return list\n}\n\n/**\n * Returns a [MutableList] filled with all elements of this array.\n */\npublic fun LongArray.toMutableList(): MutableList<Long> {\n val list = ArrayList<Long>(size)\n for (item in this) list.add(item)\n return list\n}\n\n/**\n * Returns a [MutableList] filled with all elements of this array.\n */\npublic fun FloatArray.toMutableList(): MutableList<Float> {\n val list = ArrayList<Float>(size)\n for (item in this) list.add(item)\n return list\n}\n\n/**\n * Returns a [MutableList] filled with all elements of this array.\n */\npublic fun DoubleArray.toMutableList(): MutableList<Double> {\n val list = ArrayList<Double>(size)\n for (item in this) list.add(item)\n return list\n}\n\n/**\n * Returns a [MutableList] filled with all elements of this array.\n */\npublic fun BooleanArray.toMutableList(): MutableList<Boolean> {\n val list = ArrayList<Boolean>(size)\n for (item in this) list.add(item)\n return list\n}\n\n/**\n * Returns a [MutableList] filled with all elements of this array.\n */\npublic fun CharArray.toMutableList(): MutableList<Char> {\n val list = ArrayList<Char>(size)\n for (item in this) list.add(item)\n return list\n}\n\n/**\n * Returns a [Set] of all elements.\n * \n * The returned set preserves the element iteration order of the original array.\n */\npublic fun <T> Array<out T>.toSet(): Set<T> {\n return when (size) {\n 0 -> emptySet()\n 1 -> setOf(this[0])\n else -> toCollection(LinkedHashSet<T>(mapCapacity(size)))\n }\n}\n\n/**\n * Returns a [Set] of all elements.\n * \n * The returned set preserves the element iteration order of the original array.\n */\npublic fun ByteArray.toSet(): Set<Byte> {\n return when (size) {\n 0 -> emptySet()\n 1 -> setOf(this[0])\n else -> toCollection(LinkedHashSet<Byte>(mapCapacity(size)))\n }\n}\n\n/**\n * Returns a [Set] of all elements.\n * \n * The returned set preserves the element iteration order of the original array.\n */\npublic fun ShortArray.toSet(): Set<Short> {\n return when (size) {\n 0 -> emptySet()\n 1 -> setOf(this[0])\n else -> toCollection(LinkedHashSet<Short>(mapCapacity(size)))\n }\n}\n\n/**\n * Returns a [Set] of all elements.\n * \n * The returned set preserves the element iteration order of the original array.\n */\npublic fun IntArray.toSet(): Set<Int> {\n return when (size) {\n 0 -> emptySet()\n 1 -> setOf(this[0])\n else -> toCollection(LinkedHashSet<Int>(mapCapacity(size)))\n }\n}\n\n/**\n * Returns a [Set] of all elements.\n * \n * The returned set preserves the element iteration order of the original array.\n */\npublic fun LongArray.toSet(): Set<Long> {\n return when (size) {\n 0 -> emptySet()\n 1 -> setOf(this[0])\n else -> toCollection(LinkedHashSet<Long>(mapCapacity(size)))\n }\n}\n\n/**\n * Returns a [Set] of all elements.\n * \n * The returned set preserves the element iteration order of the original array.\n */\npublic fun FloatArray.toSet(): Set<Float> {\n return when (size) {\n 0 -> emptySet()\n 1 -> setOf(this[0])\n else -> toCollection(LinkedHashSet<Float>(mapCapacity(size)))\n }\n}\n\n/**\n * Returns a [Set] of all elements.\n * \n * The returned set preserves the element iteration order of the original array.\n */\npublic fun DoubleArray.toSet(): Set<Double> {\n return when (size) {\n 0 -> emptySet()\n 1 -> setOf(this[0])\n else -> toCollection(LinkedHashSet<Double>(mapCapacity(size)))\n }\n}\n\n/**\n * Returns a [Set] of all elements.\n * \n * The returned set preserves the element iteration order of the original array.\n */\npublic fun BooleanArray.toSet(): Set<Boolean> {\n return when (size) {\n 0 -> emptySet()\n 1 -> setOf(this[0])\n else -> toCollection(LinkedHashSet<Boolean>(mapCapacity(size)))\n }\n}\n\n/**\n * Returns a [Set] of all elements.\n * \n * The returned set preserves the element iteration order of the original array.\n */\npublic fun CharArray.toSet(): Set<Char> {\n return when (size) {\n 0 -> emptySet()\n 1 -> setOf(this[0])\n else -> toCollection(LinkedHashSet<Char>(mapCapacity(size)))\n }\n}\n\n/**\n * Returns a single list of all elements yielded from results of [transform] function being invoked on each element of original array.\n */\npublic inline fun <T, R> Array<out T>.flatMap(transform: (T) -> Iterable<R>): List<R> {\n return flatMapTo(ArrayList<R>(), transform)\n}\n\n/**\n * Returns a single list of all elements yielded from results of [transform] function being invoked on each element of original array.\n */\npublic inline fun <R> ByteArray.flatMap(transform: (Byte) -> Iterable<R>): List<R> {\n return flatMapTo(ArrayList<R>(), transform)\n}\n\n/**\n * Returns a single list of all elements yielded from results of [transform] function being invoked on each element of original array.\n */\npublic inline fun <R> ShortArray.flatMap(transform: (Short) -> Iterable<R>): List<R> {\n return flatMapTo(ArrayList<R>(), transform)\n}\n\n/**\n * Returns a single list of all elements yielded from results of [transform] function being invoked on each element of original array.\n */\npublic inline fun <R> IntArray.flatMap(transform: (Int) -> Iterable<R>): List<R> {\n return flatMapTo(ArrayList<R>(), transform)\n}\n\n/**\n * Returns a single list of all elements yielded from results of [transform] function being invoked on each element of original array.\n */\npublic inline fun <R> LongArray.flatMap(transform: (Long) -> Iterable<R>): List<R> {\n return flatMapTo(ArrayList<R>(), transform)\n}\n\n/**\n * Returns a single list of all elements yielded from results of [transform] function being invoked on each element of original array.\n */\npublic inline fun <R> FloatArray.flatMap(transform: (Float) -> Iterable<R>): List<R> {\n return flatMapTo(ArrayList<R>(), transform)\n}\n\n/**\n * Returns a single list of all elements yielded from results of [transform] function being invoked on each element of original array.\n */\npublic inline fun <R> DoubleArray.flatMap(transform: (Double) -> Iterable<R>): List<R> {\n return flatMapTo(ArrayList<R>(), transform)\n}\n\n/**\n * Returns a single list of all elements yielded from results of [transform] function being invoked on each element of original array.\n */\npublic inline fun <R> BooleanArray.flatMap(transform: (Boolean) -> Iterable<R>): List<R> {\n return flatMapTo(ArrayList<R>(), transform)\n}\n\n/**\n * Returns a single list of all elements yielded from results of [transform] function being invoked on each element of original array.\n */\npublic inline fun <R> CharArray.flatMap(transform: (Char) -> Iterable<R>): List<R> {\n return flatMapTo(ArrayList<R>(), transform)\n}\n\n/**\n * Appends all elements yielded from results of [transform] function being invoked on each element of original array, to the given [destination].\n */\npublic inline fun <T, R, C : MutableCollection<in R>> Array<out T>.flatMapTo(destination: C, transform: (T) -> Iterable<R>): C {\n for (element in this) {\n val list = transform(element)\n destination.addAll(list)\n }\n return destination\n}\n\n/**\n * Appends all elements yielded from results of [transform] function being invoked on each element of original array, to the given [destination].\n */\npublic inline fun <R, C : MutableCollection<in R>> ByteArray.flatMapTo(destination: C, transform: (Byte) -> Iterable<R>): C {\n for (element in this) {\n val list = transform(element)\n destination.addAll(list)\n }\n return destination\n}\n\n/**\n * Appends all elements yielded from results of [transform] function being invoked on each element of original array, to the given [destination].\n */\npublic inline fun <R, C : MutableCollection<in R>> ShortArray.flatMapTo(destination: C, transform: (Short) -> Iterable<R>): C {\n for (element in this) {\n val list = transform(element)\n destination.addAll(list)\n }\n return destination\n}\n\n/**\n * Appends all elements yielded from results of [transform] function being invoked on each element of original array, to the given [destination].\n */\npublic inline fun <R, C : MutableCollection<in R>> IntArray.flatMapTo(destination: C, transform: (Int) -> Iterable<R>): C {\n for (element in this) {\n val list = transform(element)\n destination.addAll(list)\n }\n return destination\n}\n\n/**\n * Appends all elements yielded from results of [transform] function being invoked on each element of original array, to the given [destination].\n */\npublic inline fun <R, C : MutableCollection<in R>> LongArray.flatMapTo(destination: C, transform: (Long) -> Iterable<R>): C {\n for (element in this) {\n val list = transform(element)\n destination.addAll(list)\n }\n return destination\n}\n\n/**\n * Appends all elements yielded from results of [transform] function being invoked on each element of original array, to the given [destination].\n */\npublic inline fun <R, C : MutableCollection<in R>> FloatArray.flatMapTo(destination: C, transform: (Float) -> Iterable<R>): C {\n for (element in this) {\n val list = transform(element)\n destination.addAll(list)\n }\n return destination\n}\n\n/**\n * Appends all elements yielded from results of [transform] function being invoked on each element of original array, to the given [destination].\n */\npublic inline fun <R, C : MutableCollection<in R>> DoubleArray.flatMapTo(destination: C, transform: (Double) -> Iterable<R>): C {\n for (element in this) {\n val list = transform(element)\n destination.addAll(list)\n }\n return destination\n}\n\n/**\n * Appends all elements yielded from results of [transform] function being invoked on each element of original array, to the given [destination].\n */\npublic inline fun <R, C : MutableCollection<in R>> BooleanArray.flatMapTo(destination: C, transform: (Boolean) -> Iterable<R>): C {\n for (element in this) {\n val list = transform(element)\n destination.addAll(list)\n }\n return destination\n}\n\n/**\n * Appends all elements yielded from results of [transform] function being invoked on each element of original array, to the given [destination].\n */\npublic inline fun <R, C : MutableCollection<in R>> CharArray.flatMapTo(destination: C, transform: (Char) -> Iterable<R>): C {\n for (element in this) {\n val list = transform(element)\n destination.addAll(list)\n }\n return destination\n}\n\n/**\n * Groups elements of the original array by the key returned by the given [keySelector] function\n * applied to each element and returns a map where each group key is associated with a list of corresponding elements.\n * \n * The returned map preserves the entry iteration order of the keys produced from the original array.\n * \n * @sample samples.collections.Collections.Transformations.groupBy\n */\npublic inline fun <T, K> Array<out T>.groupBy(keySelector: (T) -> K): Map<K, List<T>> {\n return groupByTo(LinkedHashMap<K, MutableList<T>>(), keySelector)\n}\n\n/**\n * Groups elements of the original array by the key returned by the given [keySelector] function\n * applied to each element and returns a map where each group key is associated with a list of corresponding elements.\n * \n * The returned map preserves the entry iteration order of the keys produced from the original array.\n * \n * @sample samples.collections.Collections.Transformations.groupBy\n */\npublic inline fun <K> ByteArray.groupBy(keySelector: (Byte) -> K): Map<K, List<Byte>> {\n return groupByTo(LinkedHashMap<K, MutableList<Byte>>(), keySelector)\n}\n\n/**\n * Groups elements of the original array by the key returned by the given [keySelector] function\n * applied to each element and returns a map where each group key is associated with a list of corresponding elements.\n * \n * The returned map preserves the entry iteration order of the keys produced from the original array.\n * \n * @sample samples.collections.Collections.Transformations.groupBy\n */\npublic inline fun <K> ShortArray.groupBy(keySelector: (Short) -> K): Map<K, List<Short>> {\n return groupByTo(LinkedHashMap<K, MutableList<Short>>(), keySelector)\n}\n\n/**\n * Groups elements of the original array by the key returned by the given [keySelector] function\n * applied to each element and returns a map where each group key is associated with a list of corresponding elements.\n * \n * The returned map preserves the entry iteration order of the keys produced from the original array.\n * \n * @sample samples.collections.Collections.Transformations.groupBy\n */\npublic inline fun <K> IntArray.groupBy(keySelector: (Int) -> K): Map<K, List<Int>> {\n return groupByTo(LinkedHashMap<K, MutableList<Int>>(), keySelector)\n}\n\n/**\n * Groups elements of the original array by the key returned by the given [keySelector] function\n * applied to each element and returns a map where each group key is associated with a list of corresponding elements.\n * \n * The returned map preserves the entry iteration order of the keys produced from the original array.\n * \n * @sample samples.collections.Collections.Transformations.groupBy\n */\npublic inline fun <K> LongArray.groupBy(keySelector: (Long) -> K): Map<K, List<Long>> {\n return groupByTo(LinkedHashMap<K, MutableList<Long>>(), keySelector)\n}\n\n/**\n * Groups elements of the original array by the key returned by the given [keySelector] function\n * applied to each element and returns a map where each group key is associated with a list of corresponding elements.\n * \n * The returned map preserves the entry iteration order of the keys produced from the original array.\n * \n * @sample samples.collections.Collections.Transformations.groupBy\n */\npublic inline fun <K> FloatArray.groupBy(keySelector: (Float) -> K): Map<K, List<Float>> {\n return groupByTo(LinkedHashMap<K, MutableList<Float>>(), keySelector)\n}\n\n/**\n * Groups elements of the original array by the key returned by the given [keySelector] function\n * applied to each element and returns a map where each group key is associated with a list of corresponding elements.\n * \n * The returned map preserves the entry iteration order of the keys produced from the original array.\n * \n * @sample samples.collections.Collections.Transformations.groupBy\n */\npublic inline fun <K> DoubleArray.groupBy(keySelector: (Double) -> K): Map<K, List<Double>> {\n return groupByTo(LinkedHashMap<K, MutableList<Double>>(), keySelector)\n}\n\n/**\n * Groups elements of the original array by the key returned by the given [keySelector] function\n * applied to each element and returns a map where each group key is associated with a list of corresponding elements.\n * \n * The returned map preserves the entry iteration order of the keys produced from the original array.\n * \n * @sample samples.collections.Collections.Transformations.groupBy\n */\npublic inline fun <K> BooleanArray.groupBy(keySelector: (Boolean) -> K): Map<K, List<Boolean>> {\n return groupByTo(LinkedHashMap<K, MutableList<Boolean>>(), keySelector)\n}\n\n/**\n * Groups elements of the original array by the key returned by the given [keySelector] function\n * applied to each element and returns a map where each group key is associated with a list of corresponding elements.\n * \n * The returned map preserves the entry iteration order of the keys produced from the original array.\n * \n * @sample samples.collections.Collections.Transformations.groupBy\n */\npublic inline fun <K> CharArray.groupBy(keySelector: (Char) -> K): Map<K, List<Char>> {\n return groupByTo(LinkedHashMap<K, MutableList<Char>>(), keySelector)\n}\n\n/**\n * Groups values returned by the [valueTransform] function applied to each element of the original array\n * by the key returned by the given [keySelector] function applied to the element\n * and returns a map where each group key is associated with a list of corresponding values.\n * \n * The returned map preserves the entry iteration order of the keys produced from the original array.\n * \n * @sample samples.collections.Collections.Transformations.groupByKeysAndValues\n */\npublic inline fun <T, K, V> Array<out T>.groupBy(keySelector: (T) -> K, valueTransform: (T) -> V): Map<K, List<V>> {\n return groupByTo(LinkedHashMap<K, MutableList<V>>(), keySelector, valueTransform)\n}\n\n/**\n * Groups values returned by the [valueTransform] function applied to each element of the original array\n * by the key returned by the given [keySelector] function applied to the element\n * and returns a map where each group key is associated with a list of corresponding values.\n * \n * The returned map preserves the entry iteration order of the keys produced from the original array.\n * \n * @sample samples.collections.Collections.Transformations.groupByKeysAndValues\n */\npublic inline fun <K, V> ByteArray.groupBy(keySelector: (Byte) -> K, valueTransform: (Byte) -> V): Map<K, List<V>> {\n return groupByTo(LinkedHashMap<K, MutableList<V>>(), keySelector, valueTransform)\n}\n\n/**\n * Groups values returned by the [valueTransform] function applied to each element of the original array\n * by the key returned by the given [keySelector] function applied to the element\n * and returns a map where each group key is associated with a list of corresponding values.\n * \n * The returned map preserves the entry iteration order of the keys produced from the original array.\n * \n * @sample samples.collections.Collections.Transformations.groupByKeysAndValues\n */\npublic inline fun <K, V> ShortArray.groupBy(keySelector: (Short) -> K, valueTransform: (Short) -> V): Map<K, List<V>> {\n return groupByTo(LinkedHashMap<K, MutableList<V>>(), keySelector, valueTransform)\n}\n\n/**\n * Groups values returned by the [valueTransform] function applied to each element of the original array\n * by the key returned by the given [keySelector] function applied to the element\n * and returns a map where each group key is associated with a list of corresponding values.\n * \n * The returned map preserves the entry iteration order of the keys produced from the original array.\n * \n * @sample samples.collections.Collections.Transformations.groupByKeysAndValues\n */\npublic inline fun <K, V> IntArray.groupBy(keySelector: (Int) -> K, valueTransform: (Int) -> V): Map<K, List<V>> {\n return groupByTo(LinkedHashMap<K, MutableList<V>>(), keySelector, valueTransform)\n}\n\n/**\n * Groups values returned by the [valueTransform] function applied to each element of the original array\n * by the key returned by the given [keySelector] function applied to the element\n * and returns a map where each group key is associated with a list of corresponding values.\n * \n * The returned map preserves the entry iteration order of the keys produced from the original array.\n * \n * @sample samples.collections.Collections.Transformations.groupByKeysAndValues\n */\npublic inline fun <K, V> LongArray.groupBy(keySelector: (Long) -> K, valueTransform: (Long) -> V): Map<K, List<V>> {\n return groupByTo(LinkedHashMap<K, MutableList<V>>(), keySelector, valueTransform)\n}\n\n/**\n * Groups values returned by the [valueTransform] function applied to each element of the original array\n * by the key returned by the given [keySelector] function applied to the element\n * and returns a map where each group key is associated with a list of corresponding values.\n * \n * The returned map preserves the entry iteration order of the keys produced from the original array.\n * \n * @sample samples.collections.Collections.Transformations.groupByKeysAndValues\n */\npublic inline fun <K, V> FloatArray.groupBy(keySelector: (Float) -> K, valueTransform: (Float) -> V): Map<K, List<V>> {\n return groupByTo(LinkedHashMap<K, MutableList<V>>(), keySelector, valueTransform)\n}\n\n/**\n * Groups values returned by the [valueTransform] function applied to each element of the original array\n * by the key returned by the given [keySelector] function applied to the element\n * and returns a map where each group key is associated with a list of corresponding values.\n * \n * The returned map preserves the entry iteration order of the keys produced from the original array.\n * \n * @sample samples.collections.Collections.Transformations.groupByKeysAndValues\n */\npublic inline fun <K, V> DoubleArray.groupBy(keySelector: (Double) -> K, valueTransform: (Double) -> V): Map<K, List<V>> {\n return groupByTo(LinkedHashMap<K, MutableList<V>>(), keySelector, valueTransform)\n}\n\n/**\n * Groups values returned by the [valueTransform] function applied to each element of the original array\n * by the key returned by the given [keySelector] function applied to the element\n * and returns a map where each group key is associated with a list of corresponding values.\n * \n * The returned map preserves the entry iteration order of the keys produced from the original array.\n * \n * @sample samples.collections.Collections.Transformations.groupByKeysAndValues\n */\npublic inline fun <K, V> BooleanArray.groupBy(keySelector: (Boolean) -> K, valueTransform: (Boolean) -> V): Map<K, List<V>> {\n return groupByTo(LinkedHashMap<K, MutableList<V>>(), keySelector, valueTransform)\n}\n\n/**\n * Groups values returned by the [valueTransform] function applied to each element of the original array\n * by the key returned by the given [keySelector] function applied to the element\n * and returns a map where each group key is associated with a list of corresponding values.\n * \n * The returned map preserves the entry iteration order of the keys produced from the original array.\n * \n * @sample samples.collections.Collections.Transformations.groupByKeysAndValues\n */\npublic inline fun <K, V> CharArray.groupBy(keySelector: (Char) -> K, valueTransform: (Char) -> V): Map<K, List<V>> {\n return groupByTo(LinkedHashMap<K, MutableList<V>>(), keySelector, valueTransform)\n}\n\n/**\n * Groups elements of the original array by the key returned by the given [keySelector] function\n * applied to each element and puts to the [destination] map each group key associated with a list of corresponding elements.\n * \n * @return The [destination] map.\n * \n * @sample samples.collections.Collections.Transformations.groupBy\n */\npublic inline fun <T, K, M : MutableMap<in K, MutableList<T>>> Array<out T>.groupByTo(destination: M, keySelector: (T) -> K): M {\n for (element in this) {\n val key = keySelector(element)\n val list = destination.getOrPut(key) { ArrayList<T>() }\n list.add(element)\n }\n return destination\n}\n\n/**\n * Groups elements of the original array by the key returned by the given [keySelector] function\n * applied to each element and puts to the [destination] map each group key associated with a list of corresponding elements.\n * \n * @return The [destination] map.\n * \n * @sample samples.collections.Collections.Transformations.groupBy\n */\npublic inline fun <K, M : MutableMap<in K, MutableList<Byte>>> ByteArray.groupByTo(destination: M, keySelector: (Byte) -> K): M {\n for (element in this) {\n val key = keySelector(element)\n val list = destination.getOrPut(key) { ArrayList<Byte>() }\n list.add(element)\n }\n return destination\n}\n\n/**\n * Groups elements of the original array by the key returned by the given [keySelector] function\n * applied to each element and puts to the [destination] map each group key associated with a list of corresponding elements.\n * \n * @return The [destination] map.\n * \n * @sample samples.collections.Collections.Transformations.groupBy\n */\npublic inline fun <K, M : MutableMap<in K, MutableList<Short>>> ShortArray.groupByTo(destination: M, keySelector: (Short) -> K): M {\n for (element in this) {\n val key = keySelector(element)\n val list = destination.getOrPut(key) { ArrayList<Short>() }\n list.add(element)\n }\n return destination\n}\n\n/**\n * Groups elements of the original array by the key returned by the given [keySelector] function\n * applied to each element and puts to the [destination] map each group key associated with a list of corresponding elements.\n * \n * @return The [destination] map.\n * \n * @sample samples.collections.Collections.Transformations.groupBy\n */\npublic inline fun <K, M : MutableMap<in K, MutableList<Int>>> IntArray.groupByTo(destination: M, keySelector: (Int) -> K): M {\n for (element in this) {\n val key = keySelector(element)\n val list = destination.getOrPut(key) { ArrayList<Int>() }\n list.add(element)\n }\n return destination\n}\n\n/**\n * Groups elements of the original array by the key returned by the given [keySelector] function\n * applied to each element and puts to the [destination] map each group key associated with a list of corresponding elements.\n * \n * @return The [destination] map.\n * \n * @sample samples.collections.Collections.Transformations.groupBy\n */\npublic inline fun <K, M : MutableMap<in K, MutableList<Long>>> LongArray.groupByTo(destination: M, keySelector: (Long) -> K): M {\n for (element in this) {\n val key = keySelector(element)\n val list = destination.getOrPut(key) { ArrayList<Long>() }\n list.add(element)\n }\n return destination\n}\n\n/**\n * Groups elements of the original array by the key returned by the given [keySelector] function\n * applied to each element and puts to the [destination] map each group key associated with a list of corresponding elements.\n * \n * @return The [destination] map.\n * \n * @sample samples.collections.Collections.Transformations.groupBy\n */\npublic inline fun <K, M : MutableMap<in K, MutableList<Float>>> FloatArray.groupByTo(destination: M, keySelector: (Float) -> K): M {\n for (element in this) {\n val key = keySelector(element)\n val list = destination.getOrPut(key) { ArrayList<Float>() }\n list.add(element)\n }\n return destination\n}\n\n/**\n * Groups elements of the original array by the key returned by the given [keySelector] function\n * applied to each element and puts to the [destination] map each group key associated with a list of corresponding elements.\n * \n * @return The [destination] map.\n * \n * @sample samples.collections.Collections.Transformations.groupBy\n */\npublic inline fun <K, M : MutableMap<in K, MutableList<Double>>> DoubleArray.groupByTo(destination: M, keySelector: (Double) -> K): M {\n for (element in this) {\n val key = keySelector(element)\n val list = destination.getOrPut(key) { ArrayList<Double>() }\n list.add(element)\n }\n return destination\n}\n\n/**\n * Groups elements of the original array by the key returned by the given [keySelector] function\n * applied to each element and puts to the [destination] map each group key associated with a list of corresponding elements.\n * \n * @return The [destination] map.\n * \n * @sample samples.collections.Collections.Transformations.groupBy\n */\npublic inline fun <K, M : MutableMap<in K, MutableList<Boolean>>> BooleanArray.groupByTo(destination: M, keySelector: (Boolean) -> K): M {\n for (element in this) {\n val key = keySelector(element)\n val list = destination.getOrPut(key) { ArrayList<Boolean>() }\n list.add(element)\n }\n return destination\n}\n\n/**\n * Groups elements of the original array by the key returned by the given [keySelector] function\n * applied to each element and puts to the [destination] map each group key associated with a list of corresponding elements.\n * \n * @return The [destination] map.\n * \n * @sample samples.collections.Collections.Transformations.groupBy\n */\npublic inline fun <K, M : MutableMap<in K, MutableList<Char>>> CharArray.groupByTo(destination: M, keySelector: (Char) -> K): M {\n for (element in this) {\n val key = keySelector(element)\n val list = destination.getOrPut(key) { ArrayList<Char>() }\n list.add(element)\n }\n return destination\n}\n\n/**\n * Groups values returned by the [valueTransform] function applied to each element of the original array\n * by the key returned by the given [keySelector] function applied to the element\n * and puts to the [destination] map each group key associated with a list of corresponding values.\n * \n * @return The [destination] map.\n * \n * @sample samples.collections.Collections.Transformations.groupByKeysAndValues\n */\npublic inline fun <T, K, V, M : MutableMap<in K, MutableList<V>>> Array<out T>.groupByTo(destination: M, keySelector: (T) -> K, valueTransform: (T) -> V): M {\n for (element in this) {\n val key = keySelector(element)\n val list = destination.getOrPut(key) { ArrayList<V>() }\n list.add(valueTransform(element))\n }\n return destination\n}\n\n/**\n * Groups values returned by the [valueTransform] function applied to each element of the original array\n * by the key returned by the given [keySelector] function applied to the element\n * and puts to the [destination] map each group key associated with a list of corresponding values.\n * \n * @return The [destination] map.\n * \n * @sample samples.collections.Collections.Transformations.groupByKeysAndValues\n */\npublic inline fun <K, V, M : MutableMap<in K, MutableList<V>>> ByteArray.groupByTo(destination: M, keySelector: (Byte) -> K, valueTransform: (Byte) -> V): M {\n for (element in this) {\n val key = keySelector(element)\n val list = destination.getOrPut(key) { ArrayList<V>() }\n list.add(valueTransform(element))\n }\n return destination\n}\n\n/**\n * Groups values returned by the [valueTransform] function applied to each element of the original array\n * by the key returned by the given [keySelector] function applied to the element\n * and puts to the [destination] map each group key associated with a list of corresponding values.\n * \n * @return The [destination] map.\n * \n * @sample samples.collections.Collections.Transformations.groupByKeysAndValues\n */\npublic inline fun <K, V, M : MutableMap<in K, MutableList<V>>> ShortArray.groupByTo(destination: M, keySelector: (Short) -> K, valueTransform: (Short) -> V): M {\n for (element in this) {\n val key = keySelector(element)\n val list = destination.getOrPut(key) { ArrayList<V>() }\n list.add(valueTransform(element))\n }\n return destination\n}\n\n/**\n * Groups values returned by the [valueTransform] function applied to each element of the original array\n * by the key returned by the given [keySelector] function applied to the element\n * and puts to the [destination] map each group key associated with a list of corresponding values.\n * \n * @return The [destination] map.\n * \n * @sample samples.collections.Collections.Transformations.groupByKeysAndValues\n */\npublic inline fun <K, V, M : MutableMap<in K, MutableList<V>>> IntArray.groupByTo(destination: M, keySelector: (Int) -> K, valueTransform: (Int) -> V): M {\n for (element in this) {\n val key = keySelector(element)\n val list = destination.getOrPut(key) { ArrayList<V>() }\n list.add(valueTransform(element))\n }\n return destination\n}\n\n/**\n * Groups values returned by the [valueTransform] function applied to each element of the original array\n * by the key returned by the given [keySelector] function applied to the element\n * and puts to the [destination] map each group key associated with a list of corresponding values.\n * \n * @return The [destination] map.\n * \n * @sample samples.collections.Collections.Transformations.groupByKeysAndValues\n */\npublic inline fun <K, V, M : MutableMap<in K, MutableList<V>>> LongArray.groupByTo(destination: M, keySelector: (Long) -> K, valueTransform: (Long) -> V): M {\n for (element in this) {\n val key = keySelector(element)\n val list = destination.getOrPut(key) { ArrayList<V>() }\n list.add(valueTransform(element))\n }\n return destination\n}\n\n/**\n * Groups values returned by the [valueTransform] function applied to each element of the original array\n * by the key returned by the given [keySelector] function applied to the element\n * and puts to the [destination] map each group key associated with a list of corresponding values.\n * \n * @return The [destination] map.\n * \n * @sample samples.collections.Collections.Transformations.groupByKeysAndValues\n */\npublic inline fun <K, V, M : MutableMap<in K, MutableList<V>>> FloatArray.groupByTo(destination: M, keySelector: (Float) -> K, valueTransform: (Float) -> V): M {\n for (element in this) {\n val key = keySelector(element)\n val list = destination.getOrPut(key) { ArrayList<V>() }\n list.add(valueTransform(element))\n }\n return destination\n}\n\n/**\n * Groups values returned by the [valueTransform] function applied to each element of the original array\n * by the key returned by the given [keySelector] function applied to the element\n * and puts to the [destination] map each group key associated with a list of corresponding values.\n * \n * @return The [destination] map.\n * \n * @sample samples.collections.Collections.Transformations.groupByKeysAndValues\n */\npublic inline fun <K, V, M : MutableMap<in K, MutableList<V>>> DoubleArray.groupByTo(destination: M, keySelector: (Double) -> K, valueTransform: (Double) -> V): M {\n for (element in this) {\n val key = keySelector(element)\n val list = destination.getOrPut(key) { ArrayList<V>() }\n list.add(valueTransform(element))\n }\n return destination\n}\n\n/**\n * Groups values returned by the [valueTransform] function applied to each element of the original array\n * by the key returned by the given [keySelector] function applied to the element\n * and puts to the [destination] map each group key associated with a list of corresponding values.\n * \n * @return The [destination] map.\n * \n * @sample samples.collections.Collections.Transformations.groupByKeysAndValues\n */\npublic inline fun <K, V, M : MutableMap<in K, MutableList<V>>> BooleanArray.groupByTo(destination: M, keySelector: (Boolean) -> K, valueTransform: (Boolean) -> V): M {\n for (element in this) {\n val key = keySelector(element)\n val list = destination.getOrPut(key) { ArrayList<V>() }\n list.add(valueTransform(element))\n }\n return destination\n}\n\n/**\n * Groups values returned by the [valueTransform] function applied to each element of the original array\n * by the key returned by the given [keySelector] function applied to the element\n * and puts to the [destination] map each group key associated with a list of corresponding values.\n * \n * @return The [destination] map.\n * \n * @sample samples.collections.Collections.Transformations.groupByKeysAndValues\n */\npublic inline fun <K, V, M : MutableMap<in K, MutableList<V>>> CharArray.groupByTo(destination: M, keySelector: (Char) -> K, valueTransform: (Char) -> V): M {\n for (element in this) {\n val key = keySelector(element)\n val list = destination.getOrPut(key) { ArrayList<V>() }\n list.add(valueTransform(element))\n }\n return destination\n}\n\n/**\n * Creates a [Grouping] source from an array to be used later with one of group-and-fold operations\n * using the specified [keySelector] function to extract a key from each element.\n * \n * @sample samples.collections.Grouping.groupingByEachCount\n */\n@SinceKotlin(\"1.1\")\npublic inline fun <T, K> Array<out T>.groupingBy(crossinline keySelector: (T) -> K): Grouping<T, K> {\n return object : Grouping<T, K> {\n override fun sourceIterator(): Iterator<T> = [email protected]()\n override fun keyOf(element: T): K = keySelector(element)\n }\n}\n\n/**\n * Returns a list containing the results of applying the given [transform] function\n * to each element in the original array.\n */\npublic inline fun <T, R> Array<out T>.map(transform: (T) -> R): List<R> {\n return mapTo(ArrayList<R>(size), transform)\n}\n\n/**\n * Returns a list containing the results of applying the given [transform] function\n * to each element in the original array.\n */\npublic inline fun <R> ByteArray.map(transform: (Byte) -> R): List<R> {\n return mapTo(ArrayList<R>(size), transform)\n}\n\n/**\n * Returns a list containing the results of applying the given [transform] function\n * to each element in the original array.\n */\npublic inline fun <R> ShortArray.map(transform: (Short) -> R): List<R> {\n return mapTo(ArrayList<R>(size), transform)\n}\n\n/**\n * Returns a list containing the results of applying the given [transform] function\n * to each element in the original array.\n */\npublic inline fun <R> IntArray.map(transform: (Int) -> R): List<R> {\n return mapTo(ArrayList<R>(size), transform)\n}\n\n/**\n * Returns a list containing the results of applying the given [transform] function\n * to each element in the original array.\n */\npublic inline fun <R> LongArray.map(transform: (Long) -> R): List<R> {\n return mapTo(ArrayList<R>(size), transform)\n}\n\n/**\n * Returns a list containing the results of applying the given [transform] function\n * to each element in the original array.\n */\npublic inline fun <R> FloatArray.map(transform: (Float) -> R): List<R> {\n return mapTo(ArrayList<R>(size), transform)\n}\n\n/**\n * Returns a list containing the results of applying the given [transform] function\n * to each element in the original array.\n */\npublic inline fun <R> DoubleArray.map(transform: (Double) -> R): List<R> {\n return mapTo(ArrayList<R>(size), transform)\n}\n\n/**\n * Returns a list containing the results of applying the given [transform] function\n * to each element in the original array.\n */\npublic inline fun <R> BooleanArray.map(transform: (Boolean) -> R): List<R> {\n return mapTo(ArrayList<R>(size), transform)\n}\n\n/**\n * Returns a list containing the results of applying the given [transform] function\n * to each element in the original array.\n */\npublic inline fun <R> CharArray.map(transform: (Char) -> R): List<R> {\n return mapTo(ArrayList<R>(size), transform)\n}\n\n/**\n * Returns a list containing the results of applying the given [transform] function\n * to each element and its index in the original array.\n * @param [transform] function that takes the index of an element and the element itself\n * and returns the result of the transform applied to the element.\n */\npublic inline fun <T, R> Array<out T>.mapIndexed(transform: (index: Int, T) -> R): List<R> {\n return mapIndexedTo(ArrayList<R>(size), transform)\n}\n\n/**\n * Returns a list containing the results of applying the given [transform] function\n * to each element and its index in the original array.\n * @param [transform] function that takes the index of an element and the element itself\n * and returns the result of the transform applied to the element.\n */\npublic inline fun <R> ByteArray.mapIndexed(transform: (index: Int, Byte) -> R): List<R> {\n return mapIndexedTo(ArrayList<R>(size), transform)\n}\n\n/**\n * Returns a list containing the results of applying the given [transform] function\n * to each element and its index in the original array.\n * @param [transform] function that takes the index of an element and the element itself\n * and returns the result of the transform applied to the element.\n */\npublic inline fun <R> ShortArray.mapIndexed(transform: (index: Int, Short) -> R): List<R> {\n return mapIndexedTo(ArrayList<R>(size), transform)\n}\n\n/**\n * Returns a list containing the results of applying the given [transform] function\n * to each element and its index in the original array.\n * @param [transform] function that takes the index of an element and the element itself\n * and returns the result of the transform applied to the element.\n */\npublic inline fun <R> IntArray.mapIndexed(transform: (index: Int, Int) -> R): List<R> {\n return mapIndexedTo(ArrayList<R>(size), transform)\n}\n\n/**\n * Returns a list containing the results of applying the given [transform] function\n * to each element and its index in the original array.\n * @param [transform] function that takes the index of an element and the element itself\n * and returns the result of the transform applied to the element.\n */\npublic inline fun <R> LongArray.mapIndexed(transform: (index: Int, Long) -> R): List<R> {\n return mapIndexedTo(ArrayList<R>(size), transform)\n}\n\n/**\n * Returns a list containing the results of applying the given [transform] function\n * to each element and its index in the original array.\n * @param [transform] function that takes the index of an element and the element itself\n * and returns the result of the transform applied to the element.\n */\npublic inline fun <R> FloatArray.mapIndexed(transform: (index: Int, Float) -> R): List<R> {\n return mapIndexedTo(ArrayList<R>(size), transform)\n}\n\n/**\n * Returns a list containing the results of applying the given [transform] function\n * to each element and its index in the original array.\n * @param [transform] function that takes the index of an element and the element itself\n * and returns the result of the transform applied to the element.\n */\npublic inline fun <R> DoubleArray.mapIndexed(transform: (index: Int, Double) -> R): List<R> {\n return mapIndexedTo(ArrayList<R>(size), transform)\n}\n\n/**\n * Returns a list containing the results of applying the given [transform] function\n * to each element and its index in the original array.\n * @param [transform] function that takes the index of an element and the element itself\n * and returns the result of the transform applied to the element.\n */\npublic inline fun <R> BooleanArray.mapIndexed(transform: (index: Int, Boolean) -> R): List<R> {\n return mapIndexedTo(ArrayList<R>(size), transform)\n}\n\n/**\n * Returns a list containing the results of applying the given [transform] function\n * to each element and its index in the original array.\n * @param [transform] function that takes the index of an element and the element itself\n * and returns the result of the transform applied to the element.\n */\npublic inline fun <R> CharArray.mapIndexed(transform: (index: Int, Char) -> R): List<R> {\n return mapIndexedTo(ArrayList<R>(size), transform)\n}\n\n/**\n * Returns a list containing only the non-null results of applying the given [transform] function\n * to each element and its index in the original array.\n * @param [transform] function that takes the index of an element and the element itself\n * and returns the result of the transform applied to the element.\n */\npublic inline fun <T, R : Any> Array<out T>.mapIndexedNotNull(transform: (index: Int, T) -> R?): List<R> {\n return mapIndexedNotNullTo(ArrayList<R>(), transform)\n}\n\n/**\n * Applies the given [transform] function to each element and its index in the original array\n * and appends only the non-null results to the given [destination].\n * @param [transform] function that takes the index of an element and the element itself\n * and returns the result of the transform applied to the element.\n */\npublic inline fun <T, R : Any, C : MutableCollection<in R>> Array<out T>.mapIndexedNotNullTo(destination: C, transform: (index: Int, T) -> R?): C {\n forEachIndexed { index, element -> transform(index, element)?.let { destination.add(it) } }\n return destination\n}\n\n/**\n * Applies the given [transform] function to each element and its index in the original array\n * and appends the results to the given [destination].\n * @param [transform] function that takes the index of an element and the element itself\n * and returns the result of the transform applied to the element.\n */\npublic inline fun <T, R, C : MutableCollection<in R>> Array<out T>.mapIndexedTo(destination: C, transform: (index: Int, T) -> R): C {\n var index = 0\n for (item in this)\n destination.add(transform(index++, item))\n return destination\n}\n\n/**\n * Applies the given [transform] function to each element and its index in the original array\n * and appends the results to the given [destination].\n * @param [transform] function that takes the index of an element and the element itself\n * and returns the result of the transform applied to the element.\n */\npublic inline fun <R, C : MutableCollection<in R>> ByteArray.mapIndexedTo(destination: C, transform: (index: Int, Byte) -> R): C {\n var index = 0\n for (item in this)\n destination.add(transform(index++, item))\n return destination\n}\n\n/**\n * Applies the given [transform] function to each element and its index in the original array\n * and appends the results to the given [destination].\n * @param [transform] function that takes the index of an element and the element itself\n * and returns the result of the transform applied to the element.\n */\npublic inline fun <R, C : MutableCollection<in R>> ShortArray.mapIndexedTo(destination: C, transform: (index: Int, Short) -> R): C {\n var index = 0\n for (item in this)\n destination.add(transform(index++, item))\n return destination\n}\n\n/**\n * Applies the given [transform] function to each element and its index in the original array\n * and appends the results to the given [destination].\n * @param [transform] function that takes the index of an element and the element itself\n * and returns the result of the transform applied to the element.\n */\npublic inline fun <R, C : MutableCollection<in R>> IntArray.mapIndexedTo(destination: C, transform: (index: Int, Int) -> R): C {\n var index = 0\n for (item in this)\n destination.add(transform(index++, item))\n return destination\n}\n\n/**\n * Applies the given [transform] function to each element and its index in the original array\n * and appends the results to the given [destination].\n * @param [transform] function that takes the index of an element and the element itself\n * and returns the result of the transform applied to the element.\n */\npublic inline fun <R, C : MutableCollection<in R>> LongArray.mapIndexedTo(destination: C, transform: (index: Int, Long) -> R): C {\n var index = 0\n for (item in this)\n destination.add(transform(index++, item))\n return destination\n}\n\n/**\n * Applies the given [transform] function to each element and its index in the original array\n * and appends the results to the given [destination].\n * @param [transform] function that takes the index of an element and the element itself\n * and returns the result of the transform applied to the element.\n */\npublic inline fun <R, C : MutableCollection<in R>> FloatArray.mapIndexedTo(destination: C, transform: (index: Int, Float) -> R): C {\n var index = 0\n for (item in this)\n destination.add(transform(index++, item))\n return destination\n}\n\n/**\n * Applies the given [transform] function to each element and its index in the original array\n * and appends the results to the given [destination].\n * @param [transform] function that takes the index of an element and the element itself\n * and returns the result of the transform applied to the element.\n */\npublic inline fun <R, C : MutableCollection<in R>> DoubleArray.mapIndexedTo(destination: C, transform: (index: Int, Double) -> R): C {\n var index = 0\n for (item in this)\n destination.add(transform(index++, item))\n return destination\n}\n\n/**\n * Applies the given [transform] function to each element and its index in the original array\n * and appends the results to the given [destination].\n * @param [transform] function that takes the index of an element and the element itself\n * and returns the result of the transform applied to the element.\n */\npublic inline fun <R, C : MutableCollection<in R>> BooleanArray.mapIndexedTo(destination: C, transform: (index: Int, Boolean) -> R): C {\n var index = 0\n for (item in this)\n destination.add(transform(index++, item))\n return destination\n}\n\n/**\n * Applies the given [transform] function to each element and its index in the original array\n * and appends the results to the given [destination].\n * @param [transform] function that takes the index of an element and the element itself\n * and returns the result of the transform applied to the element.\n */\npublic inline fun <R, C : MutableCollection<in R>> CharArray.mapIndexedTo(destination: C, transform: (index: Int, Char) -> R): C {\n var index = 0\n for (item in this)\n destination.add(transform(index++, item))\n return destination\n}\n\n/**\n * Returns a list containing only the non-null results of applying the given [transform] function\n * to each element in the original array.\n */\npublic inline fun <T, R : Any> Array<out T>.mapNotNull(transform: (T) -> R?): List<R> {\n return mapNotNullTo(ArrayList<R>(), transform)\n}\n\n/**\n * Applies the given [transform] function to each element in the original array\n * and appends only the non-null results to the given [destination].\n */\npublic inline fun <T, R : Any, C : MutableCollection<in R>> Array<out T>.mapNotNullTo(destination: C, transform: (T) -> R?): C {\n forEach { element -> transform(element)?.let { destination.add(it) } }\n return destination\n}\n\n/**\n * Applies the given [transform] function to each element of the original array\n * and appends the results to the given [destination].\n */\npublic inline fun <T, R, C : MutableCollection<in R>> Array<out T>.mapTo(destination: C, transform: (T) -> R): C {\n for (item in this)\n destination.add(transform(item))\n return destination\n}\n\n/**\n * Applies the given [transform] function to each element of the original array\n * and appends the results to the given [destination].\n */\npublic inline fun <R, C : MutableCollection<in R>> ByteArray.mapTo(destination: C, transform: (Byte) -> R): C {\n for (item in this)\n destination.add(transform(item))\n return destination\n}\n\n/**\n * Applies the given [transform] function to each element of the original array\n * and appends the results to the given [destination].\n */\npublic inline fun <R, C : MutableCollection<in R>> ShortArray.mapTo(destination: C, transform: (Short) -> R): C {\n for (item in this)\n destination.add(transform(item))\n return destination\n}\n\n/**\n * Applies the given [transform] function to each element of the original array\n * and appends the results to the given [destination].\n */\npublic inline fun <R, C : MutableCollection<in R>> IntArray.mapTo(destination: C, transform: (Int) -> R): C {\n for (item in this)\n destination.add(transform(item))\n return destination\n}\n\n/**\n * Applies the given [transform] function to each element of the original array\n * and appends the results to the given [destination].\n */\npublic inline fun <R, C : MutableCollection<in R>> LongArray.mapTo(destination: C, transform: (Long) -> R): C {\n for (item in this)\n destination.add(transform(item))\n return destination\n}\n\n/**\n * Applies the given [transform] function to each element of the original array\n * and appends the results to the given [destination].\n */\npublic inline fun <R, C : MutableCollection<in R>> FloatArray.mapTo(destination: C, transform: (Float) -> R): C {\n for (item in this)\n destination.add(transform(item))\n return destination\n}\n\n/**\n * Applies the given [transform] function to each element of the original array\n * and appends the results to the given [destination].\n */\npublic inline fun <R, C : MutableCollection<in R>> DoubleArray.mapTo(destination: C, transform: (Double) -> R): C {\n for (item in this)\n destination.add(transform(item))\n return destination\n}\n\n/**\n * Applies the given [transform] function to each element of the original array\n * and appends the results to the given [destination].\n */\npublic inline fun <R, C : MutableCollection<in R>> BooleanArray.mapTo(destination: C, transform: (Boolean) -> R): C {\n for (item in this)\n destination.add(transform(item))\n return destination\n}\n\n/**\n * Applies the given [transform] function to each element of the original array\n * and appends the results to the given [destination].\n */\npublic inline fun <R, C : MutableCollection<in R>> CharArray.mapTo(destination: C, transform: (Char) -> R): C {\n for (item in this)\n destination.add(transform(item))\n return destination\n}\n\n/**\n * Returns a lazy [Iterable] of [IndexedValue] for each element of the original array.\n */\npublic fun <T> Array<out T>.withIndex(): Iterable<IndexedValue<T>> {\n return IndexingIterable { iterator() }\n}\n\n/**\n * Returns a lazy [Iterable] of [IndexedValue] for each element of the original array.\n */\npublic fun ByteArray.withIndex(): Iterable<IndexedValue<Byte>> {\n return IndexingIterable { iterator() }\n}\n\n/**\n * Returns a lazy [Iterable] of [IndexedValue] for each element of the original array.\n */\npublic fun ShortArray.withIndex(): Iterable<IndexedValue<Short>> {\n return IndexingIterable { iterator() }\n}\n\n/**\n * Returns a lazy [Iterable] of [IndexedValue] for each element of the original array.\n */\npublic fun IntArray.withIndex(): Iterable<IndexedValue<Int>> {\n return IndexingIterable { iterator() }\n}\n\n/**\n * Returns a lazy [Iterable] of [IndexedValue] for each element of the original array.\n */\npublic fun LongArray.withIndex(): Iterable<IndexedValue<Long>> {\n return IndexingIterable { iterator() }\n}\n\n/**\n * Returns a lazy [Iterable] of [IndexedValue] for each element of the original array.\n */\npublic fun FloatArray.withIndex(): Iterable<IndexedValue<Float>> {\n return IndexingIterable { iterator() }\n}\n\n/**\n * Returns a lazy [Iterable] of [IndexedValue] for each element of the original array.\n */\npublic fun DoubleArray.withIndex(): Iterable<IndexedValue<Double>> {\n return IndexingIterable { iterator() }\n}\n\n/**\n * Returns a lazy [Iterable] of [IndexedValue] for each element of the original array.\n */\npublic fun BooleanArray.withIndex(): Iterable<IndexedValue<Boolean>> {\n return IndexingIterable { iterator() }\n}\n\n/**\n * Returns a lazy [Iterable] of [IndexedValue] for each element of the original array.\n */\npublic fun CharArray.withIndex(): Iterable<IndexedValue<Char>> {\n return IndexingIterable { iterator() }\n}\n\n/**\n * Returns a list containing only distinct elements from the given array.\n * \n * The elements in the resulting list are in the same order as they were in the source array.\n */\npublic fun <T> Array<out T>.distinct(): List<T> {\n return this.toMutableSet().toList()\n}\n\n/**\n * Returns a list containing only distinct elements from the given array.\n * \n * The elements in the resulting list are in the same order as they were in the source array.\n */\npublic fun ByteArray.distinct(): List<Byte> {\n return this.toMutableSet().toList()\n}\n\n/**\n * Returns a list containing only distinct elements from the given array.\n * \n * The elements in the resulting list are in the same order as they were in the source array.\n */\npublic fun ShortArray.distinct(): List<Short> {\n return this.toMutableSet().toList()\n}\n\n/**\n * Returns a list containing only distinct elements from the given array.\n * \n * The elements in the resulting list are in the same order as they were in the source array.\n */\npublic fun IntArray.distinct(): List<Int> {\n return this.toMutableSet().toList()\n}\n\n/**\n * Returns a list containing only distinct elements from the given array.\n * \n * The elements in the resulting list are in the same order as they were in the source array.\n */\npublic fun LongArray.distinct(): List<Long> {\n return this.toMutableSet().toList()\n}\n\n/**\n * Returns a list containing only distinct elements from the given array.\n * \n * The elements in the resulting list are in the same order as they were in the source array.\n */\npublic fun FloatArray.distinct(): List<Float> {\n return this.toMutableSet().toList()\n}\n\n/**\n * Returns a list containing only distinct elements from the given array.\n * \n * The elements in the resulting list are in the same order as they were in the source array.\n */\npublic fun DoubleArray.distinct(): List<Double> {\n return this.toMutableSet().toList()\n}\n\n/**\n * Returns a list containing only distinct elements from the given array.\n * \n * The elements in the resulting list are in the same order as they were in the source array.\n */\npublic fun BooleanArray.distinct(): List<Boolean> {\n return this.toMutableSet().toList()\n}\n\n/**\n * Returns a list containing only distinct elements from the given array.\n * \n * The elements in the resulting list are in the same order as they were in the source array.\n */\npublic fun CharArray.distinct(): List<Char> {\n return this.toMutableSet().toList()\n}\n\n/**\n * Returns a list containing only elements from the given array\n * having distinct keys returned by the given [selector] function.\n * \n * The elements in the resulting list are in the same order as they were in the source array.\n */\npublic inline fun <T, K> Array<out T>.distinctBy(selector: (T) -> K): List<T> {\n val set = HashSet<K>()\n val list = ArrayList<T>()\n for (e in this) {\n val key = selector(e)\n if (set.add(key))\n list.add(e)\n }\n return list\n}\n\n/**\n * Returns a list containing only elements from the given array\n * having distinct keys returned by the given [selector] function.\n * \n * The elements in the resulting list are in the same order as they were in the source array.\n */\npublic inline fun <K> ByteArray.distinctBy(selector: (Byte) -> K): List<Byte> {\n val set = HashSet<K>()\n val list = ArrayList<Byte>()\n for (e in this) {\n val key = selector(e)\n if (set.add(key))\n list.add(e)\n }\n return list\n}\n\n/**\n * Returns a list containing only elements from the given array\n * having distinct keys returned by the given [selector] function.\n * \n * The elements in the resulting list are in the same order as they were in the source array.\n */\npublic inline fun <K> ShortArray.distinctBy(selector: (Short) -> K): List<Short> {\n val set = HashSet<K>()\n val list = ArrayList<Short>()\n for (e in this) {\n val key = selector(e)\n if (set.add(key))\n list.add(e)\n }\n return list\n}\n\n/**\n * Returns a list containing only elements from the given array\n * having distinct keys returned by the given [selector] function.\n * \n * The elements in the resulting list are in the same order as they were in the source array.\n */\npublic inline fun <K> IntArray.distinctBy(selector: (Int) -> K): List<Int> {\n val set = HashSet<K>()\n val list = ArrayList<Int>()\n for (e in this) {\n val key = selector(e)\n if (set.add(key))\n list.add(e)\n }\n return list\n}\n\n/**\n * Returns a list containing only elements from the given array\n * having distinct keys returned by the given [selector] function.\n * \n * The elements in the resulting list are in the same order as they were in the source array.\n */\npublic inline fun <K> LongArray.distinctBy(selector: (Long) -> K): List<Long> {\n val set = HashSet<K>()\n val list = ArrayList<Long>()\n for (e in this) {\n val key = selector(e)\n if (set.add(key))\n list.add(e)\n }\n return list\n}\n\n/**\n * Returns a list containing only elements from the given array\n * having distinct keys returned by the given [selector] function.\n * \n * The elements in the resulting list are in the same order as they were in the source array.\n */\npublic inline fun <K> FloatArray.distinctBy(selector: (Float) -> K): List<Float> {\n val set = HashSet<K>()\n val list = ArrayList<Float>()\n for (e in this) {\n val key = selector(e)\n if (set.add(key))\n list.add(e)\n }\n return list\n}\n\n/**\n * Returns a list containing only elements from the given array\n * having distinct keys returned by the given [selector] function.\n * \n * The elements in the resulting list are in the same order as they were in the source array.\n */\npublic inline fun <K> DoubleArray.distinctBy(selector: (Double) -> K): List<Double> {\n val set = HashSet<K>()\n val list = ArrayList<Double>()\n for (e in this) {\n val key = selector(e)\n if (set.add(key))\n list.add(e)\n }\n return list\n}\n\n/**\n * Returns a list containing only elements from the given array\n * having distinct keys returned by the given [selector] function.\n * \n * The elements in the resulting list are in the same order as they were in the source array.\n */\npublic inline fun <K> BooleanArray.distinctBy(selector: (Boolean) -> K): List<Boolean> {\n val set = HashSet<K>()\n val list = ArrayList<Boolean>()\n for (e in this) {\n val key = selector(e)\n if (set.add(key))\n list.add(e)\n }\n return list\n}\n\n/**\n * Returns a list containing only elements from the given array\n * having distinct keys returned by the given [selector] function.\n * \n * The elements in the resulting list are in the same order as they were in the source array.\n */\npublic inline fun <K> CharArray.distinctBy(selector: (Char) -> K): List<Char> {\n val set = HashSet<K>()\n val list = ArrayList<Char>()\n for (e in this) {\n val |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment