Skip to content

Commit 8736c88

Browse files
committed
Fix class properties should have defaults as standard js classes would have
Changed PNG consts to static properties
1 parent 2db6f49 commit 8736c88

10 files changed

+107
-100
lines changed

CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ This release notably changes to using N-API. 🎉
2929
* Remove unused private field `backend` in the `Backend` class. (#2229)
3030
* Add Node.js v20 to CI. (#2237)
3131
* Replaced `dtslint` with `tsd` (#2313)
32+
* Changed PNG consts to static properties of Canvas class
3233
### Added
3334
* Added string tags to support class detection
3435
### Fixed
@@ -41,6 +42,7 @@ This release notably changes to using N-API. 🎉
4142
* RGB functions should support real numbers now instead of just integers. (#2339)
4243
* Allow alternate or properly escaped quotes *within* font-family names
4344
* Fix TextMetrics type to include alphabeticBaseline, emHeightAscent, and emHeightDescent properties
45+
* Fix class properties should have defaults as standard js classes (#2390)
4446

4547
2.11.2
4648
==================

index.d.ts

+7-7
Original file line numberDiff line numberDiff line change
@@ -63,19 +63,19 @@ export class Canvas {
6363
readonly stride: number;
6464

6565
/** Constant used in PNG encoding methods. */
66-
readonly PNG_NO_FILTERS: number
66+
static readonly PNG_NO_FILTERS: number
6767
/** Constant used in PNG encoding methods. */
68-
readonly PNG_ALL_FILTERS: number
68+
static readonly PNG_ALL_FILTERS: number
6969
/** Constant used in PNG encoding methods. */
70-
readonly PNG_FILTER_NONE: number
70+
static readonly PNG_FILTER_NONE: number
7171
/** Constant used in PNG encoding methods. */
72-
readonly PNG_FILTER_SUB: number
72+
static readonly PNG_FILTER_SUB: number
7373
/** Constant used in PNG encoding methods. */
74-
readonly PNG_FILTER_UP: number
74+
static readonly PNG_FILTER_UP: number
7575
/** Constant used in PNG encoding methods. */
76-
readonly PNG_FILTER_AVG: number
76+
static readonly PNG_FILTER_AVG: number
7777
/** Constant used in PNG encoding methods. */
78-
readonly PNG_FILTER_PAETH: number
78+
static readonly PNG_FILTER_PAETH: number
7979

8080
constructor(width: number, height: number, type?: 'image'|'pdf'|'svg')
8181

index.test-d.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ expectType<number>(dm.a)
3333

3434
expectType<Buffer>(canv.toBuffer())
3535
expectType<Buffer>(canv.toBuffer('application/pdf'))
36-
canv.toBuffer((err, data) => {}, 'image/png')
36+
canv.toBuffer((err, data) => {}, 'image/png', {filters: Canvas.Canvas.PNG_ALL_FILTERS})
3737
expectAssignable<Readable>(canv.createJPEGStream({ quality: 0.5 }))
3838
expectAssignable<Readable>(canv.createPDFStream({ author: 'octocat' }))
3939
canv.toDataURL()

src/Canvas.cc

+17-17
Original file line numberDiff line numberDiff line change
@@ -50,25 +50,25 @@ Canvas::Initialize(Napi::Env& env, Napi::Object& exports) {
5050

5151
// Constructor
5252
Napi::Function ctor = DefineClass(env, "Canvas", {
53-
InstanceMethod<&Canvas::ToBuffer>("toBuffer"),
54-
InstanceMethod<&Canvas::StreamPNGSync>("streamPNGSync"),
55-
InstanceMethod<&Canvas::StreamPDFSync>("streamPDFSync"),
53+
InstanceMethod<&Canvas::ToBuffer>("toBuffer", napi_default_method),
54+
InstanceMethod<&Canvas::StreamPNGSync>("streamPNGSync", napi_default_method),
55+
InstanceMethod<&Canvas::StreamPDFSync>("streamPDFSync", napi_default_method),
5656
#ifdef HAVE_JPEG
57-
InstanceMethod<&Canvas::StreamJPEGSync>("streamJPEGSync"),
57+
InstanceMethod<&Canvas::StreamJPEGSync>("streamJPEGSync", napi_default_method),
5858
#endif
59-
InstanceAccessor<&Canvas::GetType>("type"),
60-
InstanceAccessor<&Canvas::GetStride>("stride"),
61-
InstanceAccessor<&Canvas::GetWidth, &Canvas::SetWidth>("width"),
62-
InstanceAccessor<&Canvas::GetHeight, &Canvas::SetHeight>("height"),
63-
InstanceValue("PNG_NO_FILTERS", Napi::Number::New(env, PNG_NO_FILTERS)),
64-
InstanceValue("PNG_FILTER_NONE", Napi::Number::New(env, PNG_FILTER_NONE)),
65-
InstanceValue("PNG_FILTER_SUB", Napi::Number::New(env, PNG_FILTER_SUB)),
66-
InstanceValue("PNG_FILTER_UP", Napi::Number::New(env, PNG_FILTER_UP)),
67-
InstanceValue("PNG_FILTER_AVG", Napi::Number::New(env, PNG_FILTER_AVG)),
68-
InstanceValue("PNG_FILTER_PAETH", Napi::Number::New(env, PNG_FILTER_PAETH)),
69-
InstanceValue("PNG_ALL_FILTERS", Napi::Number::New(env, PNG_ALL_FILTERS)),
70-
StaticMethod<&Canvas::RegisterFont>("_registerFont"),
71-
StaticMethod<&Canvas::DeregisterAllFonts>("_deregisterAllFonts")
59+
InstanceAccessor<&Canvas::GetType>("type", napi_default_jsproperty),
60+
InstanceAccessor<&Canvas::GetStride>("stride", napi_default_jsproperty),
61+
InstanceAccessor<&Canvas::GetWidth, &Canvas::SetWidth>("width", napi_default_jsproperty),
62+
InstanceAccessor<&Canvas::GetHeight, &Canvas::SetHeight>("height", napi_default_jsproperty),
63+
StaticValue("PNG_NO_FILTERS", Napi::Number::New(env, PNG_NO_FILTERS), napi_default_jsproperty),
64+
StaticValue("PNG_FILTER_NONE", Napi::Number::New(env, PNG_FILTER_NONE), napi_default_jsproperty),
65+
StaticValue("PNG_FILTER_SUB", Napi::Number::New(env, PNG_FILTER_SUB), napi_default_jsproperty),
66+
StaticValue("PNG_FILTER_UP", Napi::Number::New(env, PNG_FILTER_UP), napi_default_jsproperty),
67+
StaticValue("PNG_FILTER_AVG", Napi::Number::New(env, PNG_FILTER_AVG), napi_default_jsproperty),
68+
StaticValue("PNG_FILTER_PAETH", Napi::Number::New(env, PNG_FILTER_PAETH), napi_default_jsproperty),
69+
StaticValue("PNG_ALL_FILTERS", Napi::Number::New(env, PNG_ALL_FILTERS), napi_default_jsproperty),
70+
StaticMethod<&Canvas::RegisterFont>("_registerFont", napi_default_method),
71+
StaticMethod<&Canvas::DeregisterAllFonts>("_deregisterAllFonts", napi_default_method)
7272
});
7373

7474
data->CanvasCtor = Napi::Persistent(ctor);

src/CanvasGradient.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ Gradient::Initialize(Napi::Env& env, Napi::Object& exports) {
1818
InstanceData* data = env.GetInstanceData<InstanceData>();
1919

2020
Napi::Function ctor = DefineClass(env, "CanvasGradient", {
21-
InstanceMethod<&Gradient::AddColorStop>("addColorStop")
21+
InstanceMethod<&Gradient::AddColorStop>("addColorStop", napi_default_method)
2222
});
2323

2424
exports.Set("CanvasGradient", ctor);

src/CanvasPattern.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ Pattern::Initialize(Napi::Env& env, Napi::Object& exports) {
2121

2222
// Constructor
2323
Napi::Function ctor = DefineClass(env, "CanvasPattern", {
24-
InstanceMethod<&Pattern::setTransform>("setTransform")
24+
InstanceMethod<&Pattern::setTransform>("setTransform", napi_default_method)
2525
});
2626

2727
// Prototype

src/CanvasRenderingContext2d.cc

+63-63
Original file line numberDiff line numberDiff line change
@@ -94,69 +94,69 @@ Context2d::Initialize(Napi::Env& env, Napi::Object& exports) {
9494
InstanceData* data = env.GetInstanceData<InstanceData>();
9595

9696
Napi::Function ctor = DefineClass(env, "CanvasRenderingContext2D", {
97-
InstanceMethod<&Context2d::DrawImage>("drawImage"),
98-
InstanceMethod<&Context2d::PutImageData>("putImageData"),
99-
InstanceMethod<&Context2d::GetImageData>("getImageData"),
100-
InstanceMethod<&Context2d::CreateImageData>("createImageData"),
101-
InstanceMethod<&Context2d::AddPage>("addPage"),
102-
InstanceMethod<&Context2d::Save>("save"),
103-
InstanceMethod<&Context2d::Restore>("restore"),
104-
InstanceMethod<&Context2d::Rotate>("rotate"),
105-
InstanceMethod<&Context2d::Translate>("translate"),
106-
InstanceMethod<&Context2d::Transform>("transform"),
107-
InstanceMethod<&Context2d::GetTransform>("getTransform"),
108-
InstanceMethod<&Context2d::ResetTransform>("resetTransform"),
109-
InstanceMethod<&Context2d::SetTransform>("setTransform"),
110-
InstanceMethod<&Context2d::IsPointInPath>("isPointInPath"),
111-
InstanceMethod<&Context2d::Scale>("scale"),
112-
InstanceMethod<&Context2d::Clip>("clip"),
113-
InstanceMethod<&Context2d::Fill>("fill"),
114-
InstanceMethod<&Context2d::Stroke>("stroke"),
115-
InstanceMethod<&Context2d::FillText>("fillText"),
116-
InstanceMethod<&Context2d::StrokeText>("strokeText"),
117-
InstanceMethod<&Context2d::FillRect>("fillRect"),
118-
InstanceMethod<&Context2d::StrokeRect>("strokeRect"),
119-
InstanceMethod<&Context2d::ClearRect>("clearRect"),
120-
InstanceMethod<&Context2d::Rect>("rect"),
121-
InstanceMethod<&Context2d::RoundRect>("roundRect"),
122-
InstanceMethod<&Context2d::MeasureText>("measureText"),
123-
InstanceMethod<&Context2d::MoveTo>("moveTo"),
124-
InstanceMethod<&Context2d::LineTo>("lineTo"),
125-
InstanceMethod<&Context2d::BezierCurveTo>("bezierCurveTo"),
126-
InstanceMethod<&Context2d::QuadraticCurveTo>("quadraticCurveTo"),
127-
InstanceMethod<&Context2d::BeginPath>("beginPath"),
128-
InstanceMethod<&Context2d::ClosePath>("closePath"),
129-
InstanceMethod<&Context2d::Arc>("arc"),
130-
InstanceMethod<&Context2d::ArcTo>("arcTo"),
131-
InstanceMethod<&Context2d::Ellipse>("ellipse"),
132-
InstanceMethod<&Context2d::SetLineDash>("setLineDash"),
133-
InstanceMethod<&Context2d::GetLineDash>("getLineDash"),
134-
InstanceMethod<&Context2d::CreatePattern>("createPattern"),
135-
InstanceMethod<&Context2d::CreateLinearGradient>("createLinearGradient"),
136-
InstanceMethod<&Context2d::CreateRadialGradient>("createRadialGradient"),
137-
InstanceAccessor<&Context2d::GetFormat>("pixelFormat"),
138-
InstanceAccessor<&Context2d::GetPatternQuality, &Context2d::SetPatternQuality>("patternQuality"),
139-
InstanceAccessor<&Context2d::GetImageSmoothingEnabled, &Context2d::SetImageSmoothingEnabled>("imageSmoothingEnabled"),
140-
InstanceAccessor<&Context2d::GetGlobalCompositeOperation, &Context2d::SetGlobalCompositeOperation>("globalCompositeOperation"),
141-
InstanceAccessor<&Context2d::GetGlobalAlpha, &Context2d::SetGlobalAlpha>("globalAlpha"),
142-
InstanceAccessor<&Context2d::GetShadowColor, &Context2d::SetShadowColor>("shadowColor"),
143-
InstanceAccessor<&Context2d::GetMiterLimit, &Context2d::SetMiterLimit>("miterLimit"),
144-
InstanceAccessor<&Context2d::GetLineWidth, &Context2d::SetLineWidth>("lineWidth"),
145-
InstanceAccessor<&Context2d::GetLineCap, &Context2d::SetLineCap>("lineCap"),
146-
InstanceAccessor<&Context2d::GetLineJoin, &Context2d::SetLineJoin>("lineJoin"),
147-
InstanceAccessor<&Context2d::GetLineDashOffset, &Context2d::SetLineDashOffset>("lineDashOffset"),
148-
InstanceAccessor<&Context2d::GetShadowOffsetX, &Context2d::SetShadowOffsetX>("shadowOffsetX"),
149-
InstanceAccessor<&Context2d::GetShadowOffsetY, &Context2d::SetShadowOffsetY>("shadowOffsetY"),
150-
InstanceAccessor<&Context2d::GetShadowBlur, &Context2d::SetShadowBlur>("shadowBlur"),
151-
InstanceAccessor<&Context2d::GetAntiAlias, &Context2d::SetAntiAlias>("antialias"),
152-
InstanceAccessor<&Context2d::GetTextDrawingMode, &Context2d::SetTextDrawingMode>("textDrawingMode"),
153-
InstanceAccessor<&Context2d::GetQuality, &Context2d::SetQuality>("quality"),
154-
InstanceAccessor<&Context2d::GetCurrentTransform, &Context2d::SetCurrentTransform>("currentTransform"),
155-
InstanceAccessor<&Context2d::GetFillStyle, &Context2d::SetFillStyle>("fillStyle"),
156-
InstanceAccessor<&Context2d::GetStrokeStyle, &Context2d::SetStrokeStyle>("strokeStyle"),
157-
InstanceAccessor<&Context2d::GetFont, &Context2d::SetFont>("font"),
158-
InstanceAccessor<&Context2d::GetTextBaseline, &Context2d::SetTextBaseline>("textBaseline"),
159-
InstanceAccessor<&Context2d::GetTextAlign, &Context2d::SetTextAlign>("textAlign")
97+
InstanceMethod<&Context2d::DrawImage>("drawImage", napi_default_method),
98+
InstanceMethod<&Context2d::PutImageData>("putImageData", napi_default_method),
99+
InstanceMethod<&Context2d::GetImageData>("getImageData", napi_default_method),
100+
InstanceMethod<&Context2d::CreateImageData>("createImageData", napi_default_method),
101+
InstanceMethod<&Context2d::AddPage>("addPage", napi_default_method),
102+
InstanceMethod<&Context2d::Save>("save", napi_default_method),
103+
InstanceMethod<&Context2d::Restore>("restore", napi_default_method),
104+
InstanceMethod<&Context2d::Rotate>("rotate", napi_default_method),
105+
InstanceMethod<&Context2d::Translate>("translate", napi_default_method),
106+
InstanceMethod<&Context2d::Transform>("transform", napi_default_method),
107+
InstanceMethod<&Context2d::GetTransform>("getTransform", napi_default_method),
108+
InstanceMethod<&Context2d::ResetTransform>("resetTransform", napi_default_method),
109+
InstanceMethod<&Context2d::SetTransform>("setTransform", napi_default_method),
110+
InstanceMethod<&Context2d::IsPointInPath>("isPointInPath", napi_default_method),
111+
InstanceMethod<&Context2d::Scale>("scale", napi_default_method),
112+
InstanceMethod<&Context2d::Clip>("clip", napi_default_method),
113+
InstanceMethod<&Context2d::Fill>("fill", napi_default_method),
114+
InstanceMethod<&Context2d::Stroke>("stroke", napi_default_method),
115+
InstanceMethod<&Context2d::FillText>("fillText", napi_default_method),
116+
InstanceMethod<&Context2d::StrokeText>("strokeText", napi_default_method),
117+
InstanceMethod<&Context2d::FillRect>("fillRect", napi_default_method),
118+
InstanceMethod<&Context2d::StrokeRect>("strokeRect", napi_default_method),
119+
InstanceMethod<&Context2d::ClearRect>("clearRect", napi_default_method),
120+
InstanceMethod<&Context2d::Rect>("rect", napi_default_method),
121+
InstanceMethod<&Context2d::RoundRect>("roundRect", napi_default_method),
122+
InstanceMethod<&Context2d::MeasureText>("measureText", napi_default_method),
123+
InstanceMethod<&Context2d::MoveTo>("moveTo", napi_default_method),
124+
InstanceMethod<&Context2d::LineTo>("lineTo", napi_default_method),
125+
InstanceMethod<&Context2d::BezierCurveTo>("bezierCurveTo", napi_default_method),
126+
InstanceMethod<&Context2d::QuadraticCurveTo>("quadraticCurveTo", napi_default_method),
127+
InstanceMethod<&Context2d::BeginPath>("beginPath", napi_default_method),
128+
InstanceMethod<&Context2d::ClosePath>("closePath", napi_default_method),
129+
InstanceMethod<&Context2d::Arc>("arc", napi_default_method),
130+
InstanceMethod<&Context2d::ArcTo>("arcTo", napi_default_method),
131+
InstanceMethod<&Context2d::Ellipse>("ellipse", napi_default_method),
132+
InstanceMethod<&Context2d::SetLineDash>("setLineDash", napi_default_method),
133+
InstanceMethod<&Context2d::GetLineDash>("getLineDash", napi_default_method),
134+
InstanceMethod<&Context2d::CreatePattern>("createPattern", napi_default_method),
135+
InstanceMethod<&Context2d::CreateLinearGradient>("createLinearGradient", napi_default_method),
136+
InstanceMethod<&Context2d::CreateRadialGradient>("createRadialGradient", napi_default_method),
137+
InstanceAccessor<&Context2d::GetFormat>("pixelFormat", napi_default_jsproperty),
138+
InstanceAccessor<&Context2d::GetPatternQuality, &Context2d::SetPatternQuality>("patternQuality", napi_default_jsproperty),
139+
InstanceAccessor<&Context2d::GetImageSmoothingEnabled, &Context2d::SetImageSmoothingEnabled>("imageSmoothingEnabled", napi_default_jsproperty),
140+
InstanceAccessor<&Context2d::GetGlobalCompositeOperation, &Context2d::SetGlobalCompositeOperation>("globalCompositeOperation", napi_default_jsproperty),
141+
InstanceAccessor<&Context2d::GetGlobalAlpha, &Context2d::SetGlobalAlpha>("globalAlpha", napi_default_jsproperty),
142+
InstanceAccessor<&Context2d::GetShadowColor, &Context2d::SetShadowColor>("shadowColor", napi_default_jsproperty),
143+
InstanceAccessor<&Context2d::GetMiterLimit, &Context2d::SetMiterLimit>("miterLimit", napi_default_jsproperty),
144+
InstanceAccessor<&Context2d::GetLineWidth, &Context2d::SetLineWidth>("lineWidth", napi_default_jsproperty),
145+
InstanceAccessor<&Context2d::GetLineCap, &Context2d::SetLineCap>("lineCap", napi_default_jsproperty),
146+
InstanceAccessor<&Context2d::GetLineJoin, &Context2d::SetLineJoin>("lineJoin", napi_default_jsproperty),
147+
InstanceAccessor<&Context2d::GetLineDashOffset, &Context2d::SetLineDashOffset>("lineDashOffset", napi_default_jsproperty),
148+
InstanceAccessor<&Context2d::GetShadowOffsetX, &Context2d::SetShadowOffsetX>("shadowOffsetX", napi_default_jsproperty),
149+
InstanceAccessor<&Context2d::GetShadowOffsetY, &Context2d::SetShadowOffsetY>("shadowOffsetY", napi_default_jsproperty),
150+
InstanceAccessor<&Context2d::GetShadowBlur, &Context2d::SetShadowBlur>("shadowBlur", napi_default_jsproperty),
151+
InstanceAccessor<&Context2d::GetAntiAlias, &Context2d::SetAntiAlias>("antialias", napi_default_jsproperty),
152+
InstanceAccessor<&Context2d::GetTextDrawingMode, &Context2d::SetTextDrawingMode>("textDrawingMode", napi_default_jsproperty),
153+
InstanceAccessor<&Context2d::GetQuality, &Context2d::SetQuality>("quality", napi_default_jsproperty),
154+
InstanceAccessor<&Context2d::GetCurrentTransform, &Context2d::SetCurrentTransform>("currentTransform", napi_default_jsproperty),
155+
InstanceAccessor<&Context2d::GetFillStyle, &Context2d::SetFillStyle>("fillStyle", napi_default_jsproperty),
156+
InstanceAccessor<&Context2d::GetStrokeStyle, &Context2d::SetStrokeStyle>("strokeStyle", napi_default_jsproperty),
157+
InstanceAccessor<&Context2d::GetFont, &Context2d::SetFont>("font", napi_default_jsproperty),
158+
InstanceAccessor<&Context2d::GetTextBaseline, &Context2d::SetTextBaseline>("textBaseline", napi_default_jsproperty),
159+
InstanceAccessor<&Context2d::GetTextAlign, &Context2d::SetTextAlign>("textAlign", napi_default_jsproperty)
160160
});
161161

162162
exports.Set("CanvasRenderingContext2d", ctor);

src/Image.cc

+8-8
Original file line numberDiff line numberDiff line change
@@ -53,14 +53,14 @@ Image::Initialize(Napi::Env& env, Napi::Object& exports) {
5353
Napi::HandleScope scope(env);
5454

5555
Napi::Function ctor = DefineClass(env, "Image", {
56-
InstanceAccessor<&Image::GetComplete>("complete"),
57-
InstanceAccessor<&Image::GetWidth, &Image::SetWidth>("width"),
58-
InstanceAccessor<&Image::GetHeight, &Image::SetHeight>("height"),
59-
InstanceAccessor<&Image::GetNaturalWidth>("naturalWidth"),
60-
InstanceAccessor<&Image::GetNaturalHeight>("naturalHeight"),
61-
InstanceAccessor<&Image::GetDataMode, &Image::SetDataMode>("dataMode"),
62-
StaticValue("MODE_IMAGE", Napi::Number::New(env, DATA_IMAGE)),
63-
StaticValue("MODE_MIME", Napi::Number::New(env, DATA_MIME))
56+
InstanceAccessor<&Image::GetComplete>("complete", napi_default_jsproperty),
57+
InstanceAccessor<&Image::GetWidth, &Image::SetWidth>("width", napi_default_jsproperty),
58+
InstanceAccessor<&Image::GetHeight, &Image::SetHeight>("height", napi_default_jsproperty),
59+
InstanceAccessor<&Image::GetNaturalWidth>("naturalWidth", napi_default_jsproperty),
60+
InstanceAccessor<&Image::GetNaturalHeight>("naturalHeight", napi_default_jsproperty),
61+
InstanceAccessor<&Image::GetDataMode, &Image::SetDataMode>("dataMode", napi_default_jsproperty),
62+
StaticValue("MODE_IMAGE", Napi::Number::New(env, DATA_IMAGE), napi_default_jsproperty),
63+
StaticValue("MODE_MIME", Napi::Number::New(env, DATA_MIME), napi_default_jsproperty)
6464
});
6565

6666
// Used internally in lib/image.js

src/ImageData.cc

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ ImageData::Initialize(Napi::Env& env, Napi::Object& exports) {
1414
InstanceData *data = env.GetInstanceData<InstanceData>();
1515

1616
Napi::Function ctor = DefineClass(env, "ImageData", {
17-
InstanceAccessor<&ImageData::GetWidth>("width"),
18-
InstanceAccessor<&ImageData::GetHeight>("height")
17+
InstanceAccessor<&ImageData::GetWidth>("width", napi_default_jsproperty),
18+
InstanceAccessor<&ImageData::GetHeight>("height", napi_default_jsproperty)
1919
});
2020

2121
exports.Set("ImageData", ctor);

test/canvas.test.js

+5
Original file line numberDiff line numberDiff line change
@@ -694,6 +694,11 @@ describe('Canvas', function () {
694694
assert.equal('PNG', buf.slice(1, 4).toString())
695695
})
696696

697+
it('Canvas#toBuffer("image/png", {filters: PNG_ALL_FILTERS})', function () {
698+
const buf = createCanvas(200, 200).toBuffer('image/png', { filters: Canvas.PNG_ALL_FILTERS })
699+
assert.equal('PNG', buf.slice(1, 4).toString())
700+
})
701+
697702
it('Canvas#toBuffer("image/jpeg")', function () {
698703
const buf = createCanvas(200, 200).toBuffer('image/jpeg')
699704
assert.equal(buf[0], 0xff)

0 commit comments

Comments
 (0)