Socket
Socket
Sign inDemoInstall

durations

Package Overview
Dependencies
Maintainers
1
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

durations - npm Package Compare versions

Comparing version 3.3.1 to 3.3.2

2

package.json

@@ -10,3 +10,3 @@ {

],
"version": "3.3.1",
"version": "3.3.2",
"author": "Joel Edwards (https://github.com/joeledwards)",

@@ -13,0 +13,0 @@ "contributors": [

@@ -30,7 +30,10 @@ # durations

```coffeescript
{duration} = require 'durations'
```javascript
const {duration} = require('durations')
nanoseconds = 987654321
console.log "Duration is", duration(nanoseconds).format()
const nanoseconds = 987654321
console.log("Duration is", duration(nanoseconds).format())
// Or, since toString() is an alias to format()
console.log(`Duration is ${duration(nanoseconds)}`)
```

@@ -48,5 +51,2 @@

# Or, since toString() is an alias to format()
console.log "Duration is #{duration(nanoseconds)}"
## Stopwatch

@@ -57,9 +57,18 @@

```coffeescript
{stopwatch} = require 'durations'
watch = stopwatch()
watch.stop() # Pauses the stopwatch. Returns the stopwatch.
watch.start() # Starts the stopwatch from where it was last stopped. Returns the stopwatch.
watch.reset() # Reset the stopwatch (duration is set back to zero). Returns the stopwatch.
duration = watch.duration() # Returns the Duration.
```javascript
const {stopwatch} = require('durations')
const watch = stopwatch()
// Pauses the stopwatch. Returns the stopwatch.
watch.stop()
// Starts the stopwatch from where it was last stopped. Returns the stopwatch.
watch.start()
// Reset the stopwatch (duration is set back to zero). Returns the stopwatch.
watch.reset()
console.log(`${watch.duration().seconds()} seconds have elapsed`)
// OR
console.log(`${watch} have elapsed`)
```

@@ -78,22 +87,28 @@

```coffeescript
{time: timeSync, timeAsync} = require 'durations'
```javascript
const {time: timeSync, timeAsync} = require('durations')
# Synchronous work
someFunction = ->
count = 0
for c in [1 .. 1000000]
count += 1
console.log "Count is: #{count}"
// Synchronous work
const someFunction = () => {
let count = 0
console.log "Took #{timeSync(someFunction)} to do something"
while (count < 1000000) {
count++
}
# Asynchronous work
someOtherFunction = (next) ->
console.log(`Count is: ${count}`)
}
console.log(`Took ${timeSync(someFunction)} to do something`)
// Asynchronous work
const someOtherFunction = next => {
someFunction()
next()
}
timeAsync someOtherFunction, (duration) ->
console.log "Took #{duration} to do something else."
timeAsync(someOtherFunction, duration => {
console.log(`Took ${duration} to do something else.`)
})
```
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc