Skip to content

Commit 4d830b9

Browse files
authored
refactor!: migrate to ESM (#4)
1 parent 7f87885 commit 4d830b9

15 files changed

+123
-129
lines changed

.eslintrc.yml

Lines changed: 0 additions & 1 deletion
This file was deleted.

.github/workflows/nodejs.yml

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
name: Node.js CI
2-
3-
on:
4-
push:
5-
branches:
6-
- main
7-
pull_request:
8-
9-
jobs:
10-
nodejs:
11-
# Documentation: https://github.com/zakodium/workflows#nodejs-ci
12-
uses: zakodium/workflows/.github/workflows/nodejs.yml@nodejs-v1
13-
with:
14-
lint-check-types: true
1+
name: Node.js CI
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
9+
jobs:
10+
nodejs:
11+
# Documentation: https://github.com/zakodium/workflows#nodejs-ci
12+
uses: zakodium/workflows/.github/workflows/nodejs.yml@nodejs-v1
13+
with:
14+
lint-check-types: true

.github/workflows/release.yml

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
1-
name: Release
2-
3-
on:
4-
push:
5-
branches:
6-
- main
7-
8-
jobs:
9-
release:
10-
# Documentation: https://github.com/zakodium/workflows#release
11-
uses: zakodium/workflows/.github/workflows/release.yml@release-v1
12-
with:
13-
npm: true
14-
secrets:
15-
github-token: ${{ secrets.BOT_TOKEN }}
16-
npm-token: ${{ secrets.NPM_BOT_TOKEN }}
1+
name: Release
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
jobs:
9+
release:
10+
# Documentation: https://github.com/zakodium/workflows#release
11+
uses: zakodium/workflows/.github/workflows/release.yml@release-v1
12+
with:
13+
npm: true
14+
secrets:
15+
github-token: ${{ secrets.BOT_TOKEN }}
16+
npm-token: ${{ secrets.NPM_BOT_TOKEN }}

.github/workflows/typedoc.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
name: TypeDoc
2+
3+
on:
4+
workflow_dispatch:
5+
release:
6+
types: [published]
7+
8+
jobs:
9+
typedoc:
10+
# Documentation: https://github.com/zakodium/workflows#typedoc
11+
uses: zakodium/workflows/.github/workflows/typedoc.yml@typedoc-v1
12+
with:
13+
entry: 'src/index.ts'
14+
secrets:
15+
github-token: ${{ secrets.BOT_TOKEN }}

.prettierignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
CHANGELOG.md

.prettierrc.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"arrowParens": "always",
3+
"semi": true,
4+
"singleQuote": true,
5+
"tabWidth": 2,
6+
"trailingComma": "all"
7+
}

README.md

Lines changed: 13 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,20 @@
1-
# fast-jpeg
2-
3-
4-
5-
JPEG image decoder written entirely in JavaScript.
6-
71
<h3 align="center">
8-
92
<a href="https://www.zakodium.com">
103
<img src="https://www.zakodium.com/brand/zakodium-logo-white.svg" width="50" alt="Zakodium logo" />
114
</a>
12-
135
<p>
146
Maintained by <a href="https://www.zakodium.com">Zakodium</a>
157
</p>
16-
17-
[![NPM version][npm-image]][npm-url]
18-
[![npm download][download-image]][download-url]
19-
208
</h3>
219

10+
# fast-jpeg
2211

