https://github.com/chrishanzlik/textmasks
Masking texts with typescript / javascript
https://github.com/chrishanzlik/textmasks
inputmask mask placeholders textmask typescript
Last synced: about 1 month ago
JSON representation
Masking texts with typescript / javascript
- Host: GitHub
- URL: https://github.com/chrishanzlik/textmasks
- Owner: chrishanzlik
- License: mit
- Created: 2022-06-05T23:17:28.000Z (almost 3 years ago)
- Default Branch: development
- Last Pushed: 2022-06-13T15:23:28.000Z (almost 3 years ago)
- Last Synced: 2025-03-20T21:16:53.117Z (2 months ago)
- Topics: inputmask, mask, placeholders, textmask, typescript
- Language: TypeScript
- Homepage:
- Size: 368 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# textmasks
[](https://www.npmjs.com/package/textmasks)
Experimental typescript/javascript lib for masking texts.
## Installation guide
```bash
npm install textmasks --save
```## Mask options
TBC...
### Default definitions
Default definitions for all numbers and alphabetical characters:
| Char(s) | Description | Expression |
| ------- | ------------------- | ----------- |
| a-z | Lower case letters | `/^[a-z]$/` |
| A-Z | Uppser case letters | `/^[A-Z]$/` |
| 0-9 | Numbers | `/^[0-9]$/` |## Work with the string extension
```typescript
'123456'.mask('(999)-999', options);
```## Examples
Direct match:
```typescript
import { maskText } from 'textmasks';const result = maskText({
text: '123456',
mask: '(9)99-999',
});result.output === '(1)23-456'; // true
```Partial mask output:
```typescript
import { maskText } from 'textmasks';const result = maskText({
text: '123',
mask: '(9)99-999',
options: {
partialOutput: true,
},
});result.output === '(1)123-'; // true
```Full mask output with RTL-direction:
```typescript
import { maskText } from 'textmasks';const result = maskText({
text: '12',
mask: '(9)99-999',
options: {
placeholder: '_',
partialOutput: false,
direction: 'rtl',
},
});result.output === '(_)__-_21'; // true
```