
Security News
TypeScript is Porting Its Compiler to Go for 10x Faster Builds
TypeScript is porting its compiler to Go, delivering 10x faster builds, lower memory usage, and improved editor performance for a smoother developer experience.
Function to efficiently traverse large strings or arrays and run a predicate on adjacent values.
bracketing
is a small utility function to effeciantly walk and compare consecutive elements in an array or string and extract the longest sub array that fulfills this predicate. It is essentially two managed array pointers to traverse an array with the bare minimum number of comparisons. It will return the longest sequence that satisfies the supplied predicate function.
These following examples demonstrate some basic usage and should give you a better idea what bracketing
is all about
const bracketing = require('bracketing');
let result;
result = bracketing((left, right) => right > left, [1, 2, 3, 0, 5, 6, 7, 8, 100]);
// result equals [0, 5, 6, 7, 8, 100] because it is the longest sub array where the right value is greater than the left
result = bracketing((left, right) => left === right, 'aaaaaabbbbbccdeeeeeeeeeee');
// result equals "eeeeeeeeeee" because it is the longest substring where each character equals the one to the right
bracketing(predicate, sequence)
Returns the result of running the predicate
against sequence
. The result is either a string or array, matching the type of sequence
.
predicate
- a function to run against the elements of sequence
. It must return a boolean
value indicating pass or fail of the two elements. Has the following signature
left
- the left valueright
- the right valuesequence
- a string
or array
to traverse.There is a UMD build provided in the "dist" folder. bracketing
should have no issues working in a browser context. The only potential "got ya" is that accessing a string using bracket notation, which this module does, will not work in Internet Explorer 7.
FAQs
Function to efficiently traverse large strings or arrays and run a predicate on adjacent values.
The npm package bracketing receives a total of 0 weekly downloads. As such, bracketing popularity was classified as not popular.
We found that bracketing 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
TypeScript is porting its compiler to Go, delivering 10x faster builds, lower memory usage, and improved editor performance for a smoother developer experience.
Research
Security News
The Socket Research Team has discovered six new malicious npm packages linked to North Korea’s Lazarus Group, designed to steal credentials and deploy backdoors.
Security News
Socket CEO Feross Aboukhadijeh discusses the open web, open source security, and how Socket tackles software supply chain attacks on The Pair Program podcast.