Create new
Bindings
Transitions
Animations
Easing
Component composition
Context API
Special elements
Module context
Debugging
Miscellaneous
App.svelte
Comment.svelte
Item.svelte
List.svelte
Summary.svelte
runes
This component is in runes mode.
To disable runes mode, add the following to the top of your component:
<svelte:options runes={false} />
99
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
›
⌄
⌄
⌄
⌄
⌄
⌄
⌄
<script>
import { onMount } from 'svelte';
import List from './List.svelte';
import Item from './Item.svelte';
let item = $state();
let page = $state();
async function hashchange() {
// the poor man's router!
const path = window.location.hash.slice(1);
if (path.startsWith('/item')) {
const id = path.slice(6);
item = await fetch(`https://node-hnapi.herokuapp.com/item/${id}`).then((r) => r.json());
window.scrollTo(0, 0);
} else if (path.startsWith('/top')) {
page = +path.slice(5);
item = null;
} else {
window.location.hash = '/top/1';
}
}
onMount(hashchange);
</script>
<svelte:window onhashchange={hashchange} />
<main>
{#if item}
<Item {item} returnTo="#/top/{page}" />
{:else if page}
<List {page} />
{/if}
Error compiling component
WebAssembly.instantiateStreaming(): value type opcode @+13
99
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
›
⌄
⌄
⌄
⌄
⌄
import 'svelte/internal/disclose-version';
import * as $ from 'svelte/internal/client';
import { onMount } from 'svelte';
import List from './List.svelte';
import Item from './Item.svelte';
var root = $.template(`<main class="svelte-1omk9tf"><!></main>`);
export default function App($$anchor, $$props) {
$.push($$props, true);
let item = $.state(undefined);
let page = $.state(undefined);
async function hashchange() {
// the poor man's router!
const path = window.location.hash.slice(1);
if (path.startsWith('/item')) {
const id = path.slice(6);
$.set(item, $.proxy(await fetch(`https://node-hnapi.herokuapp.com/item/${id}`).then((r) => r.json())));
window.scrollTo(0, 0);
} else if (path.startsWith('/top')) {
$.set(page, +path.slice(5));
$.set(item, null);
} else {
window.location.hash = '/top/1';
}
}
onMount(hashchange);
var main = root();
$.event('hashchange', $.window, hashchange);
result = svelte.compile(source, {
generate: ,
});99
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
›
main.svelte-1omk9tf {
position: relative;
max-width: 800px;
margin: 0 auto;
min-height: 101vh;
padding: 1em;
}
main.svelte-1omk9tf .meta {
color: #999;
font-size: 12px;
margin: 0 0 1em 0;
}
Root {
css: StyleSheet {...}
- type: "StyleSheet"
- start: 775
- end: 981
- attributes: []
children: [...] (2)
Rule {...}
- type: "Rule"
prelude: SelectorList {...}
- type: "SelectorList"
- start: 784
- end: 788
children: [...] (1)
ComplexSelector {...}
- type: "ComplexSelector"
- start: 784
- end: 788
children: [...] (1)
RelativeSelector {...}
- type: "RelativeSelector"
- combinator: null
selectors: [...] (1)
TypeSelector {...}
- type: "TypeSelector"
- name: "main"
- start: 784
- end: 788
}
]- start: 784
- end: 788
}
]
}
]
}block: Block {...}
- type: "Block"
- start: 789
- end: 890
children: [...] (5)
Declaration {...}
- type: "Declaration"
- start: 793
- end: 811
- property: "position"
- value: "relative"
} Declaration {...}
- type: "Declaration"
- start: 815
- end: 831
- property: "max-width"
- value: "800px"
} Declaration {...}
- type: "Declaration"
- start: 835
- end: 849
- property: "margin"
- value: "0 auto"
} Declaration {...}
- type: "Declaration"
- start: 853
- end: 870
- property: "min-height"
- value: "101vh"
} Declaration {...}
- type: "Declaration"
- start: 874
- end: 886
- property: "padding"
- value: "1em"
}
]
}- start: 784
- end: 890
} Rule {...}
- type: "Rule"
prelude: SelectorList {...}
- type: "SelectorList"
- start: 893
- end: 912
children: [...] (1)
ComplexSelector {...}
- type: "ComplexSelector"
- start: 893
- end: 912
children: [...] (2)
RelativeSelector {...}
- type: "RelativeSelector"
- combinator: null
selectors: [...] (1)
TypeSelector {...}
- type: "TypeSelector"
- name: "main"
- start: 893
- end: 897
}
]- start: 893
- end: 897
} RelativeSelector {...}
- type: "RelativeSelector"
combinator: Combinator {...}
- type: "Combinator"
- name: " "
- start: 897
- end: 898
}selectors: [...] (1)
PseudoClassSelector {...}
- type: "PseudoClassSelector"
- name: "global"
args: SelectorList {...}
- type: "SelectorList"
- start: 906
- end: 911
children: [...] (1)
ComplexSelector {...}
- type: "ComplexSelector"
- start: 906
- end: 911
children: [...] (1)
RelativeSelector {...}
- type: "RelativeSelector"
- combinator: null
selectors: [...] (1)
ClassSelector {...}
- type: "ClassSelector"
- name: "meta"
- start: 906
- end: 911
}
]- start: 906
- end: 911
}
]
}
]
}- start: 898
- end: 912
}
]- start: 897
- end: 912
}
]
}
]
}block: Block {...}
- type: "Block"
- start: 913
- end: 972
children: [...] (3)
Declaration {...}
- type: "Declaration"
- start: 917
- end: 928
- property: "color"
- value: "#999"
} Declaration {...}
- type: "Declaration"
- start: 932
- end: 947
- property: "font-size"
- value: "12px"
} Declaration {...}
- type: "Declaration"
- start: 951
- end: 968
- property: "margin"
- value: "0 0 1em 0"
}
]
}- start: 893
- end: 972
}
]content: {...}
- start: 782
- end: 973
- styles: "\n\tmain {\n\t\tposition: relative;\n\t\tmax-width: 800px;\n\t\tmargin: 0 auto;\n\t\tmin-height: 101vh;\n\t\tpadding: 1em;\n\t}\n\n\tmain :global(.meta) {\n\t\tcolor: #999;\n\t\tfont-size: 12px;\n\t\tmargin: 0 0 1em 0;\n\t}\n"
- comment: null
}
}- js: []
- start: 618
- end: 773
- type: "Root"
fragment: Fragment {...}
- type: "Fragment"
nodes: [...] (5)
Text {...}
- type: "Text"
- start: 616
- end: 618
- raw: "\n\n"
- data: "\n\n"
} SvelteWindow {...}
- type: "SvelteWindow"
- start: 618
- end: 661
- name: "svelte:window"
attributes: [...] (1)
Attribute {...}
- type: "Attribute"
- start: 633
- end: 658
- name: "onhashchange"
value: ExpressionTag {...}
- type: "ExpressionTag"
- start: 646
- end: 658
expression: Identifier {...}
- type: "Identifier"
- start: 647
- end: 657
loc: {...}
start: {...}
- line: 29
- column: 29
}end: {...}
- line: 29
- column: 39
}
}- name: "hashchange"
}
}
}
]fragment: Fragment {...}
- type: "Fragment"
- nodes: []
}
} Text {...}
- type: "Text"
- start: 661
- end: 663
- raw: "\n\n"
- data: "\n\n"
} RegularElement {...}
- type: "RegularElement"
- start: 663
- end: 773
- name: "main"
attributes: [...] (1)
Attribute {...}
- type: "Attribute"
- start: -1
- end: -1
- name: "class"
value: [...] (1)
Text {...}
- type: "Text"
- data: "svelte-1omk9tf"
- raw: "svelte-1omk9tf"
- start: -1
- end: -1
}
]
}
]fragment: Fragment {...}
- type: "Fragment"
nodes: [...] (3)
Text {...}
- type: "Text"
- start: 669
- end: 671
- raw: "\n\t"
- data: "\n\t"
} IfBlock {...}
- type: "IfBlock"
- elseif: false
- start: 671
- end: 765
test: Identifier {...}
- type: "Identifier"
- start: 676
- end: 680
loc: {...}
start: {...}
- line: 32
- column: 6
}end: {...}
- line: 32
- column: 10
}
}- name: "item"
}consequent: Fragment {...}
- type: "Fragment"
nodes: [...] (3)
Text {...}
- type: "Text"
- start: 681
- end: 684
- raw: "\n\t\t"
- data: "\n\t\t"
} Component {...}
- type: "Component"
- start: 684
- end: 723
- name: "Item"
attributes: [...] (2)
Attribute {...}
- type: "Attribute"
- start: 690
- end: 696
- name: "item"
value: ExpressionTag {...}
- type: "ExpressionTag"
- start: 691
- end: 695
expression: Identifier {...}
- start: 691
- end: 695
- type: "Identifier"
- name: "item"
}
}
} Attribute {...}
- type: "Attribute"
- start: 697
- end: 720
- name: "returnTo"
value: [...] (2)
Text {...}
- start: 707
- end: 713
- type: "Text"
- raw: "#/top/"
- data: "#/top/"
} ExpressionTag {...}
- type: "ExpressionTag"
- start: 713
- end: 719
expression: Identifier {...}
- type: "Identifier"
- start: 714
- end: 718
loc: {...}
start: {...}
- line: 33
- column: 32
}end: {...}
- line: 33
- column: 36
}
}- name: "page"
}
}
]
}
]fragment: Fragment {...}
- type: "Fragment"
- nodes: []
}
} Text {...}
- type: "Text"
- start: 723
- end: 725
- raw: "\n\t"
- data: "\n\t"
}
]
}alternate: Fragment {...}
- type: "Fragment"
nodes: [...] (1)
IfBlock {...}
- start: 725
- end: 765
- type: "IfBlock"
- elseif: true
test: Identifier {...}
- type: "Identifier"
- start: 735
- end: 739
loc: {...}
start: {...}
- line: 34
- column: 11
}end: {...}
- line: 34
- column: 15
}
}- name: "page"
}consequent: Fragment {...}
- type: "Fragment"
nodes: [...] (3)
Text {...}
- type: "Text"
- start: 740
- end: 743
- raw: "\n\t\t"
- data: "\n\t\t"
} Component {...}
- type: "Component"
- start: 743
- end: 758
- name: "List"
attributes: [...] (1)
Attribute {...}
- type: "Attribute"
- start: 749
- end: 755
- name: "page"
value: ExpressionTag {...}
- type: "ExpressionTag"
- start: 750
- end: 754
expression: Identifier {...}
- start: 750
- end: 754
- type: "Identifier"
- name: "page"
}
}
}
]fragment: Fragment {...}
- type: "Fragment"
- nodes: []
}
} Text {...}
- type: "Text"
- start: 758
- end: 760
- raw: "\n\t"
- data: "\n\t"
}
]
}- alternate: null
}
]
}
} Text {...}
- type: "Text"
- start: 765
- end: 766
- raw: "\n"
- data: "\n"
}
]
}
} Text {...}
- type: "Text"
- start: 773
- end: 775
- raw: "\n\n"
- data: "\n\n"
}
]
}- options: null
instance: Script {...}
- type: "Script"
- start: 0
- end: 616
- context: "default"
content: Program {...}
- type: "Program"
- start: 8
- end: 607
loc: {...}
start: {...}
- line: 1
- column: 0
}end: {...}
- line: 27
- column: 0
}
}body: [...] (7)
ImportDeclaration {...}
- type: "ImportDeclaration"
- start: 10
- end: 43
loc: {...}
start: {...}
- line: 2
- column: 1
}end: {...}
- line: 2
- column: 34
}
}specifiers: [...] (1)
ImportSpecifier {...}
- type: "ImportSpecifier"
- start: 19
- end: 26
loc: {...}
start: {...}
- line: 2
- column: 10
}end: {...}
- line: 2
- column: 17
}
}imported: Identifier {...}
- type: "Identifier"
- start: 19
- end: 26
loc: {...}
start: {...}
- line: 2
- column: 10
}end: {...}
- line: 2
- column: 17
}
}- name: "onMount"
}local: Identifier {...}
- type: "Identifier"
- start: 19
- end: 26
loc: {...}
start: {...}
- line: 2
- column: 10
}end: {...}
- line: 2
- column: 17
}
}- name: "onMount"
}
}
]source: Literal {...}
- type: "Literal"
- start: 34
- end: 42
loc: {...}
start: {...}
- line: 2
- column: 25
}end: {...}
- line: 2
- column: 33
}
}- value: "svelte"
- raw: "'svelte'"
}
} ImportDeclaration {...}
- type: "ImportDeclaration"
- start: 45
- end: 78
loc: {...}
start: {...}
- line: 3
- column: 1
}end: {...}
- line: 3
- column: 34
}
}specifiers: [...] (1)
ImportDefaultSpecifier {...}
- type: "ImportDefaultSpecifier"
- start: 52
- end: 56
loc: {...}
start: {...}
- line: 3
- column: 8
}end: {...}
- line: 3
- column: 12
}
}local: Identifier {...}
- type: "Identifier"
- start: 52
- end: 56
loc: {...}
start: {...}
- line: 3
- column: 8
}end: {...}
- line: 3
- column: 12
}
}- name: "List"
}
}
]source: Literal {...}
- type: "Literal"
- start: 62
- end: 77
loc: {...}
start: {...}
- line: 3
- column: 18
}end: {...}
- line: 3
- column: 33
}
}- value: "./List.svelte"
- raw: "'./List.svelte'"
}
} ImportDeclaration {...}
- type: "ImportDeclaration"
- start: 80
- end: 113
loc: {...}
start: {...}
- line: 4
- column: 1
}end: {...}
- line: 4
- column: 34
}
}specifiers: [...] (1)
ImportDefaultSpecifier {...}
- type: "ImportDefaultSpecifier"
- start: 87
- end: 91
loc: {...}
start: {...}
- line: 4
- column: 8
}end: {...}
- line: 4
- column: 12
}
}local: Identifier {...}
- type: "Identifier"
- start: 87
- end: 91
loc: {...}
start: {...}
- line: 4
- column: 8
}end: {...}
- line: 4
- column: 12
}
}- name: "Item"
}
}
]source: Literal {...}
- type: "Literal"
- start: 97
- end: 112
loc: {...}
start: {...}
- line: 4
- column: 18
}end: {...}
- line: 4
- column: 33
}
}- value: "./Item.svelte"
- raw: "'./Item.svelte'"
}
} VariableDeclaration {...}
- type: "VariableDeclaration"
- start: 116
- end: 136
loc: {...}
start: {...}
- line: 6
- column: 1
}end: {...}
- line: 6
- column: 21
}
}declarations: [...] (1)
VariableDeclarator {...}
- type: "VariableDeclarator"
- start: 120
- end: 135
loc: {...}
start: {...}
- line: 6
- column: 5
}end: {...}
- line: 6
- column: 20
}
}id: Identifier {...}
- type: "Identifier"
- start: 120
- end: 124
loc: {...}
start: {...}
- line: 6
- column: 5
}end: {...}
- line: 6
- column: 9
}
}- name: "item"
}init: CallExpression {...}
- type: "CallExpression"
- start: 127
- end: 135
loc: {...}
start: {...}
- line: 6
- column: 12
}end: {...}
- line: 6
- column: 20
}
}callee: Identifier {...}
- type: "Identifier"
- start: 127
- end: 133
loc: {...}
start: {...}
- line: 6
- column: 12
}end: {...}
- line: 6
- column: 18
}
}- name: "$state"
}- arguments: []
- optional: false
}
}
]- kind: "let"
} VariableDeclaration {...}
- type: "VariableDeclaration"
- start: 138
- end: 158
loc: {...}
start: {...}
- line: 7
- column: 1
}end: {...}
- line: 7
- column: 21
}
}declarations: [...] (1)
VariableDeclarator {...}
- type: "VariableDeclarator"
- start: 142
- end: 157
loc: {...}
start: {...}
- line: 7
- column: 5
}end: {...}
- line: 7
- column: 20
}
}id: Identifier {...}
- type: "Identifier"
- start: 142
- end: 146
loc: {...}
start: {...}
- line: 7
- column: 5
}end: {...}
- line: 7
- column: 9
}
}- name: "page"
}init: CallExpression {...}
- type: "CallExpression"
- start: 149
- end: 157
loc: {...}
start: {...}
- line: 7
- column: 12
}end: {...}
- line: 7
- column: 20
}
}callee: Identifier {...}
- type: "Identifier"
- start: 149
- end: 155
loc: {...}
start: {...}
- line: 7
- column: 12
}end: {...}
- line: 7
- column: 18
}
}- name: "$state"
}- arguments: []
- optional: false
}
}
]- kind: "let"
} FunctionDeclaration {...}
- type: "FunctionDeclaration"
- start: 161
- end: 583
loc: {...}
start: {...}
- line: 9
- column: 1
}end: {...}
- line: 24
- column: 2
}
}id: Identifier {...}
- type: "Identifier"
- start: 176
- end: 186
loc: {...}
start: {...}
- line: 9
- column: 16
}end: {...}
- line: 9
- column: 26
}
}- name: "hashchange"
}- expression: false
- generator: false
- async: true
- params: []
body: BlockStatement {...}
- type: "BlockStatement"
- start: 189
- end: 583
loc: {...}
start: {...}
- line: 9
- column: 29
}end: {...}
- line: 24
- column: 2
}
}body: [...] (2)
VariableDeclaration {...}
- type: "VariableDeclaration"
- start: 221
- end: 264
loc: {...}
start: {...}
- line: 11
- column: 2
}end: {...}
- line: 11
- column: 45
}
}declarations: [...] (1)
VariableDeclarator {...}
- type: "VariableDeclarator"
- start: 227
- end: 263
loc: {...}
start: {...}
- line: 11
- column: 8
}end: {...}
- line: 11
- column: 44
}
}id: Identifier {...}
- type: "Identifier"
- start: 227
- end: 231
loc: {...}
start: {...}
- line: 11
- column: 8
}end: {...}
- line: 11
- column: 12
}
}- name: "path"
}init: CallExpression {...}
- type: "CallExpression"
- start: 234
- end: 263
loc: {...}
start: {...}
- line: 11
- column: 15
}end: {...}
- line: 11
- column: 44
}
}callee: MemberExpression {...}
- type: "MemberExpression"
- start: 234
- end: 260
loc: {...}
start: {...}
- line: 11
- column: 15
}end: {...}
- line: 11
- column: 41
}
}object: MemberExpression {...}
- type: "MemberExpression"
- start: 234
- end: 254
loc: {...}
start: {...}
- line: 11
- column: 15
}end: {...}
- line: 11
- column: 35
}
}object: MemberExpression {...}
- type: "MemberExpression"
- start: 234
- end: 249
loc: {...}
start: {...}
- line: 11
- column: 15
}end: {...}
- line: 11
- column: 30
}
}object: Identifier {...}
- type: "Identifier"
- start: 234
- end: 240
loc: {...}
start: {...}
- line: 11
- column: 15
}end: {...}
- line: 11
- column: 21
}
}- name: "window"
}property: Identifier {...}
- type: "Identifier"
- start: 241
- end: 249
loc: {...}
start: {...}
- line: 11
- column: 22
}end: {...}
- line: 11
- column: 30
}
}- name: "location"
}- computed: false
- optional: false
}property: Identifier {...}
- type: "Identifier"
- start: 250
- end: 254
loc: {...}
start: {...}
- line: 11
- column: 31
}end: {...}
- line: 11
- column: 35
}
}- name: "hash"
}- computed: false
- optional: false
}property: Identifier {...}
- type: "Identifier"
- start: 255
- end: 260
loc: {...}
start: {...}
- line: 11
- column: 36
}end: {...}
- line: 11
- column: 41
}
}- name: "slice"
}- computed: false
- optional: false
}arguments: [...] (1)
Literal {...}
- type: "Literal"
- start: 261
- end: 262
loc: {...}
start: {...}
- line: 11
- column: 42
}end: {...}
- line: 11
- column: 43
}
}- value: 1
- raw: "1"
}
]- optional: false
}
}
]- kind: "const"
leadingComments: [...] (1)
Line {...}
- type: "Line"
- value: " the poor man's router!"
- start: 193
- end: 218
}
]
} IfStatement {...}
- type: "IfStatement"
- start: 268
- end: 580
loc: {...}
start: {...}
- line: 13
- column: 2
}end: {...}
- line: 23
- column: 3
}
}test: CallExpression {...}
- type: "CallExpression"
- start: 272
- end: 296
loc: {...}
start: {...}
- line: 13
- column: 6
}end: {...}
- line: 13
- column: 30
}
}callee: MemberExpression {...}
- type: "MemberExpression"
- start: 272
- end: 287
loc: {...}
start: {...}
- line: 13
- column: 6
}end: {...}
- line: 13
- column: 21
}
}object: Identifier {...}
- type: "Identifier"
- start: 272
- end: 276
loc: {...}
start: {...}
- line: 13
- column: 6
}end: {...}
- line: 13
- column: 10
}
}- name: "path"
}property: Identifier {...}
- type: "Identifier"
- start: 277
- end: 287
loc: {...}
start: {...}
- line: 13
- column: 11
}end: {...}
- line: 13
- column: 21
}
}- name: "startsWith"
}- computed: false
- optional: false
}arguments: [...] (1)
Literal {...}
- type: "Literal"
- start: 288
- end: 295
loc: {...}
start: {...}
- line: 13
- column: 22
}end: {...}
- line: 13
- column: 29
}
}- value: "/item"
- raw: "'/item'"
}
]- optional: false
}consequent: BlockStatement {...}
- type: "BlockStatement"
- start: 298
- end: 451
loc: {...}
start: {...}
- line: 13
- column: 32
}end: {...}
- line: 18
- column: 3
}
}body: [...] (3)
VariableDeclaration {...}
- type: "VariableDeclaration"
- start: 303
- end: 328
loc: {...}
start: {...}
- line: 14
- column: 3
}end: {...}
- line: 14
- column: 28
}
}declarations: [...] (1)
VariableDeclarator {...}
- type: "VariableDeclarator"
- start: 309
- end: 327
loc: {...}
start: {...}
- line: 14
- column: 9
}end: {...}
- line: 14
- column: 27
}
}id: Identifier {...}
- type: "Identifier"
- start: 309
- end: 311
loc: {...}
start: {...}
- line: 14
- column: 9
}end: {...}
- line: 14
- column: 11
}
}- name: "id"
}init: CallExpression {...}
- type: "CallExpression"
- start: 314
- end: 327
loc: {...}
start: {...}
- line: 14
- column: 14
}end: {...}
- line: 14
- column: 27
}
}callee: MemberExpression {...}
- type: "MemberExpression"
- start: 314
- end: 324
loc: {...}
start: {...}
- line: 14
- column: 14
}end: {...}
- line: 14
- column: 24
}
}object: Identifier {...}
- type: "Identifier"
- start: 314
- end: 318
loc: {...}
start: {...}
- line: 14
- column: 14
}end: {...}
- line: 14
- column: 18
}
}- name: "path"
}property: Identifier {...}
- type: "Identifier"
- start: 319
- end: 324
loc: {...}
start: {...}
- line: 14
- column: 19
}end: {...}
- line: 14
- column: 24
}
}- name: "slice"
}- computed: false
- optional: false
}arguments: [...] (1)
Literal {...}
- type: "Literal"
- start: 325
- end: 326
loc: {...}
start: {...}
- line: 14
- column: 25
}end: {...}
- line: 14
- column: 26
}
}- value: 6
- raw: "6"
}
]- optional: false
}
}
]- kind: "const"
} ExpressionStatement {...}
- type: "ExpressionStatement"
- start: 332
- end: 420
loc: {...}
start: {...}
- line: 15
- column: 3
}end: {...}
- line: 15
- column: 91
}
}expression: AssignmentExpression {...}
- type: "AssignmentExpression"
- start: 332
- end: 419
loc: {...}
start: {...}
- line: 15
- column: 3
}end: {...}
- line: 15
- column: 90
}
}- operator: "="
left: Identifier {...}
- type: "Identifier"
- start: 332
- end: 336
loc: {...}
start: {...}
- line: 15
- column: 3
}end: {...}
- line: 15
- column: 7
}
}- name: "item"
}right: AwaitExpression {...}
- type: "AwaitExpression"
- start: 339
- end: 419
loc: {...}
start: {...}
- line: 15
- column: 10
}end: {...}
- line: 15
- column: 90
}
}argument: CallExpression {...}
- type: "CallExpression"
- start: 345
- end: 419
loc: {...}
start: {...}
- line: 15
- column: 16
}end: {...}
- line: 15
- column: 90
}
}callee: MemberExpression {...}
- type: "MemberExpression"
- start: 345
- end: 402
loc: {...}
start: {...}
- line: 15
- column: 16
}end: {...}
- line: 15
- column: 73
}
}object: CallExpression {...}
- type: "CallExpression"
- start: 345
- end: 397
loc: {...}
start: {...}
- line: 15
- column: 16
}end: {...}
- line: 15
- column: 68
}
}callee: Identifier {...}
- type: "Identifier"
- start: 345
- end: 350
loc: {...}
start: {...}
- line: 15
- column: 16
}end: {...}
- line: 15
- column: 21
}
}- name: "fetch"
}arguments: [...] (1)
TemplateLiteral {...}
- type: "TemplateLiteral"
- start: 351
- end: 396
loc: {...}
start: {...}
- line: 15
- column: 22
}end: {...}
- line: 15
- column: 67
}
}expressions: [...] (1)
Identifier {...}
- type: "Identifier"
- start: 392
- end: 394
loc: {...}
start: {...}
- line: 15
- column: 63
}end: {...}
- line: 15
- column: 65
}
}- name: "id"
}
]quasis: [...] (2)
TemplateElement {...}
- type: "TemplateElement"
- start: 352
- end: 390
loc: {...}
start: {...}
- line: 15
- column: 23
}end: {...}
- line: 15
- column: 61
}
}value: {...}
- raw: "https://node-hnapi.herokuapp.com/item/"
- cooked: "https://node-hnapi.herokuapp.com/item/"
}- tail: false
} TemplateElement {...}
- type: "TemplateElement"
- start: 395
- end: 395
loc: {...}
start: {...}
- line: 15
- column: 66
}end: {...}
- line: 15
- column: 66
}
}value: {...}
- raw: ""
- cooked: ""
}- tail: true
}
]
}
]- optional: false
}property: Identifier {...}
- type: "Identifier"
- start: 398
- end: 402
loc: {...}
start: {...}
- line: 15
- column: 69
}end: {...}
- line: 15
- column: 73
}
}- name: "then"
}- computed: false
- optional: false
}arguments: [...] (1)
ArrowFunctionExpression {...}
- type: "ArrowFunctionExpression"
- start: 403
- end: 418
loc: {...}
start: {...}
- line: 15
- column: 74
}end: {...}
- line: 15
- column: 89
}
}- id: null
- expression: true
- generator: false
- async: false
params: [...] (1)
Identifier {...}
- type: "Identifier"
- start: 404
- end: 405
loc: {...}
start: {...}
- line: 15
- column: 75
}end: {...}
- line: 15
- column: 76
}
}- name: "r"
}
]body: CallExpression {...}
- type: "CallExpression"
- start: 410
- end: 418
loc: {...}
start: {...}
- line: 15
- column: 81
}end: {...}
- line: 15
- column: 89
}
}callee: MemberExpression {...}
- type: "MemberExpression"
- start: 410
- end: 416
loc: {...}
start: {...}
- line: 15
- column: 81
}end: {...}
- line: 15
- column: 87
}
}object: Identifier {...}
- type: "Identifier"
- start: 410
- end: 411
loc: {...}
start: {...}
- line: 15
- column: 81
}end: {...}
- line: 15
- column: 82
}
}- name: "r"
}property: Identifier {...}
- type: "Identifier"
- start: 412
- end: 416
loc: {...}
start: {...}
- line: 15
- column: 83
}end: {...}
- line: 15
- column: 87
}
}- name: "json"
}- computed: false
- optional: false
}- arguments: []
- optional: false
}
}
]- optional: false
}
}
}
} ExpressionStatement {...}
- type: "ExpressionStatement"
- start: 425
- end: 447
loc: {...}
start: {...}
- line: 17
- column: 3
}end: {...}
- line: 17
- column: 25
}
}expression: CallExpression {...}
- type: "CallExpression"
- start: 425
- end: 446
loc: {...}
start: {...}
- line: 17
- column: 3
}end: {...}
- line: 17
- column: 24
}
}callee: MemberExpression {...}
- type: "MemberExpression"
- start: 425
- end: 440
loc: {...}
start: {...}
- line: 17
- column: 3
}end: {...}
- line: 17
- column: 18
}
}object: Identifier {...}
- type: "Identifier"
- start: 425
- end: 431
loc: {...}
start: {...}
- line: 17
- column: 3
}end: {...}
- line: 17
- column: 9
}
}- name: "window"
}property: Identifier {...}
- type: "Identifier"
- start: 432
- end: 440
loc: {...}
start: {...}
- line: 17
- column: 10
}end: {...}
- line: 17
- column: 18
}
}- name: "scrollTo"
}- computed: false
- optional: false
}arguments: [...] (2)
Literal {...}
- type: "Literal"
- start: 441
- end: 442
loc: {...}
start: {...}
- line: 17
- column: 19
}end: {...}
- line: 17
- column: 20
}
}- value: 0
- raw: "0"
} Literal {...}
- type: "Literal"
- start: 444
- end: 445
loc: {...}
start: {...}
- line: 17
- column: 22
}end: {...}
- line: 17
- column: 23
}
}- value: 0
- raw: "0"
}
]- optional: false
}
}
]
}alternate: IfStatement {...}
- type: "IfStatement"
- start: 457
- end: 580
loc: {...}
start: {...}
- line: 18
- column: 9
}end: {...}
- line: 23
- column: 3
}
}test: CallExpression {...}
- type: "CallExpression"
- start: 461
- end: 484
loc: {...}
start: {...}
- line: 18
- column: 13
}end: {...}
- line: 18
- column: 36
}
}callee: MemberExpression {...}
- type: "MemberExpression"
- start: 461
- end: 476
loc: {...}
start: {...}
- line: 18
- column: 13
}end: {...}
- line: 18
- column: 28
}
}object: Identifier {...}
- type: "Identifier"
- start: 461
- end: 465
loc: {...}
start: {...}
- line: 18
- column: 13
}end: {...}
- line: 18
- column: 17
}
}- name: "path"
}property: Identifier {...}
- type: "Identifier"
- start: 466
- end: 476
loc: {...}
start: {...}
- line: 18
- column: 18
}end: {...}
- line: 18
- column: 28
}
}- name: "startsWith"
}- computed: false
- optional: false
}arguments: [...] (1)
Literal {...}
- type: "Literal"
- start: 477
- end: 483
loc: {...}
start: {...}
- line: 18
- column: 29
}end: {...}
- line: 18
- column: 35
}
}- value: "/top"
- raw: "'/top'"
}
]- optional: false
}consequent: BlockStatement {...}
- type: "BlockStatement"
- start: 486
- end: 533
loc: {...}
start: {...}
- line: 18
- column: 38
}end: {...}
- line: 21
- column: 3
}
}body: [...] (2)
ExpressionStatement {...}
- type: "ExpressionStatement"
- start: 491
- end: 513
loc: {...}
start: {...}
- line: 19
- column: 3
}end: {...}
- line: 19
- column: 25
}
}expression: AssignmentExpression {...}
- type: "AssignmentExpression"
- start: 491
- end: 512
loc: {...}
start: {...}
- line: 19
- column: 3
}end: {...}
- line: 19
- column: 24
}
}- operator: "="
left: Identifier {...}
- type: "Identifier"
- start: 491
- end: 495
loc: {...}
start: {...}
- line: 19
- column: 3
}end: {...}
- line: 19
- column: 7
}
}- name: "page"
}right: UnaryExpression {...}
- type: "UnaryExpression"
- start: 498
- end: 512
loc: {...}
start: {...}
- line: 19
- column: 10
}end: {...}
- line: 19
- column: 24
}
}- operator: "+"
- prefix: true
argument: CallExpression {...}
- type: "CallExpression"
- start: 499
- end: 512
loc: {...}
start: {...}
- line: 19
- column: 11
}end: {...}
- line: 19
- column: 24
}
}callee: MemberExpression {...}
- type: "MemberExpression"
- start: 499
- end: 509
loc: {...}
start: {...}
- line: 19
- column: 11
}end: {...}
- line: 19
- column: 21
}
}object: Identifier {...}
- type: "Identifier"
- start: 499
- end: 503
loc: {...}
start: {...}
- line: 19
- column: 11
}end: {...}
- line: 19
- column: 15
}
}- name: "path"
}property: Identifier {...}
- type: "Identifier"
- start: 504
- end: 509
loc: {...}
start: {...}
- line: 19
- column: 16
}end: {...}
- line: 19
- column: 21
}
}- name: "slice"
}- computed: false
- optional: false
}arguments: [...] (1)
Literal {...}
- type: "Literal"
- start: 510
- end: 511
loc: {...}
start: {...}
- line: 19
- column: 22
}end: {...}
- line: 19
- column: 23
}
}- value: 5
- raw: "5"
}
]- optional: false
}
}
}
} ExpressionStatement {...}
- type: "ExpressionStatement"
- start: 517
- end: 529
loc: {...}
start: {...}
- line: 20
- column: 3
}end: {...}
- line: 20
- column: 15
}
}expression: AssignmentExpression {...}
- type: "AssignmentExpression"
- start: 517
- end: 528
loc: {...}
start: {...}
- line: 20
- column: 3
}end: {...}
- line: 20
- column: 14
}
}- operator: "="
left: Identifier {...}
- type: "Identifier"
- start: 517
- end: 521
loc: {...}
start: {...}
- line: 20
- column: 3
}end: {...}
- line: 20
- column: 7
}
}- name: "item"
}right: Literal {...}
- type: "Literal"
- start: 524
- end: 528
loc: {...}
start: {...}
- line: 20
- column: 10
}end: {...}
- line: 20
- column: 14
}
}- value: null
- raw: "null"
}
}
}
]
}alternate: BlockStatement {...}
- type: "BlockStatement"
- start: 539
- end: 580
loc: {...}
start: {...}
- line: 21
- column: 9
}end: {...}
- line: 23
- column: 3
}
}body: [...] (1)
ExpressionStatement {...}
- type: "ExpressionStatement"
- start: 544
- end: 576
loc: {...}
start: {...}
- line: 22
- column: 3
}end: {...}
- line: 22
- column: 35
}
}expression: AssignmentExpression {...}
- type: "AssignmentExpression"
- start: 544
- end: 575
loc: {...}
start: {...}
- line: 22
- column: 3
}end: {...}
- line: 22
- column: 34
}
}- operator: "="
left: MemberExpression {...}
- type: "MemberExpression"
- start: 544
- end: 564
loc: {...}
start: {...}
- line: 22
- column: 3
}end: {...}
- line: 22
- column: 23
}
}object: MemberExpression {...}
- type: "MemberExpression"
- start: 544
- end: 559
loc: {...}
start: {...}
- line: 22
- column: 3
}end: {...}
- line: 22
- column: 18
}
}object: Identifier {...}
- type: "Identifier"
- start: 544
- end: 550
loc: {...}
start: {...}
- line: 22
- column: 3
}end: {...}
- line: 22
- column: 9
}
}- name: "window"
}property: Identifier {...}
- type: "Identifier"
- start: 551
- end: 559
loc: {...}
start: {...}
- line: 22
- column: 10
}end: {...}
- line: 22
- column: 18
}
}- name: "location"
}- computed: false
- optional: false
}property: Identifier {...}
- type: "Identifier"
- start: 560
- end: 564
loc: {...}
start: {...}
- line: 22
- column: 19
}end: {...}
- line: 22
- column: 23
}
}- name: "hash"
}- computed: false
- optional: false
}right: Literal {...}
- type: "Literal"
- start: 567
- end: 575
loc: {...}
start: {...}
- line: 22
- column: 26
}end: {...}
- line: 22
- column: 34
}
}- value: "/top/1"
- raw: "'/top/1'"
}
}
}
]
}
}
}
]
}
} ExpressionStatement {...}
- type: "ExpressionStatement"
- start: 586
- end: 606
loc: {...}
start: {...}
- line: 26
- column: 1
}end: {...}
- line: 26
- column: 21
}
}expression: CallExpression {...}
- type: "CallExpression"
- start: 586
- end: 605
loc: {...}
start: {...}
- line: 26
- column: 1
}end: {...}
- line: 26
- column: 20
}
}callee: Identifier {...}
- type: "Identifier"
- start: 586
- end: 593
loc: {...}
start: {...}
- line: 26
- column: 1
}end: {...}
- line: 26
- column: 8
}
}- name: "onMount"
}arguments: [...] (1)
Identifier {...}
- type: "Identifier"
- start: 594
- end: 604
loc: {...}
start: {...}
- line: 26
- column: 9
}end: {...}
- line: 26
- column: 19
}
}- name: "hashchange"
}
]- optional: false
}
}
]- sourceType: "module"
}- attributes: []
}
}
The AST is not public API and may change at any point in time