Skip to content

Commit 9a5712d

Browse files
committed
fix: update pako to v2
1 parent 25fcf4e commit 9a5712d

File tree

8 files changed

+72
-52
lines changed

8 files changed

+72
-52
lines changed

‎.github/workflows/nodejs.yml

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: Node.js CI
2+
3+
on:
4+
push:
5+
branches: master
6+
pull_request:
7+
8+
jobs:
9+
lint:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v2
13+
- uses: actions/setup-node@v2-beta
14+
with:
15+
node-version: 14.x
16+
- name: Install dependencies
17+
run: npm install
18+
- name: Run ESLint
19+
run: npm run eslint
20+
- name: Check types
21+
run: npm run check-types
22+
test:
23+
runs-on: ubuntu-latest
24+
strategy:
25+
matrix:
26+
node-version: [10.x, 12.x, 14.x, 15.x]
27+
steps:
28+
- uses: actions/checkout@v2
29+
- name: Use Node.js ${{ matrix.node-version }}
30+
uses: actions/setup-node@v2-beta
31+
with:
32+
node-version: ${{ matrix.node-version }}
33+
- name: Install dependencies
34+
run: npm install
35+
- name: Run tests
36+
run: npm run test-coverage
37+
- name: Send coverage report to Codecov
38+
uses: codecov/codecov-action@v1

‎.travis.yml

-6
This file was deleted.

‎README.md

+6-9
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
# fast-png
22

33
[![NPM version][npm-image]][npm-url]
4-
[![build status][travis-image]][travis-url]
5-
[![Test coverage][codecov-image]][codecov-url]
4+
[![build status][ci-image]][ci-url]
65
[![npm download][download-image]][download-url]
76

87
PNG image decoder and encoder written entirely in JavaScript.
@@ -15,18 +14,18 @@ PNG image decoder and encoder written entirely in JavaScript.
1514

1615
### `decode(png[, options])`
1716

18-
**Arguments**
17+
#### Arguments
1918

2019
- `png` - A TypedArray or Buffer that contains the PNG data.
2120
- `options` - An object of options
2221

23-
**Options**
22+
#### Options
2423

2524
- `checkCrc` - If set to `true`, the CRC will be checked for each chunk and an error will be thrown in case it's wrong (default: false).
2625

2726
### `encode(image)`
2827

29-
**Arguments**
28+
#### Arguments
3029

3130
- `png` - An object representing the image. You can pass an ImageData from the Canvas API or an object with the following properties:
3231
- `width` - The width of the image
@@ -45,9 +44,7 @@ Spec can be found at: https://www.w3.org/TR/PNG/
4544

4645
[npm-image]: https://img.shields.io/npm/v/fast-png.svg?style=flat-square
4746
[npm-url]: https://www.npmjs.com/package/fast-png
48-
[travis-image]: https://img.shields.io/travis/image-js/fast-png/master.svg?style=flat-square
49-
[travis-url]: https://travis-ci.org/image-js/fast-png
50-
[codecov-image]: https://img.shields.io/codecov/c/github/image-js/fast-png.svg?style=flat-square
51-
[codecov-url]: https://codecov.io/gh/image-js/fast-png
47+
[ci-image]: https://github.com/image-js/fast-png/workflows/Node.js%20CI/badge.svg?branch=master
48+
[ci-url]: https://github.com/image-js/fast-png/actions?query=workflow%3A%22Node.js+CI%22
5249
[download-image]: https://img.shields.io/npm/dm/fast-png.svg?style=flat-square
5350
[download-url]: https://www.npmjs.com/package/fast-png

‎package.json

