Security News
Research
Data Theft Repackaged: A Case Study in Malicious Wrapper Packages on npm
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
timer2 is an evented timer.
$ npm install timer2
First you need to add a reference to timer2 to your application.
const Timer = require('timer2');
Then you are able to create new timers by calling the Timer
constructor with the desired timeout in milliseconds.
const timer = new Timer(100);
The timer then periodically emits tick
events. You can subscribe to these events using the usual EventEmitter
functions, such as on
and once
.
timer.on('tick', () => {
// ...
});
Please remember that you need to unsubscribe from the tick
event if you do not need the timer any longer. For that you can use the usual EventEmitter
functions, such as removeListener
and removeAllListeners
.
By default, timers do not start immediately, but wait for the specified number of milliseconds before emitting the first tick
event. If you need a timer that starts immediately, provide an options
object to the constructor and set its immediate
property to true
.
const timer = new Timer(100, {
immediate: true
});
Normally, the timer ticks at a constant rate. If you want to make ticking a little unreliable, you can specify a variation for the timeout
. This means, e.g. if you specify a timeout of 2000 ms and a variation of 500 ms, you will get ticks between every 1500 ms and 2500 ms.
To enable wobbling, provide a variation
property within the options
object and set its value to the desired number of milliseconds.
const timer = new Timer(2000, {
variation: 500
});
You can stop a running timer at an arbitrary point in time. For that you need to call its stop
function.
timer.stop();
To restart a stopped timer call its start
function accordingly.
timer.start();
If you don't longer need a timer you have to stop it and remove all subscribers.
timer.stop();
timer.removeAllListeners();
Alternatively, you may use the convenience function destroy
that does all the necessary things for you.
timer.destroy();
To build this module use roboter.
$ bot
The MIT License (MIT) Copyright (c) 2013-2018 the native web.
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
FAQs
timer2 is an evented timer.
The npm package timer2 receives a total of 22,963 weekly downloads. As such, timer2 popularity was classified as popular.
We found that timer2 demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 4 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
Research
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Research
Security News
Attackers used a malicious npm package typosquatting a popular ESLint plugin to steal sensitive data, execute commands, and exploit developer systems.
Security News
The Ultralytics' PyPI Package was compromised four times in one weekend through GitHub Actions cache poisoning and failure to rotate previously compromised API tokens.