Skip to content

Instantly share code, notes, and snippets.

View jridgewell's full-sized avatar
😬

Justin Ridgewell jridgewell

😬
  • New York, NY
  • 05:25 (UTC -04:00)
View GitHub Profile
@jridgewell
jridgewell / flatten.ts
Last active February 12, 2024 05:15
Flatten unobservable AsyncContext.Variable values from all living snapshot chains
/**
* Flattens all "snapshots", removing unobservable nodes so they may free their
* values.
*
* "snapshots" here is all Snapshot instances, every created
* Generator/AsyncGenerator, every stored Job, etc.
*/
function flatten(snapshots: Snapshot[]) {
const current = new Map<Variable>();
const maybe = new Map<LinkNode, LinkNode>();
@jridgewell
jridgewell / index.html
Last active February 9, 2024 09:00
encodeInto with subarrays vs offsets (https://jsbench.github.io/#f7ee4cec9df6f49e404d44ca8d5d3de8) #jsbench #jsperf
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<title>encodeInto with subarrays vs offsets</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/benchmark/1.0.0/benchmark.min.js"></script>
<script src="./suite.js"></script>
</head>
<body>
<h1>Open the console to view the results</h1>
@jridgewell
jridgewell / string-raw.md
Last active February 7, 2024 23:18
String.raw can't represent all strings

For reference, the only things that can't be represented in with String.raw are:

  1. Backslash as last char
    • String.raw`\` is a syntax error, it thinks you're escaping the closing `.
    • String.raw`\\` will output \\, not \.
  2. Interpolation sigils anywhere
    • String.raw`${` is another syntax error, it thinks you're trying to interpolate but you don't have the expression and closing }.
    • String.raw`\${` and String.raw`$\{` both contain a backslash in the output
  3. Backticks anywhere – String.raw``` is another syntax error, that's actually 2 tagged template literals with the second one missing its closing `.
  • String.raw`\`` contains a backslash in the output.
@jridgewell
jridgewell / index.html
Last active December 15, 2023 22:03
Source Map encode with TypedArrays (https://jsbench.github.io/#94c46cc814cab852a54aef37c56d59c4) #jsbench #jsperf
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<title>Source Map encode with TypedArrays</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/benchmark/1.0.0/benchmark.min.js"></script>
<script src="./suite.js"></script>
</head>
<body>
<h1>Open the console to view the results</h1>
@jridgewell
jridgewell / index.html
Last active December 15, 2023 21:43
Source Map encode with TypedArrays #jsbench #jsperf (https://jsbench.github.io/#9cf1800a21b25e7cc0af56649178b174) #jsbench #jsperf
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<title>Source Map encode with TypedArrays #jsbench #jsperf</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/benchmark/1.0.0/benchmark.min.js"></script>
<script src="./suite.js"></script>
</head>
<body>
<h1>Open the console to view the results</h1>
@jridgewell
jridgewell / id.pub
Created June 10, 2023 08:51
ssh key
ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBKuRIXMhWHFjn/F8N+vb7szhzf5vqwVxLCkO3bcLIr8PgbwmUcOfSgH4IJJG3Mi4qgWCVRwKZFnvH5MQ9LHdles= ID@secretive.Dandy.local
@jridgewell
jridgewell / index.html
Created August 11, 2022 23:40
Class Fields vs This Assignment vs Object.defineProperty(this) (https://jsbench.github.io/#659bbd90bd6534565ecd10a4721d1565) #jsbench #jsperf
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<title>Class Fields vs This Assignment vs Object.defineProperty(this)</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/benchmark/1.0.0/benchmark.min.js"></script>
<script src="./suite.js"></script>
</head>
<body>
<h1>Open the console to view the results</h1>
@jridgewell
jridgewell / index.html
Created August 1, 2022 21:29
String.replace vs RegExp.exec loop (https://jsbench.github.io/#0f971d52c8a86eb2c3e5983f5e8ebd0a) #jsbench #jsperf
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<title>String.replace vs RegExp.exec loop</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/benchmark/1.0.0/benchmark.min.js"></script>
<script src="./suite.js"></script>
</head>
<body>
<h1>Open the console to view the results</h1>
@jridgewell
jridgewell / index.html
Created January 25, 2022 09:08
new Array vs Int32Array.subarray (http://jsbench.github.io/#c5efc58acd31b29a5c2a454fd35bff9c) #jsbench #jsperf
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<title>new Array vs Int32Array.subarray</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/benchmark/1.0.0/benchmark.min.js"></script>
<script src="./suite.js"></script>
</head>
<body>
<h1>Open the console to view the results</h1>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<title>defineProperty vs set</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/benchmark/1.0.0/benchmark.min.js"></script>
<script src="./suite.js"></script>
</head>
<body>
<h1>Open the console to view the results</h1>