Skip to content

Commit

Permalink
chore: update dependencies and migrate to vitest
Browse files Browse the repository at this point in the history
  • Loading branch information
lpatiny committed Dec 18, 2024
1 parent cc734a0 commit dafb336
Show file tree
Hide file tree
Showing 8 changed files with 29 additions and 21 deletions.
1 change: 0 additions & 1 deletion .eslintrc.yml

This file was deleted.

9 changes: 9 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import cheminfo from 'eslint-config-cheminfo-typescript';

export default [
...cheminfo,
{
languageOptions: {},
rules: {},
},
];
28 changes: 11 additions & 17 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"prettier-write": "prettier --write src",
"test": "npm run test-coverage && npm run eslint && npm run prettier && npm run check-types",
"test-coverage": "npm run test-only -- --coverage",
"test-only": "jest",
"test-only": "vitest run",
"tsc": "npm run clean && npm run tsc-cjs && npm run tsc-esm",
"tsc-cjs": "tsc --project tsconfig.cjs.json",
"tsc-esm": "tsc --project tsconfig.esm.json"
Expand All @@ -36,22 +36,16 @@
"url": "https://github.com/cheminfo/uint8-base64/issues"
},
"homepage": "https://github.com/cheminfo/uint8-base64#readme",
"jest": {
"preset": "ts-jest",
"testEnvironment": "node",
"testPathIgnorePatterns": [
"node_modules",
"data.ts"
]
},
"devDependencies": {
"@types/jest": "^27.0.1",
"eslint": "^7.32.0",
"eslint-config-cheminfo-typescript": "^8.0.9",
"jest": "^27.1.0",
"prettier": "^2.3.2",
"rimraf": "^3.0.2",
"ts-jest": "^27.0.5",
"typescript": "^4.4.2"
"@types/jest": "^29.5.14",
"@vitest/coverage-v8": "2.1.8",
"eslint": "^9.17.0",
"eslint-config-cheminfo-typescript": "^17.0.0",
"jest": "^29.7.0",
"prettier": "^3.4.2",
"rimraf": "^6.0.1",
"ts-jest": "^29.2.5",
"typescript": "^5.7.2",
"vitest": "^2.1.8"
}
}
2 changes: 2 additions & 0 deletions src/__tests__/decode.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { describe, expect, it } from 'vitest';

import { decode } from '..';

import { tests, allBytes, base64AllBytes } from './data';
Expand Down
2 changes: 2 additions & 0 deletions src/__tests__/encode.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { describe, expect, it } from 'vitest';

import { encode } from '..';

import { tests, allBytes, base64AllBytes } from './data';
Expand Down
6 changes: 3 additions & 3 deletions src/decode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ const base64codes = Uint8Array.from([

/**
* Convert a Uint8Array containing a base64 encoded bytes to a Uint8Array containing decoded values
* @param input
* @returns a Uint8Array containing the decoded bytes
*/

Expand All @@ -24,11 +25,10 @@ export function decode(
throw new Error('Unable to parse base64 string.');
}

let output = new Uint8Array(3 * (input.length / 4));
const output = new Uint8Array(3 * (input.length / 4));
if (input.length === 0) return output;

const missingOctets =
input[input.length - 2] === 61 ? 2 : input[input.length - 1] === 61 ? 1 : 0;
const missingOctets = input.at(-2) === 61 ? 2 : input.at(-1) === 61 ? 1 : 0;

for (let i = 0, j = 0; i < input.length; i += 4, j += 3) {
const buffer =
Expand Down
1 change: 1 addition & 0 deletions src/encode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ const base64codes = Uint8Array.from([

/**
* Convert a Uint8Array containing bytes to a Uint8Array containing the base64 encoded values
* @param input
* @returns a Uint8Array containing the encoded bytes
*/

Expand Down
1 change: 1 addition & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"compilerOptions": {
"esModuleInterop": true,
"skipLibCheck": true,
"moduleResolution": "node",
"sourceMap": true,
"strict": true,
Expand Down

0 comments on commit dafb336

Please sign in to comment.