From a65541117aca943d844436135ac78d490bdd6081 Mon Sep 17 00:00:00 2001 From: tonya Date: Sun, 7 May 2023 15:58:31 +0000 Subject: [PATCH] feat: add readme --- .changeset/tiny-dogs-admire.md | 5 +++++ README.md | 41 ++++++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+) create mode 100644 .changeset/tiny-dogs-admire.md create mode 100644 README.md diff --git a/.changeset/tiny-dogs-admire.md b/.changeset/tiny-dogs-admire.md new file mode 100644 index 0000000..fd3e24e --- /dev/null +++ b/.changeset/tiny-dogs-admire.md @@ -0,0 +1,5 @@ +--- +"time-morph": patch +--- + +add a readme diff --git a/README.md b/README.md new file mode 100644 index 0000000..df8208d --- /dev/null +++ b/README.md @@ -0,0 +1,41 @@ +# Time Morph + +TimeMorph is a lightweight package for converting between different time units in JavaScript. It provides a simple API for converting durations from one unit of time to another, such as milliseconds to seconds or hours to days. + +## Installation + +You can install TimeMorph via npm: + +```bash +npm install time-morph +``` + +## Usage + +To use TimeMorph, import the `convertTime` function and pass in an object with the duration to convert and the source and target units. For example: + +```typescript +import convertTime from 'time-morph'; + +const durationInSeconds = convertTime({ + duration: 1000, + from: 'ms', + to: 'sec', +}); // 1 +``` + +In this example, the `convertTime` function takes an object with the following properties: + +- `duration` (required): The duration to convert, in the source unit of time. +- `from` (required): The source unit of time, specified as one of the following strings: ms, sec, min, hour, day, week, month, or year. +- `to` (optional): The target unit of time, specified as one of the same strings as from. If not specified, the function will return the duration in the source unit of time. + +The function returns the converted duration, rounded to the nearest integer. + +## Contributing + +Contributions to TimeMorph are welcome! To contribute, please fork the [repository](https://github.com/tonyaellie/convert-time) and submit a pull request with your changes. + +## License + +TimeMorph is licensed under the MIT License. See the LICENSE file for more information.