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
| node_modules | |
| package-lock.json |
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
| import hljs from 'highlight.js/lib/highlight'; | |
| import javascript from 'highlight.js/lib/languages/javascript'; | |
| import json from 'highlight.js/lib/languages/json'; | |
| import xml from 'highlight.js/lib/languages/xml'; | |
| import 'highlight.js/styles/tomorrow-night-eighties.css'; | |
| const LANGUAGES = { javascript, json, xml }; | |
| Object.keys(LANGUAGES).forEach( key => hljs.registerLanguage(key, LANGUAGES[key]) ); | |
| export function syntaxHighlight(code, lang) { |
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() { | |
| const { name, description, setup, teardown, tests, tags } = window['view-bench']._component.state.bench; | |
| name = name.replace(/(?:\s*\((\d+)\))?$/, (s,d) => ` (${(d||0)+1})`); | |
| history.replaceState(null, null, '/bench'); | |
| dispatchEvent(new Event('popstate')); | |
| setTimeout(() => { | |
| window['view-bench']._component.setState({ bench: { name, description, setup, teardown, tests, tags } }); | |
| window['view-bench']._component.save(); | |
| }, 100); | |
| }()); |
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
| module.exports = { | |
| format(parts) { | |
| return new URL(parts).href; | |
| }, | |
| parse(url) { | |
| const parsed = new URL(url); | |
| parsed.query = parsed.search ? parsed.search.substring(1) : null; | |
| parsed.auth = parsed.username + ':' + parsed.password; | |
| return parsed; | |
| }, |
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
| export function loadConfigModule(filename) { | |
| // sub your own | |
| return require(filename); | |
| } | |
| /** | |
| * Modify a Webpack configuration by applying a mutator module/function. | |
| * @param {Object} options | |
| * @param {Object} options.config Webpack configuration object to modify in-place |
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
| if (typeof WeakMap !== 'function') { | |
| let c = 0; | |
| WeakMap = function() { | |
| let id = typeof Symbol === 'function' ? Symbol() : `__weak$${++c}`; | |
| this.set = (key, val) => { key[id] = val }; | |
| this.get = key => key[id]; | |
| }; | |
| } |
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 xhr2 = false; | |
| try { xhr2 = 'useCredentials' in new XMLHttpRequest; } catch (e) {} | |
| var old = window.XMLHttpRequest; | |
| function XMLHttpRequest() { | |
| if (xhr2) return new old(); | |
| } | |
| XMLHttpRequest.prototype.open = function(method, url, async, user, pass) { | |
| var pageOrigin = location.protocol + ':' + location.host; | |
| var self = this; | |
| function wrap(m) { |
We're getting Constructable Stylesheets. This seems like an intuitive value to obtain when importing CSS from JavaScript, since it's the DOM's representation of a Stylesheet:
import stylesheet from './style.css';
console.log(stylesheet); // CSSStyleSheetNo such system is in place to allow this to work (see [whatwg/loader]), however frontend build tooling has congregated around this approach as a mechanism for bringing CSS assets into the JavaScript module graph. There are many benefits to be obtained from moving CSS into this graph, however the most important is that imported CSS can be attributed to the consuming JS Module. This allows it to be bundled, optimized, and potentially dead-code-eliminated leveraging static analysis performed on the surrounding module graph.
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
| import { Component } from 'preact'; | |
| /** Example: | |
| * componentWillUnmount(){ uncache(this) } | |
| */ | |
| export function uncache(component) { | |
| setTimeout(() => { | |
| component.__b = component.nextBase = null; | |
| }) | |
| } |