This file contains 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 handlerFactory = (sub = null) => { | |
const handlers = []; | |
const handler = (...args) => { | |
for (let handler of handlers) { | |
handler.apply(null, args); | |
} | |
}; | |
handler.add = (sub) => { | |
if (sub !== handler && sub instanceof Function && handlers.indexOf(sub) < 0) { | |
handlers.push(sub); |
This file contains 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
class AbstractCallableObject { | |
constructor() { | |
return (...args) => this.apply(this, args); | |
} | |
apply(target, args) { | |
this.call(target, ...args); | |
} | |
/*abstract*/ call(target, ...args) { |
This file contains 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
'use strict'; | |
let SymbolImpl; | |
if (typeof(Symbol) === 'undefined') { | |
SymbolImpl = (value) => { | |
const salt = Math.random(); | |
const symbol = () => `@@${value}:${salt}`; | |
symbol.toString = symbol; | |
symbol.valueOf = symbol; |
This file contains 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
'use strict'; | |
import SymbolImpl from 'SymbolImpl'; | |
import EventDispatcher from 'event-dispatcher'; | |
const INTERNALS_FIELD = SymbolImpl('timer::internals'); | |
const getInitObject = (delay, repeatCount,) => ({ | |
delay, | |
repeatCount, |
This file contains 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
import SymbolImpl from 'SymbolImpl'; | |
const INTERNALS_FIELD = SymbolImpl('event.deferred::internals'); | |
class EventDeferred { | |
constructor(dispatcher, eventType) { | |
this.promise = new Promise((resolve, reject) => { | |
this[INTERNALS_FIELD] = { | |
dispatcher, | |
eventType, |
This file contains 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
import SymbolImpl from 'SymbolImpl'; | |
import EventDeferred from 'EventDeferred'; | |
const INTERNALS_FIELD = SymbolImpl('duplex.listener::internals'); | |
class DuplexListener { | |
constructor(dispatcher, event, responseEventType, data = null) { | |
if (responseEventType) { | |
const deferred = new EventDeferred(dispatcher, responseEventType); | |
this.promise = deferred.promise; |
This file contains 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
/** | |
Login to your IndieGala accountand launch this script in console. | |
It asks to trade for any game. | |
*/ | |
((window, document) => { | |
let alertsCount = 0; | |
const alert = (content) => { | |
console.warn('Alert:', content); | |
alertsCount++; |
This file contains 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
import React, { Component } from 'react'; | |
import PropTypes from 'prop-types'; | |
import { WebView } from 'react-native'; | |
const WEBVIEW_URL = 'https://github.com/login/oauth/authorize'; | |
const TOKEN_URL = 'https://github.com/login/oauth/access_token'; | |
/* | |
URL that will be displayed after successful login, it should be different to track URL change, so component can grab code | |
*/ |
This file contains 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
export const parseHTTPRequest = (data) => { | |
const headers = {}; | |
const rgx = /^([^\:\r\n]+)\:\s*([^\r\n]+)$/gm; | |
const [requestHeader, method, path, httpVersion] = data.match(/^(\w+)\s+([^\r\n]+)\s+HTTP\/([\d\.]+)/); | |
const request = { requestHeader, method, path, httpVersion, headers }; | |
let header; | |
while ((header = rgx.exec(data))) { | |
const [, name, value] = header; | |
headers[name] = value; |
This file contains 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
(() => { | |
let index = 0; | |
const step = 10; | |
const root = document.querySelector('#searchResultsRows'); | |
root.innerHTML = ''; | |
const loadPage = (page, count) => { | |
fetch(`https://steamcommunity.com/market/listings/<GAME_ID>/<ITEM_NAME>/render/?query=&start=${page*count}&count=${count}&country=RU&language=english¤cy=5`) | |
.then((response) => response.json()) | |
.then(({results_html, listinginfo, assets}) => { | |
assets = assets['570']['2']; |