Skip to content

Commit

Permalink
➕ isHalfWidth
Browse files Browse the repository at this point in the history
  • Loading branch information
Bunlong committed Sep 30, 2020
1 parent 1e2abac commit 4f45ed5
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -28,7 +28,7 @@ Validate is a standard Deno module for validating string.
* [x] isFloat
* [x] isFQDN
* [x] isFullWidth
* [ ] isHalfWidth
* [x] isHalfWidth
* [ ] isHash
* [ ] isHexColor
* [ ] isHexadecimal
Expand Down
9 changes: 9 additions & 0 deletions src/libs/isHalfWidth.ts
@@ -0,0 +1,9 @@
// @ts-ignore allowing typedoc to build
import assertString from '../utils/assertString.ts';

export const halfWidth = /[\u0020-\u007E\uFF61-\uFF9F\uFFA0-\uFFDC\uFFE8-\uFFEE0-9a-zA-Z]/;

export const isHalfWidth = (str: string) => {
assertString(str);
return halfWidth.test(str);
};
2 changes: 2 additions & 0 deletions src/mod.ts
Expand Up @@ -42,3 +42,5 @@ export * from './libs/isFloat.ts';
export * from './libs/isFQDN.ts';
// @ts-ignore allowing typedoc to build
export * from './libs/isFullWidth.ts';
// @ts-ignore allowing typedoc to build
export * from './libs/isHalfWidth.ts';

0 comments on commit 4f45ed5

Please sign in to comment.