Skip to content

Commit

Permalink
fix: default export to expose to browser
Browse files Browse the repository at this point in the history
  • Loading branch information
jukbot committed Oct 21, 2023
1 parent c10064c commit 3601f63
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 150 deletions.
1 change: 0 additions & 1 deletion dist/assets/index-a505a960.js

This file was deleted.

1 change: 0 additions & 1 deletion dist/assets/index-aadd4a5c.css

This file was deleted.

141 changes: 0 additions & 141 deletions dist/index.html

This file was deleted.

13 changes: 7 additions & 6 deletions dist/validator.es.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
function c(t) {
if (!/^\d{13}$/.test(t))
function t(u) {
if (!/^\d{13}$/.test(u))
return !1;
let u = 0;
let i = 0;
for (let e = 0; e < 12; e++)
u += Number(t[e]) * (13 - e);
return (11 - u % 11) % 10 === Number(t[12]);
i += Number(u[e]) * (13 - e);
return (11 - i % 11) % 10 === Number(u[12]);
}
typeof module < "u" && typeof module.exports < "u" ? (module.exports = t, exports.default = t, exports.isValidThaiID = t) : window.isValidThaiID = t;
export {
c as default
t as default
};
2 changes: 1 addition & 1 deletion dist/validator.umd.js

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

5 changes: 5 additions & 0 deletions global.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
declare global {
interface Window {
isValidThaiID: (id: string) => boolean;
}
}
9 changes: 9 additions & 0 deletions lib/validator.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,13 @@ function isValidThaiID(id) {
}

// Export the function.
if (typeof module !== "undefined" && typeof module.exports !== "undefined") {
module.exports = isValidThaiID;
exports.default = isValidThaiID;
exports.isValidThaiID = isValidThaiID;
} else {
// @ts-ignore
window.isValidThaiID = isValidThaiID;
}

export default isValidThaiID;

0 comments on commit 3601f63

Please sign in to comment.