Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
binmap
Advanced tools
Readme
binmap
is a Map
implementation compatible to the Built-in Map but guaranteeing the keys to be ordered.
The constructor has an optional options object and the class has a member function between
for iterating between two boundary keys.
BinMap
instances are convertible to and from built-in Maps and Arrays (of sub-arrays).
The constructor works like the built-in Map in that it can optionally take an iterable of key-value pairs (as individual arrays), but can also have an extra optional options object which can contain a comparison function cmp
with the same semantics as the custom sort
comparator.
import BinMap from 'binmap'
// Custom comparator
const cmp = ( a, b ) => a.length - b.length;
const bm1 = new BinMap( { cmp } );
// or
const bm2 = new BinMap( [ [ 'key1', 'value1' ], ... ], { cmp } );
between( { ... } )
returns an IterableIterator between two boundary keys. The options object can contain:
lt
(less than) or an le
(less than or equal to).gt
(greater than) or a ge
(greater than or equal to).reverse
being a boolean (defaults to false
), which if true
returns an iterator from the end to the beginning of the span.There are two magic values for lt
, le
, gt
and ge
which is BinMap.min
and BinMap.max
which represents the lowest/highest possible values. These are also the default, so an empty between( { } )
(or just between( )
) iterates the whole map.
import BinMap from 'binmap'
const bm = new BinMap( [
[ "a", 1 ],
[ "b", 2 ],
[ "c", 3 ],
[ "d", 4 ],
] );
Array.from( bm.between( { gt: 'b' } ) )
// -> [ [ "c", 3 ], [ "d", 4 ] ]
Array.from( bm.between( { gt: 'b', reverse: true } ) )
// -> [ [ "d", 4 ], [ "c", 3 ] ]
FAQs
Ordered Map (ES Map compatible)
The npm package binmap receives a total of 10 weekly downloads. As such, binmap popularity was classified as not popular.
We found that binmap 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
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.