Skip to content

Instantly share code, notes, and snippets.

@ryanbaer
ryanbaer / numeric.ts
Created October 7, 2023 07:44
safeParse and ensureParse for numeric strings in Typescript
type Result<T, E extends Error = Error> = {
success: true,
data: T,
} | {
success: false,
error: E,
};
class NumericError extends Error {
cause: { input: string };
/*
# 🗡️ Strip Query Params
- ⌨️ Prompts the user for a URL
- 🗡️ Cuts off all query params
- 🛡️ Maintains essential query params (e.g., `youtube.com/watch?v=[videoId]`)
- 📋 Automatically copies the updated URL to the clipboard.
Useful for removing tracking / other information from URLs before sharing with others.

Keybase proof

I hereby claim:

  • I am ryanbaer on github.
  • I am ryanbaer (https://keybase.io/ryanbaer) on keybase.
  • I have a public key ASBShL6ThgW1FkDvOFH-jHHH7UnHJCaw1umJ2YHiOROyFAo

To claim this, I am signing this object: