Skip to content

Commit

Permalink
Add isValid(), fix security issues in dependency (#11)
Browse files Browse the repository at this point in the history
* fix security issues in dependency with npm audit fix

* added: isValid()

* case insensitive. remove redundant import.

* case insensitive. remove redundant import.

* Make isValid more efficient

Co-authored-by: Perry Mitchell <perrymitchell@live.com>
  • Loading branch information
bluet and perry-mitchell committed Dec 30, 2022
1 parent 8912c48 commit 52de42c
Show file tree
Hide file tree
Showing 6 changed files with 245 additions and 360 deletions.
11 changes: 11 additions & 0 deletions README.md
Expand Up @@ -64,6 +64,17 @@ import { decodeTime } from "ulidx";
decodeTime("01ARYZ6S41TSV4RRFFQ69G5FAV"); // 1469918176385
```

### Validate ULID

Import `isValid` to check if a string is a valid ULID:

```typescript
import { isValid } from "ulidx";

isValid("01ARYZ6S41TSV4RRFFQ69G5FAV"); // true
isValid("01ARYZ6S41TSV4RRFFQ69G5FA"); // false
```

## Pseudo-Random Number Generation (PRNG)

`ulidx` will attempt to locate a suitable cryptographically-secure random number generator in the environment where it's loaded. On NodeJS this will be `crypto.randomBytes` and in the browser it will be `crypto.getRandomValues`.
Expand Down

0 comments on commit 52de42c

Please sign in to comment.