Skip to content

Commit

Permalink
Updated docs about token transform functions
Browse files Browse the repository at this point in the history
  • Loading branch information
beholdr committed Oct 10, 2020
1 parent 2237462 commit 7cc8274
Show file tree
Hide file tree
Showing 9 changed files with 72 additions and 15 deletions.
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,16 @@ Default tokens:

You can add your own tokens by passing them in `maska` directive or `create` method at initialization (see above). **Important**: `pattern` field should be JS *regular expression* (`/[0-9]/`) or *string without delimiters* (`"[0-9]"`).

### Transform function for tokens

While specifying custom tokens you can also add a symbol-transformation behavior such as uppercase, lowercase, or even define a transform function:

``` javascript
{
'T': { pattern: /[0-9]/, transform: (char) => String(Number(char) % 2) } // '1234567890' -> '1010101010'
}
```

## Dynamic masks

To use several masks on single input, pass array instead of string as mask value.
Expand Down
4 changes: 2 additions & 2 deletions dist/es6/maska.esm.js

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

4 changes: 2 additions & 2 deletions dist/es6/maska.js

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

Loading

0 comments on commit 7cc8274

Please sign in to comment.