
Security News
npm Adopts OIDC for Trusted Publishing in CI/CD Workflows
npm now supports Trusted Publishing with OIDC, enabling secure package publishing directly from CI/CD workflows without relying on long-lived tokens.
level-option-wrap
Advanced tools
wrap opts.{{g,l}{t,e,te},start,end}
arguments with functions
With this package you can expose familiar db.createReadStream()
options like
from leveldb but without leaking information about your internal key
representations.
For example, suppose you have a list of users using a bytewise keyEncoding and
you want to let api consumers constrain the output. If you pass through
opts.gt
/opts.lt
arguments directly, you must communicate to api consumers
the internal structure of your keys, which breaks encapsulation.
However, implementing opts.{{g,l}{t,e,te},start,end}
yourself inside your library
or application code is madness! This library lets you do that:
var wrap = require('level-option-wrap');
var minimist = require('minimist');
var defined = require('defined');
var argv = minimist(process.argv.slice(2));
var opts = wrap(argv, {
gt: function (x) { return [ 'user', defined(x, null) ] },
lt: function (x) { return [ 'user', defined(x, undefined) ] }
});
console.log(opts);
Now to get all users >= 'mafintosh'
and < 'maxogden'
we can just do:
$ node example/prefix.js --gte mafintosh --lt maxogden
{ gte: [ 'user', 'mafintosh' ], lt: [ 'user', 'maxogden' ] }
This works even though we only specified gt
and lt
as our prefix functions,
because narrower ranges take precedence.
var wrap = require('level-option-wrap')
Generate newOpts
given some leveldb createReadStream-style options opts
and
an object fns
mapping key contraints {g,l}{t,e,te}
to functions. Each
function gets the relevant constraint (whether exclusive or not) and should
return the new key bound. Exclusivity for each key is determined by the
corresponding opts
key.
opts.limit
values will be passed through and can be modified by defining an
fns.limit(n)
function.
With npm do:
npm install level-option-wrap
MIT
FAQs
wrap `opts.{{g,l}{t,e,te},start,end}` arguments with functions
The npm package level-option-wrap receives a total of 105,246 weekly downloads. As such, level-option-wrap popularity was classified as popular.
We found that level-option-wrap 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
npm now supports Trusted Publishing with OIDC, enabling secure package publishing directly from CI/CD workflows without relying on long-lived tokens.
Research
/Security News
A RubyGems malware campaign used 60 malicious packages posing as automation tools to steal credentials from social media and marketing tool users.
Security News
The CNA Scorecard ranks CVE issuers by data completeness, revealing major gaps in patch info and software identifiers across thousands of vulnerabilities.