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
// This is a quick example on how we could wait for real loaded state | |
// by monitoring traffic. If needed, traffic filtering could be added. | |
var dataByTabId = {} | |
function getDataByTabId (tabId) { | |
if (!dataByTabId[tabId]) { | |
dataByTabId[tabId] = { | |
reqCounter: 0, | |
callbacks: [], |
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
'use strict'; | |
const spawn = generatorFunction => function() { | |
const gen = generatorFunction.apply(this, arguments); | |
return new Promise(resolve => { | |
const handle = (it) => { | |
if (it.done) { | |
return it.value; |
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
/*eslint-env es6*/ | |
const hasOwn = ({}).hasOwnProperty; | |
// Check if two objects are equal by comparing own enumerable properties. | |
const isEqualShallow = (a, b) => { | |
if (a === b) return true; | |
if (!a || !b) return false; | |
const akeys = Object.keys(a); | |
const bkeys = Object.keys(b); |
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
def edgesFunc(G): | |
if callable(G): | |
return G | |
items = _itemsFunc(G) | |
return lambda v: items(G[v]) | |
# (list of dictionaries) | |
def bgraph(x, dicttype=dict): |
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 asap = require("asap") | |
asap.sub = function (onerror) { | |
var parent = this; | |
var self = function (task) { | |
parent(function () { | |
try { | |
task(); | |
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 loop (fn, startValue) { | |
var deferred = Q.defer(), | |
finished = false; | |
function end (val) { | |
finished = true; | |
deferred.resolve(val); | |
} |
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
// array already sorted! | |
function unique( array ) { | |
var j = 0, | |
i = 1, | |
l = array.length | 0; | |
while ( i < l && array[i-1] !== array[i] ) { | |
++i; | |
} |
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
// Based on the Q.nextTick implementation https://github.com/kriskowal/q/pull/195. | |
var later = (function(){ | |
var head = { task: void 0, next: null }, tail = head, | |
maxPendingTicks = 2, pendingTicks = 0, queuedTasks = 0, usedTicks = 0, | |
requestTick; | |
var onTick = function() { | |
--pendingTicks; | |
if ( ++usedTicks >= maxPendingTicks ) { |
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 formCheckedRadios = {}; | |
function OldWebKitFakeRadio() { | |
this._name = ""; | |
this._defaultChecked = false; | |
this._checked = false; | |
} | |
OldWebKitFakeRadio.prototype = { | |
get name() { |
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( jQuery, undefined ){ | |
var toString = ({}).toString, | |
hasOwn = ({}).hasOwnProperty, | |
slice = [].slice, | |
push = [].push, | |
// [[Class]] --> type (for all natives) | |
class2type = {}, |