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
// https://developer.github.com/v3/issues/comments/#create-a-comment | |
// https://developer.github.com/v3/issues/comments/#edit-a-comment | |
const fetch = require("node-fetch") | |
const commentGithubPullRequest = async ({ | |
token, | |
repoOwner, | |
repoName, | |
issueNumber, | |
commentBody, |
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 lighthouse = require("lighthouse") | |
const chromeLauncher = require("chrome-launcher") | |
const launchChromeAndRunLighthouse = async ({ url, opts, config = null }) => { | |
const chrome = await chromeLauncher.launch({ chromeFlags: opts.chromeFlags }) | |
opts.port = chrome.port | |
const results = await lighthouse(url, opts, config) | |
// use results.lhr for the JS-consumeable output | |
// https://github.com/GoogleChrome/lighthouse/blob/master/types/lhr.d.ts | |
// use results.report for the HTML/JSON/CSV output as a string |
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
// keep in mind element may be inside an iframe | |
// var childWindow = elem.document.frames.window; | |
// while (childWindow != parentWindow) { | |
// offset.left = offset.left + childWindow.frameElement.getBoundingClientRect().left; | |
// offset.top = offset.top + childWindow.frameElement.getBoundingClientRect().top; | |
// childWindow = childWindow.parent; | |
// } | |
const getRelativeBoundingClientRect = (element, relativeElement) => { | |
const { left, top, right, bottom } = element.getBoundingClientRect() |
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 delayFunction = ({ fn, ms = 0 } = {}) => { | |
let delayed = false | |
let delayedMs | |
let paused = false | |
let pausedMs | |
let id | |
const callback = () => { | |
delayed = false | |
fn() |
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 batchUIMutation = (fnMutatingUI) => { | |
if (typeof window !== 'undefined' && window.requestAnimationFrame) { | |
const id = requestAnimationFrame(() => { | |
cancelAnimationFrame(id) | |
fnMutatingUI() | |
}) | |
return () => cancelAnimationFrame(id) | |
} | |
const id = setTimeout(() => { |
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
/* | |
href | |
ββββββββββββββββββββββββββββββββββββββββββ΄βββββββββββββββββββββββββββββββββββββββββββββββ | |
origin β | |
ββββββββββββββ΄βββββββββββββββ β | |
β authority β | |
β βββββββββββββββββ΄ββββββββββββββββββββββββββββ β | |
β β host resource | |
β β ββββββββββββ΄ββββββββββββββββββ ββββββββββββββ΄ββββββββββββ¬ββββββββ | |
β β hostname β pathname β β |
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 isAncestorOf = (node, possibleDescendantNode) => { | |
let ancestor = possibleDescendantNode.parentNode | |
while (ancestor) { | |
if (ancestor === node) { | |
return true | |
} | |
ancestor = ancestor.parentNode | |
} | |
return false | |
} |
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 bubbleIframeEvents = (iframe, document) => { | |
const iframeWindow = iframe.contentWindow | |
iframeWindow.addEventListener( | |
'mousemove', | |
(event) => { | |
const boundingClientRect = iframe.getBoundingClientRect() | |
const fakeEvent = new CustomEvent( | |
'mousemove', | |
{ |
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 STRING = 0; // name is a string it cannot be an array index | |
const INFINITE = 1; // name is casted to Infinity, NaN or -Infinity, it cannot be an array index | |
const FLOATING = 2; // name is casted to a floating number, it cannot be an array index | |
const NEGATIVE = 3; // name is casted to a negative integer, it cannot be an array index | |
const TOO_BIG = 4; // name is casted to a integer above Math.pow(2, 32) - 1, it cannot be an array index | |
const VALID = 5; // name is a valid array index | |
const maxArrayIndexValue = Math.pow(2, 32) - 1; | |
function getArrayIndexStatusForString(name) { | |
if (isNaN(name)) { |