Security News
vlt Debuts New JavaScript Package Manager and Serverless Registry at NodeConf EU
vlt introduced its new package manager and a serverless registry this week, innovating in a space where npm has stagnated.
Both Node.js and browsers are supported by durations
. When using Node.js, the nanosecond-granulatiry process.hrtime()
function is used. The best substitution is selected when in the browser such that consistency is maintained even if time granularity cannot be.
npm install --save durations
The following functions are exported:
duration(nanoseconds)
- constructs a new Durationnanos(nanoseconds)
- constructs a new Durationmicros(microseconds)
- constructs a new Durationmillis(milliseconds)
- constructs a new Durationseconds(seconds)
- constructs a new Durationstopwatch()
- constructs a new Stopwatch (stopped)time(function)
- times a functiontimeAsync(function(callback))
- times a function asynchronouslyRepresents a duration with nanosecond granularity, and provides methods for converting to other granularities, and formatting the duration.
{duration} = require 'durations'
nanoseconds = 987654321
console.log "Duration is", duration(nanoseconds).format()
format()
- human readable string representing the durationnanos()
- duration as nanosecondsmicros()
- duration as microsecondsmillis()
- duration as millisecondsseconds()
- duration as secondsminutes()
- duration as minuteshours()
- duration as hoursdays()
- duration as daysconsole.log "Duration is #{duration(nanoseconds)}"
A nanosecond granularity (on Node.js) stopwatch with chainable control methods, and built-in formatting.
{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.
start()
- start the stopwatch (no-op if already running)stop()
- stop the stopwatch (no-op if not running)reset()
- reset the stopwatch to zero elapsed time (implies stop)duration()
- fetch the elapsed time as a DurationisRunning()
- is the stopwatch running (true
/false
)Times the execution of a function, and returns the duration.
{time: timeSync, timeAsync} = require 'durations'
# Synchronous work
someFunction = ->
count = 0
for c in [1 .. 1000000]
count += 1
console.log "Count is: #{count}"
console.log "Took #{timeSync(someFunction)} to do something"
# Asynchronous work
someOtherFunction = (next) ->
someFunction()
next()
timeAsync someOtherFunction, (duration) ->
console.log "Took #{duration} to do something else."
FAQs
Duration tracking and formattng for node.js
We found that durations demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
vlt introduced its new package manager and a serverless registry this week, innovating in a space where npm has stagnated.
Security News
Research
The Socket Research Team uncovered a malicious Python package typosquatting the popular 'fabric' SSH library, silently exfiltrating AWS credentials from unsuspecting developers.
Security News
At its inaugural meeting, the JSR Working Group outlined plans for an open governance model and a roadmap to enhance JavaScript package management.