mirror of
https://github.com/NaN72dev/kunkun-ext-string-utils.git
synced 2025-04-03 17:56:45 +00:00
feat(random): add random command
This commit is contained in:
parent
9100715bde
commit
613b99b6e3
2
build.ts
2
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",
|
||||
];
|
||||
|
@ -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
14
src/random-case.ts
Normal 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())
|
Loading…
x
Reference in New Issue
Block a user