You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: readme.md
+24
Original file line number
Diff line number
Diff line change
@@ -111,6 +111,30 @@ function example(value: OnlyDaysAndWeeks) {
111
111
example('5.2 days');
112
112
```
113
113
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
+
returnparseStrict(str); // tsc error
135
+
}
136
+
```
137
+
114
138
## Edge Runtime Support
115
139
116
140
`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