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 fakeGen() { | |
return { | |
[Symbol.iterator]: {} | |
} | |
} | |
let [...x] = fakeGen(); | |
// We need error that [Symbol.iterator] is not callable |
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
const myInterface = Symbol('myInterface'); | |
export default myInterface; |
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
const objWithIterator = { | |
[Symbol.iterator]() { | |
return { | |
next: function() { | |
console.log('do next'); | |
return {done: false, value: 'foo'}; | |
}, | |
return: function() { | |
console.log('do return'); | |
return {done: true, value: 'foo'}; |
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
@globalPrivate | |
function next() { | |
} | |
@globalPrivate | |
function return() { | |
} | |
@globalPrivate | |
function throw() { |
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
async function foo (value) { | |
return Promise.resolve(value + 1); | |
} | |
async function bar (value) { | |
return Promise.resolve(value + 2); | |
} | |
async function foobar() { | |
const value = await foo(1); |
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
async function getOrder1(id) { | |
return _http.get('some/path'+1); | |
} | |
async function getOrder2(id) { | |
return _http.get('some/path'+1); | |
} | |
async function flow(id) { | |
const someValue = await getOrder1(id); |
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 foo () { | |
try { | |
throw new Error('Error'); | |
} catch (boo) { | |
eval('{ function boo() {} }'); | |
print(boo); // should be Error | |
} | |
print(boo); // should be function boo | |
} |
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
var apiRoot = "https://jsonplaceholder.typicode.com/"; | |
var currentUserCode = "[email protected]"; | |
function fetchCurrentUser(cb) { | |
$.ajax({url: apiRoot + "users", | |
complete: function(result) { | |
if (result.status === 200) { | |
var users = result.responseJSON; | |
var currentUser = users | |
.filter(user => user.email === currentUserCode) |
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
async function* asyncRandomNumbers() { | |
// This is a web service that returns a random number | |
const url = 'https://www.random.org/decimal-fractions/?num=1&dec=10&col=1&format=plain&rnd=new'; | |
while (true) { | |
const response = await fetch(url); | |
const text = await response.text(); | |
yield Number(text); | |
} | |
} |
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
var foo = async function() {}; | |
typeof foo; | |
// "function" | |
foo.toString(); | |
// "async function () {}" | |
foo[Symbol.toStringTag]; | |
// "AsyncFunction" |