feat(random): add random command

This commit is contained in:
Nan72 2025-02-17 09:29:18 +07:00
parent 9100715bde
commit 613b99b6e3
No known key found for this signature in database
3 changed files with 20 additions and 1 deletions

View File

@ -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",
];

View File

@ -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",

14
src/random-case.ts Normal file
View File

@ -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())