forked from swiftwasm/JavaScriptKit
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
382 lines (356 loc) · 19.2 KB
/
Copy pathindex.html
File metadata and controls
382 lines (356 loc) · 19.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>JavaScriptKit - JSObject</title>
<link rel="stylesheet" type="text/css" href="/JavaScriptKit/all.css" media="all" />
</head>
<body>
<header>
<a href="/JavaScriptKit">
<strong>
JavaScriptKit
</strong>
<span>Documentation</span>
</a>
</header>
<!--
<form class="search">
<input type="search" placeholder="Search" />
</form>
-->
<nav>
<div class="wrapper">
<h2>On This Page</h2>
<ol><li><a href="#relationships">Relationships</a><ul><li><a href="#relationships">Subclasses</a></li><li><a href="#relationships">Conforms To</a></li></ul></li><li><a href="#properties">Properties</a><ul><li class="variable"><a href="#jsobject.`throwing`">`throwing`</a></li><li class="variable"><a href="#jsobject.global">global</a></li><li class="variable"><a href="#jsobject.description">description</a></li></ul></li><li><a href="#methods">Methods</a><ul><li class="function"><a href="#jsobject.isinstanceof(_:)">isInstanceOf(_:)</a></li><li class="function"><a href="#jsobject.construct(from:)">construct(from:)</a></li><li class="function"><a href="#jsobject.jsvalue()">jsValue()</a></li><li class="function"><a href="#jsobject.hash(into:)">hash(into:)</a></li></ul></li><li><a href="#operators">Operators</a><ul><li class="function"><a href="#jsobject.==">==</a></li></ul></li></ol>
</div>
</nav>
<main>
<article>
<h1>
<small>Class</small>
<code class="name">JSObject</code>
</h1>
<div class="declaration">
<pre class="highlight"><code><html><body><span class="attribute">@</span><span class="attribute">dynamicMemberLookup</span>
<span class="keyword">public</span> <span class="keyword">class</span> <span class="type">JSObject</span>: <span class="type">Equatable</span> </body></html></code></pre>
</div>
<div class="summary" role="doc-abstract">
<p><code>JSObject</code> represents an object in JavaScript and supports dynamic member lookup.
Any member access like <code>object.foo</code> will dynamically request the JavaScript and Swift
runtime bridge library for a member with the specified name in this object.</p>
</div>
<div class="discussion">
<p>And this object supports to call a member method of the object.</p>
<p>e.g.</p>
<html><body><pre class="highlight"><code><span class="keyword">let</span> <span class="variable">document</span> = <span class="variable">JSObject</span>.<span class="variable">global</span>.<span class="variable">document</span>.<span class="variable">object</span>!
<span class="keyword">let</span> <span class="variable">divElement</span> = <span class="variable">document</span>.<span class="variable">createElement</span>!(<span class="string literal">"</span><span class="string literal">div</span><span class="string literal">"</span>)
</code></pre></body></html>
<p>The lifetime of this object is managed by the JavaScript and Swift runtime bridge library with
reference counting system.</p>
</div>
<section id="relationships">
<h2 hidden>Relationships</h2>
<figure>
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<!-- Generated by graphviz version 2.40.1 (20161225.0304)
-->
<!-- Title: %87 Pages: 1 -->
<svg width="1357pt" height="292pt"
viewBox="0.00 0.00 1357.46 291.60" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<g id="graph0" class="graph" transform="scale(1 1) rotate(0) translate(4 287.6013)">
<title>%87</title>
<polygon fill="#ffffff" stroke="transparent" points="-4,4 -4,-287.6013 1353.4613,-287.6013 1353.4613,4 -4,4"/>
<!-- JSObject -->
<g id="node1" class="node class current">
<title>JSObject</title>
<g id="a_node1"><a xlink:href="/JavaScriptKit/JSObject" xlink:title="JSObject">
<path fill="none" stroke="#000000" stroke-width="3" d="M769.9618,-159.7703C769.9618,-159.7703 577.9618,-159.7703 577.9618,-159.7703 571.9618,-159.7703 565.9618,-153.7703 565.9618,-147.7703 565.9618,-147.7703 565.9618,-135.7703 565.9618,-135.7703 565.9618,-129.7703 571.9618,-123.7703 577.9618,-123.7703 577.9618,-123.7703 769.9618,-123.7703 769.9618,-123.7703 775.9618,-123.7703 781.9618,-129.7703 781.9618,-135.7703 781.9618,-135.7703 781.9618,-147.7703 781.9618,-147.7703 781.9618,-153.7703 775.9618,-159.7703 769.9618,-159.7703"/>
<text text-anchor="middle" x="673.9618" y="-138.0703" font-family="Menlo" font-size="14.00" fill="#000000">JSObject</text>
</a>
</g>
</g>
<!-- CustomStringConvertible -->
<g id="node2" class="node unknown">
<title>CustomStringConvertible</title>
<path fill="none" stroke="#000000" d="M1332.8561,-97.5122C1332.8561,-97.5122 1140.8561,-97.5122 1140.8561,-97.5122 1134.8561,-97.5122 1128.8561,-91.5122 1128.8561,-85.5122 1128.8561,-85.5122 1128.8561,-73.5122 1128.8561,-73.5122 1128.8561,-67.5122 1134.8561,-61.5122 1140.8561,-61.5122 1140.8561,-61.5122 1332.8561,-61.5122 1332.8561,-61.5122 1338.8561,-61.5122 1344.8561,-67.5122 1344.8561,-73.5122 1344.8561,-73.5122 1344.8561,-85.5122 1344.8561,-85.5122 1344.8561,-91.5122 1338.8561,-97.5122 1332.8561,-97.5122"/>
<text text-anchor="middle" x="1236.8561" y="-75.8122" font-family="Menlo" font-size="14.00" fill="#000000">CustomStringConvertible</text>
</g>
<!-- JSObject->CustomStringConvertible -->
<g id="edge6" class="edge conformsTo">
<title>JSObject->CustomStringConvertible</title>
<path fill="none" stroke="#000000" d="M782.1603,-129.8031C878.49,-119.1487 1019.1355,-103.5929 1118.4453,-92.6089"/>
<polygon fill="#000000" stroke="#000000" points="1118.9729,-96.0719 1128.5275,-91.4937 1118.2034,-89.1144 1118.9729,-96.0719"/>
</g>
<!-- Equatable -->
<g id="node3" class="node unknown">
<title>Equatable</title>
<path fill="none" stroke="#000000" d="M768.6571,-36C768.6571,-36 576.6571,-36 576.6571,-36 570.6571,-36 564.6571,-30 564.6571,-24 564.6571,-24 564.6571,-12 564.6571,-12 564.6571,-6 570.6571,0 576.6571,0 576.6571,0 768.6571,0 768.6571,0 774.6571,0 780.6571,-6 780.6571,-12 780.6571,-12 780.6571,-24 780.6571,-24 780.6571,-30 774.6571,-36 768.6571,-36"/>
<text text-anchor="middle" x="672.6571" y="-14.3" font-family="Menlo" font-size="14.00" fill="#000000">Equatable</text>
</g>
<!-- JSObject->Equatable -->
<g id="edge2" class="edge conformsTo">
<title>JSObject->Equatable</title>
<path fill="none" stroke="#000000" d="M673.7693,-123.5075C673.5554,-103.2146 673.2073,-70.1891 672.9575,-46.4906"/>
<polygon fill="#000000" stroke="#000000" points="676.4557,-46.3002 672.8504,-36.3377 669.4561,-46.374 676.4557,-46.3002"/>
</g>
<!-- Hashable -->
<g id="node6" class="node unknown">
<title>Hashable</title>
<path fill="none" stroke="#000000" d="M781.2916,-283.6013C781.2916,-283.6013 589.2916,-283.6013 589.2916,-283.6013 583.2916,-283.6013 577.2916,-277.6013 577.2916,-271.6013 577.2916,-271.6013 577.2916,-259.6013 577.2916,-259.6013 577.2916,-253.6013 583.2916,-247.6013 589.2916,-247.6013 589.2916,-247.6013 781.2916,-247.6013 781.2916,-247.6013 787.2916,-247.6013 793.2916,-253.6013 793.2916,-259.6013 793.2916,-259.6013 793.2916,-271.6013 793.2916,-271.6013 793.2916,-277.6013 787.2916,-283.6013 781.2916,-283.6013"/>
<text text-anchor="middle" x="685.2916" y="-261.9013" font-family="Menlo" font-size="14.00" fill="#000000">Hashable</text>
</g>
<!-- JSObject->Hashable -->
<g id="edge4" class="edge conformsTo">
<title>JSObject->Hashable</title>
<path fill="none" stroke="#000000" d="M675.6093,-159.7764C677.472,-180.1358 680.5288,-213.5456 682.7093,-237.3784"/>
<polygon fill="#000000" stroke="#000000" points="679.2455,-237.934 683.6421,-247.5735 686.2164,-237.2962 679.2455,-237.934"/>
</g>
<!-- JSClosure -->
<g id="node4" class="node class">
<title>JSClosure</title>
<g id="a_node4"><a xlink:href="/JavaScriptKit/JSClosure" xlink:title="JSClosure">
<path fill="none" stroke="#000000" d="M212.1715,-223.4423C212.1715,-223.4423 20.1715,-223.4423 20.1715,-223.4423 14.1715,-223.4423 8.1715,-217.4423 8.1715,-211.4423 8.1715,-211.4423 8.1715,-199.4423 8.1715,-199.4423 8.1715,-193.4423 14.1715,-187.4423 20.1715,-187.4423 20.1715,-187.4423 212.1715,-187.4423 212.1715,-187.4423 218.1715,-187.4423 224.1715,-193.4423 224.1715,-199.4423 224.1715,-199.4423 224.1715,-211.4423 224.1715,-211.4423 224.1715,-217.4423 218.1715,-223.4423 212.1715,-223.4423"/>
<text text-anchor="middle" x="116.1715" y="-201.7423" font-family="Menlo" font-size="14.00" fill="#000000">JSClosure</text>
</a>
</g>
</g>
<!-- JSClosure->JSObject -->
<g id="edge1" class="edge inheritsFrom">
<title>JSClosure->JSObject</title>
<path fill="none" stroke="#000000" d="M224.3805,-193.0902C319.4848,-182.234 457.6156,-166.4663 555.6262,-155.2783"/>
<polygon fill="#000000" stroke="#000000" points="556.0404,-158.7539 565.5789,-154.1422 555.2464,-151.799 556.0404,-158.7539"/>
</g>
<!-- JSFunction -->
<g id="node5" class="node class">
<title>JSFunction</title>
<g id="a_node5"><a xlink:href="/JavaScriptKit/JSFunction" xlink:title="JSFunction">
<path fill="none" stroke="#000000" d="M1337.4613,-220.5748C1337.4613,-220.5748 1145.4613,-220.5748 1145.4613,-220.5748 1139.4613,-220.5748 1133.4613,-214.5748 1133.4613,-208.5748 1133.4613,-208.5748 1133.4613,-196.5748 1133.4613,-196.5748 1133.4613,-190.5748 1139.4613,-184.5748 1145.4613,-184.5748 1145.4613,-184.5748 1337.4613,-184.5748 1337.4613,-184.5748 1343.4613,-184.5748 1349.4613,-190.5748 1349.4613,-196.5748 1349.4613,-196.5748 1349.4613,-208.5748 1349.4613,-208.5748 1349.4613,-214.5748 1343.4613,-220.5748 1337.4613,-220.5748"/>
<text text-anchor="middle" x="1241.4613" y="-198.8748" font-family="Menlo" font-size="14.00" fill="#000000">JSFunction</text>
</a>
</g>
</g>
<!-- JSFunction->JSObject -->
<g id="edge5" class="edge inheritsFrom">
<title>JSFunction->JSObject</title>
<path fill="none" stroke="#000000" d="M1133.3832,-190.9948C1035.9118,-180.5513 892.8449,-165.2224 792.3224,-154.452"/>
<polygon fill="#000000" stroke="#000000" points="792.4357,-150.9441 782.1197,-153.3588 791.6899,-157.9043 792.4357,-150.9441"/>
</g>
<!-- JSOneshotClosure -->
<g id="node7" class="node class">
<title>JSOneshotClosure</title>
<g id="a_node7"><a xlink:href="/JavaScriptKit/JSOneshotClosure" xlink:title="JSOneshotClosure">
<path fill="none" stroke="#000000" d="M204,-98.844C204,-98.844 12,-98.844 12,-98.844 6,-98.844 0,-92.844 0,-86.844 0,-86.844 0,-74.844 0,-74.844 0,-68.844 6,-62.844 12,-62.844 12,-62.844 204,-62.844 204,-62.844 210,-62.844 216,-68.844 216,-74.844 216,-74.844 216,-86.844 216,-86.844 216,-92.844 210,-98.844 204,-98.844"/>
<text text-anchor="middle" x="108" y="-77.144" font-family="Menlo" font-size="14.00" fill="#000000">JSOneshotClosure</text>
</a>
</g>
</g>
<!-- JSOneshotClosure->JSObject -->
<g id="edge3" class="edge inheritsFrom">
<title>JSOneshotClosure->JSObject</title>
<path fill="none" stroke="#000000" d="M216.1192,-92.4832C313.2094,-102.935 455.4652,-118.2489 555.5829,-129.0267"/>
<polygon fill="#000000" stroke="#000000" points="555.4282,-132.5302 565.7454,-130.1207 556.1775,-125.5704 555.4282,-132.5302"/>
</g>
</g>
</svg>
<figcaption hidden>Inheritance graph for JSObject.</figcaption>
</figure>
<h3>Subclasses</h3>
<dl>
<dt class="class"><code><a href="/JavaScriptKit/JSOneshotClosure">JSOneshotClosure</a></code></dt>
<dd><p><code>JSOneshotClosure</code> is a JavaScript function that can be called only once.</p>
</dd>
<dt class="class"><code><a href="/JavaScriptKit/JSClosure">JSClosure</a></code></dt>
<dd><p><code>JSClosure</code> represents a JavaScript function the body of which is written in Swift.
This type can be passed as a callback handler to JavaScript functions.</p>
</dd>
<dt class="class"><code><a href="/JavaScriptKit/JSFunction">JSFunction</a></code></dt>
<dd><p><code>JSFunction</code> represents a function in JavaScript and supports new object instantiation.
This type can be callable as a function using <code>callAsFunction</code>.</p>
</dd>
</dl>
<h3>Conforms To</h3>
<dl>
<dt class="unknown"><code>CustomStringConvertible</code></dt>
<dt class="unknown"><code>Equatable</code></dt>
<dt class="unknown"><code>Hashable</code></dt>
</dl>
</section>
<section id="properties">
<h2>Properties</h2>
<div role="article" class="variable" id="jsobject.`throwing`">
<h3>
<code><a href="#jsobject.`throwing`">`throwing`</a></code>
</h3>
<div class="declaration">
<pre class="highlight"><code><html><body><span class="keyword">public</span> <span class="keyword">var</span> <span class="variable">`throwing`</span>: <a href="/JavaScriptKit/JSThrowingObject"><span class="type">JSThrowingObject</span></a> </body></html></code></pre>
</div>
<div class="summary" role="doc-abstract">
<p>A modifier to call methods as throwing methods capturing <code>this</code></p>
</div>
<div class="discussion">
<html><body><pre><code class="language-javascript">const animal = {
validateAge: function() {
if (this.age < 0) {
throw new Error("Invalid age");
}
}
}
</code></pre>
</body></html>
<html><body><pre class="highlight"><code><span class="keyword">let</span> <span class="variable">animal</span> = <span class="variable">JSObject</span>.<span class="variable">global</span>.<span class="variable">animal</span>.<span class="variable">object</span>!
<span class="keyword">try</span> <span class="variable">animal</span>.<span class="variable">throwing</span>.<span class="variable">validateAge</span>!()
</code></pre></body></html>
</div>
</div>
<div role="article" class="variable" id="jsobject.global">
<h3>
<code><a href="#jsobject.global">global</a></code>
</h3>
<div class="declaration">
<pre class="highlight"><code><html><body><span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">let</span> <span class="variable">global</span> </body></html></code></pre>
</div>
<div class="summary" role="doc-abstract">
<p>A <code>JSObject</code> of the global scope object.
This allows access to the global properties and global names by accessing the <code>JSObject</code> returned.</p>
</div>
</div>
<div role="article" class="variable" id="jsobject.description">
<h3>
<code><a href="#jsobject.description">description</a></code>
</h3>
<div class="declaration">
<pre class="highlight"><code><html><body><span class="keyword">public</span> <span class="keyword">var</span> <span class="variable">description</span>: <span class="type">String</span> </body></html></code></pre>
</div>
</div>
</section>
<section id="methods">
<h2>Methods</h2>
<div role="article" class="function" id="jsobject.isinstanceof(_:)">
<h3>
<code><a href="#jsobject.isinstanceof(_:)">isInstanceOf(_:)</a></code>
</h3>
<div class="declaration">
<pre class="highlight"><code><html><body><span class="keyword">public</span> <span class="keyword">func</span> <span class="function">isInstanceOf</span>(<span class="keyword">_</span> <span class="variable">constructor</span>: <a href="/JavaScriptKit/JSFunction"><span class="type">JSFunction</span></a>) -> <span class="type">Bool</span> </body></html></code></pre>
</div>
<div class="summary" role="doc-abstract">
<p>Return <code>true</code> if this value is an instance of the passed <code>constructor</code> function.</p>
</div>
<h4>Parameters</h4>
<table class="parameters">
<thead hidden>
<tr>
<th>Name</th>
<th>Type</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<th>constructor</th>
<td><code class="type">JSFunction</code></td>
<td><p>The constructor function to check.</p>
</td>
</tr>
</tbody>
</table>
<h4>Returns</h4>
<p>The result of <code>instanceof</code> in the JavaScript environment.</p>
</div>
<div role="article" class="function" id="jsobject.construct(from:)">
<h3>
<code><a href="#jsobject.construct(from:)">construct(from:)</a></code>
</h3>
<div class="declaration">
<pre class="highlight"><code><html><body><span class="keyword">public</span> <span class="keyword">class</span> <span class="keyword">func</span> <span class="function">construct</span>(<span class="variable">from</span> <span class="variable">value</span>: <a href="/JavaScriptKit/JSValue"><span class="type">JSValue</span></a>) -> <span class="keyword">Self</span>? </body></html></code></pre>
</div>
</div>
<div role="article" class="function" id="jsobject.jsvalue()">
<h3>
<code><a href="#jsobject.jsvalue()">jsValue()</a></code>
</h3>
<div class="declaration">
<pre class="highlight"><code><html><body><span class="keyword">public</span> <span class="keyword">func</span> <span class="function">jsValue</span>() -> <a href="/JavaScriptKit/JSValue"><span class="type">JSValue</span></a> </body></html></code></pre>
</div>
</div>
<div role="article" class="function" id="jsobject.hash(into:)">
<h3>
<code><a href="#jsobject.hash(into:)">hash(into:)</a></code>
</h3>
<div class="declaration">
<pre class="highlight"><code><html><body><span class="keyword">public</span> <span class="keyword">func</span> <span class="function">hash</span>(<span class="variable">into</span> <span class="variable">hasher</span>: <span class="keyword">inout</span> <span class="type">Hasher</span>) </body></html></code></pre>
</div>
<div class="summary" role="doc-abstract">
<p>Hashes the essential components of this value by feeding them into the
given hasher.</p>
</div>
<h4>Parameters</h4>
<table class="parameters">
<thead hidden>
<tr>
<th>Name</th>
<th>Type</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<th>hasher</th>
<td><code class="type">inout Hasher</code></td>
<td><p>The hasher to use when combining the components of this instance.</p>
</td>
</tr>
</tbody>
</table>
</div>
</section>
<section id="operators">
<h2>Operators</h2>
<div role="article" class="function" id="jsobject.==">
<h3>
<code><a href="#jsobject.==">==</a></code>
</h3>
<div class="declaration">
<pre class="highlight"><code><html><body><span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">func</span> == (<span class="variable">lhs</span>: <a href="/JavaScriptKit/JSObject"><span class="type">JSObject</span></a>, <span class="variable">rhs</span>: <a href="/JavaScriptKit/JSObject"><span class="type">JSObject</span></a>) -> <span class="type">Bool</span> </body></html></code></pre>
</div>
<div class="summary" role="doc-abstract">
<p>Returns a Boolean value indicating whether two values point to same objects.</p>
</div>
<h4>Parameters</h4>
<table class="parameters">
<thead hidden>
<tr>
<th>Name</th>
<th>Type</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<th>lhs</th>
<td><code class="type">JSObject</code></td>
<td><p>A object to compare.</p>
</td>
</tr>
<tr>
<th>rhs</th>
<td><code class="type">JSObject</code></td>
<td><p>Another object to compare.</p>
</td>
</tr>
</tbody>
</table>
</div>
</section>
</article>
</main>
<footer>
<p>
Generated on <time datetime="2022-02-22T15:19:50+0000">February 22, 2022</time> using <a href="https://github.com/SwiftDocOrg/swift-doc">swift-doc</a> <span class="version">1.0.0-rc.1</span>.
</p>
</footer>
</body>
</html>