Skip to content

Commit

Permalink
chore: remove unused file, bump deps
Browse files Browse the repository at this point in the history
  • Loading branch information
jukbot committed Sep 17, 2024
1 parent 590e97b commit f4f45b3
Show file tree
Hide file tree
Showing 10 changed files with 39 additions and 77 deletions.
Binary file modified bun.lockb
Binary file not shown.
1 change: 1 addition & 0 deletions dist/assets/index-CtF5sz_F.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/browser/validator.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/esm/validator.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
crossorigin="anonymous"
referrerpolicy="no-referrer"
></script>
<script type="module" crossorigin src="./assets/index-ByB4O58P.js"></script>
<script type="module" crossorigin src="./assets/index-CtF5sz_F.js"></script>
<link rel="stylesheet" crossorigin href="./assets/index-Bjn-ATP8.css">
</head>

Expand Down
11 changes: 6 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,13 @@
"license": "MIT",
"devDependencies": {
"@istanbuljs/nyc-config-typescript": "^1.0.2",
"@types/node": "^22.3.0",
"eslint": "^9.9.0",
"@types/bun": "^1.1.9",
"@types/node": "^22.5.5",
"eslint": "^9.10.0",
"nyc": "^17.0.0",
"standard": "^17.1.0",
"typescript": "^5.5.4",
"vite": "^5.4.0"
"standard": "^17.1.2",
"typescript": "^5.6.2",
"vite": "^5.4.6"
},
"standard": {
"ignore": [
Expand Down
5 changes: 4 additions & 1 deletion src/validator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,15 @@ function isValidThaiID(id: string | number): boolean {
}

// Export the function.
if (typeof module !== 'undefined' && typeof module.exports !== 'undefined') {
if (typeof module !== 'undefined' && typeof module.exports !== 'undefined' || window === undefined) {
module.exports = isValidThaiID
exports.default = isValidThaiID
exports.isValidThaiID = isValidThaiID
} else if (typeof window !== 'undefined') {
// Support legacy version of the browser.
// @ts-ignore
window.isValidThaiID = isValidThaiID
} else {
// @ts-ignore
global.isValidThaiID = isValidThaiID
}
52 changes: 0 additions & 52 deletions tests/validator.test.js

This file was deleted.

25 changes: 25 additions & 0 deletions tests/validator.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { describe, it, expect } from 'bun:test';
// @ts-ignore
import isValidThaiID from '../src/validator';

describe('isValidThaiID Function', () => {
it('Case 1: Valid ID Correct pattern', () => {
expect(isValidThaiID('1112034563562')).toBe(true);
});

it('Case 2: Invalid ID Wrong pattern', () => {
expect(isValidThaiID('1101700230705')).toBe(false);
});

it('Case 3: Invalid ID Less than 13 characters', () => {
expect(isValidThaiID('110170023073')).toBe(false);
});

it('Case 4: Invalid ID Mixed characters', () => {
expect(isValidThaiID('11017002070d3')).toBe(false);
});

it('Case 5: Invalid ID Mixed characters', () => {
expect(isValidThaiID('rytege54fsfsf')).toBe(false);
});
});
16 changes: 0 additions & 16 deletions vite.config.js

This file was deleted.

0 comments on commit f4f45b3

Please sign in to comment.