New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

fliptime

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fliptime

fluent timer with laps, microtime (polyfill) + parsing, multiple timers, shorthand diffs & specifications

latest
Source
npmnpm
Version
3.0.2
Version published
Weekly downloads
4
-66.67%
Maintainers
1
Weekly downloads
 
Created
Source

⛓⏲ fliptime

NPM version MIT License fliphub

fluent timer with laps, microtime + parsing, multiple timers, (fallback to performance & Date), shorthand diffs & specifications

usage

yarn add fliptime
npm i fliptime --save
const timer = require('fliptime')

uses microtime polyfill and if you install microtime it will require it when available (for node_gyp compat reasons) formatted with microseconds

simple

timer.start('canada')
setTimeout(() => timer.end('canada').log('canada'), 500)

laps

timer.start('canada')
const lapper = setInterval(() => {
  timer.lap('canada')
}, 1000)
setTimeout(() => clearInterval(lapper), 10000)
timer.logLaps('canada')

took

timer.start('canada')
setTimeout(() => console.log(timer.end('canada').took('canada')), 500)

multiple

const sleepfor = require('sleepfor')
timer.start('eh')
timer.start('canada')

sleepfor(100)
timer.lap('canada')
timer.stop('eh')
sleepfor(100)
timer.lap('canada')

timer
.stop('canada')
.log('eh')
.log('canada')
.logLaps('canada')

// second param is whether to use laps
const lapTime = timer.msTook('canada', true)

formats

timer.start('eh')
timer.stop('eh')

const microseconds = timer.took('eh')
const ms = timer.msTook('eh')
const parsed = timer.parsedTook()

⚖️ tillNow

diff for each: milliseconds, seconds, minutes, hours, days, years.

const now = Date.now()
sleepfor(60000)
const {ms, s, m, h, d, y} = timer.tillNow(now)

// ms === 60000
// s === 60
// m === 1
// h === 0
// d === 0
// y === 0


⚖️ tillNowSatisfies

check that the difference is equal or greater than specification.

const then = Date.now()
sleepfor(60000)

// seconds, hours, minutes, days, years...
// or shorthand: s, h, m, d, y
//
// true: >= 60 seconds
const satisfies = timer.tillNowSatisfies(then, {seconds: 60})

🏊 additional

const now = timer.microtime.now()
const micro = timer.parseMicro(now)

timer.times = {}
timer.laps = {}
timer.index = 0

example

timer.times[name].start
timer.times[name].end
timer.times[name].diff

Keywords

debugging

FAQs

Package last updated on 10 May 2017

Did you know?

Socket

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.

Install

Related posts