+13-18
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,12 @@
2020
"lib-esm"
2121
],
2222
"scripts": {
23+
"check-types": "tsc --noEmit",
2324
"clean": "rimraf lib lib-esm",
2425
"eslint": "eslint src --ext ts",
2526
"eslint-fix": "npm run eslint -- --fix",
2627
"prepublishOnly": "npm run tsc",
27-
"test": "npm run test-coverage && npm run eslint",
28+
"test": "npm run test-coverage && npm run eslint && npm run check-types",
2829
"test-coverage": "npm run test-only -- --coverage",
2930
"test-only": "jest",
3031
"tsc": "npm run clean && npm run tsc-cjs && npm run tsc-esm",
@@ -44,27 +45,21 @@
4445
"testEnvironment": "node"
4546
},
4647
"devDependencies": {
47-
"@types/jest": "^24.0.22",
48-
"@types/node": "^12.12.7",
49-
"@typescript-eslint/eslint-plugin": "^2.7.0",
50-
"@typescript-eslint/parser": "^2.7.0",
51-
"eslint": "^6.6.0",
52-
"eslint-config-cheminfo": "^2.0.4",
53-
"eslint-config-cheminfo-typescript": "^4.1.2",
54-
"eslint-plugin-import": "^2.18.2",
55-
"eslint-plugin-jest": "^23.0.3",
56-
"eslint-plugin-prettier": "^3.1.1",
57-
"jest": "^24.9.0",
58-
"pngjs": "^3.4.0",
59-
"prettier": "^1.19.1",
60-
"rimraf": "^3.0.0",
61-
"ts-jest": "^24.1.0",
62-
"typescript": "^3.7.2"
48+
"@types/jest": "^26.0.19",
49+
"@types/node": "^14.14.13",
50+
"eslint": "^7.15.0",
51+
"eslint-config-cheminfo-typescript": "^8.0.5",
52+
"jest": "^26.6.3",
53+
"pngjs": "^6.0.0",
54+
"prettier": "^2.2.1",
55+
"rimraf": "^3.0.2",
56+
"ts-jest": "^26.4.4",
57+
"typescript": "^4.1.3"
6358
},
6459
"dependencies": {
6560
"@types/pako": "^1.0.1",
6661
"iobuffer": "^5.0.2",
67-
"pako": "^1.0.10"
62+
"pako": "^2.0.2"
6863
},
6964
"prettier": {
7065
"arrowParens": "always",

‎src/PNGDecoder.ts

+6-8
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@ import { IOBuffer } from 'iobuffer';
22
import { Inflate as Inflator } from 'pako';
33

44
import { pngSignature, crc } from './common';
5+
import {
6+
ColorType,
7+
CompressionMethod,
8+
FilterMethod,
9+
InterlaceMethod,
10+
} from './internalTypes';
511
import {
612
IDecodedPNG,
713
DecoderInputType,
@@ -10,12 +16,6 @@ import {
1016
IndexedColors,
1117
BitDepth,
1218
} from './types';
13-
import {
14-
ColorType,
15-
CompressionMethod,
16-
FilterMethod,
17-
InterlaceMethod,
18-
} from './internalTypes';
1919

2020
const empty = new Uint8Array(0);
2121
const NULL = '\0';
@@ -200,7 +200,6 @@ export default class PNGDecoder extends IOBuffer {
200200
private decodeIDAT(length: number): void {
201201
this._inflator.push(
202202
new Uint8Array(this.buffer, this.offset + this.byteOffset, length),
203-
false,
204203
);
205204
this.skip(length);
206205
}
@@ -244,7 +243,6 @@ export default class PNGDecoder extends IOBuffer {
244243
}
245244

246245
private decodeImage(): void {
247-
this._inflator.push(empty, true);
248246
if (this._inflator.err) {
249247
throw new Error(
250248
`Error while decompressing the data: ${this._inflator.err}`,

‎src/PNGEncoder.ts

+7-7
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@ import { IOBuffer } from 'iobuffer';
22
import { deflate } from 'pako';
33

44
import { pngSignature, crc } from './common';
5+
import {
6+
ColorType,
7+
CompressionMethod,
8+
FilterMethod,
9+
InterlaceMethod,
10+
} from './internalTypes';
511
import {
612
DeflateFunctionOptions,
713
IPNGEncoderOptions,
@@ -10,12 +16,6 @@ import {
1016
PNGDataArray,
1117
BitDepth,
1218
} from './types';
13-
import {
14-
ColorType,
15-
CompressionMethod,
16-
FilterMethod,
17-
InterlaceMethod,
18-
} from './internalTypes';
1919

2020
const defaultZlibOptions: DeflateFunctionOptions = {
2121
level: 3,
@@ -172,7 +172,7 @@ function getColorType(
172172
returnValue.colorType = ColorType.GREYSCALE_ALPHA;
173173
break;
174174
default:
175-
throw new Error(`unsupported number of channels: ${channels}`);
175+
throw new Error('unsupported number of channels');
176176
}
177177
return returnValue;
178178
}

‎src/__tests__/decode.test.ts

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
1-
/* eslint jest/expect-expect: ["error", { "assertFunctionNames": ["expect", "loadAndDecode"] }] */
2-
3-
import { join } from 'path';
41
import { readFileSync } from 'fs';
2+
import { join } from 'path';
53

64
import { decode, IPNGDecoderOptions, IDecodedPNG } from '../index';
75

‎src/types.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { DeflateFunctionOptions } from 'pako';
21
import { IOBuffer } from 'iobuffer';
2+
import { DeflateFunctionOptions } from 'pako';
33

44
export { DeflateFunctionOptions };
55

0 commit comments

Comments
 (0)