Skip to content

Instantly share code, notes, and snippets.

View gskachkov's full-sized avatar

Oleksander Skachkov gskachkov

  • Itera Consulting
  • Ukraine, Kiev
View GitHub Profile
function fakeGen() {
return {
[Symbol.iterator]: {}
}
}
let [...x] = fakeGen();
// We need error that [Symbol.iterator] is not callable
const myInterface = Symbol('myInterface');
export default myInterface;
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'};
@globalPrivate
function next() {
}
@globalPrivate
function return() {
}
@globalPrivate
function throw() {
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);
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);
function foo () {
try {
throw new Error('Error');
} catch (boo) {
eval('{ function boo() {} }');
print(boo); // should be Error
}
print(boo); // should be function boo
}
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)
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);
}
}
var foo = async function() {};
typeof foo;
// "function"
foo.toString();
// "async function () {}"
foo[Symbol.toStringTag];
// "AsyncFunction"