diff --git a/build.ts b/build.ts index 94c19a9..d87bfe7 100644 --- a/build.ts +++ b/build.ts @@ -14,7 +14,7 @@ const entrypoints = [ "./src/trim.ts", "./src/trim-end.ts", "./src/trim-start.ts", - + "./src/random-case.ts", "./src/uis/truncate.ts", "./src/uis/pad.ts", ]; diff --git a/package.json b/package.json index 31a0e9b..5bf9e96 100644 --- a/package.json +++ b/package.json @@ -56,6 +56,11 @@ "main": "dist/to-upper.js", "cmds": [] }, + { + "name": "Convert clipboard text to RaNDoM caSE", + "main": "dist/random-case.js", + "cmds": [] + }, { "name": "Trim the clipboard text", "main": "dist/trim.js", diff --git a/src/random-case.ts b/src/random-case.ts new file mode 100644 index 0000000..b3e1f75 --- /dev/null +++ b/src/random-case.ts @@ -0,0 +1,14 @@ +import {expose} from "@kksh/api/headless"; +import {BaseExt} from "./base"; + +class RandomCaseExt extends BaseExt { + constructor() { + super(string => { + return string.split("").map(char => { + return Math.random() > 0.5 ? char.toUpperCase() : char.toLowerCase(); + }).join(""); + }); + } +} + +expose(new RandomCaseExt())