Skip to content

Commit fe53382

Browse files
authored
chore(docs): add advanced usage section (#214)
1 parent f150c1c commit fe53382

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

readme.md

+24
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,30 @@ function example(value: OnlyDaysAndWeeks) {
111111
example('5.2 days');
112112
```
113113

114+
## Advanced Usage
115+
116+
As of `v3.0`, you can import `parse` and `format` separately.
117+
118+
```ts
119+
import { parse, format } from 'ms';
120+
121+
parse('1h'); // 3600000
122+
123+
format(2000); // "2s"
124+
```
125+
126+
If you want strict type checking for the input value, you can use `parseStrict`.
127+
128+
```ts
129+
import { parseStrict } from 'ms';
130+
131+
parseStrict('1h'); // 3600000
132+
133+
function example(s: string) {
134+
return parseStrict(str); // tsc error
135+
}
136+
```
137+
114138
## Edge Runtime Support
115139

116140
`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:

0 commit comments

Comments
 (0)