12+
[![NPM version](https://img.shields.io/npm/v/fast-jpeg.svg)](https://www.npmjs.com/package/fast-jpeg)
13+
[![npm download](https://img.shields.io/npm/dm/fast-jpeg.svg)](https://www.npmjs.com/package/fast-jpeg)
14+
[![test coverage](https://img.shields.io/codecov/c/github/image-js/fast-jpeg.svg)](https://codecov.io/gh/image-js/fast-jpeg)
15+
[![license](https://img.shields.io/npm/l/fast-jpeg.svg)](https://github.com/image-js/fast-jpeg/blob/main/LICENSE)
16+
17+
JPEG image decoder written entirely in JavaScript.
2318

2419
## Installation
2520

@@ -29,16 +24,13 @@ $ npm install fast-jpeg
2924

3025
## API
3126

32-
Currently this library is not able to decode the image data.
33-
It can read EXIF information only.
27+
Currently, this library is not able to decode the image data.
28+
It can only read EXIF information.
3429

35-
### jpeg.decode(data)
30+
### [Complete API documentation](https://image-js.github.io/fast-jpeg/)
3631

37-
## License
32+
### `jpeg.decode(data)`
3833

39-
[MIT](./LICENSE)
34+
## License
4035

41-
[npm-image]: https://img.shields.io/npm/v/fast-jpeg.svg?style=flat-square
42-
[npm-url]: https://www.npmjs.com/package/fast-jpeg
43-
[download-image]: https://img.shields.io/npm/dm/fast-jpeg.svg?style=flat-square
44-
[download-url]: https://www.npmjs.com/package/fast-jpeg
36+
[MIT](./LICENSE)

eslint.config.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import { defineConfig, globalIgnores } from 'eslint/config';
2+
import base from 'eslint-config-cheminfo-typescript/base';
3+
import unicorn from 'eslint-config-cheminfo-typescript/unicorn';
4+
5+
export default defineConfig(globalIgnores(['coverage', 'lib']), base, unicorn);

package.json

Lines changed: 33 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,63 +1,50 @@
11
{
22
"name": "fast-jpeg",
33
"version": "2.0.1",
4+
"license": "MIT",
45
"description": "JPEG image decoder written entirely in JavaScript",
5-
"main": "lib/index.js",
6-
"module": "lib-esm/index.js",
7-
"types": "lib/index.d.ts",
6+
"author": "Michaël Zasso",
7+
"keywords": [],
8+
"type": "module",
9+
"exports": "./lib/index.js",
810
"files": [
9-
"src",
10-
"lib-esm",
11-
"lib"
11+
"lib",
12+
"src"
1213
],
1314
"scripts": {
1415
"check-types": "tsc --noEmit",
15-
"clean": "rimraf lib lib-esm",
16-
"eslint": "eslint src",
17-
"eslint-fix": "npm run eslint -- --fix",
16+
"clean": "rimraf coverage lib",
17+
"eslint": "eslint .",
18+
"eslint-fix": "eslint . --fix",
1819
"prepack": "npm run tsc",
19-
"prettier": "prettier --check src",
20-
"prettier-write": "prettier --write src",
21-
"test": "npm run test-only && npm run eslint && npm run prettier && npm run check-types",
22-
"test-only": "jest --coverage",
23-
"tsc": "npm run clean && npm run tsc-cjs && npm run tsc-esm",
24-
"tsc-cjs": "tsc --project tsconfig.cjs.json",
25-
"tsc-esm": "tsc --project tsconfig.esm.json"
20+
"prettier": "prettier --check .",
21+
"prettier-write": "prettier --write .",
22+
"test": "npm run test-only && npm run check-types && npm run eslint && npm run prettier",
23+
"test-only": "vitest run --coverage",
24+
"tsc": "npm run clean && npm run tsc-build",
25+
"tsc-build": "tsc --project tsconfig.build.json"
26+
},
27+
"dependencies": {
28+
"iobuffer": "^6.0.0",
29+
"tiff": "^7.0.0"
30+
},
31+
"devDependencies": {
32+
"@types/node": "^24.0.1",
33+
"@vitest/coverage-v8": "^3.2.3",
34+
"@zakodium/tsconfig": "^1.0.1",
35+
"eslint": "^9.29.0",
36+
"eslint-config-cheminfo-typescript": "^18.0.1",
37+
"prettier": "^3.5.3",
38+
"rimraf": "^6.0.1",
39+
"typescript": "^5.8.3",
40+
"vitest": "^3.2.3"
2641
},
2742
"repository": {
2843
"type": "git",
29-
"url": "git+https://github.com/image-js/jpeg-js.git"
44+
"url": "git+https://github.com/image-js/fast-jpeg.git"
3045
},
31-
"keywords": [],
32-
"author": "Michaël Zasso",
33-
"license": "MIT",
3446
"bugs": {
3547
"url": "https://github.com/image-js/fast-jpeg/issues"
3648
},
37-
"homepage": "https://github.com/image-js/fast-jpeg#readme",
38-
"dependencies": {
39-
"iobuffer": "^5.3.2",
40-
"tiff": "^6.0.0"
41-
},
42-
"devDependencies": {
43-
"@types/jest": "^29.5.12",
44-
"eslint": "^8.41.0",
45-
"eslint-config-cheminfo-typescript": "^12.3.0",
46-
"jest": "^29.7.0",
47-
"prettier": "^3.2.5",
48-
"rimraf": "^5.0.5",
49-
"ts-jest": "^29.1.2",
50-
"typescript": "^5.4.5"
51-
},
52-
"prettier": {
53-
"arrowParens": "always",
54-
"semi": true,
55-
"singleQuote": true,
56-
"tabWidth": 2,
57-
"trailingComma": "all"
58-
},
59-
"jest": {
60-
"preset": "ts-jest",
61-
"testEnvironment": "node"
62-
}
49+
"homepage": "https://image-js.github.io/fast-jpeg/"
6350
}

src/__tests__/decode.test.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,21 @@
11
import { readFileSync } from 'node:fs';
22
import { join } from 'node:path';
33

4-
import { decode } from '../decode';
4+
import { expect, test } from 'vitest';
5+
6+
import { decode } from '../index.ts';
57

68
function readImage(file: string): Buffer {
79
return readFileSync(join(__dirname, './img', file));
810
}
911

1012
test('should extract exif', () => {
1113
const result = decode(readImage('sample.jpg'));
12-
expect(result.exif).toBeDefined();
1314

1415
const { exif } = result;
15-
expect(exif?.[0].fields.size).toBe(12);
16-
expect(exif?.[0].fields.get(271)).toBe('SONY');
17-
expect(exif?.[0].fields.get(272).trimEnd()).toBe('DSC-HX9V');
18-
expect(exif?.[0].fields.get(274)).toBe(1);
16+
expect(exif).toHaveLength(1);
17+
expect(exif?.[0]?.fields.size).toBe(12);
18+
expect(exif?.[0]?.fields.get(271)).toBe('SONY');
19+
expect(exif?.[0]?.fields.get(272).trimEnd()).toBe('DSC-HX9V');
20+
expect(exif?.[0]?.fields.get(274)).toBe(1);
1921
});

0 commit comments

Comments
 (0)