Skip to content

Commit

Permalink
fix: add Inflator type
Browse files Browse the repository at this point in the history
  • Loading branch information
MariusVatasoiu committed Dec 8, 2020
1 parent f7cf40b commit 3be9d74
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
7 changes: 4 additions & 3 deletions lib/decoders/fast-png/PNGDecoder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@ import { IOBuffer } from './iobuffer/IOBuffer.ts';
import { Inflate as Inflator } from './pako/index.js';

import { pngSignature, crc } from './common.ts';
import {
import type {
IDecodedPNG,
DecoderInputType,
IPNGDecoderOptions,
PNGDataArray,
IndexedColors,
BitDepth,
IInflator
} from './types.ts';
import {
ColorType,
Expand All @@ -27,7 +28,7 @@ const osIsLittleEndian = uint8[0] === 0xff;

export default class PNGDecoder extends IOBuffer {
private _checkCrc: boolean;
private _inflator: typeof Inflator;
private _inflator: IInflator;
private _png: IDecodedPNG;
private _end: boolean;
private _hasPalette: boolean;
Expand All @@ -41,7 +42,7 @@ export default class PNGDecoder extends IOBuffer {
super(data);
const { checkCrc = false } = options;
this._checkCrc = checkCrc;
this._inflator = new Inflator();
this._inflator = <IInflator>new Inflator();
this._png = {
width: -1,
height: -1,
Expand Down
2 changes: 1 addition & 1 deletion lib/decoders/fast-png/PNGEncoder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ export default class PNGEncoder extends IOBuffer {
}
}
const buffer = newData.toArray();
const compressed = deflate(buffer, this._zlibOptions);
const compressed = <Uint8Array>deflate(buffer, this._zlibOptions);
this.encodeIDAT(compressed);
}

Expand Down
9 changes: 9 additions & 0 deletions lib/decoders/fast-png/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,3 +79,12 @@ export interface IPNGEncoderOptions {
}

export type IndexedColors = number[][];

export interface IInflator {
result: Uint8Array | Array<any> | string;
err: number;
msg: string;
push: Function;
onData: Function;
onEnd: Function;
}

0 comments on commit 3be9d74

Please sign in to comment.