Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(docs): add advanced usage section #214

Merged
merged 1 commit into from Mar 20, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
24 changes: 24 additions & 0 deletions readme.md
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