Security News
New Python Packaging Proposal Aims to Solve Phantom Dependency Problem with SBOMs
PEP 770 proposes adding SBOM support to Python packages to improve transparency and catch hidden non-Python dependencies that security tools oft miss.
Runs a binary search on any sorted collection.
Requires Node.js 8.3.0 or above.
npm i bfind
The module exports a single function.
compare
(function, array, or any):
a
and b
, expected to return -1
if a
is less than b
, 1
if a
is greater than b
, and 0
if they are equal.get
(function): A callback that should return a value from the collection for a given index from 0
to length - 1
.length
(positive integer): The length of the collection.multiple
(string): Specifies behavior in the event that more than one existing collection item is sort-equivalent with value
.
first
or last
, the index of the first or last sort-equivalent item (respectively) will be returned.identical
, every sort-equivalent item will be scanned for identity (===
) with value
and the first identical item found will have its index returned.value
(any): The value to search for.Returns an object:
found
(boolean): true
if compare
reported that the collection contains another value with the same sort value as value
; false
otherwise.index
(positive integer): The index of value
or its sort-equivalent (if equal
is true
); or, the appropriate insertion index for value
(if equal
is false
).const bfind = require('bfind')
const arr = ['a', 'c', 'c']
const argsForArr = {get: i => arr[i], length: arr.length}
bfind({...argsForArr, value: 'a'}) // {found: true, index: 0}
bfind({...argsForArr, value: 'b'}) // {found: false, index: 1}
bfind({...argsForArr, value: 'c'}) // {found: true, index: 1}
bfind({...argsForArr, value: 'c', multiple: 'last'}) // {found: true, index: 2}
This module is part of the “b” family of binary search modules.
FAQs
Runs a binary search on any sorted collection.
The npm package bfind receives a total of 3 weekly downloads. As such, bfind popularity was classified as not popular.
We found that bfind 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
PEP 770 proposes adding SBOM support to Python packages to improve transparency and catch hidden non-Python dependencies that security tools oft miss.
Security News
Socket CEO Feross Aboukhadijeh discusses open source security challenges, including zero-day attacks and supply chain risks, on the Cyber Security Council podcast.
Security News
Research
Socket researchers uncover how threat actors weaponize Out-of-Band Application Security Testing (OAST) techniques across the npm, PyPI, and RubyGems ecosystems to exfiltrate sensitive data.