Skip to content

Instantly share code, notes, and snippets.

@treuks
Last active December 12, 2023 12:54
Show Gist options
  • Save treuks/59d9259874da452f005993ab9fd8f161 to your computer and use it in GitHub Desktop.
Save treuks/59d9259874da452f005993ab9fd8f161 to your computer and use it in GitHub Desktop.
prepend.js
class InvalidString extends Error {
constructor(message, cause) {
super(message);
this.cause = cause;
this.name = "InvalidString"
}
}
const main = () => {
const text = args.join(" ");
if (!text.includes("<~~")) {
throw new InvalidString("The message supplied to prepend does not contain <~~");
}
const splitText = text.split("<~~");
return `${splitText[1]}${splitText[0]}`;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment