Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/after-finitude/rescript-ms
Reimplementation of ms in ReScript
https://github.com/after-finitude/rescript-ms
ms rescript
Last synced: about 1 month ago
JSON representation
Reimplementation of ms in ReScript
- Host: GitHub
- URL: https://github.com/after-finitude/rescript-ms
- Owner: after-finitude
- Created: 2021-07-04T18:52:20.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2021-07-17T09:23:08.000Z (over 3 years ago)
- Last Synced: 2024-10-10T23:34:24.421Z (3 months ago)
- Topics: ms, rescript
- Language: ReScript
- Homepage:
- Size: 6.84 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# rescript-ms
Reimplementation of [ms](https://github.com/vercel/ms) in [ReScript](https://rescript-lang.org).
## Installation
```shell
# yarn
yarn add rescript-ms# or npm
npm install --save rescript-ms
```Then add `rescript-validator` to your `bsconfig.json`'s `bs-dependencies`:
```json
"bs-dependencies": [
"rescript-ms"
]
```## Usage
```js
Ms.parse("2 days"); // 172800000
Ms.parse("1d"); // 86400000
Ms.parse("10h"); // 36000000
Ms.parse("2.5 hrs"); // 9000000
Ms.parse("2h"); // 7200000
Ms.parse("1m"); // 60000
Ms.parse("5s"); // 5000
Ms.parse("1y"); // 31557600000
Ms.parse("100"); // 100
Ms.parse("-3 days"); // -259200000
Ms.parse("-1h"); // -3600000
Ms.parse("-200"); // -200Ms.format(60000.0); // "1m"
Ms.format(2.0 *. 60000.0); // "2m"
Ms.format(-3.0 *. 60000.0); // "-3m"
```