Instead of checks like:
if (value === null) {
throw new Error("missing value")
}
doSomethingThatNeedsValue(value)
// Step 1: Define the Branded Type | |
type LowercaseString = string & { __brand: "LowercaseString" }; | |
// Step 2: Type Guard Function | |
function toLowercaseString(s: string): LowercaseString { | |
return s.toLowerCase() as LowercaseString; | |
} | |
// Step 3: Override Type Definitions | |
type RemoveToLowerCase<T> = Omit<T, "toLowerCase">; |
<!DOCTYPE html> | |
<head> | |
<meta name="view-transition" content="same-origin"> | |
</head> | |
<body> | |
<style> | |
h1 { | |
view-transition-name: hero; | |
} |
/* https://go.tacodewolff.nl/minify */ | |
enScroll=!1,enFdl=!1,extCurrent=void 0,filename=void 0,targetText=void 0,splitOrigin=void 0;const lStor=localStorage,sStor=sessionStorage,doc=document,docEl=document.documentElement,docBody=document.body,docLoc=document.location,w=window,s=screen,nav=navigator||{},extensions=["pdf","xls","xlsx","doc","docx","txt","rtf","csv","exe","key","pps","ppt","pptx","7z","pkg","rar","gz","zip","avi","mov","mp4","mpe","mpeg","wmv","mid","midi","mp3","wav","wma"];function a(e,t,n,o){const j="G-XXXXXXXXXX",r=()=>Math.floor(Math.random()*1e9)+1,c=()=>Math.floor(Date.now()/1e3),F=()=>(sStor._p||(sStor._p=r()),sStor._p),E=()=>r()+"."+c(),_=()=>(lStor.cid_v4||(lStor.cid_v4=E()),lStor.cid_v4),m=lStor.getItem("cid_v4"),v=()=>m?void 0:enScroll==!0?void 0:"1",p=()=>(sStor.sid||(sStor.sid=c()),sStor.sid),O=()=>{if(!sStor._ss)return sStor._ss="1",sStor._ss;if(sStor.getItem("_ss")=="1")return void 0},a="1",g=()=>{if(sStor.sct)if(enScroll==!0)return sStor.sct;else x=+sStor.getItem("sct")+ +a,sSto |
// | |
// See: https://kentcdodds.com/blog/profile-a-react-app-for-performance#build-and-measure-the-production-app | |
// See: https://nextjs.org/docs/api-reference/next.config.js/custom-webpack-config | |
const TerserPlugin = require('next/dist/compiled/terser-webpack-plugin'); | |
module.exports = { | |
webpack: (config, options) => { | |
// | |
// Use profiler-enabled React builds |
Profile | download (kb/s) | upload (kb/s) | latency (ms) |
---|---|---|---|
Native | 0 | 0 | 0 |
GPRS | 50 | 20 | 500 |
56K Dial-up | 50 | 30 | 120 |
Mobile EDGE | 240 | 200 | 840 |
2G Regular | 250 | 50 | 300 |
2G Good | 450 | 150 | 150 |
3G Slow | 780 | 330 | 200 |
<?php | |
require_once __DIR__.'/relative/path/to/PrettierPHPFixer/File'; | |
return PhpCsFixer\Config::create() | |
->registerCustomFixers([ | |
(new PrettierPHPFixer()), | |
]) | |
->setRules([ | |
'Prettier/php' => true, |
React recently introduced an experimental profiler API. This page gives instructions on how to use this API in a production release of your app.
Table of Contents
React DOM automatically supports profiling in development mode for v16.5+, but since profiling adds some small additional overhead it is opt-in for production mode. This gist explains how to opt-in.
/** | |
* Copyright 2018 Google Inc. All Rights Reserved. | |
* Licensed under the Apache License, Version 2.0 (the "License"); | |
* you may not use this file except in compliance with the License. | |
* You may obtain a copy of the License at | |
* http://www.apache.org/licenses/LICENSE-2.0 | |
* Unless required by applicable law or agreed to in writing, software | |
* distributed under the License is distributed on an "AS IS" BASIS, | |
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
* See the License for the specific language governing permissions and |