-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy path_template.ts
More file actions
49 lines (41 loc) · 1.63 KB
/
Copy path_template.ts
File metadata and controls
49 lines (41 loc) · 1.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import { Plugin } from '../decoders/decorators';
@Plugin({
id: 'new-decoder', // Unique identifier, contains only lowercase letters, numbers, and hyphens
name: 'New Decoder Plugin', // Display name
// // Optional properties
// description: 'Template for new plugins', // Description, shown in decoding result
// author: 'name', // Author name, shown in about page
// link: 'https://example.com', // Link to documentation or homepage, shown in decoding result and encoding result
// encodeKey: 'not-allowed', // Whether the plugin needs a key, can be 'optional', 'required', or 'not-allowed', default is 'not-allowed'
// encoderHelpMessage: '', // Shown in encoding page
// needNetwork: false, // Whether the plugin need external API calls
// hide: false, // Whether to hide this plugin in about page and encoding page
})
export class NewDecoder {
// Analyze the input string and return a confidence score (0-100)
// score is just a very subjective value, you can implement your own logic
checkString(input: string): number {
if (/^[a-zA-Z0-9]+$/.test(input)) {
return 100; // High score for alphanumeric strings
}
return 0; // Low score for other cases
}
// Decode
decode(input: string): string {
return input;
}
// // Optionally implement encoding
// encode(input: string): string {
// return input;
// }
// // All these methods can be async if needed
// async checkString(input: string): Promise<number> {
// return 0;
// }
// async decode(input: string): Promise<string> {
// return input;
// }
// async encode(input: string): Promise<string> {
// return input;
// }
}