Instead of checks like:
if (value === null) {
throw new Error("missing value")
}
doSomethingThatNeedsValue(value)| let fs = require("fs"); | |
| // TODO: Make it configurable based on publicPath and assetsBuildDirectory | |
| function inlineCssMiddleware() { | |
| /** | |
| * | |
| * @param {import("express").Request} req | |
| * @param {import("express").Response} res | |
| * @param {import("express").NextFunction} next | |
| */ |
| /* Using a JavaScript proxy for a super low code REST client */ | |
| // via https://dev.to/dipsaus9/javascript-lets-create-aproxy-19hg | |
| // also see https://towardsdatascience.com/why-to-use-javascript-proxy-5cdc69d943e3 | |
| // also see https://github.com/fastify/manifetch | |
| // also see https://github.com/flash-oss/allserver | |
| // and https://gist.github.com/v1vendi/75d5e5dad7a2d1ef3fcb48234e4528cb | |
| const createApi = (url) => { | |
| return new Proxy({}, { | |
| get(target, key) { |
| ":" //#;exec /usr/bin/env node --input-type=module - $@<$0 | |
| import process from 'process' | |
| const { argv } = process | |
| console.log(argv) |
| <link rel="shortcut icon" width=32px> | |
| <canvas style="display: none" id="loader" width="16" height="16"></canvas> | |
| <script> | |
| class Loader { | |
| constructor(link, canvas) { | |
| this.link = link; | |
| this.canvas = canvas; | |
| this.context = canvas.getContext('2d'); | |
| this.context.lineWidth = 2; |
| export default class MailgunClient { | |
| apiKey: string; | |
| domain: string; | |
| defaults?: { | |
| from?: string; | |
| subject?: string; | |
| }; | |
| constructor(apiKey: string, domain: string, defaults?: Record<string, any>) { | |
| this.apiKey = apiKey; |
| /** | |
| * Test if a string is a valid email address | |
| * using the constraint validation API, rather | |
| * than unwieldy regular expressions | |
| * | |
| * @param {string} value | |
| * @returns {boolean} | |
| */ | |
| const validateEmail = value => Object.assign( | |
| document.createElement('input'), |
| function setFocusIfFocusable(node) { | |
| if (node.nodeType !== Node.ELEMENT_NODE) { | |
| // Text and comment nodes aren't focusable. | |
| return false; | |
| } | |
| if (node.disabled === true) { | |
| // Disabled elements can't be focused. | |
| return false; | |
| } |
| export const h=(t,p,...c)=>({t,p,c,k:p&&p.key}) | |
| export const render=(e,d,t=d.t||(d.t={}),p,r,c,m,y)=> | |
| // arrays | |
| e.map?e.map((e,p)=>render(e,d,t.o&&t.o[p])): | |
| // components | |
| e.t.call?(e.i=render((render.c=e).t(Object.assign({children:e.c},e.p),e.s=t.s||{},t=> | |
| render(Object.assign(e.s,t)&&e,d,e)),t.i||d,t&&t.i||{}),d.t=t=e):( | |
| // create notes | |
| m=t.d||(e.t?document.createElement(e.t):new Text(e.p)), | |
| // diff props |
| //######################################################################################## | |
| var WebCom = {}; | |
| //////////////////////////////////////////////////////// | |
| // Initialize Web Component and Create an Instance | |
| //////////////////////////////////////////////////////// | |
| // Need when creating an instance of a Web Component while using the polyfill | |
| WebCom.instance = function( fn, self ){ return (( Object.getPrototypeOf )? Object.getPrototypeOf( fn ) : fn.__proto__).call( self ); } |