Skip to content

Commit

Permalink
chore(docs): add advanced usage section (#214)
Browse files Browse the repository at this point in the history
  • Loading branch information
styfle authored Mar 20, 2024
1 parent f150c1c commit fe53382
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,30 @@ function example(value: OnlyDaysAndWeeks) {
example('5.2 days');
```

## Advanced Usage

As of `v3.0`, you can import `parse` and `format` separately.

```ts
import { parse, format } from 'ms';

parse('1h'); // 3600000

format(2000); // "2s"
```

If you want strict type checking for the input value, you can use `parseStrict`.

```ts
import { parseStrict } from 'ms';

parseStrict('1h'); // 3600000

function example(s: string) {
return parseStrict(str); // tsc error
}
```

## Edge Runtime Support

`ms` is compatible with the [Edge Runtime](https://edge-runtime.vercel.app/). It can be used inside environments like [Vercel Edge Functions](https://vercel.com/edge) as follows:
Expand Down

0 comments on commit fe53382

Please sign in to comment.