Skip to content

Commit 293e7c2

Browse files
shugokateinoigakukun
authored andcommitted
Fix the setTimeout example not to return immediately
1 parent 41ffd72 commit 293e7c2

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

ext/js/lib/js.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -137,10 +137,10 @@ def respond_to_missing?(sym, include_private)
137137
#
138138
# The below examples show typical usage in Ruby
139139
#
140-
# JS.eval("return new Promise((ok) => setTimeout(ok(42), 1000))").await # => 42 (after 1 second)
141-
# JS.global.fetch("https://example.com").await # => [object Response]
142-
# JS.eval("return 42").await # => 42
143-
# JS.eval("return new Promise((ok, err) => err(new Error())").await # => raises JS::Error
140+
# JS.eval("return new Promise((ok) => setTimeout(() => ok(42), 1000))").await # => 42 (after 1 second)
141+
# JS.global.fetch("https://example.com").await # => [object Response]
142+
# JS.eval("return 42").await # => 42
143+
# JS.eval("return new Promise((ok, err) => err(new Error())").await # => raises JS::Error
144144
def await
145145
# Promise.resolve wrap a value or flattens promise-like object and its thenable chain
146146
promise = JS.global[:Promise].resolve(self)

0 commit comments

Comments
 (0)