mirror of
https://github.com/NaN72dev/kunkun-ext-string-utils.git
synced 2025-04-04 10:16:44 +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.ts",
|
||||||
"./src/trim-end.ts",
|
"./src/trim-end.ts",
|
||||||
"./src/trim-start.ts",
|
"./src/trim-start.ts",
|
||||||
|
"./src/random-case.ts",
|
||||||
"./src/uis/truncate.ts",
|
"./src/uis/truncate.ts",
|
||||||
"./src/uis/pad.ts",
|
"./src/uis/pad.ts",
|
||||||
];
|
];
|
||||||
|
@ -56,6 +56,11 @@
|
|||||||
"main": "dist/to-upper.js",
|
"main": "dist/to-upper.js",
|
||||||
"cmds": []
|
"cmds": []
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "Convert clipboard text to RaNDoM caSE",
|
||||||
|
"main": "dist/random-case.js",
|
||||||
|
"cmds": []
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "Trim the clipboard text",
|
"name": "Trim the clipboard text",
|
||||||
"main": "dist/trim.js",
|
"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