Research
Security News
Threat Actor Exposes Playbook for Exploiting npm to Build Blockchain-Powered Botnets
A threat actor's playbook for exploiting the npm ecosystem was exposed on the dark web, detailing how to build a blockchain-powered botnet.
box-intersect-1d
Advanced tools
Find all intersections in a collection of intervals.
Here is how you can use this module to detect all intersections in a collection of intervals:
var boxIntersect1D = require('box-intersect-1d')
var boxes = [
[0, 1],
[0, 2],
[10, 100],
[5, 8],
[1.5, 7]
]
boxIntersect1D.full(boxes, function(i,j) {
console.log(i,j)
console.log('overlap:', boxes[i], boxes[j])
})
overlap: [ 0, 1 ] [ 0, 2 ]
overlap: [ 1.5, 7 ] [ 0, 2 ]
overlap: [ 5, 8 ] [ 1.5, 7 ]
If you want to compare intersections between two different sets of intervals you can use the .bipartite
version of the test:
var boxIntersect1D = require('box-intersect-1d')
var red = [
[0, 1],
[0, 2],
[10, 100],
[5, 8],
[1.5, 7]
]
var blue = [
[0, 100],
[1, 2],
[-1, 5]
]
boxIntersect1D.bipartite(red, blue, function(r, b) {
console.log('overlap:', red[r], blue[b])
})
overlap: [ 0, 2 ] [ -1, 5 ]
overlap: [ 0, 2 ] [ 0, 100 ]
overlap: [ 0, 1 ] [ -1, 5 ]
overlap: [ 0, 1 ] [ 0, 100 ]
overlap: [ 0, 2 ] [ 1, 2 ]
overlap: [ 0, 1 ] [ 1, 2 ]
overlap: [ 1.5, 7 ] [ -1, 5 ]
overlap: [ 1.5, 7 ] [ 0, 100 ]
overlap: [ 1.5, 7 ] [ 1, 2 ]
overlap: [ 5, 8 ] [ -1, 5 ]
overlap: [ 5, 8 ] [ 0, 100 ]
overlap: [ 10, 100 ] [ 0, 100 ]
npm install box-intersect-1d
var boxIntersect1D = require('box-intersect-1d')
boxIntersect1D.full(boxes, visit)
Find all pairs of boxes which intersect
boxes
is an array of intervals represented by [lo,hi]
value pairsvisit(i,j)
is called for every pair over overlapping intervals with the index of the intervals. If visit
returns any value other than undefined
, then this terminates early with that value.boxIntersect1D.bipartite(red, blue, visit)
Find all intersections between two sets of intervals
red
and blue
are two collections of intervals as described abovevisit(r,b)
is called once for every pair of intervals in red
and blue
which overlap. r
and b
are the indices of the overlapping boxes.(c) 2014 Mikola Lysenko. MIT License
FAQs
Find all intersections in a set of intervals
The npm package box-intersect-1d receives a total of 0 weekly downloads. As such, box-intersect-1d popularity was classified as not popular.
We found that box-intersect-1d 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.
Research
Security News
A threat actor's playbook for exploiting the npm ecosystem was exposed on the dark web, detailing how to build a blockchain-powered botnet.
Security News
NVD’s backlog surpasses 20,000 CVEs as analysis slows and NIST announces new system updates to address ongoing delays.
Security News
Research
A malicious npm package disguised as a WhatsApp client is exploiting authentication flows with a remote kill switch to exfiltrate data and destroy files.