diff --git a/.eslintrc.yml b/.eslintrc.yml deleted file mode 100644 index bc57d11..0000000 --- a/.eslintrc.yml +++ /dev/null @@ -1 +0,0 @@ -extends: cheminfo-typescript diff --git a/eslint.config.mjs b/eslint.config.mjs new file mode 100644 index 0000000..9ced323 --- /dev/null +++ b/eslint.config.mjs @@ -0,0 +1,9 @@ +import cheminfo from 'eslint-config-cheminfo-typescript'; + +export default [ + ...cheminfo, + { + languageOptions: {}, + rules: {}, + }, +]; diff --git a/package.json b/package.json index 4b97233..395c0b1 100644 --- a/package.json +++ b/package.json @@ -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" @@ -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" } } diff --git a/src/__tests__/decode.test.ts b/src/__tests__/decode.test.ts index 0f1b098..75cdefb 100644 --- a/src/__tests__/decode.test.ts +++ b/src/__tests__/decode.test.ts @@ -1,3 +1,5 @@ +import { describe, expect, it } from 'vitest'; + import { decode } from '..'; import { tests, allBytes, base64AllBytes } from './data'; diff --git a/src/__tests__/encode.test.ts b/src/__tests__/encode.test.ts index 1c83b37..a030a7d 100644 --- a/src/__tests__/encode.test.ts +++ b/src/__tests__/encode.test.ts @@ -1,3 +1,5 @@ +import { describe, expect, it } from 'vitest'; + import { encode } from '..'; import { tests, allBytes, base64AllBytes } from './data'; diff --git a/src/decode.ts b/src/decode.ts index eeac136..5d8be2d 100644 --- a/src/decode.ts +++ b/src/decode.ts @@ -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 */ @@ -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 = diff --git a/src/encode.ts b/src/encode.ts index 73a584c..0a1b30f 100644 --- a/src/encode.ts +++ b/src/encode.ts @@ -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 */ diff --git a/tsconfig.json b/tsconfig.json index 4c83c06..950dc30 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,6 +1,7 @@ { "compilerOptions": { "esModuleInterop": true, + "skipLibCheck": true, "moduleResolution": "node", "sourceMap": true, "strict": true,