typed-duration
Advanced tools
Comparing version 1.0.7 to 1.0.8
{ | ||
"name": "typed-duration", | ||
"version": "1.0.7", | ||
"version": "1.0.8", | ||
"description": "Zero-dependency typed duration library for JavaScript", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -104,4 +104,26 @@ # Typed Duration | ||
## Logging | ||
You can log times for user information in the format that the user specified them, including units, with `Duration.value.of`. For example: | ||
```TypeScript | ||
import { Duration, MaybeTimeDuration } from 'typed-duration' | ||
function executePeriodically(fn: () => void, period: MaybeTimeDuration) { | ||
console.log(`Executing in ${Duration.value.of(period)}...`) | ||
setTimeout(fn, Duration.milliseconds.from(period)) | ||
} | ||
executePeriodically(doSomething, Duration.seconds.from(20)) | ||
// Executing in 20s... | ||
executePeriodically(doSomething, Duration.milliseconds.from(350)) | ||
// Executing in 350ms... | ||
executePeriodically(doSomething, 2500) | ||
// Executing in 2500... | ||
``` | ||
## Feature Requests, Bug Reports | ||
See the [GitHub repo](https://github.com/jwulf/typed-duration). |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
14507
128