Skip to content

Commit 6a2a87a

Browse files
neko782ren-lv
andauthored
Move formats into declaration instead of init (#598)
Co-authored-by: ren.lv <garders.renars@gmail.com>
1 parent 92ae5ac commit 6a2a87a

1 file changed

Lines changed: 20 additions & 21 deletions

File tree

README.md

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -98,30 +98,29 @@ import CommonFormats, { Category } from "src/CommonFormats.ts";
9898
class dummyHandler implements FormatHandler {
9999

100100
public name: string = "dummy";
101-
public supportedFormats?: FileFormat[];
101+
public supportedFormats: FileFormat[] = [
102+
// Example PNG format, with both input and output disabled
103+
CommonFormats.PNG.builder("png")
104+
.markLossless()
105+
.allowFrom(false)
106+
.allowTo(false),
107+
108+
// Alternatively, if you need a custom format, define it like so:
109+
{
110+
name: "CompuServe Graphics Interchange Format (GIF)",
111+
format: "gif",
112+
extension: "gif",
113+
mime: "image/gif",
114+
from: false,
115+
to: false,
116+
internal: "gif",
117+
category: [Category.IMAGE, CATEGORY.VIDEO], // See src/CommonFormats.ts for valid categories
118+
lossless: false
119+
},
120+
];
102121
public ready: boolean = false;
103122

104123
async init () {
105-
this.supportedFormats = [
106-
// Example PNG format, with both input and output disabled
107-
CommonFormats.PNG.builder("png")
108-
.markLossless()
109-
.allowFrom(false)
110-
.allowTo(false),
111-
112-
// Alternatively, if you need a custom format, define it like so:
113-
{
114-
name: "CompuServe Graphics Interchange Format (GIF)",
115-
format: "gif",
116-
extension: "gif",
117-
mime: "image/gif",
118-
from: false,
119-
to: false,
120-
internal: "gif",
121-
category: [Category.IMAGE, CATEGORY.VIDEO], // See src/CommonFormats.ts for valid categories
122-
lossless: false
123-
},
124-
];
125124
this.ready = true;
126125
}
127126

0 commit comments

Comments
 (0)