Research
Security News
Malicious npm Package Targets Solana Developers and Hijacks Funds
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Collections of one-shot and periodic timers, intended for use with event loops such as async.
Add this line to your application's Gemfile:
gem 'timers'
And then execute:
$ bundle
Or install it yourself as:
$ gem install timers
Create a new timer group with Timers::Group.new
:
require 'timers'
timers = Timers::Group.new
Schedule a proc to run after 5 seconds with Timers::Group#after
:
five_second_timer = timers.after(5) { puts "Take five" }
The five_second_timer
variable is now bound to a Timers::Timer object. To
cancel a timer, use Timers::Timer#cancel
Once you've scheduled a timer, you can wait until the next timer fires with Timers::Group#wait
:
# Waits 5 seconds
timers.wait
# The script will now print "Take five"
You can schedule a block to run periodically with Timers::Group#every
:
every_five_seconds = timers.every(5) { puts "Another 5 seconds" }
loop { timers.wait }
You can also schedule a block to run immediately and periodically with Timers::Group#now_and_every
:
now_and_every_five_seconds = timers.now_and_every(5) { puts "Now and in another 5 seconds" }
loop { timers.wait }
If you'd like another method to do the waiting for you, e.g. Kernel.select
,
you can use Timers::Group#wait_interval
to obtain the amount of time to wait. When
a timeout is encountered, you can fire all pending timers with Timers::Group#fire
:
loop do
interval = timers.wait_interval
ready_readers, ready_writers = select readers, writers, nil, interval
if ready_readers || ready_writers
# Handle IO
...
else
# Timeout!
timers.fire
end
end
You can also pause and continue individual timers, or all timers:
paused_timer = timers.every(5) { puts "I was paused" }
paused_timer.pause
10.times { timers.wait } # will not fire paused timer
paused_timer.resume
10.times { timers.wait } # will fire timer
timers.pause
10.times { timers.wait } # will not fire any timers
timers.resume
10.times { timers.wait } # will fire all timers
git checkout -b my-new-feature
)git commit -am 'Add some feature'
)git push origin my-new-feature
)FAQs
Unknown package
We found that timers demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 31 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.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.