
Security News
/Research
Wallet-Draining npm Package Impersonates Nodemailer to Hijack Crypto Transactions
Malicious npm package impersonates Nodemailer and drains wallets by hijacking crypto transactions across multiple blockchains.
A faster, immutable replacement for Ruby's Set
.
On Ruby >= 2.4, all operations are faster, some by several orders of magnitude (see benchmarks).
require 'immutable_set'
class MySet < ImmutableSet; end
Mutating methods of Set
(e.g. #add
, #delete
) are removed. They can be substituted like this if needed:
set1 = MySet[1, 2, 3]
set1 += MySet[4] # => MySet[1, 2, 3, 4]
set1 -= MySet[3] # => MySet[1, 2, 4]
Immutability is required for most of the performance optimizations.
All other methods behave as in Set
/SortedSet
, so see the official documentation for details about what they do.
#distinct_bounds?
Returns true iff the passed set is beyond the #minmax
boundaries of self
.
MySet[2, 4].distinct_bounds?(MySet[3]) # => false
MySet[2, 4].distinct_bounds?(MySet[5]) # => true
::from_ranges
Returns a set built from all passed Ranges
.
MySet.from_ranges(2..4, 6..8) # => MySet[2, 3, 4, 6, 7, 8]
#inversion
Returns a new set of the same class, containing all members from
..upto
that are not in self
. Faster than Set.new(from..upto) - self
.
MySet[3, 5].inversion(from: 1, upto: 4) # => MySet[1, 2, 4]`
MySet['c'].inversion(from: 'a', upto: 'd') # => MySet['a', 'b', 'd']
The cost of many methods is reduced from O(m*n) to O(m+n) or better. The underlying ideas are:
@hash
is built in order and then frozen#max
cheaply whenever possible#minmax
boundaries#while
over slower, scope-building iteration methodsRun rake benchmark
or see BENCHMARK.md.
FAQs
Unknown package
We found that immutable_set demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer 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
Malicious npm package impersonates Nodemailer and drains wallets by hijacking crypto transactions across multiple blockchains.
Security News
This episode explores the hard problem of reachability analysis, from static analysis limits to handling dynamic languages and massive dependency trees.
Security News
/Research
Malicious Nx npm versions stole secrets and wallet info using AI CLI tools; Socket’s AI scanner detected the supply chain attack and flagged the malware.