![Introducing Enhanced Alert Actions and Triage Functionality](https://cdn.sanity.io/images/cgdhsj6q/production/fe71306d515f85de6139b46745ea7180362324f0-2530x946.png?w=800&fit=max&auto=format)
Product
Introducing Enhanced Alert Actions and Triage Functionality
Socket now supports four distinct alert actions instead of the previous two, and alert triaging allows users to override the actions taken for all individual alerts.
tick-tock
Advanced tools
Readme
tick-tock
is a small timer and setTimeout
management library. Nothing to
fancy, but fancy enough to make your code more readable.
This library can be used with both browserify and node.js and can be installed using npm:
npm install --save tick-tock
In all example we assume that you've required and initialized the library using:
'use strict';
var Tick = require('tick-tock')
, tock = new Tick();
All methods return this
unless stated otherwise.
The setTimeout
method adds as you might have expected.. a new setTimeout. The
timeouts are stored based on the name that your provide them. If you've already
stored a timer with the given name, it will add the supplied callback to the
same stack so only one timer is used and they all run at the same time. Normally
you would supply the setTimeout
method with a number indicating long it should
timeout. In this library we also support human readable strings.
tock.setTimeout('foo', function () {}, 10);
// Ran at the same point in time as the timeout above
setTimeout(function () {
tock.setTimeout('foo', function () {}, 10);
}, 5);
tock.setTimeout('another', function () {}, '10 minutes');
Exactly the same method and functionality as above but instead of only being called once, it will called at an interval.
The clear
method allows you to clear every stored timeout by name. You can
supply it multiple arguments (strings) to clear all given timers and if you
supply 1 strings it can be comma separated list of names. If no arguments are
supplied it will clear all timers in this instance.
tock.clear('foo', 'bar');
tock.clear('foo, bar'); // Same as above.
tock.clear(); // Nuke everything.
Check if there's an active timer for the given name and returns a boolean.
tock.active('foo'); // true;
tock.clear();
tock.active('foo'); // false;
There are cases where you sometimes need to update or change the interval of an
setTimeout
or setInterval
for example in the case of a setTimeout which
coordinates a heartbeat. In order to make this easier you call the .adjust
method with the name of the timeout that you want to adjust and the new
interval/timeout.
tock.setTimeout('heartbeat timeout', function () {});
// you recieved a new heartbeat so you want to reset or adjust the heartbeat;
tock.adjust('heartbeat timeout', '1 second');
MIT
FAQs
Timer management, never forget to clear timers again
The npm package tick-tock receives a total of 1,198 weekly downloads. As such, tick-tock popularity was classified as popular.
We found that tick-tock demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 3 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.
Product
Socket now supports four distinct alert actions instead of the previous two, and alert triaging allows users to override the actions taken for all individual alerts.
Security News
Polyfill.io has been serving malware for months via its CDN, after the project's open source maintainer sold the service to a company based in China.
Security News
OpenSSF is warning open source maintainers to stay vigilant against reputation farming on GitHub, where users artificially inflate their status by manipulating interactions on closed issues and PRs.