Skip to content

Instantly share code, notes, and snippets.

'use strict';
try {
Promise.resolve(true).then(function{
undefinedVariable = [];
console.log("Boo");
}, function(err) {
console.log(err)
})
} catch (err) {
console.log(err.stack)
/**
* @record
*/
var LocalDomWithBackground = function(){};
/**
* @type HTMLElement
*/
LocalDomWithBackground.prototype.backgroundFrontLayer;
/**
@garlicnation
garlicnation / biz.html
Created June 7, 2016 01:48
Element style project pathological paths. Since gists can't be subdirs, imagine this file is /components/bar/subfolder/biz.html
<link rel="import" href="/components/biz/bizdep.html"> <!-- should be /bower_components/biz/bizdep.html -->
<link rel="import" href="../boo.html"> <!-- should be /biz.html-->
<link rel="import" href="../../biz/bizdep.html"> <!-- Should be the same as the absolute path above.-->
<head>
<style is="custom-style" include="shared-styles"></style>
</head>
<body>
<div>Content goes here</div>
<link rel="vulcanized.html">
<!--<script src="init.js"></script>-->
</body>
while(htmlImportRemaining()) {
// Get the first inlinable HTML import
let nextImport = getNextImport();
// Resolve the paths relative to the current document URL
let resolvedImport = resolvePaths(
thisDocument,
nextImport.href,
nextImport.document
)
// Replace <link rel="import"> with the document's DOM
const func = () => {
return {};
};
// TSLint requires whitespace after ;, clang-format forcibly removes the whitespace.
for (let variable; variable = func();) {
break;
}
1) Given N endpoints, build map from endpoint -> dependency[]
2) Given endpoint -> dep map, build dep -> endpoint[] map
3) Apply user-provided function to the results from step 2 to build bundle manifest
4) Bundle endpoints according to map from step 3
bundle(["shop-app.html", "shop-list.html", "shop-cart.html"], analyzer, appShellHeuristic("end1.html"))
async bundle(url: string|string[], orchestrator?: BundleOrchestrator): Promise<DocumentCollection> {}
@garlicnation
garlicnation / github.ts
Created December 13, 2016 22:50
Async await github api example
let tagResponse = await api.gitdata.getTags({owner: org, repo: component});
let allTags = tagResponse.slice();
while (api.hasNextPage(tagResponse)) {
tagResponse = await api.getNextPage(tagResponse);
allTags = allTags.concat(tagResponse);
}
@garlicnation
garlicnation / roots.js
Last active July 10, 2018 15:22
Select inside shadow roots
/**
* Find all elements inside `root` that match `selector`, even inside shadow roots.
*/
function qsAllDom(root, selector, results){
if (!results) {
results = []
}
var newResults = root.querySelectorAll(selector);
for (var result of newResults) {
results.push(result);
@garlicnation
garlicnation / queries.js
Last active December 20, 2016 21:25
Two different deep queries
/**
* Find all elements inside `root` that match `selector`, even inside shadow roots.
*/
function qsAllDomTreeWalker(root, selector, results){
if (!results) {
results = []
}
var queue = [];
const newWalker = (root) => document.createTreeWalker(